]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/settings.cpp
restore setting m_appName broken by recent change (fixes bug 1921954)
[wxWidgets.git] / src / gtk / settings.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
e7c80f9e 2// Name: src/gtk/settings.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
9b0b5ba7 5// Modified by: Mart Raudsepp (GetMetric)
f96aa4d9
RR
6// Id: $Id$
7// Copyright: (c) 1998 Robert Roebling
65571936 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
14f355c2
VS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
c801d85f 14#include "wx/settings.h"
e7c80f9e 15
ce5d92e1
WS
16#ifndef WX_PRECOMP
17 #include "wx/cmndata.h"
1832043f 18 #include "wx/toplevel.h"
ce5d92e1
WS
19#endif
20
2b5f62a0 21#include "wx/fontutil.h"
d06b34a7 22
b0ae510a
PC
23#include <gtk/gtkversion.h>
24#if GTK_CHECK_VERSION(2, 9, 0)
25 // gtk_object_sink
26 #undef GTK_DISABLE_DEPRECATED
1efb5db8 27#endif
aed8ac3f 28#include <gtk/gtk.h>
b0ae510a 29#include <gdk/gdkx.h>
83624f79 30
9b0b5ba7
RR
31#include <X11/Xatom.h>
32
0ab5e0e8 33// ----------------------------------------------------------------------------
94a09ea5 34// wxSystemObjects
0ab5e0e8
VS
35// ----------------------------------------------------------------------------
36
94a09ea5 37struct wxSystemObjects
1ecc4d80 38{
c1ef87c3
VZ
39 wxColour m_colBtnFace,
40 m_colBtnShadow,
41 m_colBtnHighlight,
42 m_colHighlight,
43 m_colHighlightText,
44 m_colListBox,
a51d7c4b
JS
45 m_colWindow,
46 m_colWindowText,
9d6a9fdd 47 m_colBtnText,
c05cc2c7
RR
48 m_colMenuItemHighlight,
49 m_colTooltip,
3ab6b7e6
VZ
50 m_colTooltipText,
51 m_colMenubarBg;
c1ef87c3
VZ
52
53 wxFont m_fontSystem;
0ab5e0e8
VS
54};
55
94a09ea5 56static wxSystemObjects gs_objects;
c1ef87c3 57
a51d7c4b
JS
58void wxClearGtkSystemObjects()
59{
60 gs_objects.m_colBtnFace = wxColour();
61 gs_objects.m_colBtnShadow = wxColour();
62 gs_objects.m_colBtnHighlight = wxColour();
63 gs_objects.m_colHighlightText = wxColour();
64 gs_objects.m_colListBox = wxColour();
65 gs_objects.m_colWindow = wxColour();
66 gs_objects.m_colWindowText = wxColour();
67 gs_objects.m_colBtnText = wxColour();
68 gs_objects.m_colMenuItemHighlight = wxColour();
69 gs_objects.m_colTooltip = wxColour();
70 gs_objects.m_colTooltipText = wxColour();
3ab6b7e6 71 gs_objects.m_colMenubarBg = wxColour();
a51d7c4b
JS
72 gs_objects.m_fontSystem = wxNullFont;
73}
74
0ab5e0e8
VS
75// ----------------------------------------------------------------------------
76// wxSystemSettings implementation
77// ----------------------------------------------------------------------------
a3622daa 78
643ccf62 79// kind of widget to use in GetColourFromGTKWidget
dbcbe229 80enum wxGtkWidgetType
643ccf62 81{
dbcbe229 82 wxGTK_BUTTON,
9d6a9fdd 83 wxGTK_LIST,
a51d7c4b 84 wxGTK_MENUITEM,
3ab6b7e6
VZ
85 wxGTK_TEXTCTRL,
86 wxGTK_MENUBAR,
dbcbe229
VZ
87};
88
89// the colour we need
90enum wxGtkColourType
91{
92 wxGTK_FG,
93 wxGTK_BG,
94 wxGTK_BASE
643ccf62
VZ
95};
96
984152a6 97// wxSystemSettings::GetColour() helper: get the colours from a GTK+
b0ae510a
PC
98// widget style, return true if we did get them
99static bool GetColourFromGTKWidget(GdkColor& gdkColor,
dbcbe229
VZ
100 wxGtkWidgetType type = wxGTK_BUTTON,
101 GtkStateType state = GTK_STATE_NORMAL,
102 wxGtkColourType colour = wxGTK_BG)
643ccf62 103{
dbcbe229
VZ
104 GtkWidget *widget;
105 switch ( type )
106 {
107 default:
108 wxFAIL_MSG( _T("unexpected GTK widget type") );
109 // fall through
110
111 case wxGTK_BUTTON:
112 widget = gtk_button_new();
113 break;
114
a51d7c4b
JS
115 case wxGTK_TEXTCTRL:
116 widget = gtk_text_view_new();
117 break;
118
dbcbe229 119 case wxGTK_LIST:
b0ae510a
PC
120 widget = gtk_tree_view_new_with_model(
121 (GtkTreeModel*)gtk_list_store_new(1, G_TYPE_INT));
e24b680c
VZ
122 break;
123
9d6a9fdd
RR
124 case wxGTK_MENUITEM:
125 widget = gtk_menu_item_new();
3ab6b7e6
VZ
126
127 case wxGTK_MENUBAR:
128 widget = gtk_menu_bar_new();
129 break;
130
dbcbe229
VZ
131 }
132
643ccf62
VZ
133 GtkStyle *def = gtk_rc_get_style( widget );
134 if ( !def )
135 def = gtk_widget_get_default_style();
136
b0ae510a
PC
137 const bool ok = def != NULL;
138 if (ok)
643ccf62 139 {
dbcbe229
VZ
140 switch ( colour )
141 {
142 default:
143 wxFAIL_MSG( _T("unexpected GTK colour type") );
144 // fall through
145
146 case wxGTK_FG:
b0ae510a 147 gdkColor = def->fg[state];
dbcbe229
VZ
148 break;
149
150 case wxGTK_BG:
b0ae510a 151 gdkColor = def->bg[state];
dbcbe229
VZ
152 break;
153
154 case wxGTK_BASE:
b0ae510a 155 gdkColor = def->base[state];
dbcbe229
VZ
156 break;
157 }
643ccf62
VZ
158 }
159
dd2422b3 160 gtk_object_sink((GtkObject*)widget);
643ccf62
VZ
161
162 return ok;
163}
164
c05cc2c7
RR
165static void GetTooltipColors()
166{
a5de860f 167 GtkWidget* widget = gtk_window_new(GTK_WINDOW_POPUP);
a5de860f
PC
168 const char* name = "gtk-tooltip";
169 if (gtk_check_version(2, 11, 0))
170 name = "gtk-tooltips";
171 gtk_widget_set_name(widget, name);
172 gtk_widget_ensure_style(widget);
173
174 GdkColor c = widget->style->bg[GTK_STATE_NORMAL];
175 gs_objects.m_colTooltip = wxColor(c);
176 c = widget->style->fg[GTK_STATE_NORMAL];
177 gs_objects.m_colTooltipText = wxColor(c);
178
179 gtk_widget_destroy(widget);
c05cc2c7
RR
180}
181
0ab5e0e8 182wxColour wxSystemSettingsNative::GetColour( wxSystemColour index )
c801d85f 183{
b0ae510a
PC
184 wxColor color;
185 GdkColor gdkColor;
db434467 186 switch (index)
c801d85f 187 {
db434467
RR
188 case wxSYS_COLOUR_SCROLLBAR:
189 case wxSYS_COLOUR_BACKGROUND:
db434467
RR
190 case wxSYS_COLOUR_INACTIVECAPTION:
191 case wxSYS_COLOUR_MENU:
192 case wxSYS_COLOUR_WINDOWFRAME:
193 case wxSYS_COLOUR_ACTIVEBORDER:
194 case wxSYS_COLOUR_INACTIVEBORDER:
195 case wxSYS_COLOUR_BTNFACE:
5b211fbf 196 case wxSYS_COLOUR_3DLIGHT:
94a09ea5 197 if (!gs_objects.m_colBtnFace.Ok())
37d403aa 198 {
b0ae510a
PC
199 gdkColor.red =
200 gdkColor.green = 0;
201 gdkColor.blue = 0x9c40;
202 GetColourFromGTKWidget(gdkColor);
203 gs_objects.m_colBtnFace = wxColor(gdkColor);
37d403aa 204 }
b0ae510a
PC
205 color = gs_objects.m_colBtnFace;
206 break;
643ccf62 207
db434467 208 case wxSYS_COLOUR_WINDOW:
a51d7c4b
JS
209 if (!gs_objects.m_colWindow.Ok())
210 {
211 gdkColor.red =
212 gdkColor.green =
213 gdkColor.blue = 0xFFFF;
214 GetColourFromGTKWidget(gdkColor, wxGTK_TEXTCTRL, GTK_STATE_NORMAL, wxGTK_BASE);
215 gs_objects.m_colWindow = wxColor(gdkColor);
216 }
217 color = gs_objects.m_colWindow;
b0ae510a 218 break;
643ccf62 219
3ab6b7e6
VZ
220
221 case wxSYS_COLOUR_MENUBAR:
222 if (!gs_objects.m_colMenubarBg.Ok())
223 {
224 gdkColor.red =
225 gdkColor.green = 0;
226 gdkColor.blue = 0x9c40;
227 GetColourFromGTKWidget(gdkColor,wxGTK_MENUBAR);
228 gs_objects.m_colMenubarBg = wxColor(gdkColor);
229 }
230 color = gs_objects.m_colMenubarBg;
231 break;
232
37d403aa 233 case wxSYS_COLOUR_3DDKSHADOW:
b0ae510a
PC
234 color = *wxBLACK;
235 break;
643ccf62 236
db434467
RR
237 case wxSYS_COLOUR_GRAYTEXT:
238 case wxSYS_COLOUR_BTNSHADOW:
37d403aa 239 //case wxSYS_COLOUR_3DSHADOW:
94a09ea5 240 if (!gs_objects.m_colBtnShadow.Ok())
37d403aa 241 {
984152a6 242 wxColour faceColour(GetColour(wxSYS_COLOUR_3DFACE));
94a09ea5 243 gs_objects.m_colBtnShadow =
b0ae510a
PC
244 wxColour((unsigned char) (faceColour.Red() * 2 / 3),
245 (unsigned char) (faceColour.Green() * 2 / 3),
246 (unsigned char) (faceColour.Blue() * 2 / 3));
db434467 247 }
b0ae510a
PC
248 color = gs_objects.m_colBtnShadow;
249 break;
643ccf62 250
37d403aa
JS
251 case wxSYS_COLOUR_3DHIGHLIGHT:
252 //case wxSYS_COLOUR_BTNHIGHLIGHT:
b0ae510a
PC
253 color = *wxWHITE;
254 break;
643ccf62 255
db434467 256 case wxSYS_COLOUR_HIGHLIGHT:
94a09ea5 257 if (!gs_objects.m_colHighlight.Ok())
db434467 258 {
b0ae510a
PC
259 gdkColor.red =
260 gdkColor.green = 0;
261 gdkColor.blue = 0x9c40;
262 GetColourFromGTKWidget(
263 gdkColor, wxGTK_BUTTON, GTK_STATE_SELECTED);
264 gs_objects.m_colHighlight = wxColour(gdkColor);
db434467 265 }
b0ae510a
PC
266 color = gs_objects.m_colHighlight;
267 break;
643ccf62 268
74f55195 269 case wxSYS_COLOUR_LISTBOX:
94a09ea5 270 if (!gs_objects.m_colListBox.Ok())
74f55195 271 {
b0ae510a 272 if ( GetColourFromGTKWidget(gdkColor,
dbcbe229
VZ
273 wxGTK_LIST,
274 GTK_STATE_NORMAL,
275 wxGTK_BASE) )
74f55195 276 {
b0ae510a 277 gs_objects.m_colListBox = wxColour(gdkColor);
74f55195
VS
278 }
279 else
643ccf62 280 {
b0ae510a 281 gs_objects.m_colListBox = *wxWHITE;
643ccf62 282 }
74f55195 283 }
b0ae510a
PC
284 color = gs_objects.m_colListBox;
285 break;
643ccf62
VZ
286
287 case wxSYS_COLOUR_MENUTEXT:
288 case wxSYS_COLOUR_WINDOWTEXT:
289 case wxSYS_COLOUR_CAPTIONTEXT:
290 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
291 case wxSYS_COLOUR_BTNTEXT:
94a09ea5 292 if (!gs_objects.m_colBtnText.Ok())
37d403aa 293 {
b0ae510a
PC
294 gdkColor.red =
295 gdkColor.green =
296 gdkColor.blue = 0;
297 GetColourFromGTKWidget(
298 gdkColor, wxGTK_BUTTON, GTK_STATE_NORMAL, wxGTK_FG);
299 gs_objects.m_colBtnText = wxColour(gdkColor);
37d403aa 300 }
b0ae510a
PC
301 color = gs_objects.m_colBtnText;
302 break;
643ccf62 303
17d61cbf 304 case wxSYS_COLOUR_INFOBK:
c05cc2c7
RR
305 if (!gs_objects.m_colTooltip.Ok()) {
306 GetTooltipColors();
307 }
b0ae510a
PC
308 color = gs_objects.m_colTooltip;
309 break;
c05cc2c7
RR
310
311 case wxSYS_COLOUR_INFOTEXT:
312 if (!gs_objects.m_colTooltipText.Ok()) {
313 GetTooltipColors();
314 }
b0ae510a
PC
315 color = gs_objects.m_colTooltipText;
316 break;
17d61cbf 317
643ccf62 318 case wxSYS_COLOUR_HIGHLIGHTTEXT:
94a09ea5 319 if (!gs_objects.m_colHighlightText.Ok())
643ccf62 320 {
984152a6 321 wxColour hclr = GetColour(wxSYS_COLOUR_HIGHLIGHT);
643ccf62 322 if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200)
b0ae510a 323 gs_objects.m_colHighlightText = *wxBLACK;
643ccf62 324 else
b0ae510a 325 gs_objects.m_colHighlightText = *wxWHITE;
643ccf62 326 }
b0ae510a
PC
327 color = gs_objects.m_colHighlightText;
328 break;
643ccf62 329
643ccf62 330 case wxSYS_COLOUR_APPWORKSPACE:
b0ae510a
PC
331 color = *wxWHITE; // ?
332 break;
221ed576 333
9d6a9fdd
RR
334 case wxSYS_COLOUR_ACTIVECAPTION:
335 case wxSYS_COLOUR_MENUHILIGHT:
336 if (!gs_objects.m_colMenuItemHighlight.Ok())
337 {
b0ae510a
PC
338 gdkColor.red =
339 gdkColor.green =
340 gdkColor.blue = 0;
341 GetColourFromGTKWidget(
342 gdkColor, wxGTK_MENUITEM, GTK_STATE_SELECTED, wxGTK_BG);
343 gs_objects.m_colMenuItemHighlight = wxColour(gdkColor);
9d6a9fdd 344 }
b0ae510a
PC
345 color = gs_objects.m_colMenuItemHighlight;
346 break;
9d6a9fdd 347
221ed576
VZ
348 case wxSYS_COLOUR_HOTLIGHT:
349 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
350 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
221ed576 351 // TODO
b0ae510a
PC
352 color = *wxBLACK;
353 break;
221ed576
VZ
354
355 case wxSYS_COLOUR_MAX:
356 default:
357 wxFAIL_MSG( _T("unknown system colour index") );
b0ae510a
PC
358 color = *wxWHITE;
359 break;
e24b680c 360 }
643ccf62 361
b0ae510a 362 return color;
ff7b1510 363}
c801d85f 364
0ab5e0e8 365wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
c801d85f 366{
b0ae510a 367 wxFont font;
2d17d68f 368 switch (index)
c801d85f 369 {
2d17d68f
RR
370 case wxSYS_OEM_FIXED_FONT:
371 case wxSYS_ANSI_FIXED_FONT:
372 case wxSYS_SYSTEM_FIXED_FONT:
b0ae510a
PC
373 font = *wxNORMAL_FONT;
374 break;
375
2d17d68f
RR
376 case wxSYS_ANSI_VAR_FONT:
377 case wxSYS_SYSTEM_FONT:
378 case wxSYS_DEVICE_DEFAULT_FONT:
379 case wxSYS_DEFAULT_GUI_FONT:
94a09ea5 380 if (!gs_objects.m_fontSystem.Ok())
d06b34a7 381 {
e7370dac
VS
382 GtkWidget *widget = gtk_button_new();
383 GtkStyle *def = gtk_rc_get_style( widget );
2269ff56 384 if ( !def || !def->font_desc )
17a1ebd1 385 def = gtk_widget_get_default_style();
2269ff56 386 if ( def && def->font_desc )
17a1ebd1
VZ
387 {
388 wxNativeFontInfo info;
389 info.description =
fdf7514a 390 pango_font_description_copy(def->font_desc);
17a1ebd1
VZ
391 gs_objects.m_fontSystem = wxFont(info);
392 }
393 else
394 {
119cd341
RR
395 GtkSettings *settings = gtk_settings_get_default();
396 gchar *font_name = NULL;
397 g_object_get ( settings,
17a1ebd1 398 "gtk-font-name",
119cd341
RR
399 &font_name,
400 NULL);
401 if (!font_name)
402 gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
403 else
404 gs_objects.m_fontSystem = wxFont(wxString::FromAscii(font_name));
405 g_free (font_name);
17a1ebd1 406 }
dd2422b3 407 gtk_object_sink((GtkObject*)widget);
d06b34a7 408 }
b0ae510a
PC
409 font = gs_objects.m_fontSystem;
410 break;
c801d85f 411
0ab5e0e8 412 default:
b0ae510a 413 break;
0ab5e0e8 414 }
b0ae510a 415 return font;
c801d85f 416}
c801d85f 417
37cafc6a 418static bool GetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* bottom)
c801d85f 419{
5ac8ce9e 420 bool success = false;
37cafc6a 421 Atom property = 0;
ff654490
VZ
422 if (gdk_x11_screen_supports_net_wm_hint(
423 gdk_drawable_get_screen(window),
424 gdk_atom_intern("_NET_FRAME_EXTENTS", false)))
b0ae510a 425 {
ff654490
VZ
426 success = true;
427 property = gdk_x11_get_xatom_by_name_for_display(
428 gdk_drawable_get_display(window),
429 "_NET_FRAME_EXTENTS");
37cafc6a 430 }
ff654490 431
37cafc6a
PC
432 if (success)
433 {
434 Atom type;
435 int format;
436 gulong nitems, bytes_after;
e8769ed1 437 guchar* data;
37cafc6a
PC
438 success = XGetWindowProperty(
439 gdk_x11_drawable_get_xdisplay(window),
440 gdk_x11_drawable_get_xid(window),
441 property,
442 0, 4,
443 false,
444 XA_CARDINAL,
e8769ed1 445 &type, &format, &nitems, &bytes_after, &data
37cafc6a
PC
446 ) == Success;
447 if (success)
448 {
449 success = data && nitems == 4;
450 if (success)
451 {
e8769ed1
PC
452 long* p = (long*)data;
453 if (left) *left = int(p[0]);
454 if (right) *right = int(p[1]);
455 if (top) *top = int(p[2]);
456 if (bottom) *bottom = int(p[3]);
37cafc6a
PC
457 }
458 if (data)
459 XFree(data);
460 }
461 }
b0ae510a
PC
462 return success;
463}
17a1ebd1 464
ff654490
VZ
465// helper: return the GtkSettings either for the screen the current window is
466// on or for the default screen if window is NULL
467static GtkSettings *GetSettingsForWindowScreen(GdkWindow *window)
468{
469 return window ? gtk_settings_get_for_screen(gdk_drawable_get_screen(window))
470 : gtk_settings_get_default();
471}
472
b0ae510a
PC
473int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
474{
9b0b5ba7
RR
475 GdkWindow *window = NULL;
476 if(win && GTK_WIDGET_REALIZED(win->GetHandle()))
477 window = win->GetHandle()->window;
9b0b5ba7 478
1ecc4d80
RR
479 switch (index)
480 {
9b0b5ba7
RR
481 case wxSYS_BORDER_X:
482 case wxSYS_BORDER_Y:
483 case wxSYS_EDGE_X:
484 case wxSYS_EDGE_Y:
485 case wxSYS_FRAMESIZE_X:
486 case wxSYS_FRAMESIZE_Y:
487 // If a window is specified/realized, and it is a toplevel window, we can query from wm.
488 // The returned border thickness is outside the client area in that case.
489 if (window)
490 {
491 wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow);
492 if (!tlw)
493 return -1; // not a tlw, not sure how to approach
494 else
495 {
9b0b5ba7
RR
496 // Get the frame extents from the windowmanager.
497 // In most cases the top extent is the titlebar, so we use the bottom extent
498 // for the heights.
37cafc6a
PC
499 int right, bottom;
500 if (GetFrameExtents(window, NULL, &right, NULL, &bottom))
9b0b5ba7 501 {
37cafc6a 502 switch (index)
9b0b5ba7 503 {
37cafc6a
PC
504 case wxSYS_BORDER_X:
505 case wxSYS_EDGE_X:
506 case wxSYS_FRAMESIZE_X:
507 return right; // width of right extent
508 default:
509 return bottom; // height of bottom extent
9b0b5ba7 510 }
9b0b5ba7
RR
511 }
512 }
513 }
514
515 return -1; // no window specified
516
517 case wxSYS_CURSOR_X:
518 case wxSYS_CURSOR_Y:
ff654490
VZ
519 return gdk_display_get_default_cursor_size(
520 window ? gdk_drawable_get_display(window)
521 : gdk_display_get_default());
17d61cbf 522
44fd6f72
VS
523 case wxSYS_DCLICK_X:
524 case wxSYS_DCLICK_Y:
525 gint dclick_distance;
ff654490
VZ
526 g_object_get(GetSettingsForWindowScreen(window),
527 "gtk-double-click-distance", &dclick_distance, NULL);
9b0b5ba7
RR
528
529 return dclick_distance * 2;
44fd6f72 530
5595181f
VZ
531 case wxSYS_DCLICK_MSEC:
532 gint dclick;
ff654490 533 g_object_get(GetSettingsForWindowScreen(window),
5595181f
VZ
534 "gtk-double-click-time", &dclick, NULL);
535 return dclick;
536
44fd6f72
VS
537 case wxSYS_DRAG_X:
538 case wxSYS_DRAG_Y:
539 gint drag_threshold;
ff654490
VZ
540 g_object_get(GetSettingsForWindowScreen(window),
541 "gtk-dnd-drag-threshold", &drag_threshold, NULL);
44fd6f72 542
9fcdfe05
RR
543 // The correct thing here would be to double the value
544 // since that is what the API wants. But the values
545 // are much bigger under GNOME than under Windows and
546 // just seem to much in many cases to be useful.
f4322df6 547 // drag_threshold *= 2;
9fcdfe05 548
1e7373d0 549 return drag_threshold;
9b0b5ba7 550
ff654490
VZ
551 case wxSYS_ICON_X:
552 case wxSYS_ICON_Y:
553 return 32;
9b0b5ba7
RR
554
555 case wxSYS_SCREEN_X:
ff654490 556 if (window)
9b0b5ba7
RR
557 return gdk_screen_get_width(gdk_drawable_get_screen(window));
558 else
9b0b5ba7
RR
559 return gdk_screen_width();
560
561 case wxSYS_SCREEN_Y:
ff654490 562 if (window)
9b0b5ba7
RR
563 return gdk_screen_get_height(gdk_drawable_get_screen(window));
564 else
9b0b5ba7
RR
565 return gdk_screen_height();
566
ff654490
VZ
567 case wxSYS_HSCROLL_Y:
568 case wxSYS_VSCROLL_X:
569 return 15;
9b0b5ba7 570
9b0b5ba7
RR
571 case wxSYS_CAPTION_Y:
572 if (!window)
573 // No realized window specified, and no implementation for that case yet.
574 return -1;
575
9b0b5ba7
RR
576 wxASSERT_MSG( wxDynamicCast(win, wxTopLevelWindow),
577 wxT("Asking for caption height of a non toplevel window") );
578
579 // Get the height of the top windowmanager border.
580 // This is the titlebar in most cases. The titlebar might be elsewhere, and
581 // we could check which is the thickest wm border to decide on which side the
582 // titlebar is, but this might lead to interesting behaviours in used code.
583 // Reconsider when we have a way to report to the user on which side it is.
9b0b5ba7 584 {
37cafc6a
PC
585 int top;
586 if (GetFrameExtents(window, NULL, NULL, &top, NULL))
9b0b5ba7 587 {
37cafc6a 588 return top; // top frame extent
9b0b5ba7 589 }
9b0b5ba7
RR
590 }
591
592 // Try a default approach without a window pointer, if possible
593 // ...
594
595 return -1;
9b0b5ba7
RR
596
597 case wxSYS_PENWINDOWS_PRESENT:
598 // No MS Windows for Pen computing extension available in X11 based gtk+.
599 return 0;
600
601 default:
1d451c5b 602 return -1; // metric is unknown
1ecc4d80 603 }
c67daf87 604}
253293c1 605
0ab5e0e8 606bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
253293c1
VS
607{
608 switch (index)
609 {
17a1ebd1 610 case wxSYS_CAN_ICONIZE_FRAME:
e7c80f9e 611 return false;
17a1ebd1 612
253293c1 613 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
e7c80f9e 614 return true;
17a1ebd1 615
253293c1 616 default:
e7c80f9e 617 return false;
253293c1
VS
618 }
619}