From cf8d4ef895903edde76148ebf4ca9876bcf42d26 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 8 Nov 2012 01:35:06 -0600 Subject: Fix toolbar rendering --- tdegtk/tdegtk-theme.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'tdegtk/tdegtk-theme.cpp') diff --git a/tdegtk/tdegtk-theme.cpp b/tdegtk/tdegtk-theme.cpp index e0b74a9..66e4694 100644 --- a/tdegtk/tdegtk-theme.cpp +++ b/tdegtk/tdegtk-theme.cpp @@ -704,6 +704,33 @@ void writeGtkThemeControlFile(int forceRecreate) { stream << parse_rc_string("padding: " + TQString::number(3) + "px " + TQString::number(3) + "px", "GtkNotebook"); stream << parse_rc_string("padding: " + TQString::number(3) + "px " + TQString::number(3) + "px", "GtkEntry"); + TQRect probeRect; + TQRect comboBoxArrowRect; + TQRect comboBoxEditFieldRect; + { + probeRect = TQRect(0, 0, 100, 100); + + TQStringList objectTypes; + objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + TQStyleControlElementData ceData; + TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; + ceData.widgetObjectTypes = objectTypes; + ceData.orientation = TQt::Horizontal; + ceData.rect = probeRect; + elementFlags = elementFlags | TQStyle::CEF_IsEditable; + + comboBoxArrowRect = tqApp->style().querySubControlMetrics(TQStyle::CC_ComboBox, ceData, elementFlags, TQStyle::SC_ComboBoxArrow); + comboBoxEditFieldRect = tqApp->style().querySubControlMetrics(TQStyle::CC_ComboBox, ceData, elementFlags, TQStyle::SC_ComboBoxEditField); + } + + // The padding is specified in a highly unusual format: + // top_width, right_width, bottom_width, left_width + // Compare that to the more typical format of: + // left, top, right, bottom + stream << parse_rc_string("padding: " + TQString::number(comboBoxEditFieldRect.y()-probeRect.y()) + "px " + TQString::number(probeRect.right()-comboBoxEditFieldRect.right()-comboBoxArrowRect.width()) + "px " + TQString::number(probeRect.bottom()-comboBoxEditFieldRect.bottom()) + "px " + TQString::number(comboBoxEditFieldRect.x()-probeRect.x()) + "px", "GtkComboBox>GtkEntry"); + // Set header sizes stream << parse_rc_string("padding: " + TQString::number(0) + "px " + TQString::number(0) + "px", "GtkTreeView>*>GtkButton"); stream << parse_rc_string("border-width: " + TQString::number(0) + "px " + TQString::number(0) + "px", "GtkTreeView>*>GtkButton"); @@ -745,17 +772,41 @@ void writeGtkThemeControlFile(int forceRecreate) { // Handle menu metrics int tdeStandardMenuItemHeight; int tdeSeparatorMenuItemHeight; + int tdeMenuFrameWidth; { + TQStringList objectTypes; + objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING); + TQPalette objectPalette = tqApp->palette(objectTypes); + + TQStyleControlElementData ceData; + TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None; + ceData.widgetObjectTypes = objectTypes; + ceData.orientation = TQt::Horizontal; + TQMenuItem tqt3MenuItem; tqt3MenuItem.setSeparator(false); tdeStandardMenuItemHeight = TQPopupMenu::menuItemHeight(&tqt3MenuItem, tqApp->fontMetrics()); tqt3MenuItem.setSeparator(true); tdeSeparatorMenuItemHeight = TQPopupMenu::menuItemHeight(&tqt3MenuItem, tqApp->fontMetrics()); + + TQSize sz; + ceData.rect = TQRect(0, 0, 0, tdeStandardMenuItemHeight); + sz = tqApp->style().sizeFromContents(TQStyle::CT_PopupMenuItem, ceData, elementFlags, TQSize(0, tdeStandardMenuItemHeight), TQStyleOption(&tqt3MenuItem)); + sz = sz.expandedTo(TQSize(0, sz.height())); + tdeStandardMenuItemHeight = sz.height(); + + ceData.rect = TQRect(0, 0, 0, tdeSeparatorMenuItemHeight); + sz = tqApp->style().sizeFromContents(TQStyle::CT_PopupMenuItem, ceData, elementFlags, TQSize(0, tdeSeparatorMenuItemHeight), TQStyleOption(&tqt3MenuItem)); + sz = sz.expandedTo(TQSize(0, sz.height())); + tdeSeparatorMenuItemHeight = sz.height(); + + tdeMenuFrameWidth = tqApp->style().pixelMetric(TQStyle::PM_DefaultFrameWidth, ceData, elementFlags); } stream << parse_rc_string("-GtkWidget-separator-height: " + TQString::number(tdeSeparatorMenuItemHeight), "GtkMenuItem"); stream << parse_rc_string("-GtkWidget-separator-width: " + TQString::number(tdeSeparatorMenuItemHeight), "GtkMenuItem"); stream << parse_rc_string("-GtkWidget-wide-separators: 1", "GtkMenuItem"); + stream << parse_rc_string("padding: " + TQString::number(tdeMenuFrameWidth) + "px " + TQString::number(tdeMenuFrameWidth) + "px " + TQString::number(tdeMenuFrameWidth) + "px " + TQString::number(tdeMenuFrameWidth) + "px", "GtkMenu"); // FIXME // GTK does not seem to support inserting actual space between the items in a menu bar; instead it insists on expanding the size of the menu items themselves (GtkMenuBar>GtkMenuItem padding:) -- cgit v1.2.1