Use bitmap masks for some widgets

Signed-off-by: rjb330 <122177540+rjb330@users.noreply.github.com>
pull/24/head
rjb330 4 weeks ago
parent 209a3c39ea
commit 1d10548298

@ -97,6 +97,8 @@ int isKeramik;
int isAlloy; int isAlloy;
int isDomino; int isDomino;
int isPolyester; int isPolyester;
int isMotif;
int isQtCurve;
int eclipseFix; int eclipseFix;
int openOfficeFix; int openOfficeFix;
int mozillaFix; int mozillaFix;
@ -444,6 +446,9 @@ void createTQApp()
isAlloy = (TQString(tqApp->style().name()).lower() == "alloy"); isAlloy = (TQString(tqApp->style().name()).lower() == "alloy");
isDomino = (TQString(tqApp->style().name()).lower() == "domino"); isDomino = (TQString(tqApp->style().name()).lower() == "domino");
isPolyester = (TQString(tqApp->style().name()).lower() == "polyester"); 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) if (isDomino)
{ {
@ -652,6 +657,30 @@ TQColor gdkColorToTQColor(GdkColor* c)
return TQColor(c->red / 256, c->green / 256, c->blue / 256); 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: // The drawing functions follow the same pattern:
// * Set the appropriate flags // * 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), tqApp->style().subRect(TQStyle::SR_PushButtonContents, &button),
button.colorGroup(), sflags); button.colorGroup(), sflags);
GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); if (!isBaghira && !isMotif) {
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); TQBitmap bitmap(w, h, TRUE);
g_object_unref(pix); 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 { else {
TQPixmap pixmap(w, h); 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, tqApp->style().drawControl(TQStyle::CE_PushButton, &painter, &button,
TQRect(0,0,w,h), button.palette().active(), sflags); TQRect(0,0,w,h), button.palette().active(), sflags);
GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); if (!isBaghira && !isMotif) {
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); TQBitmap bitmap(w, h, TRUE);
g_object_unref(pix); 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 realH = tqApp->style().pixelMetric(TQStyle::PM_IndicatorHeight);
int realW = tqApp->style().pixelMetric(TQStyle::PM_IndicatorWidth); int realW = tqApp->style().pixelMetric(TQStyle::PM_IndicatorWidth);
if (isKeramik) {
realW-= 2;
realH-= 2;
}
if ((realW < 1) || (realH < 1)) if ((realW < 1) || (realH < 1))
return; return;
@ -1084,9 +1130,13 @@ void drawCheckBox(GdkWindow* window, GtkStyle* style, GtkStateType state, int ch
int xOffset = (realW - w) / 2; int xOffset = (realW - w) / 2;
int yOffset = (realH - h) / 2; int yOffset = (realH - h) / 2;
GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); TQBitmap bitmap(realW, realH, TRUE);
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x - xOffset, y - yOffset, realW, realH); TQPainter bpainter(&bitmap);
g_object_unref(pix); 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) 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)) if ((realW < 1) || (realH < 1))
return; return;
TQPixmap pixmap(realH, realW); TQPixmap pixmap(realW, realH);
TQPainter painter(&pixmap); TQPainter painter(&pixmap);
TQRadioButton radio(0); TQRadioButton radio(0);
@ -1149,16 +1199,21 @@ void drawRadioButton(GdkWindow* window, GtkStyle* style, GtkStateType state, int
else else
painter.fillRect(0, 0, realW, realH, tqApp->palette().active().brush(TQColorGroup::Background)); 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. // TQt checkboxes are usually bigger than GTK wants.
// We cheat, and draw them over the expected area. // We cheat, and draw them over the expected area.
int xOffset = (realW - w) / 2; int xOffset = (realW - w) / 2;
int yOffset = (realH - h) / 2; int yOffset = (realH - h) / 2;
int bOffset = isQtCurve ? -1 : 0;
GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); TQBitmap bitmap(realW, realH, TRUE);
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x - xOffset, y - yOffset, realW, realH); TQPainter bpainter(&bitmap);
g_object_unref(pix); 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); bar.setPercentageVisible(false);
TQPixmap pixmap = TQPixmap::grabWidget(&bar); TQPixmap pixmap = TQPixmap::grabWidget(&bar);
pixmap.setMask(pixmap.createHeuristicMask());
TQWMatrix matrix; TQWMatrix matrix;
switch (orientation) switch (orientation)
@ -1617,9 +1673,7 @@ void drawProgressBar(GdkWindow * window, GtkStyle * style, GtkStateType state, G
if (orientation != GTK_PROGRESS_LEFT_TO_RIGHT) if (orientation != GTK_PROGRESS_LEFT_TO_RIGHT)
pixmap = pixmap.xForm(matrix); pixmap = pixmap.xForm(matrix);
GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h);
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h);
g_object_unref(pix);
} }
void drawSlider(GdkWindow * window, GtkStyle * style, GtkStateType state, GtkAdjustment *adj, int x, int y, int w, int h, GtkOrientation orientation, int inverted) 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)); meepSlider->setValue(100-(int)((adj->value-adj->lower)/(adj->upper-adj->lower)*100));
TQPixmap pixmap = TQPixmap::grabWidget(meepSlider); TQPixmap pixmap = TQPixmap::grabWidget(meepSlider);
GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); pixmap.setMask(pixmap.createHeuristicMask());
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h);
g_object_unref(pix);
} }
void drawSpinButton(GdkWindow * window, GtkStyle * style, GtkStateType state, int direction, int x, int y, int w, int 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)); 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); 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()); pixmap.setMask(pixmap.createHeuristicMask());
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h);
g_object_unref(pix);
} }
void drawListHeader(GdkWindow* window, GtkStyle* style, GtkStateType state, int x, int y, int w, int 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); tqApp->style().drawPrimitive(element, &painter, TQRect(0,0,w,h), tqApp->palette().active(), sflags);
GdkPixmap* pix = gdk_pixmap_foreign_new(pixmap.handle()); pixmap.setMask(pixmap.createHeuristicMask());
gdk_draw_drawable(window, style->bg_gc[state], pix, 0, 0, x, y, w, h); drawTQPixmapToWindow(window, style->bg_gc[state], &pixmap, x, y, w, h);
g_object_unref(pix);
} }
void drawFocusRect(GdkWindow * window, GtkStyle * style, int x, int y, int w, int h) void drawFocusRect(GdkWindow * window, GtkStyle * style, int x, int y, int w, int h)

Loading…
Cancel
Save