diff --git a/tdegtk/tdegtk-draw.cpp b/tdegtk/tdegtk-draw.cpp index fe03272..4d34823 100644 --- a/tdegtk/tdegtk-draw.cpp +++ b/tdegtk/tdegtk-draw.cpp @@ -455,8 +455,8 @@ draw_combobox_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, G 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); + TQt3CairoPaintDevice pd(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr); + TQPainter p(&pd); TQStringList objectTypes; objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING); @@ -478,8 +478,8 @@ draw_combobox_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, G } // Draw item - //tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_ComboBoxFrame, TQStyle::SC_None); - tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_All, TQStyle::SC_None); + //tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_ComboBoxFrame, TQStyle::SC_None); + tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_All, TQStyle::SC_None); } cairo_restore(cr); @@ -498,8 +498,8 @@ draw_progressbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state 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); + TQt3CairoPaintDevice pd(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr); + TQPainter p(&pd); TQStringList objectTypes; objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING); @@ -529,13 +529,13 @@ draw_progressbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state // Draw background TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base); - DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p2, brush) + DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) // Draw frame progressBarGrooveRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags); progressBarContentsRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, NULL), ceData, elementFlags); - tqApp->style().drawControl(TQStyle::CE_ProgressBarGroove, &p2, ceData, elementFlags, progressBarGrooveRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags); + tqApp->style().drawControl(TQStyle::CE_ProgressBarGroove, &p, ceData, elementFlags, progressBarGrooveRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags); // Draw contents if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL)) { @@ -551,7 +551,7 @@ draw_progressbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state m.rotate(-90.0); m.translate((allocation.height)*(-1.0), 0); - p2.setWorldMatrix(m, TRUE); + p.setWorldMatrix(m, TRUE); boundingRect = TQRect(0, 0, allocation.height, allocation.width); ceData.rect = boundingRect; @@ -560,7 +560,7 @@ draw_progressbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state progressBarGrooveRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags); progressBarContentsRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, NULL), ceData, elementFlags); - tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p2, ceData, elementFlags, progressBarContentsRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags); + tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p, ceData, elementFlags, progressBarContentsRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags); } cairo_restore(cr); @@ -583,8 +583,8 @@ draw_slider_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, Gtk gtk_range_get_range_rect(GTK_RANGE(widget), &rangeRect); TQRect boundingRect(0, 0, rangeRect.width, rangeRect.height); - TQt3CairoPaintDevice pd2(NULL, allocation.x + rangeRect.x, allocation.y + rangeRect.y, rangeRect.width, rangeRect.height, cr); - TQPainter p2(&pd2); + TQt3CairoPaintDevice pd(NULL, allocation.x + rangeRect.x, allocation.y + rangeRect.y, rangeRect.width, rangeRect.height, cr); + TQPainter p(&pd); bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0; bool prelight = (state & GTK_STATE_FLAG_PRELIGHT) != 0; @@ -616,7 +616,7 @@ draw_slider_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, Gtk } // Draw item - tqApp->style().drawComplexControl(TQStyle::CC_Slider, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQSlider, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default), TQStyle::SC_All, ((mousedown)?TQStyle::SC_All:TQStyle::SC_None)); + tqApp->style().drawComplexControl(TQStyle::CC_Slider, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQSlider, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default), TQStyle::SC_All, ((mousedown)?TQStyle::SC_All:TQStyle::SC_None)); } cairo_restore(cr); @@ -641,8 +641,8 @@ draw_scrollbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, gtk_range_get_range_rect(GTK_RANGE(widget), &rangeRect); TQRect boundingRect(0, 0, rangeRect.width, rangeRect.height); - TQt3CairoPaintDevice pd2(NULL, allocation.x + rangeRect.x, allocation.y + rangeRect.y, rangeRect.width, rangeRect.height, cr); - TQPainter p2(&pd2); + TQt3CairoPaintDevice pd(NULL, allocation.x + rangeRect.x, allocation.y + rangeRect.y, rangeRect.width, rangeRect.height, cr); + TQPainter p(&pd); GtkStateFlags widgetStateFlags = gtk_widget_get_state_flags(widget); @@ -785,7 +785,7 @@ draw_scrollbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, } // Draw item - tqApp->style().drawComplexControl(TQStyle::CC_ScrollBar, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), sflags, TQStyle::SC_All, activeSubControl); + tqApp->style().drawComplexControl(TQStyle::CC_ScrollBar, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), sflags, TQStyle::SC_All, activeSubControl); } cairo_restore(cr); @@ -798,8 +798,8 @@ draw_checkbox(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidg TQPalette objectPalette = tqApp->palette(objectTypes); TQRect boundingRect(0, 0, width, height); - TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr); - TQPainter p2(&pd2); + TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); + TQPainter p(&pd); TQStyleControlElementData ceData; TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; @@ -811,7 +811,7 @@ draw_checkbox(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidg } // Draw item - tqApp->style().drawControl(TQStyle::CE_CheckBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget)); + tqApp->style().drawControl(TQStyle::CE_CheckBox, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget)); } static void @@ -821,8 +821,8 @@ draw_radiobutton(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkW TQPalette objectPalette = tqApp->palette(objectTypes); TQRect boundingRect(0, 0, width, height); - TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr); - TQPainter p2(&pd2); + TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); + TQPainter p(&pd); TQStyleControlElementData ceData; TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; @@ -834,7 +834,7 @@ draw_radiobutton(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkW } // Draw item - tqApp->style().drawControl(TQStyle::CE_RadioButton, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget)); + tqApp->style().drawControl(TQStyle::CE_RadioButton, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget)); } static void @@ -844,8 +844,8 @@ draw_pushbutton(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWi TQPalette objectPalette = tqApp->palette(objectTypes); TQRect boundingRect(0, 0, width, height); - TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr); - TQPainter p2(&pd2); + TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); + TQPainter p(&pd); TQStyleControlElementData ceData; TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; @@ -860,7 +860,7 @@ draw_pushbutton(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWi } // Draw item - tqApp->style().drawControl(TQStyle::CE_PushButton, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget)); + tqApp->style().drawControl(TQStyle::CE_PushButton, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget)); } static void @@ -878,8 +878,8 @@ draw_toolbar_button(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, G ceData.orientation = TQt::Horizontal; TQRect boundingRect(0, 0, width, height); - TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr); - TQPainter p2(&pd2); + TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); + TQPainter p(&pd); ceData.rect = boundingRect; @@ -896,7 +896,7 @@ draw_toolbar_button(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, G } // Draw item - tqApp->style().drawComplexControl(TQStyle::CC_ToolButton, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget), TQStyle::SC_ToolButton, ((mousedown)?TQStyle::SC_ToolButton:TQStyle::SC_None)); + tqApp->style().drawComplexControl(TQStyle::CC_ToolButton, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget), TQStyle::SC_ToolButton, ((mousedown)?TQStyle::SC_ToolButton:TQStyle::SC_None)); } /* draw a texture placed on the centroid */ @@ -991,7 +991,7 @@ tdegtk_draw_activity (DRAW_ARGS) printf("[WARNING] tdegtk_draw_activity() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); } static void @@ -1206,7 +1206,7 @@ tdegtk_draw_cell_background (DRAW_ARGS, 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); } - p.end(); + if (p.isActive()) p.end(); cairo_restore(cr); } @@ -1260,16 +1260,12 @@ tdegtk_draw_cell_frame (DRAW_ARGS, 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); } - p.end(); + if (p.isActive()) p.end(); } static void tdegtk_draw_check (DRAW_ARGS) { - TQRect boundingRect(0, 0, width, height); - TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); - TQPainter p(&pd); - const GtkWidgetPath* path; GtkStateFlags state; GtkWidget* widget; @@ -1284,7 +1280,6 @@ tdegtk_draw_check (DRAW_ARGS) else { draw_checkbox(engine, cr, x, y, width, height, path, state, widget, TQT3WT_TQCheckBox); } - p.end(); } static void @@ -1301,7 +1296,7 @@ tdegtk_draw_common (DRAW_ARGS) state = gtk_theming_engine_get_state(engine); //tqApp->style().drawPrimitive(TQStyle::PE_Indicator, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget)); - p.end(); + if (p.isActive()) p.end(); } static void @@ -1658,7 +1653,7 @@ tdegtk_draw_common_background (DRAW_ARGS) printf("[WARNING] tdegtk_draw_common_background() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); cairo_restore(cr); } @@ -1857,7 +1852,7 @@ tdegtk_draw_common_frame (DRAW_ARGS) } else if (gtk_widget_path_is_type(path, GTK_TYPE_LABEL)) { - // Do mothing + // Do nothing } else if (gtk_widget_path_is_type(path, GTK_TYPE_NOTEBOOK)) { @@ -1867,7 +1862,8 @@ tdegtk_draw_common_frame (DRAW_ARGS) else if (gtk_widget_path_is_type(path, GTK_TYPE_LEVEL_BAR)) { const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget); - + + p.end(); // Restore original Cairo context before creating a new TQt3 paint device based on that context boundingRect = TQRect(0, 0, allocation.width, allocation.height); TQt3CairoPaintDevice pd2(NULL, 0, 0, allocation.width, allocation.height, cr); TQPainter p2(&pd2); @@ -1908,7 +1904,7 @@ tdegtk_draw_common_frame (DRAW_ARGS) } } - p.end(); + if (p.isActive()) p.end(); cairo_restore(cr); } @@ -1933,7 +1929,7 @@ tdegtk_draw_expander (DRAW_ARGS) DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,255,0); printf("[WARNING] tdegtk_draw_expander() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); - p.end(); + if (p.isActive()) p.end(); #else GtkStateFlags state; GdkRGBA color; @@ -2081,6 +2077,7 @@ tdegtk_draw_extension (DRAW_ARGS, cairo_save(cr); cairo_reset_clip(cr); + p.end(); // Restore original Cairo context before creating a new TQt3 paint device based on that context TQt3CairoPaintDevice pd2(NULL, paintDeviceRect.x(), paintDeviceRect.y(), paintDeviceRect.width(), paintDeviceRect.height(), cr); TQPainter p2(&pd2); @@ -2099,7 +2096,7 @@ tdegtk_draw_extension (DRAW_ARGS, printf("[WARNING] tdegtk_draw_extension() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); } static void @@ -2194,7 +2191,7 @@ tdegtk_draw_focus (DRAW_ARGS) printf("[WARNING] tdegtk_draw_focus() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); } static void @@ -2272,7 +2269,7 @@ tdegtk_draw_frame_gap (DRAW_ARGS, printf("[WARNING] tdegtk_draw_frame_gap() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); } static void @@ -2306,7 +2303,7 @@ tdegtk_draw_grip (DRAW_ARGS) cairo_restore(cr); - p.end(); + if (p.isActive()) p.end(); } static void @@ -2347,7 +2344,7 @@ tdegtk_draw_handle (DRAW_ARGS) printf("[WARNING] tdegtk_draw_handle() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); } static void @@ -2391,8 +2388,6 @@ tdegtk_draw_notebook (DRAW_ARGS, TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); TQPainter p(&pd); - DEBUG_FILL_BACKGROUND_WITH_COLOR(p,0,255,0); - const GtkWidgetPath* path; GtkStateFlags state; GtkWidget* widget; @@ -2401,27 +2396,30 @@ tdegtk_draw_notebook (DRAW_ARGS, state = gtk_theming_engine_get_state(engine); widget = m_widgetLookup.find(cr, path); - TQStringList objectTypes; - objectTypes.append(TQTABWIDGET_OBJECT_NAME_STRING); - TQPalette objectPalette = tqApp->palette(objectTypes); - - // Draw background - TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background); - DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) + if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_NOTEBOOK)) { + TQStringList objectTypes; + objectTypes.append(TQTABWIDGET_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + // Draw background + TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background); + DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) + + // Draw tab frame + tqApp->style().drawPrimitive(TQStyle::PE_PanelTabWidget, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget)); + } - // Draw tab frame - tqApp->style().drawPrimitive(TQStyle::PE_PanelTabWidget, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget)); + else { + DEBUG_FILL_BACKGROUND_WITH_COLOR(p,0,255,0); + printf("[WARNING] tdegtk_draw_notebook() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); + } - p.end(); + if (p.isActive()) p.end(); } static void tdegtk_draw_radio (DRAW_ARGS) { - TQRect boundingRect(0, 0, width, height); - TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); - TQPainter p(&pd); - const GtkWidgetPath* path; GtkStateFlags state; GtkWidget* widget; @@ -2436,9 +2434,9 @@ tdegtk_draw_radio (DRAW_ARGS) else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM)) { const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget); - boundingRect = TQRect(0, 0, allocation.width, allocation.height); - TQt3CairoPaintDevice pd2(NULL, 0, 0, allocation.width, allocation.height, cr); - TQPainter p2(&pd2); + TQRect boundingRect(0, 0, allocation.width, allocation.height); + TQt3CairoPaintDevice pd(NULL, 0, 0, allocation.width, allocation.height, cr); + TQPainter p(&pd); bool checked = ((state & GTK_STATE_FLAG_ACTIVE) != 0); int maxAcceleratorTextWidth = 0; @@ -2459,15 +2457,13 @@ tdegtk_draw_radio (DRAW_ARGS) elementFlags = elementFlags | TQStyle::TQStyle::CEF_IsCheckable; if (checked) { - tqApp->style().drawPrimitive(TQStyle::PE_MenuItemIndicatorFrame, &p2, ceData, elementFlags, ceData.rect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQRadioButton, widget), menuOpt); - tqApp->style().drawPrimitive(TQStyle::PE_MenuItemIndicatorCheck, &p2, ceData, elementFlags, ceData.rect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQRadioButton, widget), menuOpt); + tqApp->style().drawPrimitive(TQStyle::PE_MenuItemIndicatorFrame, &p, ceData, elementFlags, ceData.rect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQRadioButton, widget), menuOpt); + tqApp->style().drawPrimitive(TQStyle::PE_MenuItemIndicatorCheck, &p, ceData, elementFlags, ceData.rect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQRadioButton, widget), menuOpt); } } else { draw_radiobutton(engine, cr, x, y, width, height, path, state, widget, TQT3WT_TQRadioButton); } - - p.end(); } static void @@ -2529,6 +2525,7 @@ tdegtk_draw_separator (DRAW_ARGS) else { y = y + (height/4); } + p.end(); // Restore original Cairo context before creating a new TQt3 paint device based on that context TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr); TQPainter p2(&pd2); @@ -2552,7 +2549,7 @@ tdegtk_draw_separator (DRAW_ARGS) printf("[WARNING] tdegtk_draw_separator() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); cairo_restore(cr); } @@ -2634,7 +2631,7 @@ tdegtk_draw_slider (DRAW_ARGS, printf("[WARNING] tdegtk_draw_slider() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout); } - p.end(); + if (p.isActive()) p.end(); cairo_restore(cr); } @@ -2648,7 +2645,7 @@ tdegtk_draw_spinbutton_background (DRAW_ARGS) DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,255,0); - p.end(); + if (p.isActive()) p.end(); } static void @@ -2660,7 +2657,7 @@ tdegtk_draw_spinbutton_frame (DRAW_ARGS) DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,255,128); - p.end(); + if (p.isActive()) p.end(); } void diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp index 90a6d3b..041e076 100644 --- a/tdegtk/tqtcairopainter.cpp +++ b/tdegtk/tqtcairopainter.cpp @@ -37,6 +37,11 @@ #define SET_BIT(x, y) (x |= 1 << y) #define TEST_BIT(x, y) ((x & (1 << y)) >> y) +// SLOW BUT VERIFIED CORRECT +//#define FASTEST_AVAILABLE_PAINTER (m_painter) +// FAST BUT EXPERIMENTAL AND UNVERIFIED +#define FASTEST_AVAILABLE_PAINTER (intermediateSurfaceInUse()?m_painter:m_devicePainter) + // Little endian #define ARGB_A_BYTE_NUMBER 3 #define ARGB_R_BYTE_NUMBER 2 @@ -403,31 +408,35 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() { m_transferNeeded = false; } +bool TQt3CairoPaintDevice::intermediateSurfaceInUse() const { + return (m_clipRegionEnabled || (m_rop != TQPainter::CopyROP)); +} + void TQt3CairoPaintDevice::dualStrokePen() { if (m_bgColorMode == TQt::OpaqueMode) { // Draw background - cairo_save(m_painter); + cairo_save(FASTEST_AVAILABLE_PAINTER); updatePen(TRUE); - cairo_stroke(m_painter); - cairo_restore(m_painter); + cairo_stroke(FASTEST_AVAILABLE_PAINTER); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } // Draw foreground updatePen(FALSE); - cairo_stroke(m_painter); + cairo_stroke(FASTEST_AVAILABLE_PAINTER); m_transferNeeded = true; } void TQt3CairoPaintDevice::dualStrokeBrush(cairo_fill_rule_t fillMethod) { if (m_bgColorMode == TQt::OpaqueMode) { // Draw background - cairo_save(m_painter); + cairo_save(FASTEST_AVAILABLE_PAINTER); updateBrush(TRUE, fillMethod); - cairo_fill(m_painter); - cairo_restore(m_painter); + cairo_fill(FASTEST_AVAILABLE_PAINTER); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } // Draw foreground updateBrush(FALSE, fillMethod); - cairo_fill(m_painter); + cairo_fill(FASTEST_AVAILABLE_PAINTER); m_transferNeeded = true; } @@ -692,8 +701,8 @@ static inline void fix_neg_rect( int *x, int *y, int *w, int *h ) { void TQt3CairoPaintDevice::drawPolygon(const TQPointArray* pointarray, bool winding, bool fill, bool close) { int i; - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (pointarray) { int x; int y; @@ -703,15 +712,15 @@ void TQt3CairoPaintDevice::drawPolygon(const TQPointArray* pointarray, bool wind for (i=0;icount();i++) { pointarray->point(i, &x, &y); if (first) { - cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); first = false; } else { - cairo_line_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_line_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); } } if (close) { - cairo_close_path(m_painter); + cairo_close_path(FASTEST_AVAILABLE_PAINTER); } dualStrokeBrush((winding)?CAIRO_FILL_RULE_EVEN_ODD:CAIRO_FILL_RULE_WINDING); } @@ -720,25 +729,25 @@ void TQt3CairoPaintDevice::drawPolygon(const TQPointArray* pointarray, bool wind for (i=0;icount();i++) { pointarray->point(i, &x, &y); if (first) { - cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); first = false; } else { - cairo_line_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_line_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); } } if (close) { - cairo_close_path(m_painter); + cairo_close_path(FASTEST_AVAILABLE_PAINTER); } dualStrokePen(); } } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } } void TQt3CairoPaintDevice::drawRoundRect(int x, int y, int w, int h, int xRnd, int yRnd) { - if (!m_painter) { + if (!FASTEST_AVAILABLE_PAINTER) { return; } @@ -801,7 +810,7 @@ void TQt3CairoPaintDevice::drawRoundRect(int x, int y, int w, int h, int xRnd, i } void TQt3CairoPaintDevice::drawEllipse(int x, int y, int w, int h) { - if (!m_painter) { + if (!FASTEST_AVAILABLE_PAINTER) { return; } @@ -815,7 +824,7 @@ void TQt3CairoPaintDevice::drawEllipse(int x, int y, int w, int h) { } void TQt3CairoPaintDevice::drawArc(int x, int y, int w, int h, int a, int alen) { - if (!m_painter) { + if (!FASTEST_AVAILABLE_PAINTER) { return; } @@ -829,7 +838,7 @@ void TQt3CairoPaintDevice::drawArc(int x, int y, int w, int h, int a, int alen) } void TQt3CairoPaintDevice::drawPie(int x, int y, int w, int h, int a, int alen) { - if (!m_painter) { + if (!FASTEST_AVAILABLE_PAINTER) { return; } @@ -861,7 +870,7 @@ void TQt3CairoPaintDevice::drawPie(int x, int y, int w, int h, int a, int alen) } void TQt3CairoPaintDevice::drawChord(int x, int y, int w, int h, int a, int alen) { - if (!m_painter) { + if (!FASTEST_AVAILABLE_PAINTER) { return; } @@ -997,29 +1006,29 @@ void TQt3CairoPaintDevice::pangoSetupTextPath(PangoLayout *layout, const char* t } void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString &str) { - if ((!m_painter) || (!p)) { + if ((!FASTEST_AVAILABLE_PAINTER) || (!p)) { return; } PangoLayout *layout; - layout = pango_cairo_create_layout(m_painter); + layout = pango_cairo_create_layout(FASTEST_AVAILABLE_PAINTER); TQFont::StyleStrategy qt3fontstrategy = m_font.styleStrategy(); pangoSetupTextPath(layout, str.utf8()); int baseline_y = pango_layout_get_baseline(layout)/PANGO_SCALE; - cairo_new_path(m_painter); - cairo_move_to(m_painter, x, y-baseline_y); + cairo_new_path(FASTEST_AVAILABLE_PAINTER); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x, y-baseline_y); updatePen(FALSE); - pango_cairo_update_layout(m_painter, layout); - pango_cairo_layout_path(m_painter, layout); + pango_cairo_update_layout(FASTEST_AVAILABLE_PAINTER, layout); + pango_cairo_layout_path(FASTEST_AVAILABLE_PAINTER, layout); if ((qt3fontstrategy & TQFont::PreferOutline) || (qt3fontstrategy & TQFont::ForceOutline)) { - cairo_stroke_preserve(m_painter); + cairo_stroke_preserve(FASTEST_AVAILABLE_PAINTER); } else { - cairo_fill(m_painter); + cairo_fill(FASTEST_AVAILABLE_PAINTER); } g_object_unref(layout); @@ -1028,12 +1037,12 @@ void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString & } void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFlags, const TQString &str) { - if ((!m_painter) || (!p)) { + if ((!FASTEST_AVAILABLE_PAINTER) || (!p)) { return; } PangoLayout *layout; - layout = pango_cairo_create_layout(m_painter); + layout = pango_cairo_create_layout(FASTEST_AVAILABLE_PAINTER); TQFont::StyleStrategy qt3fontstrategy = m_font.styleStrategy(); pangoSetupTextPath(layout, str.utf8()); @@ -1048,8 +1057,8 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla pango_layout_set_height(layout, 0); } if (!(textFlags & TQt::DontClip)) { - cairo_rectangle(m_painter, rect.x()+CAIRO_PEN_PIXEL_OFFSET, rect.y()+CAIRO_PEN_PIXEL_OFFSET, rect.width(), rect.height()); - cairo_clip(m_painter); + cairo_rectangle(FASTEST_AVAILABLE_PAINTER, rect.x()+CAIRO_PEN_PIXEL_OFFSET, rect.y()+CAIRO_PEN_PIXEL_OFFSET, rect.width(), rect.height()); + cairo_clip(FASTEST_AVAILABLE_PAINTER); } if (textFlags & TQt::ExpandTabs) { // FIXME @@ -1102,32 +1111,44 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla fudgedOffsetY = ((rect.height()-stockHeight)/2); } - cairo_new_path(m_painter); - cairo_move_to(m_painter, rect.x(), rect.y() + fudgedOffsetY); + cairo_new_path(FASTEST_AVAILABLE_PAINTER); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, rect.x(), rect.y() + fudgedOffsetY); updatePen(FALSE); - pango_cairo_update_layout(m_painter, layout); - pango_cairo_layout_path(m_painter, layout); + pango_cairo_update_layout(FASTEST_AVAILABLE_PAINTER, layout); + pango_cairo_layout_path(FASTEST_AVAILABLE_PAINTER, layout); if ((qt3fontstrategy & TQFont::PreferOutline) || (qt3fontstrategy & TQFont::ForceOutline)) { - cairo_stroke_preserve(m_painter); + cairo_stroke_preserve(FASTEST_AVAILABLE_PAINTER); } else { - cairo_fill(m_painter); + cairo_fill(FASTEST_AVAILABLE_PAINTER); } - cairo_reset_clip(m_painter); + cairo_reset_clip(FASTEST_AVAILABLE_PAINTER); g_object_unref(layout); m_transferNeeded = true; } -void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable) { +void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable, bool applyBaseDeviceTransform) { cairo_matrix_t combinedMatrix; cairo_matrix_t tempMatrix; cairo_matrix_init_identity(&combinedMatrix); if (!forceDisable) { + if (applyBaseDeviceTransform) { + // Handle specified offsets + cairo_matrix_t offsetMatrix; + cairo_matrix_init_identity(&offsetMatrix); + cairo_matrix_init_translate(&offsetMatrix, m_offsetX, m_offsetY); + + cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_deviceMatrix); + combinedMatrix = tempMatrix; + + cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &offsetMatrix); + combinedMatrix = tempMatrix; + } if (m_worldMatrixEnabled) { cairo_matrix_multiply(&tempMatrix, &combinedMatrix, &m_worldMatrix); combinedMatrix = tempMatrix; @@ -1280,63 +1301,63 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) case PdcNOP: break; case PdcDrawPoint: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (m_pen.style() != TQPen::NoPen) { - cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); - cairo_line_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_line_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); updatePen(FALSE); - cairo_set_line_cap(m_painter, CAIRO_LINE_CAP_ROUND); - cairo_stroke(m_painter); + cairo_set_line_cap(FASTEST_AVAILABLE_PAINTER, CAIRO_LINE_CAP_ROUND); + cairo_stroke(FASTEST_AVAILABLE_PAINTER); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); m_transferNeeded = true; } break; case PdcMoveTo: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (m_pen.style() != TQPen::NoPen) { - cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcLineTo: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (m_pen.style() != TQPen::NoPen) { - cairo_line_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET); + cairo_line_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET); dualStrokePen(); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawLine: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (m_pen.style() != TQPen::NoPen) { - cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); - cairo_line_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_line_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET); dualStrokePen(); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawRect: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); int adjustment = cairoPainterRectSubtraction(&m_pen); if (m_brush.style() != TQBrush::NoBrush) { int line_width = m_pen.width(); - cairo_rectangle(m_painter, x+line_width+CAIRO_BRUSH_PIXEL_OFFSET, y+line_width+CAIRO_BRUSH_PIXEL_OFFSET, width-(line_width*2)-adjustment, height-(line_width*2)-adjustment); + cairo_rectangle(FASTEST_AVAILABLE_PAINTER, x+line_width+CAIRO_BRUSH_PIXEL_OFFSET, y+line_width+CAIRO_BRUSH_PIXEL_OFFSET, width-(line_width*2)-adjustment, height-(line_width*2)-adjustment); dualStrokeBrush(CAIRO_FILL_RULE_EVEN_ODD); } if (m_pen.style() != TQPen::NoPen) { - cairo_rectangle(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET, width-adjustment, height-adjustment); + cairo_rectangle(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET, width-adjustment, height-adjustment); dualStrokePen(); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } else { #if defined(QT_CHECK_RANGE) @@ -1345,58 +1366,58 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) } break; case PdcDrawRoundRect: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); int adjustment = cairoPainterRectSubtraction(&m_pen); if (p) { drawRoundRect(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawEllipse: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); int adjustment = cairoPainterRectSubtraction(&m_pen); if (p) { drawEllipse(x, y, width-adjustment, height-adjustment); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawArc: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); int adjustment = cairoPainterRectSubtraction(&m_pen); if (p) { drawArc(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawPie: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); int adjustment = cairoPainterRectSubtraction(&m_pen); if (p) { drawPie(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawChord: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); int adjustment = cairoPainterRectSubtraction(&m_pen); if (p) { drawChord(x, y, width-adjustment, height-adjustment, p[1].ival, p[2].ival); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawLineSegments: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { int x; int y; @@ -1408,14 +1429,14 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) for (i=0;icount();i=i+2) { pointarray->point(i+0, &x, &y); pointarray->point(i+1, &x2, &y2); - cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); - cairo_line_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_line_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET); dualStrokePen(); } } } } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawPolyline: @@ -1429,8 +1450,8 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) } break; case PdcDrawCubicBezier: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { int x; int y; @@ -1448,61 +1469,61 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) pointarray->point(i+1, &x2, &y2); pointarray->point(i+2, &x3, &y3); pointarray->point(i+3, &x4, &y4); - cairo_move_to(m_painter, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); - cairo_curve_to(m_painter, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET, x3+CAIRO_PEN_PIXEL_OFFSET, y3+CAIRO_PEN_PIXEL_OFFSET, x4+CAIRO_PEN_PIXEL_OFFSET, y4+CAIRO_PEN_PIXEL_OFFSET); + cairo_move_to(FASTEST_AVAILABLE_PAINTER, x+CAIRO_PEN_PIXEL_OFFSET, y+CAIRO_PEN_PIXEL_OFFSET); + cairo_curve_to(FASTEST_AVAILABLE_PAINTER, x2+CAIRO_PEN_PIXEL_OFFSET, y2+CAIRO_PEN_PIXEL_OFFSET, x3+CAIRO_PEN_PIXEL_OFFSET, y3+CAIRO_PEN_PIXEL_OFFSET, x4+CAIRO_PEN_PIXEL_OFFSET, y4+CAIRO_PEN_PIXEL_OFFSET); dualStrokePen(); } } } } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawText: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { TQString string = *p[1].str; drawText(pt, p[0].rect->x()+CAIRO_PEN_PIXEL_OFFSET, p[0].rect->y()+CAIRO_PEN_PIXEL_OFFSET, string); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawTextFormatted: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { TQRect rect = *p[0].rect; TQString string = *p[2].str; drawTextInRect(pt, rect, p[1].ival, string); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawText2: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { TQString string = *p[1].str; drawText(pt, p[0].rect->x()+CAIRO_PEN_PIXEL_OFFSET, p[0].rect->y()+CAIRO_PEN_PIXEL_OFFSET, string); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawText2Formatted: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { TQRect rect = *p[0].rect; TQString string = *p[2].str; drawTextInRect(pt, rect, p[1].ival, string); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); } break; case PdcDrawPixmap: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { TQImage sourceImage; const TQBitmap* bitmap = dynamic_cast(p[1].pixmap); @@ -1516,28 +1537,28 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) sourceImage = p[1].pixmap->convertToImage(); } cairo_surface_t* sourceSurface = TQImageToCairoSurface(sourceImage); - cairo_rectangle(m_painter, p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height()); - cairo_set_source_surface(m_painter, sourceSurface, p[0].rect->x(), p[0].rect->y()); - cairo_fill(m_painter); + cairo_rectangle(FASTEST_AVAILABLE_PAINTER, p[0].rect->x(), p[0].rect->y(), p[0].rect->width(), p[0].rect->height()); + cairo_set_source_surface(FASTEST_AVAILABLE_PAINTER, sourceSurface, p[0].rect->x(), p[0].rect->y()); + cairo_fill(FASTEST_AVAILABLE_PAINTER); cairo_surface_destroy(sourceSurface); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); m_transferNeeded = true; } break; case PdcDrawImage: - if (m_painter) { - cairo_save(m_painter); + if (FASTEST_AVAILABLE_PAINTER) { + cairo_save(FASTEST_AVAILABLE_PAINTER); if (p) { TQRect rect = *p[0].rect; TQImage image = *p[1].image; cairo_surface_t* sourceSurface = TQImageToCairoSurface(image); - cairo_rectangle(m_painter, rect.x(), rect.y(), rect.width(), rect.height()); - cairo_set_source_surface(m_painter, sourceSurface, rect.x(), rect.y()); - cairo_fill(m_painter); + cairo_rectangle(FASTEST_AVAILABLE_PAINTER, rect.x(), rect.y(), rect.width(), rect.height()); + cairo_set_source_surface(FASTEST_AVAILABLE_PAINTER, sourceSurface, rect.x(), rect.y()); + cairo_fill(FASTEST_AVAILABLE_PAINTER); cairo_surface_destroy(sourceSurface); } - cairo_restore(m_painter); + cairo_restore(FASTEST_AVAILABLE_PAINTER); m_transferNeeded = true; } break; @@ -1565,6 +1586,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_matrix_init_identity(&m_worldMatrix); cairo_matrix_init_identity(&m_viewportMatrix); setCairoTransformations(m_painter); + setCairoTransformations(m_devicePainter, false, true); m_rop = TQPainter::CopyROP; m_clipRegion = TQImage(); m_clipRegionEnabled = false; @@ -1585,6 +1607,9 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) if (!m_overridePainter) { cairo_destroy(m_devicePainter); } + else { + cairo_set_matrix(m_devicePainter, &m_deviceMatrix); + } m_devicePainter = NULL; } break; @@ -1689,7 +1714,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) if ((p) && (m_painter)) { m_viewportMatrixEnabled = p[0].ival; setCairoTransformations(m_painter); - setCairoTransformations(m_devicePainter); + setCairoTransformations(m_devicePainter, false, true); } break; case PdcSetWindow: @@ -1707,7 +1732,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) double scaleH = (double)vh/(double)wh; cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH); setCairoTransformations(m_painter); - setCairoTransformations(m_devicePainter); + setCairoTransformations(m_devicePainter, false, true); } break; case PdcSetViewport: @@ -1725,14 +1750,14 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) double scaleH = (double)vh/(double)wh; cairo_matrix_init(&m_viewportMatrix, scaleW, 0, 0, scaleH, vx - wx*scaleW, vy - wy*scaleH); setCairoTransformations(m_painter); - setCairoTransformations(m_devicePainter); + setCairoTransformations(m_devicePainter, false, true); } break; case PdcSetWXform: if ((p) && (m_painter)) { m_worldMatrixEnabled = p[0].ival; setCairoTransformations(m_painter); - setCairoTransformations(m_devicePainter); + setCairoTransformations(m_devicePainter, false, true); } break; case PdcSetWMatrix: @@ -1751,7 +1776,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_matrix_init(&m_worldMatrix, tqt3matrix->m11(), tqt3matrix->m12(), tqt3matrix->m21(), tqt3matrix->m22(), tqt3matrix->dx(), tqt3matrix->dy()); } setCairoTransformations(m_painter); - setCairoTransformations(m_devicePainter); + setCairoTransformations(m_devicePainter, false, true); } } break; diff --git a/tdegtk/tqtcairopainter.h b/tdegtk/tqtcairopainter.h index 764efd7..5e7dc55 100644 --- a/tdegtk/tqtcairopainter.h +++ b/tdegtk/tqtcairopainter.h @@ -52,6 +52,7 @@ class Q_EXPORT TQt3CairoPaintDevice : public TQPaintDevice // picture class void updateSurfaceDimensions() const; void resetIntermediateSurface(); void transferIntermediateSurface(); + bool intermediateSurfaceInUse() const; void updatePen(bool backgroundStroke=FALSE); void dualStrokePen(); @@ -70,7 +71,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(cairo_t* cr, bool forceDisable=false); + void setCairoTransformations(cairo_t* cr, bool forceDisable=false, bool applyBaseDeviceTransform=false); private: mutable int m_width;