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