From: Paul Cornett Date: Fri, 17 Oct 2008 04:36:09 +0000 (+0000) Subject: partial support for border metrics of non-TLW X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/53357e241eefd2d757d38c1a5b83c28161c2ee56?ds=inline partial support for border metrics of non-TLW git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56391 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index 26951dcfd9..2db3089d23 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -21,6 +21,7 @@ #include "wx/fontutil.h" #include +#include "wx/gtk/private/win_gtk.h" bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* bottom); @@ -269,6 +270,26 @@ static GtkSettings *GetSettingsForWindowScreen(GdkWindow *window) : gtk_settings_get_default(); } +static int GetBorderWidth(wxSystemMetric index, wxWindow* win) +{ + if (win->m_wxwindow) + { + wxPizza* pizza = WX_PIZZA(win->m_wxwindow); + int x, y; + pizza->get_border_widths(x, y); + switch (index) + { + case wxSYS_BORDER_X: + case wxSYS_EDGE_X: + case wxSYS_FRAMESIZE_X: + return x; + default: + return y; + } + } + return -1; +} + int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) { GdkWindow *window = NULL; @@ -283,14 +304,12 @@ int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) case wxSYS_EDGE_Y: case wxSYS_FRAMESIZE_X: case wxSYS_FRAMESIZE_Y: - // If a window is specified/realized, and it is a toplevel window, we can query from wm. - // The returned border thickness is outside the client area in that case. - if (window) + if (win) { wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow); if (!tlw) - return -1; // not a tlw, not sure how to approach - else + return GetBorderWidth(index, win); + else if (window) { // Get the frame extents from the windowmanager. // In most cases the top extent is the titlebar, so we use the bottom extent