summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-04-27 13:15:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-04-27 17:12:06 +0100
commit37bb10790847bb2088e7f29211a31b1118fed2ad (patch)
treeaa6f85fa9c40dd92cc84a6b497c5f7aec79cb789 /vcl
parent4de9e22ce7f39936d1201fc35baac58445826819 (diff)
gtk3: hive the borders and padding calc off into a standalone
Change-Id: I0890a7d8c50b8646782bfc4358aa7c2f106dc22d
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx41
1 files changed, 23 insertions, 18 deletions
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index abab9e131e13..355e2b2bcb21 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -979,6 +979,28 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
return true;
}
+Rectangle AdjustRectForTextBordersPadding(GtkStyleContext* pStyle, long nTextHeight, const Rectangle& rControlRegion)
+{
+ gtk_style_context_save(pStyle);
+ gtk_style_context_add_class(pStyle, GTK_STYLE_CLASS_ENTRY);
+
+ GtkBorder border;
+ gtk_style_context_get_border(pStyle, GTK_STATE_FLAG_NORMAL, &border);
+
+ GtkBorder padding;
+ gtk_style_context_get_padding(pStyle, GTK_STATE_FLAG_NORMAL, &padding);
+
+ gint nWidgetHeight = nTextHeight + padding.top + padding.bottom + border.top + border.bottom;
+
+ nWidgetHeight = std::max<gint>(nWidgetHeight, rControlRegion.GetHeight());
+
+ Rectangle aEditRect(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nWidgetHeight));
+
+ gtk_style_context_restore(pStyle);
+
+ return aEditRect;
+}
+
bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState,
const ImplControlValue& rValue, const OUString&,
Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion )
@@ -1071,24 +1093,7 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPar
}
else if ((nType == CTRL_EDITBOX || nType == CTRL_LISTBOX || nType == CTRL_COMBOBOX) && nPart == PART_ENTIRE_CONTROL)
{
- gtk_style_context_save(mpEntryStyle);
- gtk_style_context_add_class(mpEntryStyle, GTK_STYLE_CLASS_ENTRY);
-
- GtkBorder border;
- gtk_style_context_get_border(mpEntryStyle, GTK_STATE_FLAG_NORMAL, &border);
-
- GtkBorder padding;
- gtk_style_context_get_padding(mpEntryStyle, GTK_STATE_FLAG_NORMAL, &padding);
-
- auto nTextHeight = rValue.getNumericVal();
-
- gint nWidgetHeight = nTextHeight + padding.top + padding.bottom + border.top + border.bottom;
-
- nWidgetHeight = std::max<gint>(nWidgetHeight, rControlRegion.GetHeight());
-
- aEditRect = Rectangle(rControlRegion.TopLeft(), Size(rControlRegion.GetWidth(), nWidgetHeight));
-
- gtk_style_context_restore(mpEntryStyle);
+ aEditRect = AdjustRectForTextBordersPadding(mpEntryStyle, rValue.getNumericVal(), rControlRegion);
}
else
{