diff options
author | Timothy Pearson <[email protected]> | 2012-11-19 02:10:46 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-11-19 02:10:46 -0600 |
commit | 114c26e88f3814bc9d864faa0b46b00c19b8513b (patch) | |
tree | caaabb45f76279fc883401aa2985be7a1e5e693e /tdegtk | |
parent | 2f93dfb8bfc66c98675499cde3f54fe90049e3ce (diff) | |
download | gtk3-tqt-engine-114c26e88f3814bc9d864faa0b46b00c19b8513b.tar.gz gtk3-tqt-engine-114c26e88f3814bc9d864faa0b46b00c19b8513b.zip |
Add GtkSwitch support
Speed up drawing operations on newer GTK/Cairo versions
Diffstat (limited to 'tdegtk')
-rw-r--r-- | tdegtk/tdegtk-draw.cpp | 32 | ||||
-rw-r--r-- | tdegtk/tqtcairopainter.cpp | 37 | ||||
-rw-r--r-- | tdegtk/tqtcairopainter.h | 2 |
3 files changed, 64 insertions, 7 deletions
diff --git a/tdegtk/tdegtk-draw.cpp b/tdegtk/tdegtk-draw.cpp index 21bd704..2bd54e8 100644 --- a/tdegtk/tdegtk-draw.cpp +++ b/tdegtk/tdegtk-draw.cpp @@ -1586,6 +1586,22 @@ tdegtk_draw_common_background (DRAW_ARGS) // Do nothing } + else if (gtk_widget_path_is_type(path, GTK_TYPE_SWITCH)) { + TQStringList objectTypes; + objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + TQStyleControlElementData ceData; + TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; + ceData.widgetObjectTypes = objectTypes; + ceData.rect = boundingRect; + ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal; + ceData.startStep = 0; + + // Draw frame + tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); + } + else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BACKGROUND)) || (gtk_widget_path_is_type(path, GTK_TYPE_EXPANDER)) || (gtk_widget_path_is_type(path, GTK_TYPE_BOX)) @@ -2515,6 +2531,22 @@ tdegtk_draw_slider (DRAW_ARGS, draw_slider_frame(engine, cr, x, y, width, height, path, state, widget); } + else if (gtk_widget_path_is_type(path, GTK_TYPE_SWITCH)) { + TQStringList objectTypes; + objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + TQStyleControlElementData ceData; + TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; + ceData.widgetObjectTypes = objectTypes; + ceData.rect = boundingRect; + ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal; + ceData.startStep = 0; + + // Draw slider + tqApp->style().drawPrimitive(TQStyle::PE_ScrollBarSlider, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); + } + else { DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,0,255); 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); diff --git a/tdegtk/tqtcairopainter.cpp b/tdegtk/tqtcairopainter.cpp index 9c7d010..a2867f0 100644 --- a/tdegtk/tqtcairopainter.cpp +++ b/tdegtk/tqtcairopainter.cpp @@ -381,6 +381,8 @@ void TQt3CairoPaintDevice::transferIntermediateSurface() { cairo_set_source_rgba(m_painter, 0.0, 0.0, 0.0, 0.0); cairo_paint(m_painter); cairo_restore(m_painter); + + m_transferNeeded = false; } void TQt3CairoPaintDevice::dualStrokePen() { @@ -394,7 +396,7 @@ void TQt3CairoPaintDevice::dualStrokePen() { // Draw foreground updatePen(FALSE); cairo_stroke(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::dualStrokeBrush(cairo_fill_rule_t fillMethod) { @@ -408,7 +410,7 @@ void TQt3CairoPaintDevice::dualStrokeBrush(cairo_fill_rule_t fillMethod) { // Draw foreground updateBrush(FALSE, fillMethod); cairo_fill(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::updatePen(bool backgroundStroke) { @@ -989,7 +991,7 @@ void TQt3CairoPaintDevice::drawText(TQPainter *p, int x, int y, const TQString & g_object_unref(layout); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFlags, const TQString &str) { @@ -1084,7 +1086,7 @@ void TQt3CairoPaintDevice::drawTextInRect(TQPainter *p, TQRect rect, int textFla g_object_unref(layout); - transferIntermediateSurface(); + m_transferNeeded = true; } void TQt3CairoPaintDevice::setCairoTransformations(cairo_t* cr, bool forceDisable) { @@ -1186,6 +1188,8 @@ void TQt3CairoPaintDevice::init() { m_overridePainter = NULL; m_tabStops = NULL; m_tabStopArray = NULL; + + m_transferNeeded = false; } void TQt3CairoPaintDevice::updateSurfaceDimensions() const { @@ -1253,7 +1257,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_stroke(m_painter); } cairo_restore(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } break; case PdcMoveTo: @@ -1485,7 +1489,7 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_surface_destroy(sourceSurface); } cairo_restore(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } break; case PdcDrawImage: @@ -1501,11 +1505,12 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) cairo_surface_destroy(sourceSurface); } cairo_restore(m_painter); - transferIntermediateSurface(); + m_transferNeeded = true; } break; case PdcBegin: if (!m_painter) { + m_transferNeeded = false; m_bgColor = TQColor(0,0,0); m_bgColorMode = TQt::TransparentMode; resetIntermediateSurface(); @@ -1536,6 +1541,9 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) break; case PdcEnd: if (m_painter) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } cairo_destroy(m_painter); m_painter = NULL; } @@ -1567,6 +1575,10 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) break; case PdcSetROP: if ((p) && (m_painter)) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } + TQt::RasterOp rop = (TQt::RasterOp)p[0].ival; m_rop = rop; } @@ -1726,11 +1738,17 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) break; case PdcSetClip: if ((p) && (m_painter)) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } m_clipRegionEnabled = p[0].ival; } break; case PdcSetClipRegion: if ((p) && (m_painter)) { + if (m_transferNeeded) { + transferIntermediateSurface(); + } // SLOW TQRect tqt3br = p[0].rgn->boundingRect(); if (!tqt3br.isNull()) { @@ -1751,6 +1769,11 @@ bool TQt3CairoPaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p ) } } break; + case PdcFlush: + case PdcFlushRegion: + if (m_transferNeeded) { + transferIntermediateSurface(); + } default: #if defined(QT_CHECK_RANGE) tqWarning( "TQt3CairoPaintDevice::cmd: Invalid command %d", c ); diff --git a/tdegtk/tqtcairopainter.h b/tdegtk/tqtcairopainter.h index 6908e03..7bd5b98 100644 --- a/tdegtk/tqtcairopainter.h +++ b/tdegtk/tqtcairopainter.h @@ -103,6 +103,8 @@ class Q_EXPORT TQt3CairoPaintDevice : public TQPaintDevice // picture class PangoTabArray* m_tabStopArray; bool m_tabStopsValid; bool m_tabStopArrayValid; + + bool m_transferNeeded; }; #endif // TQTCAIROPAINTER_H |