]>
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 | { |
984152a6 | 320 | wxColour hclr = GetColour(wxSYS_COLOUR_HIGHLIGHT); |
643ccf62 | 321 | if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200) |
b0ae510a | 322 | gs_objects.m_colHighlightText = *wxBLACK; |
643ccf62 | 323 | else |
b0ae510a | 324 | gs_objects.m_colHighlightText = *wxWHITE; |
643ccf62 | 325 | } |
b0ae510a PC |
326 | color = gs_objects.m_colHighlightText; |
327 | break; | |
643ccf62 | 328 | |
643ccf62 | 329 | case wxSYS_COLOUR_APPWORKSPACE: |
b0ae510a PC |
330 | color = *wxWHITE; // ? |
331 | break; | |
221ed576 | 332 | |
9d6a9fdd RR |
333 | case wxSYS_COLOUR_ACTIVECAPTION: |
334 | case wxSYS_COLOUR_MENUHILIGHT: | |
335 | if (!gs_objects.m_colMenuItemHighlight.Ok()) | |
336 | { | |
b0ae510a PC |
337 | gdkColor.red = |
338 | gdkColor.green = | |
339 | gdkColor.blue = 0; | |
340 | GetColourFromGTKWidget( | |
341 | gdkColor, wxGTK_MENUITEM, GTK_STATE_SELECTED, wxGTK_BG); | |
342 | gs_objects.m_colMenuItemHighlight = wxColour(gdkColor); | |
9d6a9fdd | 343 | } |
b0ae510a PC |
344 | color = gs_objects.m_colMenuItemHighlight; |
345 | break; | |
9d6a9fdd | 346 | |
221ed576 VZ |
347 | case wxSYS_COLOUR_HOTLIGHT: |
348 | case wxSYS_COLOUR_GRADIENTACTIVECAPTION: | |
349 | case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: | |
221ed576 | 350 | // TODO |
b0ae510a PC |
351 | color = *wxBLACK; |
352 | break; | |
221ed576 VZ |
353 | |
354 | case wxSYS_COLOUR_MAX: | |
355 | default: | |
356 | wxFAIL_MSG( _T("unknown system colour index") ); | |
b0ae510a PC |
357 | color = *wxWHITE; |
358 | break; | |
e24b680c | 359 | } |
643ccf62 | 360 | |
b0ae510a | 361 | return color; |
ff7b1510 | 362 | } |
c801d85f | 363 | |
0ab5e0e8 | 364 | wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) |
c801d85f | 365 | { |
b0ae510a | 366 | wxFont font; |
2d17d68f | 367 | switch (index) |
c801d85f | 368 | { |
2d17d68f RR |
369 | case wxSYS_OEM_FIXED_FONT: |
370 | case wxSYS_ANSI_FIXED_FONT: | |
371 | case wxSYS_SYSTEM_FIXED_FONT: | |
b0ae510a PC |
372 | font = *wxNORMAL_FONT; |
373 | break; | |
374 | ||
2d17d68f RR |
375 | case wxSYS_ANSI_VAR_FONT: |
376 | case wxSYS_SYSTEM_FONT: | |
377 | case wxSYS_DEVICE_DEFAULT_FONT: | |
378 | case wxSYS_DEFAULT_GUI_FONT: | |
94a09ea5 | 379 | if (!gs_objects.m_fontSystem.Ok()) |
d06b34a7 | 380 | { |
e7370dac VS |
381 | GtkWidget *widget = gtk_button_new(); |
382 | GtkStyle *def = gtk_rc_get_style( widget ); | |
2269ff56 | 383 | if ( !def || !def->font_desc ) |
17a1ebd1 | 384 | def = gtk_widget_get_default_style(); |
2269ff56 | 385 | if ( def && def->font_desc ) |
17a1ebd1 VZ |
386 | { |
387 | wxNativeFontInfo info; | |
388 | info.description = | |
fdf7514a | 389 | pango_font_description_copy(def->font_desc); |
17a1ebd1 VZ |
390 | gs_objects.m_fontSystem = wxFont(info); |
391 | } | |
392 | else | |
393 | { | |
119cd341 RR |
394 | GtkSettings *settings = gtk_settings_get_default(); |
395 | gchar *font_name = NULL; | |
396 | g_object_get ( settings, | |
17a1ebd1 | 397 | "gtk-font-name", |
119cd341 RR |
398 | &font_name, |
399 | NULL); | |
400 | if (!font_name) | |
401 | gs_objects.m_fontSystem = wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); | |
402 | else | |
403 | gs_objects.m_fontSystem = wxFont(wxString::FromAscii(font_name)); | |
404 | g_free (font_name); | |
17a1ebd1 | 405 | } |
dd2422b3 | 406 | gtk_object_sink((GtkObject*)widget); |
d06b34a7 | 407 | } |
b0ae510a PC |
408 | font = gs_objects.m_fontSystem; |
409 | break; | |
c801d85f | 410 | |
0ab5e0e8 | 411 | default: |
b0ae510a | 412 | break; |
0ab5e0e8 | 413 | } |
b0ae510a | 414 | return font; |
c801d85f | 415 | } |
c801d85f | 416 | |
ff654490 VZ |
417 | // helper: return the GtkSettings either for the screen the current window is |
418 | // on or for the default screen if window is NULL | |
419 | static GtkSettings *GetSettingsForWindowScreen(GdkWindow *window) | |
420 | { | |
421 | return window ? gtk_settings_get_for_screen(gdk_drawable_get_screen(window)) | |
422 | : gtk_settings_get_default(); | |
423 | } | |
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 | 451 | int right, bottom; |
166b4de7 | 452 | if (wxGetFrameExtents(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: | |
ff654490 VZ |
471 | return gdk_display_get_default_cursor_size( |
472 | window ? gdk_drawable_get_display(window) | |
473 | : gdk_display_get_default()); | |
17d61cbf | 474 | |
44fd6f72 VS |
475 | case wxSYS_DCLICK_X: |
476 | case wxSYS_DCLICK_Y: | |
477 | gint dclick_distance; | |
ff654490 VZ |
478 | g_object_get(GetSettingsForWindowScreen(window), |
479 | "gtk-double-click-distance", &dclick_distance, NULL); | |
9b0b5ba7 RR |
480 | |
481 | return dclick_distance * 2; | |
44fd6f72 | 482 | |
5595181f VZ |
483 | case wxSYS_DCLICK_MSEC: |
484 | gint dclick; | |
ff654490 | 485 | g_object_get(GetSettingsForWindowScreen(window), |
5595181f VZ |
486 | "gtk-double-click-time", &dclick, NULL); |
487 | return dclick; | |
488 | ||
44fd6f72 VS |
489 | case wxSYS_DRAG_X: |
490 | case wxSYS_DRAG_Y: | |
491 | gint drag_threshold; | |
ff654490 VZ |
492 | g_object_get(GetSettingsForWindowScreen(window), |
493 | "gtk-dnd-drag-threshold", &drag_threshold, NULL); | |
44fd6f72 | 494 | |
9fcdfe05 RR |
495 | // The correct thing here would be to double the value |
496 | // since that is what the API wants. But the values | |
497 | // are much bigger under GNOME than under Windows and | |
498 | // just seem to much in many cases to be useful. | |
f4322df6 | 499 | // drag_threshold *= 2; |
9fcdfe05 | 500 | |
1e7373d0 | 501 | return drag_threshold; |
9b0b5ba7 | 502 | |
ff654490 VZ |
503 | case wxSYS_ICON_X: |
504 | case wxSYS_ICON_Y: | |
505 | return 32; | |
9b0b5ba7 RR |
506 | |
507 | case wxSYS_SCREEN_X: | |
ff654490 | 508 | if (window) |
9b0b5ba7 RR |
509 | return gdk_screen_get_width(gdk_drawable_get_screen(window)); |
510 | else | |
9b0b5ba7 RR |
511 | return gdk_screen_width(); |
512 | ||
513 | case wxSYS_SCREEN_Y: | |
ff654490 | 514 | if (window) |
9b0b5ba7 RR |
515 | return gdk_screen_get_height(gdk_drawable_get_screen(window)); |
516 | else | |
9b0b5ba7 RR |
517 | return gdk_screen_height(); |
518 | ||
ff654490 VZ |
519 | case wxSYS_HSCROLL_Y: |
520 | case wxSYS_VSCROLL_X: | |
521 | return 15; | |
9b0b5ba7 | 522 | |
9b0b5ba7 RR |
523 | case wxSYS_CAPTION_Y: |
524 | if (!window) | |
525 | // No realized window specified, and no implementation for that case yet. | |
526 | return -1; | |
527 | ||
9b0b5ba7 RR |
528 | wxASSERT_MSG( wxDynamicCast(win, wxTopLevelWindow), |
529 | wxT("Asking for caption height of a non toplevel window") ); | |
530 | ||
531 | // Get the height of the top windowmanager border. | |
532 | // This is the titlebar in most cases. The titlebar might be elsewhere, and | |
533 | // we could check which is the thickest wm border to decide on which side the | |
534 | // titlebar is, but this might lead to interesting behaviours in used code. | |
535 | // Reconsider when we have a way to report to the user on which side it is. | |
9b0b5ba7 | 536 | { |
37cafc6a | 537 | int top; |
166b4de7 | 538 | if (wxGetFrameExtents(window, NULL, NULL, &top, NULL)) |
9b0b5ba7 | 539 | { |
37cafc6a | 540 | return top; // top frame extent |
9b0b5ba7 | 541 | } |
9b0b5ba7 RR |
542 | } |
543 | ||
544 | // Try a default approach without a window pointer, if possible | |
545 | // ... | |
546 | ||
547 | return -1; | |
9b0b5ba7 RR |
548 | |
549 | case wxSYS_PENWINDOWS_PRESENT: | |
550 | // No MS Windows for Pen computing extension available in X11 based gtk+. | |
551 | return 0; | |
552 | ||
553 | default: | |
1d451c5b | 554 | return -1; // metric is unknown |
1ecc4d80 | 555 | } |
c67daf87 | 556 | } |
253293c1 | 557 | |
0ab5e0e8 | 558 | bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) |
253293c1 VS |
559 | { |
560 | switch (index) | |
561 | { | |
17a1ebd1 | 562 | case wxSYS_CAN_ICONIZE_FRAME: |
e7c80f9e | 563 | return false; |
17a1ebd1 | 564 | |
253293c1 | 565 | case wxSYS_CAN_DRAW_FRAME_DECORATIONS: |
e7c80f9e | 566 | return true; |
17a1ebd1 | 567 | |
253293c1 | 568 | default: |
e7c80f9e | 569 | return false; |
253293c1 VS |
570 | } |
571 | } |