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