summaryrefslogtreecommitdiffstats
path: root/tdegtk/tdegtk-draw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdegtk/tdegtk-draw.cpp')
-rw-r--r--tdegtk/tdegtk-draw.cpp154
1 files changed, 134 insertions, 20 deletions
diff --git a/tdegtk/tdegtk-draw.cpp b/tdegtk/tdegtk-draw.cpp
index 032d6b6..20cce27 100644
--- a/tdegtk/tdegtk-draw.cpp
+++ b/tdegtk/tdegtk-draw.cpp
@@ -56,6 +56,8 @@
p.setPen(TQt::NoPen); \
p.drawRect(x, y, w, h);
+extern int m_scrollBarSubLineWidth;
+
WidgetLookup m_widgetLookup;
Animations m_animations;
@@ -265,8 +267,8 @@ static TQColorGroup::ColorRole backgroundModeToColorRole(TQt::BackgroundMode mod
return ret;
}
-void gtkScaleToSliderCeData(GtkScale* scaleWidget, TQStyleControlElementData &ceData) {
- GtkAdjustment* adjustment = gtk_range_get_adjustment(GTK_RANGE(scaleWidget));
+void gtkRangeToCeData(GtkRange* rangeWidget, TQStyleControlElementData &ceData) {
+ GtkAdjustment* adjustment = gtk_range_get_adjustment(rangeWidget);
ceData.minSteps = gtk_adjustment_get_lower(adjustment);
ceData.maxSteps = gtk_adjustment_get_upper(adjustment);
@@ -276,6 +278,10 @@ void gtkScaleToSliderCeData(GtkScale* scaleWidget, TQStyleControlElementData &ce
// ceData.startStep =
ceData.lineStep = gtk_adjustment_get_step_increment(adjustment);
ceData.pageStep = gtk_adjustment_get_page_increment(adjustment);
+}
+
+void gtkScaleToSliderCeData(GtkScale* scaleWidget, TQStyleControlElementData &ceData) {
+ gtkRangeToCeData(GTK_RANGE(scaleWidget), ceData);
// GtkPositionType valuePosition = gtk_scale_get_value_pos(scaleWidget);
// if (valuePosition == GTK_POS_LEFT) {
@@ -390,12 +396,20 @@ tdegtk_draw_arrow (GtkThemingEngine *engine,
gdouble y,
gdouble size)
{
+ cairo_save(cr);
+ cairo_reset_clip(cr);
+
TQRect boundingRect(0, 0, size, size);
- TQt3CairoPaintDevice pd(NULL, x, y, size, size, cr);
- TQPainter p(&pd);
+ TQt3CairoPaintDevice *pd = NULL;
+ TQPainter *p = NULL;
+ const GtkWidgetPath* path;
GtkStateFlags state;
+ GtkWidget* widget;
+
+ path = gtk_theming_engine_get_path(engine);
state = gtk_theming_engine_get_state(engine);
+ widget = m_widgetLookup.find(cr, path);
GtkArrowType arrow_direction;
@@ -417,16 +431,64 @@ tdegtk_draw_arrow (GtkThemingEngine *engine,
objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
+ GtkRange* rangeWidget = GTK_RANGE(widget);
+
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
- ceData.rect = boundingRect;
ceData.orientation = ((arrow_direction == GTK_ARROW_UP) || (arrow_direction == GTK_ARROW_DOWN))?TQt::Vertical:TQt::Horizontal;
-
bool subline = ((arrow_direction == GTK_ARROW_DOWN) || (arrow_direction == GTK_ARROW_RIGHT))?false:true;
+ bool combine_addlineregion_drawing_areas = tqApp->style().styleHint(TQStyle::SH_ScrollBar_CombineAddLineRegionDrawingAreas);
+ const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget);
+
+ TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_NONE);
+ sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default);
+
+ if (combine_addlineregion_drawing_areas) {
+ int newx = x;
+ int newy = y;
+ int neww = size;
+ int newh = size;
+ if (!subline) {
+ if (ceData.orientation == TQt::Horizontal) {
+ if ((x+m_scrollBarSubLineWidth) == allocation.width) {
+ newx = x-m_scrollBarSubLineWidth;
+ }
+ boundingRect.setWidth(m_scrollBarSubLineWidth*2);
+ neww = m_scrollBarSubLineWidth*2;
+ }
+ else {
+ if ((y+m_scrollBarSubLineWidth) == allocation.height) {
+ newy = y-m_scrollBarSubLineWidth;
+ }
+ boundingRect.setHeight(m_scrollBarSubLineWidth*2);
+ newh = m_scrollBarSubLineWidth*2;
+ }
+ }
+ pd = new TQt3CairoPaintDevice(NULL, newx, newy, neww, newh, cr);
+ p = new TQPainter(pd);
+
+ if (!subline) {
+ if (ceData.orientation == TQt::Horizontal) {
+ p->setClipRect(TQRect(0+m_scrollBarSubLineWidth, 0, m_scrollBarSubLineWidth, newh));
+ }
+ else {
+ p->setClipRect(TQRect(0, 0+m_scrollBarSubLineWidth, neww, m_scrollBarSubLineWidth));
+ }
+ }
+ }
+ else {
+ pd = new TQt3CairoPaintDevice(NULL, x, y, size, size, cr);
+ p = new TQPainter(pd);
+ }
+
+ ceData.rect = boundingRect;
+
+ gtkRangeToCeData(rangeWidget, ceData);
+
// Draw slider arrow buttons
- TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, (subline)?TQStyle::SC_ScrollBarSubLine:TQStyle::SC_ScrollBarAddLine, gtkToTQtStyleFlags(engine, state, TQT3WT_NONE));
+ TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, (subline)?TQStyle::SC_ScrollBarSubLine:TQStyle::SC_ScrollBarAddLine, sflags);
if (ceData.orientation == TQt::Vertical) {
scrollpagerect.setY(ceData.rect.y());
scrollpagerect.setHeight(ceData.rect.height());
@@ -435,9 +497,12 @@ tdegtk_draw_arrow (GtkThemingEngine *engine,
scrollpagerect.setX(ceData.rect.x());
scrollpagerect.setWidth(ceData.rect.width());
}
- tqApp->style().drawPrimitive((subline)?TQStyle::PE_ScrollBarSubLine:TQStyle::PE_ScrollBarAddLine, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
+ tqApp->style().drawPrimitive((subline)?TQStyle::PE_ScrollBarSubLine:TQStyle::PE_ScrollBarAddLine, p, scrollpagerect, gtkToTQtColorGroup(engine, state), sflags);
}
else {
+ pd = new TQt3CairoPaintDevice(NULL, x, y, size, size, cr);
+ p = new TQPainter(pd);
+
// Draw arrow
TQStyle::PrimitiveElement pe;
if (arrow_direction == GTK_ARROW_UP) {
@@ -452,10 +517,18 @@ tdegtk_draw_arrow (GtkThemingEngine *engine,
else {
pe = TQStyle::PE_ArrowRight;
}
- tqApp->style().drawPrimitive(pe, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE));
+ tqApp->style().drawPrimitive(pe, p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE));
}
- p.end();
+ if (p) {
+ p->end();
+ delete p;
+ }
+ if (pd) {
+ delete pd;
+ }
+
+ cairo_restore(cr);
return;
@@ -634,6 +707,9 @@ tdegtk_draw_common (DRAW_ARGS)
static void
tdegtk_draw_common_background (DRAW_ARGS)
{
+ cairo_save(cr);
+ cairo_reset_clip(cr);
+
TQRect boundingRect(0, 0, width, height);
TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
TQPainter p(&pd);
@@ -666,12 +742,16 @@ tdegtk_draw_common_background (DRAW_ARGS)
objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
+ GtkRange* rangeWidget = GTK_RANGE(widget);
+
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
ceData.rect = boundingRect;
ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
+ gtkRangeToCeData(rangeWidget, ceData);
+
// Draw frame
tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
}
@@ -813,12 +893,12 @@ tdegtk_draw_common_background (DRAW_ARGS)
//bool mousedown = (state & GTK_STATE_FLAG_SELECTED) != 0;
bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0;
+ GtkScale* scaleWidget = GTK_SCALE(widget);
+
TQStringList objectTypes;
objectTypes.append(TQSLIDER_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
- GtkScale* scaleWidget = GTK_SCALE(widget);
-
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
@@ -857,6 +937,8 @@ tdegtk_draw_common_background (DRAW_ARGS)
}
p.end();
+
+ cairo_restore(cr);
}
static void
@@ -885,12 +967,16 @@ tdegtk_draw_common_frame (DRAW_ARGS)
TQStringList objectTypes;
objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
+
+ GtkRange* rangeWidget = GTK_RANGE(widget);
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
ceData.rect = boundingRect;
ceData.orientation = ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal);
+
+ gtkRangeToCeData(rangeWidget, ceData);
// Draw background
// HACK
@@ -910,8 +996,24 @@ tdegtk_draw_common_frame (DRAW_ARGS)
}
else {
if (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON)) {
- // Draw frame
- tqApp->style().drawPrimitive(TQStyle::PE_ButtonBevel, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQPushButton));
+ if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TOOLBAR)) {
+ // Draw frame
+ tqApp->style().drawPrimitive(TQStyle::PE_ButtonTool, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQPushButton));
+ }
+ else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TREE_VIEW)) {
+ // Draw frame
+ tqApp->style().drawPrimitive(TQStyle::PE_HeaderSection, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE));
+ }
+ else {
+ if (gtk_widget_has_default(widget)) {
+ // Draw frame
+ tqApp->style().drawPrimitive(TQStyle::PE_ButtonDefault, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQPushButton));
+ }
+ else {
+ // Draw frame
+ tqApp->style().drawPrimitive(TQStyle::PE_ButtonCommand, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQPushButton));
+ }
+ }
}
else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM)) {
@@ -984,9 +1086,6 @@ tdegtk_draw_common_frame (DRAW_ARGS)
}
else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_TOOLTIP)) {
- GtkFrame* frame = GTK_FRAME(widget);
- GtkShadowType gtkShadowType = gtk_frame_get_shadow_type(frame);
-
TQStringList objectTypes;
objectTypes.append(TQTOOLTIP_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
@@ -1664,6 +1763,9 @@ static void
tdegtk_draw_slider (DRAW_ARGS,
GtkOrientation orientation)
{
+ cairo_save(cr);
+ cairo_reset_clip(cr);
+
TQRect boundingRect(0, 0, width, height);
TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
TQPainter p(&pd);
@@ -1681,12 +1783,16 @@ tdegtk_draw_slider (DRAW_ARGS,
objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
+ GtkRange* rangeWidget = GTK_RANGE(widget);
+
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
ceData.rect = boundingRect;
ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
+ gtkRangeToCeData(rangeWidget, ceData);
+
// Draw slider
TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarSlider, gtkToTQtStyleFlags(engine, state, TQT3WT_NONE));
if (ceData.orientation == TQt::Vertical) {
@@ -1701,7 +1807,6 @@ tdegtk_draw_slider (DRAW_ARGS,
}
else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCALE)) {
- //bool mousedown = (state & GTK_STATE_FLAG_SELECTED) != 0;
bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0;
TQStringList objectTypes;
@@ -1713,13 +1818,20 @@ tdegtk_draw_slider (DRAW_ARGS,
TQStyleControlElementData ceData;
TQStyle::ControlElementFlags elementFlags;
ceData.widgetObjectTypes = objectTypes;
- ceData.rect = boundingRect;
ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
+ // HACK
+ // GTK3 or TQt3 (not sure which) does not draw the slider in the correct location!
+ boundingRect = TQRect((ceData.orientation == TQt::Horizontal)?2:0, (ceData.orientation == TQt::Horizontal)?0:2, width, height);
+ TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr);
+ TQPainter p2(&pd2);
+
+ ceData.rect = boundingRect;
+
gtkScaleToSliderCeData(scaleWidget, ceData);
// Draw item
- tqApp->style().drawComplexControl(TQStyle::CC_Slider, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQSlider) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default), TQStyle::SC_SliderHandle, ((mousedown)?TQStyle::SC_SliderHandle:TQStyle::SC_None));
+ tqApp->style().drawComplexControl(TQStyle::CC_Slider, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQSlider) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default), TQStyle::SC_SliderHandle, ((mousedown)?TQStyle::SC_SliderHandle:TQStyle::SC_None));
}
else {
@@ -1728,6 +1840,8 @@ tdegtk_draw_slider (DRAW_ARGS,
}
p.end();
+
+ cairo_restore(cr);
}
static void