]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/settings.cpp
OS/2 fix in setdrive.
[wxWidgets.git] / src / gtk / settings.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: settings.cpp
3// Purpose:
4// Author: Robert Roebling
f96aa4d9
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
c801d85f
KB
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifdef __GNUG__
12#pragma implementation "settings.h"
13#endif
14
15#include "wx/settings.h"
1ecc4d80 16#include "wx/debug.h"
c801d85f 17
d06b34a7
RR
18#include "wx/cmndata.h"
19
aed8ac3f 20#include <gdk/gdk.h>
d06b34a7 21#include <gdk/gdkprivate.h>
aed8ac3f 22#include <gtk/gtk.h>
83624f79 23
f6bcfd97
BP
24extern GdkFont *GtkGetDefaultGuiFont();
25
d06b34a7 26
c801d85f
KB
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
94129723 65//wxColour *g_systemWinColour = (wxColour *) NULL;
74f55195
VS
66wxColour *g_systemBtnFaceColour = (wxColour *) NULL;
67wxColour *g_systemBtnShadowColour = (wxColour *) NULL;
68wxColour *g_systemBtnHighlightColour = (wxColour *) NULL;
69wxColour *g_systemHighlightColour = (wxColour *) NULL;
70wxColour *g_systemHighlightTextColour = (wxColour *) NULL;
71wxColour *g_systemListBoxColour = (wxColour *) NULL;
37d403aa 72wxColour *g_systemBtnTextColour = (wxColour *) NULL;
c801d85f 73
c67daf87 74wxFont *g_systemFont = (wxFont *) NULL;
a3622daa 75
1ecc4d80
RR
76void wxSystemSettings::Done()
77{
94129723 78// delete g_systemWinColour;
72a16063
RR
79 delete g_systemBtnFaceColour;
80 delete g_systemBtnShadowColour;
81 delete g_systemBtnHighlightColour;
82 delete g_systemHighlightColour;
74f55195
VS
83 delete g_systemHighlightTextColour;
84 delete g_systemListBoxColour;
72a16063 85 delete g_systemFont;
37d403aa 86 delete g_systemBtnTextColour;
a3622daa
VZ
87}
88
c801d85f
KB
89wxColour wxSystemSettings::GetSystemColour( int index )
90{
db434467 91 switch (index)
c801d85f 92 {
db434467
RR
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:
5b211fbf 102 case wxSYS_COLOUR_3DLIGHT:
db434467 103 {
37d403aa
JS
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 /*
db434467
RR
132 if (!g_systemBtnFaceColour)
133 {
134 g_systemBtnFaceColour =
135 new wxColour( 0xd6d6 >> SHIFT,
136 0xd6d6 >> SHIFT,
137 0xd6d6 >> SHIFT );
138 }
139 return *g_systemBtnFaceColour;
37d403aa 140 */
db434467
RR
141 }
142 case wxSYS_COLOUR_WINDOW:
143 {
144 return *wxWHITE;
145 }
37d403aa
JS
146 case wxSYS_COLOUR_3DDKSHADOW:
147 {
148 return *wxBLACK;
149 }
db434467
RR
150 case wxSYS_COLOUR_GRAYTEXT:
151 case wxSYS_COLOUR_BTNSHADOW:
37d403aa 152 //case wxSYS_COLOUR_3DSHADOW:
db434467 153 {
37d403aa
JS
154 if (!g_systemBtnShadowColour)
155 {
156 wxColour faceColour(GetSystemColour(wxSYS_COLOUR_3DFACE));
157 g_systemBtnShadowColour =
7a5e6267
JS
158 new wxColour((unsigned char) (faceColour.Red() * 0.666),
159 (unsigned char) (faceColour.Green() * 0.666),
160 (unsigned char) (faceColour.Blue() * 0.666));
37d403aa
JS
161 }
162 /*
db434467
RR
163 if (!g_systemBtnShadowColour)
164 {
165 g_systemBtnShadowColour =
166 new wxColour( 0x7530 >> SHIFT,
167 0x7530 >> SHIFT,
168 0x7530 >> SHIFT );
169 }
37d403aa 170 */
db434467
RR
171 return *g_systemBtnShadowColour;
172 }
37d403aa
JS
173 case wxSYS_COLOUR_3DHIGHLIGHT:
174 //case wxSYS_COLOUR_BTNHIGHLIGHT:
db434467 175 {
37d403aa
JS
176 return * wxWHITE;
177/* I think this should normally be white (JACS 8/2000)
db434467
RR
178 if (!g_systemBtnHighlightColour)
179 {
180 g_systemBtnHighlightColour =
181 new wxColour( 0xea60 >> SHIFT,
182 0xea60 >> SHIFT,
183 0xea60 >> SHIFT );
184 }
185 return *g_systemBtnHighlightColour;
37d403aa 186*/
db434467
RR
187 }
188 case wxSYS_COLOUR_HIGHLIGHT:
189 {
190 if (!g_systemHighlightColour)
191 {
db434467
RR
192 GtkWidget *widget = gtk_button_new();
193 GtkStyle *def = gtk_rc_get_style( widget );
e6527f9d
RR
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 }
db434467
RR
213 gtk_widget_destroy( widget );
214
db434467
RR
215 }
216 return *g_systemHighlightColour;
217 }
74f55195
VS
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 );
410207c3 224 if (!def)
74f55195
VS
225 def = gtk_widget_get_default_style();
226 if (def)
227 {
410207c3
VS
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;
74f55195
VS
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 );
74f55195
VS
239 }
240 return *g_systemListBoxColour;
241 }
c801d85f
KB
242 case wxSYS_COLOUR_MENUTEXT:
243 case wxSYS_COLOUR_WINDOWTEXT:
244 case wxSYS_COLOUR_CAPTIONTEXT:
245 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
cb0f2f54 246 case wxSYS_COLOUR_BTNTEXT:
c801d85f
KB
247 case wxSYS_COLOUR_INFOTEXT:
248 {
37d403aa
JS
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;
ff7b1510 273 }
c801d85f
KB
274 case wxSYS_COLOUR_HIGHLIGHTTEXT:
275 {
74f55195
VS
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;
ff7b1510 285 }
c801d85f
KB
286 case wxSYS_COLOUR_INFOBK:
287 case wxSYS_COLOUR_APPWORKSPACE:
288 {
289 return *wxWHITE; // ?
ff7b1510
RR
290 }
291 }
c801d85f 292 return *wxWHITE;
ff7b1510 293}
c801d85f 294
c801d85f
KB
295wxFont wxSystemSettings::GetSystemFont( int index )
296{
2d17d68f 297 switch (index)
c801d85f 298 {
2d17d68f
RR
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)
d06b34a7 311 {
d06b34a7 312#if 0
f6bcfd97 313 GdkFont *gdk_font = GtkGetDefaultGuiFont();
d06b34a7
RR
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 }
d06b34a7 322 gtk_widget_destroy( widget );
f6bcfd97
BP
323#endif
324
325 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
326
d06b34a7 327 }
2d17d68f
RR
328 return *g_systemFont;
329 }
ff7b1510 330 }
c801d85f 331
2d17d68f 332 return wxNullFont;
c801d85f 333}
c801d85f
KB
334
335int wxSystemSettings::GetSystemMetric( int index )
336{
1ecc4d80
RR
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
223d09f6 345 wxCHECK_MSG( index, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );
1ecc4d80
RR
346
347 return 0;
c67daf87 348}