From d53bb7334952ba33745413498b914948f1c5eb90 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 30 Oct 2012 17:05:14 -0500 Subject: Finished tab widgets, group boxes, and add preliminary popup menu support --- tdegtk/tdegtk-draw.cpp | 445 +++++++++++++++++++++++------------------------- tdegtk/tdegtk-theme.cpp | 50 +++++- tdegtk/tdegtk-types.h | 2 + 3 files changed, 261 insertions(+), 236 deletions(-) (limited to 'tdegtk') diff --git a/tdegtk/tdegtk-draw.cpp b/tdegtk/tdegtk-draw.cpp index a4788f2..ad8edd9 100644 --- a/tdegtk/tdegtk-draw.cpp +++ b/tdegtk/tdegtk-draw.cpp @@ -25,6 +25,10 @@ #include #include #include +#include + +#include +#include #include "tdegtk-cairo-support.h" #include "tdegtk-draw.h" @@ -149,6 +153,28 @@ static TQStyle::SFlags gtkToTQtStyleFlags(GtkThemingEngine* engine, GtkStateFlag sflags |= TQStyle::Style_Enabled; } } + else if (wt == TQT3WT_TQGroupBox) { + if (prelight) { + sflags |= TQStyle::Style_MouseOver; + } + if (focused) { + sflags |= TQStyle::Style_HasFocus; + } + if (!disabled) { + sflags |= TQStyle::Style_Enabled; + } + } + else if (wt == TQT3WT_TQMenuItem) { + if (prelight) { + sflags |= TQStyle::Style_MouseOver; + } + if (focused) { + sflags |= TQStyle::Style_HasFocus; + } + if (!disabled) { + sflags |= TQStyle::Style_Enabled; + } + } else { if (active) { sflags |= TQStyle::Style_Down; @@ -338,6 +364,23 @@ tdegtk_draw_arrow (GtkThemingEngine *engine, } tqApp->style().drawPrimitive((subline)?TQStyle::PE_ScrollBarSubLine:TQStyle::PE_ScrollBarAddLine, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); } + else { + // Draw arrow + TQStyle::PrimitiveElement pe; + if (arrow_direction == GTK_ARROW_UP) { + pe = TQStyle::PE_ArrowUp; + } + else if (arrow_direction == GTK_ARROW_DOWN) { + pe = TQStyle::PE_ArrowDown; + } + else if (arrow_direction == GTK_ARROW_LEFT) { + pe = TQStyle::PE_ArrowLeft; + } + else { + pe = TQStyle::PE_ArrowRight; + } + tqApp->style().drawPrimitive(pe, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); + } p.end(); @@ -506,7 +549,7 @@ tdegtk_draw_common_background (DRAW_ARGS) ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal; // Draw frame - tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); + tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); } if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) { @@ -529,6 +572,48 @@ tdegtk_draw_common_background (DRAW_ARGS) DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) } + if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENU)) || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM))) { + DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,128,255); + + // FIXME + // Mouse movements in the popup menu should be tracked similarly to mouse movements in the tab bar + // Many TQt3 styles highlight inactive menu items on hover; not providing this visual feedback may cause users to briefly think their GTK application has frozen up + +// // Register menu item with animation engine +// m_animations.menuItemEngine().registerWidget(widget); +// +// // Check tab properties +// int tabIndex = Gtk::gtk_notebook_find_tab(widget, x+width/2, y+height/2); +// m_animations.tabWidgetEngine().updateTabRect(widget, tabIndex, x, y, width, height); +// bool prelight = (tabIndex == m_animations.tabWidgetEngine().hoveredTab(widget)); +// GtkMenuItem* menuitem = GTK_MENU_ITEM(widget); +// const int currentPage = gtk_notebook_get_current_page(notebook); +// const int numPages = gtk_notebook_get_n_pages(notebook); +// bool selectedTab = (tabIndex==currentPage); + + TQStringList objectTypes; + objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + TQStyleControlElementData ceData; + TQStyle::ControlElementFlags elementFlags; + ceData.widgetObjectTypes = objectTypes; + ceData.rect = boundingRect; + + TQMenuItem tqt3MenuItem; + int maxAcceleratorTextWidth = 0; + int maxIconWidth = IconSize(KIcon::Small) + 4; + TQStyleOption menuOpt(&tqt3MenuItem, maxIconWidth, maxAcceleratorTextWidth); + +// 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) | ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM))?TQStyle::Style_Active:TQStyle::Style_Default), menuOpt); + } + if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BACKGROUND)) { TQStringList objectTypes; objectTypes.append(TQWIDGET_OBJECT_NAME_STRING); @@ -565,13 +650,13 @@ tdegtk_draw_common_frame (DRAW_ARGS) TQStyle::ControlElementFlags elementFlags; ceData.widgetObjectTypes = objectTypes; ceData.rect = boundingRect; - ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal; + ceData.orientation = ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal); // Draw background // HACK // PE_ScrollBarAddPage and PE_ScrollBarSubPage are separate in TQt3 // Apparently there is no such distinction in GTK3! - TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarAddPage, gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); + TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarAddPage, gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); if (ceData.orientation == TQt::Vertical) { scrollpagerect.setY(ceData.rect.y()); scrollpagerect.setHeight(ceData.rect.height()); @@ -597,6 +682,21 @@ tdegtk_draw_common_frame (DRAW_ARGS) // Draw frame tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); } + + if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENU)) { + TQStringList objectTypes; + objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + TQStyleControlElementData ceData; + TQStyle::ControlElementFlags elementFlags; + 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_PanelPopup, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); + } } p.end(); @@ -668,7 +768,7 @@ tdegtk_draw_extension (DRAW_ARGS, m_animations.tabWidgetEngine().registerWidget(widget); // Check tab properties - const int tabIndex = Gtk::gtk_notebook_find_tab(widget, x+width/2, y+height/2); + int tabIndex = Gtk::gtk_notebook_find_tab(widget, x+width/2, y+height/2); m_animations.tabWidgetEngine().updateTabRect(widget, tabIndex, x, y, width, height); bool prelight = (tabIndex == m_animations.tabWidgetEngine().hoveredTab(widget)); GtkNotebook* notebook = GTK_NOTEBOOK(widget); @@ -676,6 +776,7 @@ tdegtk_draw_extension (DRAW_ARGS, // bool lastTab = (tabIndex == gtk_notebook_get_n_pages(notebook)-1); const int currentPage = gtk_notebook_get_current_page(notebook); const int numPages = gtk_notebook_get_n_pages(notebook); + bool selectedTab = (tabIndex==currentPage); TQStringList objectTypes; objectTypes.append(TQTABBAR_OBJECT_NAME_STRING); @@ -694,42 +795,72 @@ tdegtk_draw_extension (DRAW_ARGS, ceData.parentWidgetData.widgetObjectTypes.append(TQTABBAR_OBJECT_NAME_STRING); int tab_overlap = tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap); + int tab_to_frame_gap_height = 2; - boundingRect = TQRect(0, 0, width+(tab_overlap*2)-tab_overlap, height); - TQt3CairoPaintDevice pd2(NULL, x-tab_overlap, y, width+(tab_overlap*2), height, cr); - TQPainter p2(&pd2); + ceData.tabBarData.tabCount = numPages; + ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = tabIndex; + + TQRect paintDeviceRect; + TQRect backgroundRect; switch (gap_side) { default: case GTK_POS_TOP: ceData.tabBarData.shape = TQTabBar::RoundedBelow; + + paintDeviceRect = TQRect(x-tab_overlap, y-tab_to_frame_gap_height, width+(tab_overlap*2), height+tab_to_frame_gap_height); + boundingRect = TQRect(0, 0, width+(tab_overlap*2)-tab_overlap, height+tab_to_frame_gap_height); + backgroundRect = TQRect(tab_overlap, 0, width, height+2); break; case GTK_POS_LEFT: + ceData.tabBarData.shape = TQTabBar::RoundedAbove; // FIXME // TQt3 does not know how to draw these - ceData.tabBarData.shape = TQTabBar::RoundedAbove; + // For now, draw a single unconnected tab in this location + tabIndex = 0; + ceData.tabBarData.tabCount = 1; + tqt3Tab.setIdentifier(tabIndex); + ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = tabIndex; + + paintDeviceRect = TQRect(x-tab_overlap, y, width+(tab_overlap*2), height); + boundingRect = TQRect(0, 0, width+(tab_overlap*2)-tab_overlap, height); + backgroundRect = TQRect(0, 0, width, height); break; case GTK_POS_BOTTOM: ceData.tabBarData.shape = TQTabBar::RoundedAbove; + + paintDeviceRect = TQRect(x-tab_overlap, y, width+(tab_overlap*2), height+tab_to_frame_gap_height); + boundingRect = TQRect(0, 0, width+(tab_overlap*2)-tab_overlap, height+tab_to_frame_gap_height); + backgroundRect = TQRect(tab_overlap, 0, width, height+2); break; case GTK_POS_RIGHT: + ceData.tabBarData.shape = TQTabBar::RoundedAbove; // FIXME // TQt3 does not know how to draw these - ceData.tabBarData.shape = TQTabBar::RoundedAbove; + // For now, draw a single unconnected tab in this location + tabIndex = 0; + ceData.tabBarData.tabCount = 1; + tqt3Tab.setIdentifier(tabIndex); + ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = tabIndex; + + paintDeviceRect = TQRect(x-tab_overlap, y, width+(tab_overlap*2), height); + boundingRect = TQRect(0, 0, width+(tab_overlap*2)-tab_overlap, height); + backgroundRect = TQRect(0, 0, width, height); break; } - ceData.tabBarData.tabCount = numPages; - ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = tabIndex; cairo_save(cr); cairo_reset_clip(cr); + TQt3CairoPaintDevice pd2(NULL, paintDeviceRect.x(), paintDeviceRect.y(), paintDeviceRect.width(), paintDeviceRect.height(), cr); + TQPainter p2(&pd2); + // Draw background TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background); - DRAW_FILLED_RECTANGLE_OVER_SPECIFIC_AREA(p2, brush, 0, 0, width, height) + DRAW_FILLED_RECTANGLE_OVER_SPECIFIC_AREA(p2, brush, backgroundRect.x(), backgroundRect.y(), backgroundRect.width(), backgroundRect.height()) // Draw tab - tqApp->style().drawControl(TQStyle::CE_TabBarTab, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((tabIndex==currentPage)?TQStyle::Style_Selected:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default), tabOpt); + tqApp->style().drawControl(TQStyle::CE_TabBarTab, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((selectedTab)?TQStyle::Style_Selected:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default), tabOpt); cairo_restore(cr); } @@ -759,155 +890,67 @@ tdegtk_draw_frame_gap (DRAW_ARGS, DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,128,0); - p.end(); - - return; - - GtkBorder border; - GtkBorder *outer_border; - GtkCssBorderCornerRadius *top_left_radius, *top_right_radius; - GtkCssBorderCornerRadius *bottom_left_radius, *bottom_right_radius; - GtkCssBorderRadius border_radius = { { 0, }, }; - GtkJunctionSides junction; - GtkStateFlags state; - gboolean has_outer_stroke = FALSE; - gdouble x0, y0, x1, y1, xc, yc, wc, hc; - - xc = yc = wc = hc = 0; - - junction = gtk_theming_engine_get_junction_sides (engine); - - state = gtk_theming_engine_get_state (engine); - - gtk_theming_engine_get (engine, state, - /* Can't use border-radius as it's an int for - * backwards compat */ - "border-top-left-radius", &top_left_radius, - "border-top-right-radius", &top_right_radius, - "border-bottom-right-radius", &bottom_right_radius, - "border-bottom-left-radius", &bottom_left_radius, - "-tdegtk-outer-stroke-width", &outer_border, - NULL); - gtk_theming_engine_get_border (engine, state, &border); - - if (!tdegtk_gtk_border_is_zero (outer_border)) - has_outer_stroke = TRUE; - - if (top_left_radius) - border_radius.top_left = *top_left_radius; - g_free (top_left_radius); - if (top_right_radius) - border_radius.top_right = *top_right_radius; - g_free (top_right_radius); - if (bottom_right_radius) - border_radius.bottom_right = *bottom_right_radius; - g_free (bottom_right_radius); - if (bottom_left_radius) - border_radius.bottom_left = *bottom_left_radius; - g_free (bottom_left_radius); - - cairo_save (cr); - - switch (gap_side) - { - case GTK_POS_TOP: - xc = x + xy0_gap + border.left; - yc = y; - wc = MAX (xy1_gap - xy0_gap - (border.left + border.right), 0); - hc = border.top * 2; - - if (has_outer_stroke) - { - xc += outer_border->left; - wc = MAX (xy1_gap - xy0_gap - (outer_border->left + outer_border->right) - (border.left + border.right), 0); - hc += outer_border->top; - } - - if (xy0_gap < border_radius.top_left.horizontal) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_TOPLEFT); - - if (xy1_gap > width - border_radius.top_right.horizontal) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_TOPRIGHT); - break; - default: - case GTK_POS_BOTTOM: - xc = x + xy0_gap + border.left; - yc = y + height - border.bottom * 2; - wc = MAX (xy1_gap - xy0_gap - (border.left + border.right), 0); - hc = border.bottom * 2; - - if (has_outer_stroke) - { - xc += outer_border->left; - yc -= outer_border->bottom; - wc = MAX (xy1_gap - xy0_gap - (outer_border->left + outer_border->right) - (border.left + border.right), 0); - hc += outer_border->bottom; - } - - if (xy0_gap < border_radius.bottom_left.horizontal) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_BOTTOMLEFT); - - if (xy1_gap > width - border_radius.bottom_right.horizontal) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_BOTTOMRIGHT); - - break; - case GTK_POS_LEFT: - xc = x; - yc = y + xy0_gap + border.top; - wc = border.left * 2; - hc = MAX (xy1_gap - xy0_gap - (border.top + border.bottom), 0); - - if (has_outer_stroke) - { - yc += outer_border->top; - wc += outer_border->left; - hc = MAX (xy1_gap - xy0_gap - (outer_border->top + outer_border->bottom) - (border.top + border.bottom), 0); - } - - if (xy0_gap < border_radius.top_left.vertical) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_TOPLEFT); + const GtkWidgetPath* path; + GtkStateFlags state; + GtkWidget* widget; - if (xy1_gap > height - border_radius.bottom_left.vertical) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_BOTTOMLEFT); + path = gtk_theming_engine_get_path(engine); + state = gtk_theming_engine_get_state(engine); + widget = m_widgetLookup.find(cr, path); - break; - case GTK_POS_RIGHT: - xc = x + width - border.right * 2; - yc = y + xy0_gap + border.top; - wc = border.right * 2; - hc = MAX (xy1_gap - xy0_gap - (border.top + border.bottom), 0); + if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME)) { + GtkFrame* frame = GTK_FRAME(widget); + GtkShadowType gtkShadowType = gtk_frame_get_shadow_type(frame); - if (has_outer_stroke) - { - xc -= outer_border->right; - yc += outer_border->top; - wc += outer_border->right; - hc = MAX (xy1_gap - xy0_gap - (outer_border->top + outer_border->bottom) - (border.top + border.bottom), 0); - } + TQStringList objectTypes; + objectTypes.append(TQGROUPBOX_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); - if (xy0_gap < border_radius.top_right.vertical) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_TOPRIGHT); + int groupBoxLineWidth = 1; - if (xy1_gap > height - border_radius.bottom_right.vertical) - junction = (GtkJunctionSides)(junction | GTK_JUNCTION_CORNER_BOTTOMRIGHT); + int lineWidth = 0; + int midLineWidth = 0; + TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_TQGroupBox); - break; - } + if (gtkShadowType == GTK_SHADOW_NONE) { + lineWidth = 0; + midLineWidth = 0; + } + else if (gtkShadowType == GTK_SHADOW_IN) { + lineWidth = groupBoxLineWidth; + midLineWidth = 0; + sflags = sflags | TQStyle::Style_Sunken; + } + else if (gtkShadowType == GTK_SHADOW_OUT) { + lineWidth = groupBoxLineWidth; + midLineWidth = 0; + sflags = sflags | TQStyle::Style_Raised; + } + else if (gtkShadowType == GTK_SHADOW_ETCHED_IN) { + lineWidth = groupBoxLineWidth; + midLineWidth = groupBoxLineWidth; + sflags = sflags | TQStyle::Style_Sunken; + } + else if (gtkShadowType == GTK_SHADOW_ETCHED_OUT) { + lineWidth = groupBoxLineWidth; + midLineWidth = groupBoxLineWidth; + sflags = sflags | TQStyle::Style_Raised; + } - /* clip the gap */ - cairo_clip_extents (cr, &x0, &y0, &x1, &y1); - cairo_rectangle (cr, x0, y0, x1 - x0, yc - y0); - cairo_rectangle (cr, x0, yc, xc - x0, hc); - cairo_rectangle (cr, xc + wc, yc, x1 - (xc + wc), hc); - cairo_rectangle (cr, x0, yc + hc, x1 - x0, y1 - (yc + hc)); - cairo_clip (cr); + TQStyleOption opt(lineWidth, midLineWidth); - /* draw the frame, gap area will not be drawn */ - tdegtk_cairo_draw_frame (engine, cr, x, y, width, height, 0, junction); + // Draw background + TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background); + DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush) - cairo_restore (cr); + // Draw group box + tqApp->style().drawPrimitive(TQStyle::PE_PanelGroupBox, &p, boundingRect, gtkToTQtColorGroup(engine, state), sflags, opt); - gtk_border_free (outer_border); + // Draw background behind groupbox label + DRAW_FILLED_RECTANGLE_OVER_SPECIFIC_AREA(p, brush, xy0_gap, x, (xy1_gap-xy0_gap), (height/2)) + } + + p.end(); } static void @@ -1053,7 +1096,17 @@ tdegtk_draw_notebook (DRAW_ARGS, GtkStateFlags state; state = gtk_theming_engine_get_state(engine); - //tqApp->style().drawPrimitive(TQStyle::PE_ExclusiveIndicator, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); + + TQStringList objectTypes; + objectTypes.append(TQTABWIDGET_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) + + // Draw tab frame + tqApp->style().drawPrimitive(TQStyle::PE_PanelTabWidget, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); p.end(); } @@ -1154,7 +1207,7 @@ tdegtk_draw_slider (DRAW_ARGS, scrollpagerect.setX(ceData.rect.x()); scrollpagerect.setWidth(ceData.rect.width()); } - tqApp->style().drawPrimitive(TQStyle::PE_ScrollBarSlider, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE)); + tqApp->style().drawPrimitive(TQStyle::PE_ScrollBarSlider, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default)); } p.end(); @@ -1163,89 +1216,25 @@ tdegtk_draw_slider (DRAW_ARGS, static void tdegtk_draw_spinbutton_background (DRAW_ARGS) { - GtkBorder border, *outer_border; - GtkJunctionSides junction; - GtkStateFlags state; - - junction = gtk_theming_engine_get_junction_sides (engine); - - state = gtk_theming_engine_get_state (engine); - - gtk_theming_engine_get (engine, state, - "-tdegtk-outer-stroke-width", &outer_border, - NULL); - gtk_theming_engine_get_border (engine, state, &border); - - cairo_save (cr); - - cairo_rectangle (cr, x, y, width, height); - cairo_clip (cr); - - if (!(junction & GTK_JUNCTION_CORNER_TOPRIGHT)) - { - y = ceil (y); - height = floor (height); - height += border.bottom + outer_border->bottom; - } - else - { - y = floor (y); - height = ceil (height); - y -= outer_border->top; - height += outer_border->bottom; - } - - tdegtk_cairo_draw_background (engine, cr, - x, y, width, height, - 0, junction); + TQRect boundingRect(0, 0, width, height); + TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); + TQPainter p(&pd); - cairo_restore (cr); + DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,255,0); - gtk_border_free (outer_border); + p.end(); } static void tdegtk_draw_spinbutton_frame (DRAW_ARGS) { - GtkBorder border, *outer_border; - GtkJunctionSides junction; - GtkStateFlags state; - - junction = gtk_theming_engine_get_junction_sides (engine); - - state = gtk_theming_engine_get_state (engine); - - gtk_theming_engine_get (engine, state, - "-tdegtk-outer-stroke-width", &outer_border, - NULL); - gtk_theming_engine_get_border (engine, state, &border); - - cairo_save (cr); - - cairo_rectangle (cr, x, y, width, height); - cairo_clip (cr); - - if (!(junction & GTK_JUNCTION_CORNER_TOPRIGHT)) - { - y = ceil (y); - height = floor (height); - height += border.bottom + outer_border->bottom; - } - else - { - y = floor (y); - height = ceil (height); - y -= outer_border->top; - height += outer_border->bottom; - } - - tdegtk_cairo_draw_frame (engine, cr, - x, y, width, height, - 0, junction); + TQRect boundingRect(0, 0, width, height); + TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr); + TQPainter p(&pd); - cairo_restore (cr); + DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,255,128); - gtk_border_free (outer_border); + p.end(); } void diff --git a/tdegtk/tdegtk-theme.cpp b/tdegtk/tdegtk-theme.cpp index 28ff8e9..5578fbd 100644 --- a/tdegtk/tdegtk-theme.cpp +++ b/tdegtk/tdegtk-theme.cpp @@ -18,6 +18,16 @@ * */ +// NOTE +// GTK contains a number of bugs that will interfere with your overall visual experience +// Those that I have reported can be accessed with this link: +// https://bugzilla.gnome.org/buglist.cgi?type0-0-4=substring&emailcc1=1&emailreporter1=1&emaillongdesc1=1&field0-0-0=product&type0-0-1=substring&field0-0-1=component&field0-0-4=longdesc&emailtype1=substring&type0-0-3=substring&query_format=advanced&emailassigned_to1=1&field0-0-3=status_whiteboard&emailqa_contact1=1&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=NEEDINFO&bug_status=RESOLVED&bug_status=VERIFIED&field0-0-2=short_desc&email1=kb9vqf%40pearsoncomputing.net&type0-0-0=substring&value0-0-0=gtk%2B&type0-0-2=substring + +// FIXME +// This style should use the TDE open/save dialogs instead of the stock Gnome GtkFileChooserDialog +// This is not currently possible in GTK +// See upstream GTK bug #687173 + #define TDEGTK_THEME_THEME_DIRECTORY_NAME "tdegtk" #define TDEGTK_THEME_CONTROL_FILE_NAME "gtk.css" #define RC_CACHE_VERSION TQString("1") @@ -72,7 +82,9 @@ extern "C" { #include #include +#include #include +#include #include #include #include @@ -115,13 +127,13 @@ G_MODULE_EXPORT GtkThemingEngine* create_engine(void) { // initialize icon sizes icon_sizes.push_back(std::make_pair("panel-menu", 16)); icon_sizes.push_back(std::make_pair("panel", 32)); - icon_sizes.push_back(std::make_pair("gtk-small-toolbar", 22)); - icon_sizes.push_back(std::make_pair("gtk-large-toolbar", 22)); - icon_sizes.push_back(std::make_pair("gtk-dnd", 48)); - icon_sizes.push_back(std::make_pair("gtk-button", 16)); - icon_sizes.push_back(std::make_pair("gtk-menu", 16)); - icon_sizes.push_back(std::make_pair("gtk-dialog", 32)); - icon_sizes.push_back(std::make_pair("", 16)); + icon_sizes.push_back(std::make_pair("gtk-small-toolbar", IconSize(KIcon::Toolbar))); + icon_sizes.push_back(std::make_pair("gtk-large-toolbar", IconSize(KIcon::MainToolbar))); + icon_sizes.push_back(std::make_pair("gtk-dnd", IconSize(KIcon::Small))); + icon_sizes.push_back(std::make_pair("gtk-button", IconSize(KIcon::Small))); + icon_sizes.push_back(std::make_pair("gtk-menu", IconSize(KIcon::Small))); + icon_sizes.push_back(std::make_pair("gtk-dialog", IconSize(KIcon::Small))); + icon_sizes.push_back(std::make_pair("", IconSize(KIcon::Small))); writeGtkThemeControlFile(false); @@ -451,6 +463,14 @@ void writeGtkThemeControlFile(int forceRecreate) { // setColour("text", "insensitive", tqApp->palette().disabled().text()); // setColour("base", "insensitive", tqApp->palette().disabled().background()); + TQString iconSettingsString; + iconSettingsString.append(TQString("gtk-menu=%1,%2").arg(IconSize(KIcon::Small)).arg(IconSize(KIcon::Small))); + iconSettingsString.append(TQString(":gtk-button=%1,%2").arg(IconSize(KIcon::Small)).arg(IconSize(KIcon::Small))); + iconSettingsString.append(TQString(":gtk-small-toolbar=%1,%2").arg(IconSize(KIcon::Toolbar)).arg(IconSize(KIcon::Toolbar))); + iconSettingsString.append(TQString(":gtk-large-toolbar=%1,%2").arg(IconSize(KIcon::MainToolbar)).arg(IconSize(KIcon::MainToolbar))); + iconSettingsString.append(TQString(":gtk-dnd=%1,%2").arg(IconSize(KIcon::Small)).arg(IconSize(KIcon::Small))); + iconSettingsString.append(TQString(":gtk-dialog=%1,%2").arg(IconSize(KIcon::Small)).arg(IconSize(KIcon::Small))); + // Set up global application settings GtkSettings* gtksettings = gtk_settings_get_default(); GtkSettingsValue svalue; @@ -458,6 +478,7 @@ void writeGtkThemeControlFile(int forceRecreate) { g_object_set(gtksettings, "gtk-alternative-button-order", TRUE, 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); // Handle toolbar text display if (toolbarStyle == 3) { // This is broken by GTK bug #68700 @@ -571,6 +592,8 @@ void writeGtkThemeControlFile(int forceRecreate) { bool combobox_appears_as_list = (!(tqApp->style().styleHint(TQStyle::SH_ComboBox_Popup) || tqApp->style().styleHint(TQStyle::SH_GUIStyle) == TQt::MotifStyle)); stream << parse_rc_string(TQString("-GtkComboBox-appears-as-list: %1px").arg(combobox_appears_as_list), "*"); + stream << parse_rc_string("-GtkComboBox-arrow-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ArrowSize)), "*"); + stream << parse_rc_string("-GtkComboBox-arrow-scaling: 0", "*"); stream << parse_rc_string(TQString("-GtkScrollbar-has-backward-stepper: ") + (back1 ? "1" : "0"), "*"); stream << parse_rc_string(TQString("-GtkScrollbar-has-forward-stepper: ") + (forward2 ? "1" : "0"), "*"); @@ -580,7 +603,9 @@ void writeGtkThemeControlFile(int forceRecreate) { stream << parse_rc_string("-GtkScrollbar-stepper-size: " + TQString::number(tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, &sbar, TQStyle::SC_ScrollBarSubLine).width() - 1), "*"); stream << parse_rc_string("-GtkScrollbar-min-slider-length: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ScrollBarSliderMin)), "*"); - stream << parse_rc_string("-GtkScrollbar-slider-width: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ScrollBarExtent)-2), "*"); + stream << parse_rc_string("-GtkRange-slider-width: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ScrollBarExtent)), "GtkScrollbar"); + stream << parse_rc_string("-GtkRange-stepper-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ScrollBarExtent)), "GtkScrollbar"); + stream << parse_rc_string("-GtkRange-trough-border: 0", "GtkScrollbar"); stream << parse_rc_string("-GtkButton-child-displacement-x: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ButtonShiftHorizontal)), "*"); stream << parse_rc_string("-GtkButton-child-displacement-y: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_ButtonShiftVertical)), "*"); @@ -631,15 +656,22 @@ void writeGtkThemeControlFile(int forceRecreate) { //stream << parse_rc_string("-GtkNotebook-tab-overlap: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap)), "*"); stream << parse_rc_string("-GtkNotebook-tab-overlap: 0", "*"); // Overlap is handled in the style engine itself stream << parse_rc_string("-GtkNotebook-tab-curvature: 0", "*"); + stream << parse_rc_string("-GtkNotebook-initial-gap: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap)), "*"); // This sets both the radio button and check box sizes stream << parse_rc_string("-GtkCheckButton-indicator-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_IndicatorHeight)), "*"); + stream << parse_rc_string("-GtkCheckMenuItem-indicator-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_IndicatorHeight)), "*"); // FIXME // GtkCellRendererToggle indicator-size must be set as follows, however GTK3 does not provide any means to change the default size! // See upstream GTK bug #687076 //stream << parse_rc_string("-GtkCellRendererToggle-indicator-size: " + TQString::number(tqApp->style().pixelMetric(TQStyle::PM_IndicatorHeight)), "*"); + // FIXME + // GtkSpinButton widgets use ugly unthemed horizontal buttons + // When GTK provides an option to switch to vertical buttons, implement theming support for them + // See upstream GTK bug #687172 + // FIXME // There must be a way to set the selected tab offset (shift) // If not, it may be neccessary to override the GTK text drawing routines for notebooks to insert the proper shift @@ -776,6 +808,8 @@ void writeGtkThemeControlFile(int forceRecreate) { // Other icons that really should have Trinity equivalents in tdelibs doIconMapping("list-add", "actions/add.png", factory, iconThemeDirs); doIconMapping("list-remove", "actions/remove.png", factory, iconThemeDirs); + doIconMapping("list-add-symbolic", "actions/add.png", factory, iconThemeDirs); + doIconMapping("list-remove-symbolic", "actions/remove.png", factory, iconThemeDirs); gtk_icon_factory_add_default(factory); diff --git a/tdegtk/tdegtk-types.h b/tdegtk/tdegtk-types.h index ad94d5f..8e26059 100644 --- a/tdegtk/tdegtk-types.h +++ b/tdegtk/tdegtk-types.h @@ -70,6 +70,7 @@ enum TQt3WidgetType { TQT3WT_TQCheckBox, TQT3WT_TQPushButton, TQT3WT_TQPopupMenu, + TQT3WT_TQMenuItem, TQT3WT_TQComboBox, TQT3WT_TQSlider, TQT3WT_TQScrollBar, @@ -79,6 +80,7 @@ enum TQt3WidgetType { TQT3WT_TQMenuBar, TQT3WT_TQToolBox, TQT3WT_TQToolButton, + TQT3WT_TQGroupBox, TQT3WT_GTKTreeViewCell, }; -- cgit v1.2.3