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