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