]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/settings.cpp
remove symbol exports, this code is private to the library
[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 16#ifndef WX_PRECOMP
1832043f 17 #include "wx/toplevel.h"
ce5d92e1
WS
18#endif
19
2b5f62a0 20#include "wx/fontutil.h"
e3527f7b 21#include "wx/fontenum.h"
d06b34a7 22
aed8ac3f 23#include <gtk/gtk.h>
53357e24 24#include "wx/gtk/private/win_gtk.h"
385e8575 25#include "wx/gtk/private/gtk2-compat.h"
83624f79 26
166b4de7 27bool wxGetFrameExtents(GdkWindow* window, int* left, int* right, int* top, int* bottom);
9b0b5ba7 28
0ab5e0e8 29// ----------------------------------------------------------------------------
0d0b57ac 30// wxSystemSettings implementation
0ab5e0e8
VS
31// ----------------------------------------------------------------------------
32
0d0b57ac
PC
33static wxFont gs_fontSystem;
34
35static GtkContainer* ContainerWidget()
a51d7c4b 36{
0d0b57ac
PC
37 static GtkContainer* s_widget;
38 if (s_widget == NULL)
39 {
40 s_widget = GTK_CONTAINER(gtk_fixed_new());
41 GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
42 gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(s_widget));
43 }
44 return s_widget;
a51d7c4b
JS
45}
46
0d0b57ac 47extern "C" {
9dc44eff
PC
48#ifdef __WXGTK3__
49static void style_updated(GtkWidget*, void*)
50#else
0d0b57ac 51static void style_set(GtkWidget*, GtkStyle*, void*)
9dc44eff 52#endif
643ccf62 53{
0d0b57ac
PC
54 gs_fontSystem = wxNullFont;
55}
56}
57
9dc44eff 58static GtkWidget* ButtonWidget()
643ccf62 59{
0d0b57ac
PC
60 static GtkWidget* s_widget;
61 if (s_widget == NULL)
dbcbe229 62 {
0d0b57ac
PC
63 s_widget = gtk_button_new();
64 gtk_container_add(ContainerWidget(), s_widget);
9dc44eff
PC
65#ifdef __WXGTK3__
66 g_signal_connect(s_widget, "style_updated", G_CALLBACK(style_updated), NULL);
67#else
0d0b57ac
PC
68 gtk_widget_ensure_style(s_widget);
69 g_signal_connect(s_widget, "style_set", G_CALLBACK(style_set), NULL);
9dc44eff 70#endif
dbcbe229 71 }
9dc44eff 72 return s_widget;
0d0b57ac 73}
dbcbe229 74
9dc44eff 75static GtkWidget* ListWidget()
0d0b57ac
PC
76{
77 static GtkWidget* s_widget;
78 if (s_widget == NULL)
79 {
80 s_widget = gtk_tree_view_new_with_model(
81 GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_INT)));
82 gtk_container_add(ContainerWidget(), s_widget);
9dc44eff 83#ifndef __WXGTK3__
0d0b57ac 84 gtk_widget_ensure_style(s_widget);
9dc44eff 85#endif
0d0b57ac 86 }
9dc44eff 87 return s_widget;
0d0b57ac 88}
643ccf62 89
9dc44eff 90static GtkWidget* TextCtrlWidget()
0d0b57ac
PC
91{
92 static GtkWidget* s_widget;
93 if (s_widget == NULL)
643ccf62 94 {
0d0b57ac
PC
95 s_widget = gtk_text_view_new();
96 gtk_container_add(ContainerWidget(), s_widget);
9dc44eff 97#ifndef __WXGTK3__
0d0b57ac 98 gtk_widget_ensure_style(s_widget);
9dc44eff 99#endif
643ccf62 100 }
9dc44eff 101 return s_widget;
0d0b57ac 102}
643ccf62 103
9dc44eff 104static GtkWidget* MenuItemWidget()
0d0b57ac
PC
105{
106 static GtkWidget* s_widget;
107 if (s_widget == NULL)
108 {
109 s_widget = gtk_menu_item_new();
110 gtk_container_add(ContainerWidget(), s_widget);
9dc44eff 111#ifndef __WXGTK3__
0d0b57ac 112 gtk_widget_ensure_style(s_widget);
9dc44eff 113#endif
0d0b57ac 114 }
9dc44eff 115 return s_widget;
0d0b57ac 116}
643ccf62 117
9dc44eff 118static GtkWidget* MenuBarWidget()
0d0b57ac
PC
119{
120 static GtkWidget* s_widget;
121 if (s_widget == NULL)
122 {
123 s_widget = gtk_menu_bar_new();
124 gtk_container_add(ContainerWidget(), s_widget);
9dc44eff 125#ifndef __WXGTK3__
0d0b57ac 126 gtk_widget_ensure_style(s_widget);
9dc44eff 127#endif
0d0b57ac 128 }
9dc44eff 129 return s_widget;
643ccf62
VZ
130}
131
9dc44eff 132static GtkWidget* ToolTipWidget()
c05cc2c7 133{
0d0b57ac
PC
134 static GtkWidget* s_widget;
135 if (s_widget == NULL)
136 {
137 s_widget = gtk_window_new(GTK_WINDOW_POPUP);
138 const char* name = "gtk-tooltip";
9dc44eff 139#ifndef __WXGTK3__
0d0b57ac
PC
140 if (gtk_check_version(2, 11, 0))
141 name = "gtk-tooltips";
9dc44eff 142#endif
0d0b57ac 143 gtk_widget_set_name(s_widget, name);
9dc44eff 144#ifndef __WXGTK3__
0d0b57ac 145 gtk_widget_ensure_style(s_widget);
9dc44eff
PC
146#endif
147 }
148 return s_widget;
149}
150
151#ifdef __WXGTK3__
152static void bg(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
153{
154 GtkStyleContext* sc = gtk_widget_get_style_context(widget);
155 gtk_style_context_get_background_color(sc, state, &gdkRGBA);
156}
157static void fg(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
158{
159 GtkStyleContext* sc = gtk_widget_get_style_context(widget);
160 gtk_style_context_get_color(sc, state, &gdkRGBA);
161}
162static void border(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
163{
164 GtkStyleContext* sc = gtk_widget_get_style_context(widget);
165 gtk_style_context_get_border_color(sc, state, &gdkRGBA);
166}
167
168wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
169{
170 GdkRGBA gdkRGBA = { 0, 0, 0, 1 };
171 switch (index)
172 {
173 case wxSYS_COLOUR_3DLIGHT:
174 case wxSYS_COLOUR_ACTIVEBORDER:
175 case wxSYS_COLOUR_BTNFACE:
176 case wxSYS_COLOUR_DESKTOP:
177 case wxSYS_COLOUR_INACTIVEBORDER:
178 case wxSYS_COLOUR_INACTIVECAPTION:
179 case wxSYS_COLOUR_SCROLLBAR:
180 case wxSYS_COLOUR_WINDOWFRAME:
181 bg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
182 break;
183 case wxSYS_COLOUR_BTNHIGHLIGHT:
184 case wxSYS_COLOUR_HIGHLIGHT:
185 bg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
186 break;
187 case wxSYS_COLOUR_BTNSHADOW:
188 border(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
189 break;
190 case wxSYS_COLOUR_BTNTEXT:
191 case wxSYS_COLOUR_WINDOWTEXT:
192 fg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
193 break;
194 case wxSYS_COLOUR_GRAYTEXT:
195 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
196 fg(ButtonWidget(), GTK_STATE_FLAG_INSENSITIVE, gdkRGBA);
197 break;
198 case wxSYS_COLOUR_HIGHLIGHTTEXT:
199 fg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
200 break;
201 case wxSYS_COLOUR_HOTLIGHT:
202 {
203 static GtkWidget* s_widget;
204 if (s_widget == NULL)
205 {
206 s_widget = gtk_link_button_new("");
207 gtk_container_add(ContainerWidget(), s_widget);
208 }
209 fg(s_widget, GTK_STATE_FLAG_NORMAL, gdkRGBA);
210 }
211 break;
212 case wxSYS_COLOUR_INFOBK:
213 bg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
214 break;
215 case wxSYS_COLOUR_INFOTEXT:
216 fg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
217 break;
218 case wxSYS_COLOUR_LISTBOX:
219 bg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
220 break;
221 case wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT:
222 fg(ListWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
223 break;
224 case wxSYS_COLOUR_LISTBOXTEXT:
225 fg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
226 break;
227 case wxSYS_COLOUR_MENU:
228 bg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
229 break;
230 case wxSYS_COLOUR_MENUBAR:
231 bg(MenuBarWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
232 break;
233 case wxSYS_COLOUR_ACTIVECAPTION:
234 case wxSYS_COLOUR_MENUHILIGHT:
235 bg(MenuItemWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA);
236 break;
237 case wxSYS_COLOUR_MENUTEXT:
238 fg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
239 break;
240 case wxSYS_COLOUR_APPWORKSPACE:
241 case wxSYS_COLOUR_WINDOW:
242 bg(TextCtrlWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
243 break;
244 case wxSYS_COLOUR_CAPTIONTEXT:
245 {
246 GdkRGBA c = { 1, 1, 1, 1 };
247 gdkRGBA = c;
248 }
249 break;
250 default:
251 wxFAIL_MSG("unknown system colour index");
252 // fallthrough
253 case wxSYS_COLOUR_3DDKSHADOW:
254 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
255 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
256 // black
257 break;
0d0b57ac 258 }
9dc44eff
PC
259 return wxColour(gdkRGBA);
260}
261#else
262static const GtkStyle* ButtonStyle()
263{
264 return gtk_widget_get_style(ButtonWidget());
265}
266
267static const GtkStyle* ListStyle()
268{
269 return gtk_widget_get_style(ListWidget());
270}
271
272static const GtkStyle* TextCtrlStyle()
273{
274 return gtk_widget_get_style(TextCtrlWidget());
275}
276
277static const GtkStyle* MenuItemStyle()
278{
279 return gtk_widget_get_style(MenuItemWidget());
280}
281
282static const GtkStyle* MenuBarStyle()
283{
284 return gtk_widget_get_style(MenuBarWidget());
285}
286
287static const GtkStyle* ToolTipStyle()
288{
289 return gtk_widget_get_style(ToolTipWidget());
c05cc2c7
RR
290}
291
0ab5e0e8 292wxColour wxSystemSettingsNative::GetColour( wxSystemColour index )
c801d85f 293{
b0ae510a 294 wxColor color;
db434467 295 switch (index)
c801d85f 296 {
db434467
RR
297 case wxSYS_COLOUR_SCROLLBAR:
298 case wxSYS_COLOUR_BACKGROUND:
0d0b57ac 299 //case wxSYS_COLOUR_DESKTOP:
db434467
RR
300 case wxSYS_COLOUR_INACTIVECAPTION:
301 case wxSYS_COLOUR_MENU:
302 case wxSYS_COLOUR_WINDOWFRAME:
303 case wxSYS_COLOUR_ACTIVEBORDER:
304 case wxSYS_COLOUR_INACTIVEBORDER:
305 case wxSYS_COLOUR_BTNFACE:
0d0b57ac 306 //case wxSYS_COLOUR_3DFACE:
5b211fbf 307 case wxSYS_COLOUR_3DLIGHT:
0d0b57ac 308 color = wxColor(ButtonStyle()->bg[GTK_STATE_NORMAL]);
b0ae510a 309 break;
643ccf62 310
db434467 311 case wxSYS_COLOUR_WINDOW:
0d0b57ac 312 color = wxColor(TextCtrlStyle()->base[GTK_STATE_NORMAL]);
b0ae510a 313 break;
643ccf62 314
3ab6b7e6 315 case wxSYS_COLOUR_MENUBAR:
0d0b57ac 316 color = wxColor(MenuBarStyle()->bg[GTK_STATE_NORMAL]);
3ab6b7e6
VZ
317 break;
318
37d403aa 319 case wxSYS_COLOUR_3DDKSHADOW:
b0ae510a
PC
320 color = *wxBLACK;
321 break;
643ccf62 322
db434467
RR
323 case wxSYS_COLOUR_GRAYTEXT:
324 case wxSYS_COLOUR_BTNSHADOW:
37d403aa 325 //case wxSYS_COLOUR_3DSHADOW:
37d403aa 326 {
984152a6 327 wxColour faceColour(GetColour(wxSYS_COLOUR_3DFACE));
0d0b57ac 328 color =
b0ae510a
PC
329 wxColour((unsigned char) (faceColour.Red() * 2 / 3),
330 (unsigned char) (faceColour.Green() * 2 / 3),
331 (unsigned char) (faceColour.Blue() * 2 / 3));
db434467 332 }
b0ae510a 333 break;
643ccf62 334
0d0b57ac
PC
335 case wxSYS_COLOUR_BTNHIGHLIGHT:
336 //case wxSYS_COLOUR_BTNHILIGHT:
337 //case wxSYS_COLOUR_3DHIGHLIGHT:
338 //case wxSYS_COLOUR_3DHILIGHT:
b0ae510a
PC
339 color = *wxWHITE;
340 break;
643ccf62 341
db434467 342 case wxSYS_COLOUR_HIGHLIGHT:
0d0b57ac 343 color = wxColor(ButtonStyle()->bg[GTK_STATE_SELECTED]);
b0ae510a 344 break;
643ccf62 345
74f55195 346 case wxSYS_COLOUR_LISTBOX:
0d0b57ac 347 color = wxColor(ListStyle()->base[GTK_STATE_NORMAL]);
b0ae510a 348 break;
643ccf62 349
9f2968ad
VZ
350 case wxSYS_COLOUR_LISTBOXTEXT:
351 color = wxColor(ListStyle()->text[GTK_STATE_NORMAL]);
352 break;
353
887b919b
JS
354 case wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT:
355 // This is for the text in a list control (or tree) when the
356 // item is selected, but not focused
357 color = wxColor(ListStyle()->text[GTK_STATE_ACTIVE]);
358 break;
359
643ccf62
VZ
360 case wxSYS_COLOUR_MENUTEXT:
361 case wxSYS_COLOUR_WINDOWTEXT:
362 case wxSYS_COLOUR_CAPTIONTEXT:
363 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
364 case wxSYS_COLOUR_BTNTEXT:
0d0b57ac 365 color = wxColor(ButtonStyle()->fg[GTK_STATE_NORMAL]);
b0ae510a 366 break;
643ccf62 367
17d61cbf 368 case wxSYS_COLOUR_INFOBK:
0d0b57ac 369 color = wxColor(ToolTipStyle()->bg[GTK_STATE_NORMAL]);
b0ae510a 370 break;
c05cc2c7
RR
371
372 case wxSYS_COLOUR_INFOTEXT:
0d0b57ac 373 color = wxColor(ToolTipStyle()->fg[GTK_STATE_NORMAL]);
b0ae510a 374 break;
17d61cbf 375
643ccf62 376 case wxSYS_COLOUR_HIGHLIGHTTEXT:
0d0b57ac 377 color = wxColor(ButtonStyle()->fg[GTK_STATE_SELECTED]);
b0ae510a 378 break;
643ccf62 379
643ccf62 380 case wxSYS_COLOUR_APPWORKSPACE:
b0ae510a
PC
381 color = *wxWHITE; // ?
382 break;
221ed576 383
9d6a9fdd
RR
384 case wxSYS_COLOUR_ACTIVECAPTION:
385 case wxSYS_COLOUR_MENUHILIGHT:
0d0b57ac 386 color = wxColor(MenuItemStyle()->bg[GTK_STATE_SELECTED]);
b0ae510a 387 break;
9d6a9fdd 388
221ed576
VZ
389 case wxSYS_COLOUR_HOTLIGHT:
390 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
391 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
221ed576 392 // TODO
b0ae510a
PC
393 color = *wxBLACK;
394 break;
221ed576
VZ
395
396 case wxSYS_COLOUR_MAX:
397 default:
9a83f860 398 wxFAIL_MSG( wxT("unknown system colour index") );
b0ae510a
PC
399 color = *wxWHITE;
400 break;
e24b680c 401 }
643ccf62 402
e3527f7b 403 wxASSERT(color.IsOk());
b0ae510a 404 return color;
ff7b1510 405}
9dc44eff 406#endif
c801d85f 407
0ab5e0e8 408wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
c801d85f 409{
b0ae510a 410 wxFont font;
2d17d68f 411 switch (index)
c801d85f 412 {
2d17d68f
RR
413 case wxSYS_OEM_FIXED_FONT:
414 case wxSYS_ANSI_FIXED_FONT:
415 case wxSYS_SYSTEM_FIXED_FONT:
b0ae510a
PC
416 font = *wxNORMAL_FONT;
417 break;
418
2d17d68f
RR
419 case wxSYS_ANSI_VAR_FONT:
420 case wxSYS_SYSTEM_FONT:
421 case wxSYS_DEVICE_DEFAULT_FONT:
422 case wxSYS_DEFAULT_GUI_FONT:
a1b806b9 423 if (!gs_fontSystem.IsOk())
d06b34a7 424 {
0d0b57ac 425 wxNativeFontInfo info;
9dc44eff
PC
426#ifdef __WXGTK3__
427 GtkStyleContext* sc = gtk_widget_get_style_context(ButtonWidget());
428 info.description = const_cast<PangoFontDescription*>(
429 gtk_style_context_get_font(sc, GTK_STATE_FLAG_NORMAL));
430#else
0d0b57ac 431 info.description = ButtonStyle()->font_desc;
9dc44eff 432#endif
0d0b57ac 433 gs_fontSystem = wxFont(info);
03647350 434
330b3189 435#if wxUSE_FONTENUM
e3527f7b
FM
436 // (try to) heal the default font (on some common systems e.g. Ubuntu
437 // it's "Sans Serif" but the real font is called "Sans"):
438 if (!wxFontEnumerator::IsValidFacename(gs_fontSystem.GetFaceName()) &&
439 gs_fontSystem.GetFaceName() == "Sans Serif")
440 gs_fontSystem.SetFaceName("Sans");
330b3189 441#endif // wxUSE_FONTENUM
03647350 442
0d0b57ac 443 info.description = NULL;
d06b34a7 444 }
0d0b57ac 445 font = gs_fontSystem;
b0ae510a 446 break;
c801d85f 447
0ab5e0e8 448 default:
b0ae510a 449 break;
0ab5e0e8 450 }
e3527f7b 451
330b3189 452 wxASSERT( font.IsOk() );
e3527f7b 453
b0ae510a 454 return font;
c801d85f 455}
c801d85f 456
ff654490
VZ
457// helper: return the GtkSettings either for the screen the current window is
458// on or for the default screen if window is NULL
459static GtkSettings *GetSettingsForWindowScreen(GdkWindow *window)
460{
9dc44eff 461 return window ? gtk_settings_get_for_screen(gdk_window_get_screen(window))
ff654490
VZ
462 : gtk_settings_get_default();
463}
464
53357e24
PC
465static int GetBorderWidth(wxSystemMetric index, wxWindow* win)
466{
467 if (win->m_wxwindow)
468 {
469 wxPizza* pizza = WX_PIZZA(win->m_wxwindow);
9dc44eff
PC
470 GtkBorder border;
471 pizza->get_border(border);
53357e24
PC
472 switch (index)
473 {
474 case wxSYS_BORDER_X:
475 case wxSYS_EDGE_X:
476 case wxSYS_FRAMESIZE_X:
9dc44eff 477 return border.left;
53357e24 478 default:
9dc44eff 479 return border.top;
53357e24
PC
480 }
481 }
482 return -1;
483}
484
b0ae510a
PC
485int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win )
486{
9b0b5ba7 487 GdkWindow *window = NULL;
385e8575
PC
488 if (win)
489 window = gtk_widget_get_window(win->GetHandle());
9b0b5ba7 490
1ecc4d80
RR
491 switch (index)
492 {
9b0b5ba7
RR
493 case wxSYS_BORDER_X:
494 case wxSYS_BORDER_Y:
495 case wxSYS_EDGE_X:
496 case wxSYS_EDGE_Y:
497 case wxSYS_FRAMESIZE_X:
498 case wxSYS_FRAMESIZE_Y:
53357e24 499 if (win)
9b0b5ba7
RR
500 {
501 wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow);
502 if (!tlw)
53357e24
PC
503 return GetBorderWidth(index, win);
504 else if (window)
9b0b5ba7 505 {
9b0b5ba7
RR
506 // Get the frame extents from the windowmanager.
507 // In most cases the top extent is the titlebar, so we use the bottom extent
508 // for the heights.
37cafc6a 509 int right, bottom;
166b4de7 510 if (wxGetFrameExtents(window, NULL, &right, NULL, &bottom))
9b0b5ba7 511 {
37cafc6a 512 switch (index)
9b0b5ba7 513 {
37cafc6a
PC
514 case wxSYS_BORDER_X:
515 case wxSYS_EDGE_X:
516 case wxSYS_FRAMESIZE_X:
517 return right; // width of right extent
518 default:
519 return bottom; // height of bottom extent
9b0b5ba7 520 }
9b0b5ba7
RR
521 }
522 }
523 }
524
525 return -1; // no window specified
526
527 case wxSYS_CURSOR_X:
528 case wxSYS_CURSOR_Y:
ff654490 529 return gdk_display_get_default_cursor_size(
9dc44eff 530 window ? gdk_window_get_display(window)
ff654490 531 : gdk_display_get_default());
17d61cbf 532
44fd6f72
VS
533 case wxSYS_DCLICK_X:
534 case wxSYS_DCLICK_Y:
535 gint dclick_distance;
ff654490
VZ
536 g_object_get(GetSettingsForWindowScreen(window),
537 "gtk-double-click-distance", &dclick_distance, NULL);
9b0b5ba7
RR
538
539 return dclick_distance * 2;
44fd6f72 540
5595181f
VZ
541 case wxSYS_DCLICK_MSEC:
542 gint dclick;
ff654490 543 g_object_get(GetSettingsForWindowScreen(window),
5595181f
VZ
544 "gtk-double-click-time", &dclick, NULL);
545 return dclick;
546
44fd6f72
VS
547 case wxSYS_DRAG_X:
548 case wxSYS_DRAG_Y:
549 gint drag_threshold;
ff654490
VZ
550 g_object_get(GetSettingsForWindowScreen(window),
551 "gtk-dnd-drag-threshold", &drag_threshold, NULL);
44fd6f72 552
9fcdfe05
RR
553 // The correct thing here would be to double the value
554 // since that is what the API wants. But the values
555 // are much bigger under GNOME than under Windows and
556 // just seem to much in many cases to be useful.
f4322df6 557 // drag_threshold *= 2;
9fcdfe05 558
1e7373d0 559 return drag_threshold;
9b0b5ba7 560
ff654490
VZ
561 case wxSYS_ICON_X:
562 case wxSYS_ICON_Y:
563 return 32;
9b0b5ba7
RR
564
565 case wxSYS_SCREEN_X:
ff654490 566 if (window)
9dc44eff 567 return gdk_screen_get_width(gdk_window_get_screen(window));
9b0b5ba7 568 else
9b0b5ba7
RR
569 return gdk_screen_width();
570
571 case wxSYS_SCREEN_Y:
ff654490 572 if (window)
9dc44eff 573 return gdk_screen_get_height(gdk_window_get_screen(window));
9b0b5ba7 574 else
9b0b5ba7
RR
575 return gdk_screen_height();
576
ff654490
VZ
577 case wxSYS_HSCROLL_Y:
578 case wxSYS_VSCROLL_X:
579 return 15;
9b0b5ba7 580
9b0b5ba7
RR
581 case wxSYS_CAPTION_Y:
582 if (!window)
583 // No realized window specified, and no implementation for that case yet.
584 return -1;
585
9b0b5ba7
RR
586 wxASSERT_MSG( wxDynamicCast(win, wxTopLevelWindow),
587 wxT("Asking for caption height of a non toplevel window") );
588
589 // Get the height of the top windowmanager border.
590 // This is the titlebar in most cases. The titlebar might be elsewhere, and
591 // we could check which is the thickest wm border to decide on which side the
592 // titlebar is, but this might lead to interesting behaviours in used code.
593 // Reconsider when we have a way to report to the user on which side it is.
9b0b5ba7 594 {
37cafc6a 595 int top;
166b4de7 596 if (wxGetFrameExtents(window, NULL, NULL, &top, NULL))
9b0b5ba7 597 {
37cafc6a 598 return top; // top frame extent
9b0b5ba7 599 }
9b0b5ba7
RR
600 }
601
602 // Try a default approach without a window pointer, if possible
603 // ...
604
605 return -1;
9b0b5ba7
RR
606
607 case wxSYS_PENWINDOWS_PRESENT:
608 // No MS Windows for Pen computing extension available in X11 based gtk+.
609 return 0;
610
611 default:
1d451c5b 612 return -1; // metric is unknown
1ecc4d80 613 }
c67daf87 614}
253293c1 615
0ab5e0e8 616bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
253293c1
VS
617{
618 switch (index)
619 {
17a1ebd1 620 case wxSYS_CAN_ICONIZE_FRAME:
e7c80f9e 621 return false;
17a1ebd1 622
253293c1 623 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
e7c80f9e 624 return true;
17a1ebd1 625
253293c1 626 default:
e7c80f9e 627 return false;
253293c1
VS
628 }
629}