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