Add GtkSwitch support

Speed up drawing operations on newer GTK/Cairo versions
pull/1/head
Timothy Pearson 12 years ago
parent 2f93dfb8bf
commit 114c26e88f

@ -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);

@ -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 );

@ -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

Loading…
Cancel
Save