Fix drawing problems on GTK 3.7

pull/1/head
Timothy Pearson 12 years ago
parent fe3024a816
commit 2f93dfb8bf

@ -221,6 +221,7 @@ static TQStyle::SFlags gtkToTQtStyleFlags(GtkThemingEngine* engine, GtkStateFlag
else if (wt == TQT3WT_TQMenuItem) {
if (prelight) {
sflags |= TQStyle::Style_MouseOver;
sflags |= TQStyle::Style_Active;
}
if (focused) {
sflags |= TQStyle::Style_HasFocus;
@ -232,6 +233,16 @@ static TQStyle::SFlags gtkToTQtStyleFlags(GtkThemingEngine* engine, GtkStateFlag
sflags |= TQStyle::Style_HasFocus;
}
}
else if (wt == TQT3WT_TQMenuBarItem) {
if (prelight) {
sflags |= TQStyle::Style_Active;
sflags |= TQStyle::Style_Down;
sflags |= TQStyle::Style_HasFocus;
}
if (!disabled) {
sflags |= TQStyle::Style_Enabled;
}
}
else if (wt == TQT3WT_TQSlider) {
if (active) {
sflags |= TQStyle::Style_Active;
@ -1332,6 +1343,33 @@ tdegtk_draw_common_background (DRAW_ARGS)
#endif
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_SCROLLED_WINDOW)) {
if ((x == 0) && (y == 0)) {
TQStringList objectTypes;
objectTypes.append(TQFRAME_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
int groupBoxLineWidth = 1;
int lineWidth = 0;
int midLineWidth = 0;
TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_TQGroupBox, widget);
lineWidth = groupBoxLineWidth;
midLineWidth = 0;
sflags = sflags | TQStyle::Style_Sunken;
TQStyleOption opt(lineWidth, midLineWidth);
// Draw background
TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
// Draw group box
tqApp->style().drawPrimitive(TQStyle::PE_PanelGroupBox, &p, boundingRect, gtkToTQtColorGroup(engine, state), sflags, opt);
}
}
else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) {
draw_combobox_frame(engine, cr, x, y, width, height, path, state, widget);
}
@ -1465,13 +1503,16 @@ tdegtk_draw_common_background (DRAW_ARGS)
int maxIconWidth = IconSize(KIcon::Small) + 4;
TQStyleOption menuOpt(&tqt3MenuItem, maxIconWidth, maxAcceleratorTextWidth);
TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget);
sflags = sflags | ((pressed)?TQStyle::Style_Down:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default);
// if (???) elementFlags = elementFlags | TQStyle::TQStyle::CEF_IsCheckable;
TQRect paintDeviceRect;
TQRect backgroundRect;
// Draw item
tqApp->style().drawControl(TQStyle::CE_PopupMenuItem, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget) | ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM))?TQStyle::Style_Active:TQStyle::Style_Default) | ((pressed)?TQStyle::Style_Down:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default), menuOpt);
tqApp->style().drawControl(TQStyle::CE_PopupMenuItem, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), sflags, menuOpt);
}
}
@ -1526,6 +1567,21 @@ tdegtk_draw_common_background (DRAW_ARGS)
draw_slider_frame(engine, cr, x, y, width, height, path, state, widget);
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_LABEL)) {
if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME)) {
TQStringList objectTypes;
objectTypes.append(TQFRAME_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)
}
else {
// Do nothing
}
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_IMAGE)) {
// Do nothing
}
@ -1638,22 +1694,27 @@ tdegtk_draw_common_frame (DRAW_ARGS)
GtkWidget* parent(widget?gtk_widget_get_parent(widget):0L);
if (GTK_IS_MENU_BAR(parent)) {
TQStringList objectTypes;
objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING);
objectTypes.append(TQMENUBAR_OBJECT_NAME_STRING);
TQPalette objectPalette = tqApp->palette(objectTypes);
// See FIXME in tdegtk_draw_common_background
bool pressed = true;
bool prelight = false;
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;
// Draw frame
tqApp->style().drawPrimitive(TQStyle::PE_ButtonDropDown, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default) | ((pressed)?TQStyle::Style_Down:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default));
TQMenuItem tqt3MenuItem;
int maxAcceleratorTextWidth = 0;
int maxIconWidth = IconSize(KIcon::Small) + 4;
TQStyleOption menuOpt(&tqt3MenuItem, maxIconWidth, maxAcceleratorTextWidth);
TQRect paintDeviceRect;
TQRect backgroundRect;
TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuBarItem, widget);
sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default);
// Draw item
tqApp->style().drawControl(TQStyle::CE_MenuBarItem, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), sflags, menuOpt);
}
}
@ -1744,6 +1805,10 @@ tdegtk_draw_common_frame (DRAW_ARGS)
// Do nothing
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_LABEL)) {
// Do mothing
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_NOTEBOOK)) {
// Draw frame
tqApp->style().drawPrimitive(TQStyle::PE_PanelTabWidget, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
@ -2311,6 +2376,9 @@ tdegtk_draw_radio (DRAW_ARGS)
static void
tdegtk_draw_separator (DRAW_ARGS)
{
cairo_save(cr);
cairo_reset_clip(cr);
TQRect boundingRect(0, 0, width, height);
TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
TQPainter p(&pd);
@ -2347,8 +2415,29 @@ tdegtk_draw_separator (DRAW_ARGS)
TQRect paintDeviceRect;
TQRect backgroundRect;
// Draw item
tqApp->style().drawControl(TQStyle::CE_PopupMenuItem, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget), menuOpt);
// // Draw background
// TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
// DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
// HACK
// GTK 3.7
// Gtk3 attempts to draw two separators instead of just one
if ((x==0) && (y==0)) {
// HACK
// GTK 3.7
// Related to the previous hack; the separator should therefore be drawn at the bottom of the provided rectangle instead of at the top
if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL)) {
x = x + (width/4);
}
else {
y = y + (height/4);
}
TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr);
TQPainter p2(&pd2);
// Draw item
tqApp->style().drawControl(TQStyle::CE_PopupMenuItem, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget), menuOpt);
}
}
else if (gtk_widget_path_is_type(path, GTK_TYPE_SEPARATOR)) {
@ -2367,6 +2456,8 @@ tdegtk_draw_separator (DRAW_ARGS)
}
p.end();
cairo_restore(cr);
}
static void

@ -494,6 +494,7 @@ void writeGtkThemeControlFile(int forceRecreate) {
GtkSettingsValue svalue;
if (gtksettings) {
g_object_set(gtksettings, "gtk-alternative-button-order", TRUE, NULL);
g_object_set(gtksettings, "gtk-primary-button-warps-slider", FALSE, NULL);
g_object_set(gtksettings, "gtk-button-images", tde_showIconsOnPushButtons, NULL);
g_object_set(gtksettings, "gtk-menu-popup-delay", tqApp->style().styleHint(TQStyle::SH_PopupMenu_SubMenuPopupDelay), NULL);
g_object_set(gtksettings, "gtk-icon-sizes", iconSettingsString.ascii(), NULL);
@ -674,6 +675,11 @@ void writeGtkThemeControlFile(int forceRecreate) {
stream.unsetDevice();
themeFile.close();
}
if (gtk3TQtDebug) {
// Load possibly modified theme control file before writing a new one
gtk3_tqt_reload_theme_definition_file(themeFilePath.latin1());
}
themeFile.open(IO_WriteOnly | IO_Truncate);
stream.setDevice(TQT_TQIODEVICE(&themeFile));
@ -725,6 +731,12 @@ void writeGtkThemeControlFile(int forceRecreate) {
// Work around problems detailed in upstream GTK bug #687677
stream << parse_rc_string(TQString("-GtkComboBox-shadow-type: in"), "*");
stream << parse_rc_string(TQString("-GtkScrolledWindow-scrollbars-within-bevel: 1"), "*");
stream << parse_rc_string(TQString("-GtkScrolledWindow-scrollbar-spacing: 0px"), "*");
stream << parse_rc_string(TQString("border-style: inset"), "GtkScrolledWindow");
stream << parse_rc_string("border-width: " + TQString::number(2) + "px " + TQString::number(2) + "px " + TQString::number(2) + "px " + TQString::number(2) + "px", "GtkScrolledWindow");
stream << parse_rc_string("padding: " + TQString::number(0) + "px " + TQString::number(0) + "px " + TQString::number(0) + "px " + TQString::number(0) + "px", "GtkScrolledWindow");
stream << parse_rc_string("-GtkComboBox-arrow-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ArrowSize)), "*");
stream << parse_rc_string("-GtkComboBox-arrow-scaling: 0", "*");

@ -71,6 +71,7 @@ enum TQt3WidgetType {
TQT3WT_TQPushButton,
TQT3WT_TQPopupMenu,
TQT3WT_TQMenuItem,
TQT3WT_TQMenuBarItem,
TQT3WT_TQComboBox,
TQT3WT_TQSlider,
TQT3WT_TQScrollBar,

Loading…
Cancel
Save