diff --git a/src/qt_qt_wrapper.cpp b/src/qt_qt_wrapper.cpp index 651aa80..188684c 100644 --- a/src/qt_qt_wrapper.cpp +++ b/src/qt_qt_wrapper.cpp @@ -97,6 +97,8 @@ int isKeramik; int isAlloy; int isDomino; int isPolyester; +int isMotif; +int isQtCurve; int eclipseFix; int openOfficeFix; int mozillaFix; @@ -444,6 +446,9 @@ void createTQApp() isAlloy = (TQString(tqApp->style().name()).lower() == "alloy"); isDomino = (TQString(tqApp->style().name()).lower() == "domino"); isPolyester = (TQString(tqApp->style().name()).lower() == "polyester"); + isMotif = (TQString(tqApp->style().name()).lower() == "motif" || + TQString(tqApp->style().name()).lower() == "cde"); + isQtCurve = (TQString(tqApp->style().name()).lower() == "qtcurve"); if (isDomino) { @@ -652,6 +657,30 @@ TQColor gdkColorToTQColor(GdkColor* c) return TQColor(c->red / 256, c->green / 256, c->blue / 256); } +void drawTQPixmapToWindow(GdkWindow* window, GdkGC* gc, TQPixmap* pixmap, int x, int y, int w, int h) { + static GdkGC* igc = gdk_gc_new(window); + GdkPixmap* pix; + + int width, height; + gdk_drawable_get_size(window, &width, &height); + if (!pixmap->hasAlpha() || isDomino || isBaghira || + (width < x + w) || (height < y + h)) { + pix = gdk_pixmap_foreign_new(pixmap->handle()); + gdk_draw_drawable(window, gc, pix, 0, 0, x, y, w, h); + g_object_unref(pix); + return; + } + + TQPixmap gpixmap(w, h); + pix = gdk_pixmap_foreign_new(gpixmap.handle()); + GdkImage* img = gdk_drawable_get_image(window, x, y, w, h); + gdk_draw_image(pix, igc, img, 0, 0, 0, 0, w, h); + bitBlt(&gpixmap, 0, 0, pixmap, 0, 0, w, h, TQt::CopyROP); + + gdk_draw_drawable(window, gc, pix, 0, 0, x, y, w, h); + g_object_unref(img); + g_object_unref(pix); +} // The drawing functions follow the same pattern: // * Set the appropriate flags @@ -762,9 +791,15 @@ void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defa tqApp->style().subRect(TQStyle::SR_PushButtonContents, &button), button.colorGroup(), sflags); - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); - g_object_unref(pix); + if (!isBaghira && !isMotif) { + TQBitmap bitmap(w, h, TRUE); + TQPainter bpainter(&bitmap); + bpainter.setBrush(TQt::color1); + tqApp->style().drawControlMask(TQStyle::CE_PushButton, &bpainter, &button, TQRect(0,0,w,h), sflags); + pixmap.setMask(bitmap); + } + + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h); } else { TQPixmap pixmap(w, h); @@ -786,9 +821,15 @@ void drawButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int defa tqApp->style().drawControl(TQStyle::CE_PushButton, &painter, &button, TQRect(0,0,w,h), button.palette().active(), sflags); - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); - g_object_unref(pix); + if (!isBaghira && !isMotif) { + TQBitmap bitmap(w, h, TRUE); + TQPainter bpainter(&bitmap); + bpainter.setBrush(TQt::color1); + tqApp->style().drawControlMask(TQStyle::CE_PushButton, &bpainter, &button, TQRect(0,0,w,h), sflags); + pixmap.setMask(bitmap); + } + + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h); } } @@ -1066,6 +1107,11 @@ void drawCheckBox(GdkWindow* window, GtkStyle* style, GtkStateType state, int ch int realH = tqApp->style().pixelMetric(TQStyle::PM_IndicatorHeight); int realW = tqApp->style().pixelMetric(TQStyle::PM_IndicatorWidth); + if (isKeramik) { + realW-= 2; + realH-= 2; + } + if ((realW < 1) || (realH < 1)) return; @@ -1084,9 +1130,13 @@ void drawCheckBox(GdkWindow* window, GtkStyle* style, GtkStateType state, int ch int xOffset = (realW - w) / 2; int yOffset = (realH - h) / 2; - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x - xOffset, y - yOffset, realW, realH); - g_object_unref(pix); + TQBitmap bitmap(realW, realH, TRUE); + TQPainter bpainter(&bitmap); + bpainter.setBrush(TQt::color1); + tqApp->style().drawControlMask(TQStyle::CE_CheckBox, &bpainter, &checkbox, TQRect(0,0,realW,realH), sflags); + pixmap.setMask(bitmap); + + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h); } void drawMenuCheck(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, int y, int w, int h) @@ -1135,7 +1185,7 @@ void drawRadioButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int if ((realW < 1) || (realH < 1)) return; - TQPixmap pixmap(realH, realW); + TQPixmap pixmap(realW, realH); TQPainter painter(&pixmap); TQRadioButton radio(0); @@ -1149,16 +1199,21 @@ void drawRadioButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int else painter.fillRect(0, 0, realW, realH, tqApp->palette().active().brush(TQColorGroup::Background)); - tqApp->style().drawControl(TQStyle::CE_RadioButton, &painter, &radio, TQRect(0,0,realH,realW), tqApp->palette().active(), sflags); + tqApp->style().drawControl(TQStyle::CE_RadioButton, &painter, &radio, TQRect(0,0,realW,realH), tqApp->palette().active(), sflags); // TQt checkboxes are usually bigger than GTK wants. // We cheat, and draw them over the expected area. int xOffset = (realW - w) / 2; int yOffset = (realH - h) / 2; + int bOffset = isQtCurve ? -1 : 0; - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x - xOffset, y - yOffset, realW, realH); - g_object_unref(pix); + TQBitmap bitmap(realW, realH, TRUE); + TQPainter bpainter(&bitmap); + bpainter.setBrush(TQt::color1); + tqApp->style().drawControlMask(TQStyle::CE_RadioButton, &bpainter, &radio, TQRect(0-bOffset,0-bOffset,realW,realH), sflags); + pixmap.setMask(bitmap); + + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x-xOffset, y-yOffset, realW, realH); } @@ -1604,6 +1659,7 @@ void drawProgressBar(GdkWindow * window, GtkStyle * style, GtkStateType state, G bar.setPercentageVisible(false); TQPixmap pixmap = TQPixmap::grabWidget(&bar); + pixmap.setMask(pixmap.createHeuristicMask()); TQWMatrix matrix; switch (orientation) @@ -1617,9 +1673,7 @@ void drawProgressBar(GdkWindow * window, GtkStyle * style, GtkStateType state, G if (orientation != GTK_PROGRESS_LEFT_TO_RIGHT) pixmap = pixmap.xForm(matrix); - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); - g_object_unref(pix); + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h); } void drawSlider(GdkWindow * window, GtkStyle * style, GtkStateType state, GtkAdjustment *adj, int x, int y, int w, int h, GtkOrientation orientation, int inverted) @@ -1642,9 +1696,8 @@ void drawSlider(GdkWindow * window, GtkStyle * style, GtkStateType state, GtkAdj meepSlider->setValue(100-(int)((adj->value-adj->lower)/(adj->upper-adj->lower)*100)); TQPixmap pixmap = TQPixmap::grabWidget(meepSlider); - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); - g_object_unref(pix); + pixmap.setMask(pixmap.createHeuristicMask()); + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h); } void drawSpinButton(GdkWindow * window, GtkStyle * style, GtkStateType state, int direction, int x, int y, int w, int h) @@ -1663,9 +1716,8 @@ void drawSpinButton(GdkWindow * window, GtkStyle * style, GtkStateType state, in painter.fillRect(0, 0, w, h, tqApp->palette().active().brush(TQColorGroup::Background)); tqApp->style().drawPrimitive((direction ? TQStyle::PE_SpinWidgetDown : TQStyle::PE_SpinWidgetUp), &painter, TQRect(0,0,w,h), tqApp->palette().active(), sflags); - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); - g_object_unref(pix); + pixmap.setMask(pixmap.createHeuristicMask()); + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h); } void drawListHeader(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, int y, int w, int h) @@ -1860,9 +1912,8 @@ void drawArrow(GdkWindow* window, GtkStyle* style, GtkStateType state, GtkArrowT tqApp->style().drawPrimitive(element, &painter, TQRect(0,0,w,h), tqApp->palette().active(), sflags); - GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); - gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); - g_object_unref(pix); + pixmap.setMask(pixmap.createHeuristicMask()); + drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h); } void drawFocusRect(GdkWindow * window, GtkStyle * style, int x, int y, int w, int h)