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