1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "settings.h"
15 #include "wx/settings.h"
18 #include "wx/cmndata.h"
21 #include <gdk/gdkprivate.h>
24 extern GdkFont
*GtkGetDefaultGuiFont();
28 #define wxSYS_COLOUR_SCROLLBAR 0
29 #define wxSYS_COLOUR_BACKGROUND 1
30 #define wxSYS_COLOUR_ACTIVECAPTION 2
31 #define wxSYS_COLOUR_INACTIVECAPTION 3
32 #define wxSYS_COLOUR_MENU 4
33 #define wxSYS_COLOUR_WINDOW 5
34 #define wxSYS_COLOUR_WINDOWFRAME 6
35 #define wxSYS_COLOUR_MENUTEXT 7
36 #define wxSYS_COLOUR_WINDOWTEXT 8
37 #define wxSYS_COLOUR_CAPTIONTEXT 9
38 #define wxSYS_COLOUR_ACTIVEBORDER 10
39 #define wxSYS_COLOUR_INACTIVEBORDER 11
40 #define wxSYS_COLOUR_APPWORKSPACE 12
41 #define wxSYS_COLOUR_HIGHLIGHT 13
42 #define wxSYS_COLOUR_HIGHLIGHTTEXT 14
43 #define wxSYS_COLOUR_BTNFACE 15
44 #define wxSYS_COLOUR_BTNSHADOW 16
45 #define wxSYS_COLOUR_GRAYTEXT 17
46 #define wxSYS_COLOUR_BTNTEXT 18
47 #define wxSYS_COLOUR_INACTIVECAPTIONTEXT 19
48 #define wxSYS_COLOUR_BTNHIGHLIGHT 20
50 #define wxSYS_COLOUR_3DDKSHADOW 21
51 #define wxSYS_COLOUR_3DLIGHT 22
52 #define wxSYS_COLOUR_INFOTEXT 23
53 #define wxSYS_COLOUR_INFOBK 24
55 #define wxSYS_COLOUR_DESKTOP wxSYS_COLOUR_BACKGROUND
56 #define wxSYS_COLOUR_3DFACE wxSYS_COLOUR_BTNFACE
57 #define wxSYS_COLOUR_3DSHADOW wxSYS_COLOUR_BTNSHADOW
58 #define wxSYS_COLOUR_3DHIGHLIGHT wxSYS_COLOUR_BTNHIGHLIGHT
59 #define wxSYS_COLOUR_3DHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
60 #define wxSYS_COLOUR_BTNHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
63 #define SHIFT (8*(sizeof(short int)-sizeof(char)))
65 //wxColour *g_systemWinColour = (wxColour *) NULL;
66 wxColour
*g_systemBtnFaceColour
= (wxColour
*) NULL
;
67 wxColour
*g_systemBtnShadowColour
= (wxColour
*) NULL
;
68 wxColour
*g_systemBtnHighlightColour
= (wxColour
*) NULL
;
69 wxColour
*g_systemHighlightColour
= (wxColour
*) NULL
;
70 wxColour
*g_systemHighlightTextColour
= (wxColour
*) NULL
;
71 wxColour
*g_systemListBoxColour
= (wxColour
*) NULL
;
72 wxColour
*g_systemBtnTextColour
= (wxColour
*) NULL
;
74 wxFont
*g_systemFont
= (wxFont
*) NULL
;
76 void wxSystemSettings::Done()
78 // delete g_systemWinColour;
79 delete g_systemBtnFaceColour
;
80 delete g_systemBtnShadowColour
;
81 delete g_systemBtnHighlightColour
;
82 delete g_systemHighlightColour
;
83 delete g_systemHighlightTextColour
;
84 delete g_systemListBoxColour
;
86 delete g_systemBtnTextColour
;
89 wxColour
wxSystemSettings::GetSystemColour( int index
)
93 case wxSYS_COLOUR_SCROLLBAR
:
94 case wxSYS_COLOUR_BACKGROUND
:
95 case wxSYS_COLOUR_ACTIVECAPTION
:
96 case wxSYS_COLOUR_INACTIVECAPTION
:
97 case wxSYS_COLOUR_MENU
:
98 case wxSYS_COLOUR_WINDOWFRAME
:
99 case wxSYS_COLOUR_ACTIVEBORDER
:
100 case wxSYS_COLOUR_INACTIVEBORDER
:
101 case wxSYS_COLOUR_BTNFACE
:
102 case wxSYS_COLOUR_3DLIGHT
:
104 if (!g_systemBtnFaceColour
)
106 GtkWidget
*widget
= gtk_button_new();
107 GtkStyle
*def
= gtk_rc_get_style( widget
);
109 def
= gtk_widget_get_default_style();
112 int red
= def
->bg
[GTK_STATE_NORMAL
].red
;
113 int green
= def
->bg
[GTK_STATE_NORMAL
].green
;
114 int blue
= def
->bg
[GTK_STATE_NORMAL
].blue
;
115 g_systemBtnFaceColour
=
116 new wxColour( red
>> SHIFT
,
122 g_systemBtnFaceColour
=
123 new wxColour( 0 >> SHIFT
,
127 gtk_widget_destroy( widget
);
130 return *g_systemBtnFaceColour
;
132 if (!g_systemBtnFaceColour)
134 g_systemBtnFaceColour =
135 new wxColour( 0xd6d6 >> SHIFT,
139 return *g_systemBtnFaceColour;
142 case wxSYS_COLOUR_WINDOW
:
146 case wxSYS_COLOUR_3DDKSHADOW
:
150 case wxSYS_COLOUR_GRAYTEXT
:
151 case wxSYS_COLOUR_BTNSHADOW
:
152 //case wxSYS_COLOUR_3DSHADOW:
154 if (!g_systemBtnShadowColour
)
156 wxColour
faceColour(GetSystemColour(wxSYS_COLOUR_3DFACE
));
157 g_systemBtnShadowColour
=
158 new wxColour(faceColour
.Red() * 0.666,
159 faceColour
.Green() * 0.666,
160 faceColour
.Blue() * 0.666);
163 if (!g_systemBtnShadowColour)
165 g_systemBtnShadowColour =
166 new wxColour( 0x7530 >> SHIFT,
171 return *g_systemBtnShadowColour
;
173 case wxSYS_COLOUR_3DHIGHLIGHT
:
174 //case wxSYS_COLOUR_BTNHIGHLIGHT:
177 /* I think this should normally be white (JACS 8/2000)
178 if (!g_systemBtnHighlightColour)
180 g_systemBtnHighlightColour =
181 new wxColour( 0xea60 >> SHIFT,
185 return *g_systemBtnHighlightColour;
188 case wxSYS_COLOUR_HIGHLIGHT
:
190 if (!g_systemHighlightColour
)
192 GtkWidget
*widget
= gtk_button_new();
193 GtkStyle
*def
= gtk_rc_get_style( widget
);
195 def
= gtk_widget_get_default_style();
198 int red
= def
->bg
[GTK_STATE_SELECTED
].red
;
199 int green
= def
->bg
[GTK_STATE_SELECTED
].green
;
200 int blue
= def
->bg
[GTK_STATE_SELECTED
].blue
;
201 g_systemHighlightColour
=
202 new wxColour( red
>> SHIFT
,
208 g_systemHighlightColour
=
209 new wxColour( 0 >> SHIFT
,
213 gtk_widget_destroy( widget
);
216 return *g_systemHighlightColour
;
218 case wxSYS_COLOUR_LISTBOX
:
220 if (!g_systemListBoxColour
)
222 GtkWidget
*widget
= gtk_list_new();
223 GtkStyle
*def
= gtk_rc_get_style( widget
);
225 def
= gtk_widget_get_default_style();
228 int red
= def
->base
[GTK_STATE_NORMAL
].red
;
229 int green
= def
->base
[GTK_STATE_NORMAL
].green
;
230 int blue
= def
->base
[GTK_STATE_NORMAL
].blue
;
231 g_systemListBoxColour
=
232 new wxColour( red
>> SHIFT
,
237 g_systemListBoxColour
= new wxColour(*wxWHITE
);
238 gtk_widget_destroy( widget
);
240 return *g_systemListBoxColour
;
242 case wxSYS_COLOUR_MENUTEXT
:
243 case wxSYS_COLOUR_WINDOWTEXT
:
244 case wxSYS_COLOUR_CAPTIONTEXT
:
245 case wxSYS_COLOUR_INACTIVECAPTIONTEXT
:
246 case wxSYS_COLOUR_BTNTEXT
:
247 case wxSYS_COLOUR_INFOTEXT
:
249 if (!g_systemBtnTextColour
)
251 GtkWidget
*widget
= gtk_button_new();
252 GtkStyle
*def
= gtk_rc_get_style( widget
);
254 def
= gtk_widget_get_default_style();
257 int red
= def
->fg
[GTK_STATE_NORMAL
].red
;
258 int green
= def
->fg
[GTK_STATE_NORMAL
].green
;
259 int blue
= def
->fg
[GTK_STATE_NORMAL
].blue
;
260 g_systemBtnTextColour
=
261 new wxColour( red
>> SHIFT
,
267 g_systemBtnTextColour
=
268 new wxColour(0, 0, 0);
270 gtk_widget_destroy( widget
);
272 return *g_systemBtnTextColour
;
274 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
276 if (!g_systemHighlightTextColour
)
278 wxColour hclr
= GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
);
279 if (hclr
.Red() > 200 && hclr
.Green() > 200 && hclr
.Blue() > 200)
280 g_systemHighlightTextColour
= new wxColour(*wxBLACK
);
282 g_systemHighlightTextColour
= new wxColour(*wxWHITE
);
284 return *g_systemHighlightTextColour
;
286 case wxSYS_COLOUR_INFOBK
:
287 case wxSYS_COLOUR_APPWORKSPACE
:
289 return *wxWHITE
; // ?
295 wxFont
wxSystemSettings::GetSystemFont( int index
)
299 case wxSYS_OEM_FIXED_FONT
:
300 case wxSYS_ANSI_FIXED_FONT
:
301 case wxSYS_SYSTEM_FIXED_FONT
:
303 return *wxNORMAL_FONT
;
305 case wxSYS_ANSI_VAR_FONT
:
306 case wxSYS_SYSTEM_FONT
:
307 case wxSYS_DEVICE_DEFAULT_FONT
:
308 case wxSYS_DEFAULT_GUI_FONT
:
313 GdkFont
*gdk_font
= GtkGetDefaultGuiFont();
316 GSList
*font_list
= ((GdkFontPrivate
*)gdk_font
)->names
;
317 char *name
= (char*)font_list
->data
;
318 wxString
font_string( name
);
319 wxFontData font_data
;
320 g_systemFont
= new wxFont( font_string
, font_data
);
322 gtk_widget_destroy( widget
);
325 g_systemFont
= new wxFont( 12, wxSWISS
, wxNORMAL
, wxNORMAL
);
328 return *g_systemFont
;
335 int wxSystemSettings::GetSystemMetric( int index
)
339 case wxSYS_SCREEN_X
: return gdk_screen_width();
340 case wxSYS_SCREEN_Y
: return gdk_screen_height();
341 case wxSYS_HSCROLL_Y
: return 15;
342 case wxSYS_VSCROLL_X
: return 15;
345 wxCHECK_MSG( index
, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );