diff options
author | Timothy Pearson <[email protected]> | 2012-11-05 17:21:22 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-11-05 17:21:22 -0600 |
commit | 76f5e2671f3a61225a730e3d9699833ae3bec6f2 (patch) | |
tree | 914e487936971fe409518555634b94ab27899b35 | |
parent | d3b9433c0a03c258e535556dcb7512391224ce8d (diff) | |
download | gtk3-tqt-engine-76f5e2671f3a61225a730e3d9699833ae3bec6f2.tar.gz gtk3-tqt-engine-76f5e2671f3a61225a730e3d9699833ae3bec6f2.zip |
Fix mask transforms
Use full TQt3 progress bar drawing code
-rw-r--r-- | tdegtk/tdegtk-draw.cpp | 250 | ||||
-rw-r--r-- | tdegtk/tdegtk-engine.c | 617 | ||||
-rw-r--r-- | tdegtk/tdegtk-theme.cpp | 5 | ||||
-rw-r--r-- | tdegtk/tqtcairopainter.cpp | 69 | ||||
-rw-r--r-- | tdegtk/tqtcairopainter.h | 2 |
5 files changed, 528 insertions, 415 deletions
diff --git a/tdegtk/tdegtk-draw.cpp b/tdegtk/tdegtk-draw.cpp index 36244e6..50e8eb3 100644 --- a/tdegtk/tdegtk-draw.cpp +++ b/tdegtk/tdegtk-draw.cpp @@ -301,6 +301,116 @@ void gtkScaleToSliderCeData(GtkScale* scaleWidget, TQStyleControlElementData &ce // } } +static void +draw_combobox_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) { + cairo_save(cr); + + cairo_matrix_t gtk_matrix; + cairo_get_matrix(cr, >k_matrix); + gtk_matrix.x0 = 0; + gtk_matrix.y0 = 0; + cairo_set_matrix(cr, >k_matrix); + + GtkWidget* parent(widget?gtk_widget_get_parent(widget):0L); + if (GTK_IS_COMBO_BOX(parent)) { + const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(parent); + TQRect boundingRect(0, 0, allocation.width, allocation.height); + TQt3CairoPaintDevice pd2(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr); + TQPainter p2(&pd2); + + TQStringList objectTypes; + objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + TQStyleControlElementData ceData; + TQStyle::ControlElementFlags elementFlags; + ceData.widgetObjectTypes = objectTypes; + ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal; + + if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) { + elementFlags = elementFlags | TQStyle::CEF_IsEditable; + } + + ceData.rect = boundingRect; + + // Draw item + tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE), TQStyle::SC_ComboBoxFrame, TQStyle::SC_None); + } + + cairo_restore(cr); +} + +static void +draw_progressbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) { + cairo_save(cr); + + cairo_matrix_t gtk_matrix; + cairo_get_matrix(cr, >k_matrix); + gtk_matrix.x0 = 0; + gtk_matrix.y0 = 0; + cairo_set_matrix(cr, >k_matrix); + + if (GTK_IS_PROGRESS_BAR(widget)) { + const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget); + TQRect boundingRect(0, 0, allocation.width, allocation.height); + TQt3CairoPaintDevice pd2(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr); + TQPainter p2(&pd2); + + TQStringList objectTypes; + objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + 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; + + GtkProgressBar* progressBar = GTK_PROGRESS_BAR(widget); + gdouble gtkProgressBarFraction = gtk_progress_bar_get_fraction(progressBar); + ceData.totalSteps = 8192; + ceData.currentStep = gtkProgressBarFraction*8192; + + TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_NONE); + sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default); + + if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL)) { + // If vertical, apply a 90 degree rotation matrix to the painter + // This is required to make TQt draw a vertical progress bar + + TQWMatrix m; + +// // Upside down +// m.rotate(90.0); +// m.translate(0, (allocation.width)*(-1.0)); + + // Right side up + m.rotate(-90.0); + m.translate((allocation.height)*(-1.0), 0); + + p2.setWorldMatrix(m, TRUE); + + boundingRect = TQRect(0, 0, allocation.height, allocation.width); + ceData.rect = boundingRect; + } + + TQRect progressBarGrooveRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags); + TQRect progressBarContentsRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, NULL), ceData, elementFlags); + + // Draw background + TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base); + DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p2, brush) + + // Draw frame + tqApp->style().drawControl(TQStyle::CE_ProgressBarGroove, &p2, ceData, elementFlags, progressBarGrooveRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags); + + // Draw contents + tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p2, ceData, elementFlags, progressBarContentsRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags); + } + + cairo_restore(cr); +} + /* draw a texture placed on the centroid */ static gboolean draw_centroid_texture (GtkThemingEngine *engine, @@ -364,6 +474,7 @@ tdegtk_draw_activity (DRAW_ARGS) widget = m_widgetLookup.find(cr, path); if (gtk_widget_path_is_type(path, GTK_TYPE_PROGRESS_BAR)) { +#if 0 TQStringList objectTypes; objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING); TQPalette objectPalette = tqApp->palette(objectTypes); @@ -381,6 +492,9 @@ tdegtk_draw_activity (DRAW_ARGS) // Draw item tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p, ceData, elementFlags, progressBarRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags); +#else + // Do nothing +#endif } else { @@ -509,6 +623,11 @@ tdegtk_draw_arrow (GtkThemingEngine *engine, } tqApp->style().drawPrimitive((subline)?TQStyle::PE_ScrollBarSubLine:TQStyle::PE_ScrollBarAddLine, p, scrollpagerect, gtkToTQtColorGroup(engine, state), sflags); } + + else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) { + // Do nothing + } + else { pd = new TQt3CairoPaintDevice(NULL, x, y, size, size, cr); p = new TQPainter(pd); @@ -583,6 +702,10 @@ tdegtk_draw_cell_background (DRAW_ARGS, tqApp->style().drawComplexControl(TQStyle::CC_ListView, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE), TQStyle::SC_ListView, TQStyle::SC_All, listViewItemOpt); } + // FIXME + // GtkCellRenderer backgrounds should be drawn here, however GTK3 does not provide any means for a GtkCellRenderer to call style engine methods! + // See upstream GTK bug #687677 + else { DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,128,64); printf("[WARNING] tdegtk_draw_cell_background() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); @@ -699,22 +822,7 @@ tdegtk_draw_common_background (DRAW_ARGS) state = gtk_theming_engine_get_state(engine); widget = m_widgetLookup.find(cr, path); - if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY)) - || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW)) - || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER)) - || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) - || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_COMBOBOX_ENTRY)) - ) { - TQStringList objectTypes; - objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING); - TQPalette objectPalette = tqApp->palette(objectTypes); - - // Draw background - TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base); - DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) - } - - else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) { + if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) { TQStringList objectTypes; objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING); TQPalette objectPalette = tqApp->palette(objectTypes); @@ -733,6 +841,25 @@ tdegtk_draw_common_background (DRAW_ARGS) 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)); } + else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) { + draw_combobox_frame(engine, cr, x, y, width, height, path, state, widget); + } + + else if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY)) + || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW)) + || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER)) + || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) + || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_COMBOBOX_ENTRY)) + ) { + TQStringList objectTypes; + objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + // Draw background + TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base); + DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) + } + #if 0 else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) { bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0; @@ -995,29 +1122,11 @@ tdegtk_draw_common_frame (DRAW_ARGS) tqApp->style().drawPrimitive(TQStyle::PE_ScrollBarAddPage, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); } } -#if 0 - else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) { - bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0; - TQStringList objectTypes; - objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING); - TQPalette objectPalette = tqApp->palette(objectTypes); - - TQStyleControlElementData ceData; - TQStyle::ControlElementFlags elementFlags; - ceData.widgetObjectTypes = objectTypes; - ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal; - - if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) { - elementFlags = elementFlags | TQStyle::CEF_IsEditable; - } - - ceData.rect = boundingRect; - - // Draw item - tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE), TQStyle::SC_ComboBoxFrame, TQStyle::SC_None); + else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) { + draw_combobox_frame(engine, cr, x, y, width, height, path, state, widget); } -#endif + else { if (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON)) { if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TOOLBAR)) { @@ -1125,29 +1234,7 @@ tdegtk_draw_common_frame (DRAW_ARGS) } else if (gtk_widget_path_is_type(path, GTK_TYPE_PROGRESS_BAR)) { - TQStringList objectTypes; - objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING); - TQPalette objectPalette = tqApp->palette(objectTypes); - - 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; - - GtkProgressBar* progressBar = GTK_PROGRESS_BAR(widget); - gdouble gtkProgressBarFraction = gtk_progress_bar_get_fraction(progressBar); - ceData.totalSteps = 8192; - ceData.currentStep = gtkProgressBarFraction*8192; - - TQRect progressBarRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags); - - // Draw background - TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base); - DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) - - // Draw item - tqApp->style().drawControl(TQStyle::CE_ProgressBarGroove, &p, ceData, elementFlags, progressBarRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); + draw_progressbar_frame(engine, cr, x, y, width, height, path, state, widget); } else if (gtk_widget_path_is_type(path, GTK_TYPE_IMAGE)) { @@ -1365,7 +1452,11 @@ tdegtk_draw_focus (DRAW_ARGS) state = gtk_theming_engine_get_state(engine); widget = m_widgetLookup.find(cr, path); - if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY)) + if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) { + // Draw nothing! + } + + else if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY)) || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW)) || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER)) || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) @@ -1756,43 +1847,6 @@ tdegtk_draw_separator (DRAW_ARGS) } p.end(); - - return; - - gdouble line_width; - - tdegtk_get_line_width (engine, &line_width); - - if (line_width == 0) - return; - - /* FIXME right code should be - * if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL)) - * but doesn't work for separator tool item. */ - if (width > height) - { - cairo_move_to (cr, x, y + (gint) (height / 2) + line_width / 2); - cairo_line_to (cr, x + width, y + (gint) (height / 2) + line_width / 2); - tdegtk_cairo_set_source_inner_stroke (engine, cr, width, line_width); - cairo_stroke (cr); - - cairo_move_to (cr, x, y + (gint) (height / 2) - line_width / 2); - cairo_line_to (cr, x + width, y + (gint) (height / 2) - line_width / 2); - tdegtk_cairo_set_source_border (engine, cr, width, line_width); - cairo_stroke (cr); - } - else - { - cairo_move_to (cr, x + (gint) (width / 2) + line_width / 2, y); - cairo_line_to (cr, x + (gint) (width / 2) + line_width / 2, y + height); - tdegtk_cairo_set_source_inner_stroke (engine, cr, line_width, height); - cairo_stroke (cr); - - cairo_move_to (cr, x + (gint) (width / 2) - line_width / 2, y); - cairo_line_to (cr, x + (gint) (width / 2) - line_width / 2, y + height); - tdegtk_cairo_set_source_border (engine, cr, line_width, height); - cairo_stroke (cr); - } } static void diff --git a/tdegtk/tdegtk-engine.c b/tdegtk/tdegtk-engine.c index 2032d99..fbf07a8 100644 --- a/tdegtk/tdegtk-engine.c +++ b/tdegtk/tdegtk-engine.c @@ -48,18 +48,20 @@ tdegtk_engine_render_activity (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - const GtkWidgetPath *path; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - path = gtk_theming_engine_get_path (engine); - - if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER)) - GTK_THEMING_ENGINE_CLASS (tdegtk_engine_parent_class)->render_activity (engine, cr, x, y, width, height); - else - style_functions->draw_activity (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + const GtkWidgetPath *path; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + path = gtk_theming_engine_get_path (engine); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER)) { + GTK_THEMING_ENGINE_CLASS (tdegtk_engine_parent_class)->render_activity (engine, cr, x, y, width, height); + } + else { + style_functions->draw_activity (engine, cr, x, y, width, height); + } } static void @@ -70,13 +72,13 @@ tdegtk_engine_render_arrow (GtkThemingEngine *engine, gdouble y, gdouble size) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_arrow (engine, cr, angle, x, y, size); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_arrow (engine, cr, angle, x, y, size); } static void @@ -87,24 +89,29 @@ tdegtk_engine_render_background (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - const GtkWidgetPath *path; - GtkRegionFlags flags; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - path = gtk_theming_engine_get_path (engine); - - if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) && - gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON)) - style_functions->draw_spinbutton_background (engine, cr, x, y, width, height); - else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) && - gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) && - gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags)) - style_functions->draw_cell_background (engine, cr, x, y, width, height, flags); - else - style_functions->draw_common_background (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + const GtkWidgetPath *path; + GtkRegionFlags flags; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + path = gtk_theming_engine_get_path (engine); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) && + gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON) + ) { + style_functions->draw_spinbutton_background (engine, cr, x, y, width, height); + } + else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) && + gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) && + gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags) + ) { + style_functions->draw_cell_background (engine, cr, x, y, width, height, flags); + } + else { + style_functions->draw_common_background (engine, cr, x, y, width, height); + } } static void @@ -115,13 +122,13 @@ tdegtk_engine_render_check (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_check (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_check (engine, cr, x, y, width, height); } static void @@ -132,13 +139,13 @@ tdegtk_engine_render_expander (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_expander (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_expander (engine, cr, x, y, width, height); } static void @@ -150,13 +157,13 @@ tdegtk_engine_render_extension (GtkThemingEngine *engine, gdouble height, GtkPositionType gap_side) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_extension (engine, cr, x, y, width, height, gap_side); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_extension (engine, cr, x, y, width, height, gap_side); } static void @@ -167,13 +174,13 @@ tdegtk_engine_render_focus (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_focus (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_focus (engine, cr, x, y, width, height); } static void @@ -184,26 +191,32 @@ tdegtk_engine_render_frame (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - const GtkWidgetPath *path; - GtkRegionFlags flags; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - path = gtk_theming_engine_get_path (engine); - - if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR)) - style_functions->draw_separator (engine, cr, x, y, width, height); - else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) && - gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON)) - style_functions->draw_spinbutton_frame (engine, cr, x, y, width, height); - else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) && - gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) && - gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags)) - style_functions->draw_cell_frame (engine, cr, x, y, width, height, flags); - else - style_functions->draw_common_frame (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + const GtkWidgetPath *path; + GtkRegionFlags flags; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + path = gtk_theming_engine_get_path (engine); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SEPARATOR)) { + style_functions->draw_separator (engine, cr, x, y, width, height); + } + else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_BUTTON) && + gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINBUTTON) + ) { + style_functions->draw_spinbutton_frame (engine, cr, x, y, width, height); + } + else if (!gtk_widget_path_is_type (path, GTK_TYPE_ICON_VIEW) && + gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VIEW) && + gtk_theming_engine_has_region (engine, GTK_STYLE_REGION_COLUMN, &flags) + ) { + style_functions->draw_cell_frame (engine, cr, x, y, width, height, flags); + } + else { + style_functions->draw_common_frame (engine, cr, x, y, width, height); + } } static void @@ -217,16 +230,18 @@ tdegtk_engine_render_frame_gap (GtkThemingEngine *engine, gdouble xy0_gap, gdouble xy1_gap) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK)) - style_functions->draw_notebook (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap); - else - style_functions->draw_frame_gap (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_NOTEBOOK)) { + style_functions->draw_notebook (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap); + } + else { + style_functions->draw_frame_gap (engine, cr, x, y, width, height, gap_side, xy0_gap, xy1_gap); + } } static void @@ -237,16 +252,18 @@ tdegtk_engine_render_handle (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP)) - style_functions->draw_grip (engine, cr, x, y, width, height); - else - style_functions->draw_handle (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP)) { + style_functions->draw_grip (engine, cr, x, y, width, height); + } + else { + style_functions->draw_handle (engine, cr, x, y, width, height); + } } static void @@ -257,13 +274,13 @@ tdegtk_engine_render_line (GtkThemingEngine *engine, gdouble x1, gdouble y1) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_line (engine, cr, x0, y0, x1, y1); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_line (engine, cr, x0, y0, x1, y1); } static void @@ -274,13 +291,13 @@ tdegtk_engine_render_option (GtkThemingEngine *engine, gdouble width, gdouble height) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_radio (engine, cr, x, y, width, height); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_radio (engine, cr, x, y, width, height); } static void @@ -292,202 +309,202 @@ tdegtk_engine_render_slider (GtkThemingEngine *engine, gdouble height, GtkOrientation orientation) { - TdeGtkStyleFunctions *style_functions; - - TDEGTK_CAIRO_INIT - - tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); - - style_functions->draw_slider (engine, cr, x, y, width, height, orientation); + TdeGtkStyleFunctions *style_functions; + + TDEGTK_CAIRO_INIT + + tdegtk_lookup_functions (TDEGTK_ENGINE (engine), &style_functions); + + style_functions->draw_slider (engine, cr, x, y, width, height, orientation); } void tdegtk_engine_register_types (GTypeModule *module) { - tdegtk_engine_register_type (module); + tdegtk_engine_register_type (module); } static void tdegtk_engine_init (TdeGtkEngine *engine) { - tdegtk_register_style_default (&engine->style_functions[TDEGTK_STYLE_DEFAULT]); + tdegtk_register_style_default (&engine->style_functions[TDEGTK_STYLE_DEFAULT]); } static void tdegtk_engine_class_init (TdeGtkEngineClass *klass) { - GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass); - - engine_class->render_activity = tdegtk_engine_render_activity; - engine_class->render_arrow = tdegtk_engine_render_arrow; - engine_class->render_background = tdegtk_engine_render_background; - engine_class->render_check = tdegtk_engine_render_check; - engine_class->render_expander = tdegtk_engine_render_expander; - engine_class->render_extension = tdegtk_engine_render_extension; - engine_class->render_focus = tdegtk_engine_render_focus; - engine_class->render_frame = tdegtk_engine_render_frame; - engine_class->render_frame_gap = tdegtk_engine_render_frame_gap; - engine_class->render_handle = tdegtk_engine_render_handle; - engine_class->render_line = tdegtk_engine_render_line; - engine_class->render_option = tdegtk_engine_render_option; - engine_class->render_slider = tdegtk_engine_render_slider; - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("background-texture", - "Background texture", - "Background texture", - CAIRO_GOBJECT_TYPE_PATTERN, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("border-gradient", - "Border gradient", - "Border gradient", - CAIRO_GOBJECT_TYPE_PATTERN, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("bullet-color", - "Bullet color", - "Bullet color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("bullet-outline-color", - "Bullet outline color", - "Bullet outline color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("centroid-texture", - "Centroid texture", - "Centroid texture", - CAIRO_GOBJECT_TYPE_PATTERN, 0)); - - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("focus-border-color", - "Focus border color", - "Focus border color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_int ("focus-border-radius", - "Focus border radius", - "Focus border radius", - 0, G_MAXINT, 0, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("focus-fill-color", - "Focus fill color", - "Focus fill color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("focus-outer-stroke-color", - "Focus outer stroke color", - "Focus outer stroke color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_int ("glow-radius", - "Glow radius", - "Glow radius", - 0, G_MAXINT, 0, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("glow-color", - "Glow color", - "Glow color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("inner-stroke-color", - "Inner stroke color", - "Inner stroke color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("inner-stroke-top-color", - "Inner stroke top color", - "Inner stroke top color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("inner-stroke-right-color", - "Inner stroke right color", - "Inner stroke right color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("inner-stroke-bottom-color", - "Inner stroke bottom color", - "Inner stroke bottom color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("inner-stroke-left-color", - "Inner stroke left color", - "Inner stroke left color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("inner-stroke-gradient", - "Inner stroke gradient", - "Inner stroke gradient", - CAIRO_GOBJECT_TYPE_PATTERN, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("inner-stroke-width", - "Inner stroke width", - "Inner stroke width", - GTK_TYPE_BORDER, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("outer-stroke-color", - "Outer stroke color", - "Outer stroke color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("outer-stroke-top-color", - "Outer stroke top color", - "Outer stroke top color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("outer-stroke-right-color", - "Outer stroke right color", - "Outer stroke right color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("outer-stroke-bottom-color", - "Outer stroke bottom color", - "Outer stroke bottom color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("outer-stroke-left-color", - "Outer stroke left color", - "Outer stroke left color", - GDK_TYPE_RGBA, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("outer-stroke-gradient", - "Outer stroke gradient", - "Outer stroke gradient", - CAIRO_GOBJECT_TYPE_PATTERN, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("outer-stroke-width", - "Outer stroke width", - "Outer stroke width", - GTK_TYPE_BORDER, 0)); - - gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, - g_param_spec_boxed ("text-shadow-color", - "Text shadow color", - "Text shadow color", - GDK_TYPE_RGBA, 0)); + GtkThemingEngineClass *engine_class = GTK_THEMING_ENGINE_CLASS (klass); + + engine_class->render_activity = tdegtk_engine_render_activity; + engine_class->render_arrow = tdegtk_engine_render_arrow; + engine_class->render_background = tdegtk_engine_render_background; + engine_class->render_check = tdegtk_engine_render_check; + engine_class->render_expander = tdegtk_engine_render_expander; + engine_class->render_extension = tdegtk_engine_render_extension; + engine_class->render_focus = tdegtk_engine_render_focus; + engine_class->render_frame = tdegtk_engine_render_frame; + engine_class->render_frame_gap = tdegtk_engine_render_frame_gap; + engine_class->render_handle = tdegtk_engine_render_handle; + engine_class->render_line = tdegtk_engine_render_line; + engine_class->render_option = tdegtk_engine_render_option; + engine_class->render_slider = tdegtk_engine_render_slider; + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("background-texture", + "Background texture", + "Background texture", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("border-gradient", + "Border gradient", + "Border gradient", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("bullet-color", + "Bullet color", + "Bullet color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("bullet-outline-color", + "Bullet outline color", + "Bullet outline color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("centroid-texture", + "Centroid texture", + "Centroid texture", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("focus-border-color", + "Focus border color", + "Focus border color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_int ("focus-border-radius", + "Focus border radius", + "Focus border radius", + 0, G_MAXINT, 0, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("focus-fill-color", + "Focus fill color", + "Focus fill color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("focus-outer-stroke-color", + "Focus outer stroke color", + "Focus outer stroke color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_int ("glow-radius", + "Glow radius", + "Glow radius", + 0, G_MAXINT, 0, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("glow-color", + "Glow color", + "Glow color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("inner-stroke-color", + "Inner stroke color", + "Inner stroke color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("inner-stroke-top-color", + "Inner stroke top color", + "Inner stroke top color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("inner-stroke-right-color", + "Inner stroke right color", + "Inner stroke right color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("inner-stroke-bottom-color", + "Inner stroke bottom color", + "Inner stroke bottom color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("inner-stroke-left-color", + "Inner stroke left color", + "Inner stroke left color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("inner-stroke-gradient", + "Inner stroke gradient", + "Inner stroke gradient", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("inner-stroke-width", + "Inner stroke width", + "Inner stroke width", + GTK_TYPE_BORDER, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("outer-stroke-color", + "Outer stroke color", + "Outer stroke color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("outer-stroke-top-color", + "Outer stroke top color", + "Outer stroke top color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("outer-stroke-right-color", + "Outer stroke right color", + "Outer stroke right color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("outer-stroke-bottom-color", + "Outer stroke bottom color", + "Outer stroke bottom color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("outer-stroke-left-color", + "Outer stroke left color", + "Outer stroke left color", + GDK_TYPE_RGBA, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("outer-stroke-gradient", + "Outer stroke gradient", + "Outer stroke gradient", + CAIRO_GOBJECT_TYPE_PATTERN, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("outer-stroke-width", + "Outer stroke width", + "Outer stroke width", + GTK_TYPE_BORDER, 0)); + + gtk_theming_engine_register_property (TDEGTK_NAMESPACE, NULL, + g_param_spec_boxed ("text-shadow-color", + "Text shadow color", + "Text shadow color", + GDK_TYPE_RGBA, 0)); } static void diff --git a/tdegtk/tdegtk-theme.cpp b/tdegtk/tdegtk-theme.cpp index 40c96c3..e0b74a9 100644 --- a/tdegtk/tdegtk-theme.cpp +++ b/tdegtk/tdegtk-theme.cpp @@ -597,6 +597,11 @@ void writeGtkThemeControlFile(int forceRecreate) { bool combobox_appears_as_list = (!(tqApp->style().styleHint(TQStyle::SH_ComboBox_Popup) || tqApp->style().styleHint(TQStyle::SH_GUIStyle) == TQt::MotifStyle)); stream << parse_rc_string(TQString("-GtkComboBox-appears-as-list: %1px").arg(combobox_appears_as_list), "*"); + + // FIXME + // Work around problems detailed in upstream GTK bug #687677 + stream << parse_rc_string(TQString("-GtkComboBox-shadow-type: in"), "*"); + stream << parse_rc_string("-GtkComboBox-arrow-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ArrowSize)), "*"); stream << parse_rc_string("-GtkComboBox-arrow-scaling: 0", "*"); diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp index 6d3b2cf..9c7d010 100644 --- a/tdegtk/tqtcairopainter.cpp +++ b/tdegtk/tqtcairopainter.cpp @@ -336,7 +336,42 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() { cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion); cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY); cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE); - cairo_mask_surface(m_devicePainter, maskSurface, m_offsetX, m_offsetY); + + // Clipping enabled + if (m_worldMatrixEnabled || m_viewportMatrixEnabled) { + // The mask needs to be transformed before application + cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion); + cairo_surface_t *transformedMaskSurface; + cairo_t *cr2; + int maxSize; + int w = cairo_image_surface_get_width(maskSurface); + int h = cairo_image_surface_get_height(maskSurface); + if (w>h) { + maxSize = w*2; + } + else { + maxSize = h*2; + } + transformedMaskSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, maxSize, maxSize); + cr2 = cairo_create(transformedMaskSurface); + setCairoTransformations(cr2); + cairo_set_source_surface (cr2, maskSurface, 0, 0); + cairo_set_operator(cr2, CAIRO_OPERATOR_SOURCE); + cairo_paint(cr2); + + // Paint intermediate surface to final surface through mask + cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY); + cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE); + cairo_mask_surface(m_devicePainter, transformedMaskSurface, m_offsetX, m_offsetY); + cairo_surface_destroy(transformedMaskSurface); + } + else { + // Paint intermediate surface to final surface through mask + cairo_surface_t* maskSurface = TQImageToCairoSurface(m_clipRegion); + cairo_set_source_surface(m_devicePainter, m_intermediateSurface, m_offsetX, m_offsetY); + cairo_set_operator(m_devicePainter, overlayMerge?CAIRO_OPERATOR_OVER:CAIRO_OPERATOR_SOURCE); + cairo_mask_surface(m_devicePainter, maskSurface, m_offsetX, m_offsetY); + } cairo_surface_destroy(maskSurface); } @@ -1052,21 +1087,23 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla transferIntermediateSurface(); } -void TQt3CairoPaintDevice::setCairoTransformations() { +void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable) { cairo_matrix_t combinedMatrix; cairo_matrix_t tempMatrix; cairo_matrix_init_identity(&combinedMatrix); - if (m_worldMatrixEnabled) { - cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_worldMatrix); - combinedMatrix = tempMatrix; - } - if (m_viewportMatrixEnabled) { - cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_viewportMatrix); - combinedMatrix = tempMatrix; + if (!forceDisable) { + if (m_worldMatrixEnabled) { + cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_worldMatrix); + combinedMatrix = tempMatrix; + } + if (m_viewportMatrixEnabled) { + cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_viewportMatrix); + combinedMatrix = tempMatrix; + } } - cairo_set_matrix(m_painter, &combinedMatrix); + cairo_set_matrix(cr, &combinedMatrix); } /*! @@ -1488,7 +1525,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) m_viewportMatrixEnabled = false; cairo_matrix_init_identity(&m_worldMatrix); cairo_matrix_init_identity(&m_viewportMatrix); - setCairoTransformations(); + setCairoTransformations(m_painter); m_rop = TQPainter::CopyROP; m_clipRegion = TQImage(); m_clipRegionEnabled = false; @@ -1603,7 +1640,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) case PdcSetVXform: if ((p) && (m_painter)) { m_viewportMatrixEnabled = p[0].ival; - setCairoTransformations(); + setCairoTransformations(m_painter); } break; case PdcSetWindow: @@ -1620,7 +1657,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) double scaleW = (double)vw/(double)ww; double scaleH = (double)vh/(double)wh; cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH); - setCairoTransformations(); + setCairoTransformations(m_painter); } break; case PdcSetViewport: @@ -1637,13 +1674,13 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) double scaleW = (double)vw/(double)ww; double scaleH = (double)vh/(double)wh; cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH); - setCairoTransformations(); + setCairoTransformations(m_painter); } break; case PdcSetWXform: if ((p) && (m_painter)) { m_worldMatrixEnabled = p[0].ival; - setCairoTransformations(); + setCairoTransformations(m_painter); } break; case PdcSetWMatrix: @@ -1661,7 +1698,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) // Replace cairo_matrix_init(&m_worldMatrix, tqt3matrix->m11(), tqt3matrix->m12(), tqt3matrix->m21(), tqt3matrix->m22(), tqt3matrix->dx(), tqt3matrix->dy()); } - setCairoTransformations(); + setCairoTransformations(m_painter); } } break; diff --git a/tdegtk/tqtcairopainter.h b/tdegtk/tqtcairopainter.h index 67ccd79..6908e03 100644 --- a/tdegtk/tqtcairopainter.h +++ b/tdegtk/tqtcairopainter.h @@ -70,7 +70,7 @@ class Q_EXPORT TQt3CairoPaintDevice : public TQPaintDevice // picture class void drawText(TQPainter *p, int x, int y, const TQString &str); void drawTextInRect(TQPainter *p, TQRect rect, int textFlags, const TQString &str); - void setCairoTransformations(); + void setCairoTransformations(cairo_t* cr, bool forceDisable=false); private: mutable int m_width; |