]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/settings.cpp
Fix cvs conflict.
[wxWidgets.git] / src / gtk1 / settings.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: settings.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifdef __GNUG__
12 #pragma implementation "settings.h"
13 #endif
14
15 #include "wx/settings.h"
16 #include "wx/debug.h"
17
18 #include "wx/cmndata.h"
19
20 #include <gdk/gdk.h>
21 #include <gdk/gdkprivate.h>
22 #include <gtk/gtk.h>
23
24 extern GdkFont *GtkGetDefaultGuiFont();
25
26
27 /*
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
49
50 #define wxSYS_COLOUR_3DDKSHADOW 21
51 #define wxSYS_COLOUR_3DLIGHT 22
52 #define wxSYS_COLOUR_INFOTEXT 23
53 #define wxSYS_COLOUR_INFOBK 24
54
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
61 */
62
63 #define SHIFT (8*(sizeof(short int)-sizeof(char)))
64
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;
73
74 wxFont *g_systemFont = (wxFont *) NULL;
75
76 void wxSystemSettings::Done()
77 {
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;
85 delete g_systemFont;
86 delete g_systemBtnTextColour;
87 }
88
89 wxColour wxSystemSettings::GetSystemColour( int index )
90 {
91 switch (index)
92 {
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:
103 {
104 if (!g_systemBtnFaceColour)
105 {
106 GtkWidget *widget = gtk_button_new();
107 GtkStyle *def = gtk_rc_get_style( widget );
108 if (!def)
109 def = gtk_widget_get_default_style();
110 if (def)
111 {
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,
117 green >> SHIFT,
118 blue >> SHIFT );
119 }
120 else
121 {
122 g_systemBtnFaceColour =
123 new wxColour( 0 >> SHIFT,
124 0 >> SHIFT,
125 0x9c40 >> SHIFT );
126 }
127 gtk_widget_destroy( widget );
128
129 }
130 return *g_systemBtnFaceColour;
131 /*
132 if (!g_systemBtnFaceColour)
133 {
134 g_systemBtnFaceColour =
135 new wxColour( 0xd6d6 >> SHIFT,
136 0xd6d6 >> SHIFT,
137 0xd6d6 >> SHIFT );
138 }
139 return *g_systemBtnFaceColour;
140 */
141 }
142 case wxSYS_COLOUR_WINDOW:
143 {
144 return *wxWHITE;
145 }
146 case wxSYS_COLOUR_3DDKSHADOW:
147 {
148 return *wxBLACK;
149 }
150 case wxSYS_COLOUR_GRAYTEXT:
151 case wxSYS_COLOUR_BTNSHADOW:
152 //case wxSYS_COLOUR_3DSHADOW:
153 {
154 if (!g_systemBtnShadowColour)
155 {
156 wxColour faceColour(GetSystemColour(wxSYS_COLOUR_3DFACE));
157 g_systemBtnShadowColour =
158 new wxColour((unsigned char) (faceColour.Red() * 0.666),
159 (unsigned char) (faceColour.Green() * 0.666),
160 (unsigned char) (faceColour.Blue() * 0.666));
161 }
162 /*
163 if (!g_systemBtnShadowColour)
164 {
165 g_systemBtnShadowColour =
166 new wxColour( 0x7530 >> SHIFT,
167 0x7530 >> SHIFT,
168 0x7530 >> SHIFT );
169 }
170 */
171 return *g_systemBtnShadowColour;
172 }
173 case wxSYS_COLOUR_3DHIGHLIGHT:
174 //case wxSYS_COLOUR_BTNHIGHLIGHT:
175 {
176 return * wxWHITE;
177 /* I think this should normally be white (JACS 8/2000)
178 if (!g_systemBtnHighlightColour)
179 {
180 g_systemBtnHighlightColour =
181 new wxColour( 0xea60 >> SHIFT,
182 0xea60 >> SHIFT,
183 0xea60 >> SHIFT );
184 }
185 return *g_systemBtnHighlightColour;
186 */
187 }
188 case wxSYS_COLOUR_HIGHLIGHT:
189 {
190 if (!g_systemHighlightColour)
191 {
192 GtkWidget *widget = gtk_button_new();
193 GtkStyle *def = gtk_rc_get_style( widget );
194 if (!def)
195 def = gtk_widget_get_default_style();
196 if (def)
197 {
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,
203 green >> SHIFT,
204 blue >> SHIFT );
205 }
206 else
207 {
208 g_systemHighlightColour =
209 new wxColour( 0 >> SHIFT,
210 0 >> SHIFT,
211 0x9c40 >> SHIFT );
212 }
213 gtk_widget_destroy( widget );
214
215 }
216 return *g_systemHighlightColour;
217 }
218 case wxSYS_COLOUR_LISTBOX:
219 {
220 if (!g_systemListBoxColour)
221 {
222 GtkWidget *widget = gtk_list_new();
223 GtkStyle *def = gtk_rc_get_style( widget );
224 if (!def)
225 def = gtk_widget_get_default_style();
226 if (def)
227 {
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,
233 green >> SHIFT,
234 blue >> SHIFT );
235 }
236 else
237 g_systemListBoxColour = new wxColour(*wxWHITE);
238 gtk_widget_destroy( widget );
239 }
240 return *g_systemListBoxColour;
241 }
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:
248 {
249 if (!g_systemBtnTextColour)
250 {
251 GtkWidget *widget = gtk_button_new();
252 GtkStyle *def = gtk_rc_get_style( widget );
253 if (!def)
254 def = gtk_widget_get_default_style();
255 if (def)
256 {
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,
262 green >> SHIFT,
263 blue >> SHIFT );
264 }
265 else
266 {
267 g_systemBtnTextColour =
268 new wxColour(0, 0, 0);
269 }
270 gtk_widget_destroy( widget );
271 }
272 return *g_systemBtnTextColour;
273 }
274 case wxSYS_COLOUR_HIGHLIGHTTEXT:
275 {
276 if (!g_systemHighlightTextColour)
277 {
278 wxColour hclr = GetSystemColour(wxSYS_COLOUR_HIGHLIGHT);
279 if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200)
280 g_systemHighlightTextColour = new wxColour(*wxBLACK);
281 else
282 g_systemHighlightTextColour = new wxColour(*wxWHITE);
283 }
284 return *g_systemHighlightTextColour;
285 }
286 case wxSYS_COLOUR_INFOBK:
287 case wxSYS_COLOUR_APPWORKSPACE:
288 {
289 return *wxWHITE; // ?
290 }
291 }
292 return *wxWHITE;
293 }
294
295 wxFont wxSystemSettings::GetSystemFont( int index )
296 {
297 switch (index)
298 {
299 case wxSYS_OEM_FIXED_FONT:
300 case wxSYS_ANSI_FIXED_FONT:
301 case wxSYS_SYSTEM_FIXED_FONT:
302 {
303 return *wxNORMAL_FONT;
304 }
305 case wxSYS_ANSI_VAR_FONT:
306 case wxSYS_SYSTEM_FONT:
307 case wxSYS_DEVICE_DEFAULT_FONT:
308 case wxSYS_DEFAULT_GUI_FONT:
309 {
310 if (!g_systemFont)
311 {
312 #if 0
313 GdkFont *gdk_font = GtkGetDefaultGuiFont();
314 if (gdk_font)
315 {
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 );
321 }
322 gtk_widget_destroy( widget );
323 #endif
324
325 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
326
327 }
328 return *g_systemFont;
329 }
330 }
331
332 return wxNullFont;
333 }
334
335 int wxSystemSettings::GetSystemMetric( int index )
336 {
337 switch (index)
338 {
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;
343 }
344
345 wxCHECK_MSG( index, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );
346
347 return 0;
348 }