]>
Commit | Line | Data |
---|---|---|
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 | |
d06b34a7 | 24 | |
c801d85f KB |
25 | /* |
26 | #define wxSYS_COLOUR_SCROLLBAR 0 | |
27 | #define wxSYS_COLOUR_BACKGROUND 1 | |
28 | #define wxSYS_COLOUR_ACTIVECAPTION 2 | |
29 | #define wxSYS_COLOUR_INACTIVECAPTION 3 | |
30 | #define wxSYS_COLOUR_MENU 4 | |
31 | #define wxSYS_COLOUR_WINDOW 5 | |
32 | #define wxSYS_COLOUR_WINDOWFRAME 6 | |
33 | #define wxSYS_COLOUR_MENUTEXT 7 | |
34 | #define wxSYS_COLOUR_WINDOWTEXT 8 | |
35 | #define wxSYS_COLOUR_CAPTIONTEXT 9 | |
36 | #define wxSYS_COLOUR_ACTIVEBORDER 10 | |
37 | #define wxSYS_COLOUR_INACTIVEBORDER 11 | |
38 | #define wxSYS_COLOUR_APPWORKSPACE 12 | |
39 | #define wxSYS_COLOUR_HIGHLIGHT 13 | |
40 | #define wxSYS_COLOUR_HIGHLIGHTTEXT 14 | |
41 | #define wxSYS_COLOUR_BTNFACE 15 | |
42 | #define wxSYS_COLOUR_BTNSHADOW 16 | |
43 | #define wxSYS_COLOUR_GRAYTEXT 17 | |
44 | #define wxSYS_COLOUR_BTNTEXT 18 | |
45 | #define wxSYS_COLOUR_INACTIVECAPTIONTEXT 19 | |
46 | #define wxSYS_COLOUR_BTNHIGHLIGHT 20 | |
47 | ||
48 | #define wxSYS_COLOUR_3DDKSHADOW 21 | |
49 | #define wxSYS_COLOUR_3DLIGHT 22 | |
50 | #define wxSYS_COLOUR_INFOTEXT 23 | |
51 | #define wxSYS_COLOUR_INFOBK 24 | |
52 | ||
53 | #define wxSYS_COLOUR_DESKTOP wxSYS_COLOUR_BACKGROUND | |
54 | #define wxSYS_COLOUR_3DFACE wxSYS_COLOUR_BTNFACE | |
55 | #define wxSYS_COLOUR_3DSHADOW wxSYS_COLOUR_BTNSHADOW | |
56 | #define wxSYS_COLOUR_3DHIGHLIGHT wxSYS_COLOUR_BTNHIGHLIGHT | |
57 | #define wxSYS_COLOUR_3DHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT | |
58 | #define wxSYS_COLOUR_BTNHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT | |
59 | */ | |
60 | ||
61 | #define SHIFT (8*(sizeof(short int)-sizeof(char))) | |
62 | ||
94129723 | 63 | //wxColour *g_systemWinColour = (wxColour *) NULL; |
74f55195 VS |
64 | wxColour *g_systemBtnFaceColour = (wxColour *) NULL; |
65 | wxColour *g_systemBtnShadowColour = (wxColour *) NULL; | |
66 | wxColour *g_systemBtnHighlightColour = (wxColour *) NULL; | |
67 | wxColour *g_systemHighlightColour = (wxColour *) NULL; | |
68 | wxColour *g_systemHighlightTextColour = (wxColour *) NULL; | |
69 | wxColour *g_systemListBoxColour = (wxColour *) NULL; | |
c801d85f | 70 | |
c67daf87 | 71 | wxFont *g_systemFont = (wxFont *) NULL; |
a3622daa | 72 | |
1ecc4d80 RR |
73 | void wxSystemSettings::Done() |
74 | { | |
94129723 | 75 | // delete g_systemWinColour; |
72a16063 RR |
76 | delete g_systemBtnFaceColour; |
77 | delete g_systemBtnShadowColour; | |
78 | delete g_systemBtnHighlightColour; | |
79 | delete g_systemHighlightColour; | |
74f55195 VS |
80 | delete g_systemHighlightTextColour; |
81 | delete g_systemListBoxColour; | |
72a16063 | 82 | delete g_systemFont; |
a3622daa VZ |
83 | } |
84 | ||
c801d85f KB |
85 | wxColour wxSystemSettings::GetSystemColour( int index ) |
86 | { | |
db434467 | 87 | switch (index) |
c801d85f | 88 | { |
db434467 RR |
89 | case wxSYS_COLOUR_SCROLLBAR: |
90 | case wxSYS_COLOUR_BACKGROUND: | |
91 | case wxSYS_COLOUR_ACTIVECAPTION: | |
92 | case wxSYS_COLOUR_INACTIVECAPTION: | |
93 | case wxSYS_COLOUR_MENU: | |
94 | case wxSYS_COLOUR_WINDOWFRAME: | |
95 | case wxSYS_COLOUR_ACTIVEBORDER: | |
96 | case wxSYS_COLOUR_INACTIVEBORDER: | |
97 | case wxSYS_COLOUR_BTNFACE: | |
98 | { | |
99 | if (!g_systemBtnFaceColour) | |
100 | { | |
101 | g_systemBtnFaceColour = | |
102 | new wxColour( 0xd6d6 >> SHIFT, | |
103 | 0xd6d6 >> SHIFT, | |
104 | 0xd6d6 >> SHIFT ); | |
105 | } | |
106 | return *g_systemBtnFaceColour; | |
107 | } | |
108 | case wxSYS_COLOUR_WINDOW: | |
109 | { | |
110 | return *wxWHITE; | |
111 | } | |
112 | case wxSYS_COLOUR_GRAYTEXT: | |
113 | case wxSYS_COLOUR_BTNSHADOW: | |
114 | { | |
115 | if (!g_systemBtnShadowColour) | |
116 | { | |
117 | g_systemBtnShadowColour = | |
118 | new wxColour( 0x7530 >> SHIFT, | |
119 | 0x7530 >> SHIFT, | |
120 | 0x7530 >> SHIFT ); | |
121 | } | |
122 | return *g_systemBtnShadowColour; | |
123 | } | |
124 | case wxSYS_COLOUR_BTNHIGHLIGHT: | |
125 | { | |
126 | if (!g_systemBtnHighlightColour) | |
127 | { | |
128 | g_systemBtnHighlightColour = | |
129 | new wxColour( 0xea60 >> SHIFT, | |
130 | 0xea60 >> SHIFT, | |
131 | 0xea60 >> SHIFT ); | |
132 | } | |
133 | return *g_systemBtnHighlightColour; | |
134 | } | |
135 | case wxSYS_COLOUR_HIGHLIGHT: | |
136 | { | |
137 | if (!g_systemHighlightColour) | |
138 | { | |
db434467 RR |
139 | GtkWidget *widget = gtk_button_new(); |
140 | GtkStyle *def = gtk_rc_get_style( widget ); | |
e6527f9d RR |
141 | if (!def) |
142 | def = gtk_widget_get_default_style(); | |
143 | if (def) | |
144 | { | |
145 | int red = def->bg[GTK_STATE_SELECTED].red; | |
146 | int green = def->bg[GTK_STATE_SELECTED].green; | |
147 | int blue = def->bg[GTK_STATE_SELECTED].blue; | |
148 | g_systemHighlightColour = | |
149 | new wxColour( red >> SHIFT, | |
150 | green >> SHIFT, | |
151 | blue >> SHIFT ); | |
152 | } | |
153 | else | |
154 | { | |
155 | g_systemHighlightColour = | |
156 | new wxColour( 0 >> SHIFT, | |
157 | 0 >> SHIFT, | |
158 | 0x9c40 >> SHIFT ); | |
159 | } | |
db434467 RR |
160 | gtk_widget_destroy( widget ); |
161 | ||
db434467 RR |
162 | } |
163 | return *g_systemHighlightColour; | |
164 | } | |
74f55195 VS |
165 | case wxSYS_COLOUR_LISTBOX: |
166 | { | |
167 | if (!g_systemListBoxColour) | |
168 | { | |
169 | GtkWidget *widget = gtk_list_new(); | |
170 | GtkStyle *def = gtk_rc_get_style( widget ); | |
410207c3 | 171 | if (!def) |
74f55195 VS |
172 | def = gtk_widget_get_default_style(); |
173 | if (def) | |
174 | { | |
410207c3 VS |
175 | int red = def->base[GTK_STATE_NORMAL].red; |
176 | int green = def->base[GTK_STATE_NORMAL].green; | |
177 | int blue = def->base[GTK_STATE_NORMAL].blue; | |
74f55195 VS |
178 | g_systemListBoxColour = |
179 | new wxColour( red >> SHIFT, | |
180 | green >> SHIFT, | |
181 | blue >> SHIFT ); | |
182 | } | |
183 | else | |
184 | g_systemListBoxColour = new wxColour(*wxWHITE); | |
185 | gtk_widget_destroy( widget ); | |
74f55195 VS |
186 | } |
187 | return *g_systemListBoxColour; | |
188 | } | |
c801d85f KB |
189 | case wxSYS_COLOUR_MENUTEXT: |
190 | case wxSYS_COLOUR_WINDOWTEXT: | |
191 | case wxSYS_COLOUR_CAPTIONTEXT: | |
192 | case wxSYS_COLOUR_INACTIVECAPTIONTEXT: | |
cb0f2f54 | 193 | case wxSYS_COLOUR_BTNTEXT: |
c801d85f KB |
194 | case wxSYS_COLOUR_INFOTEXT: |
195 | { | |
196 | return *wxBLACK; | |
ff7b1510 | 197 | } |
c801d85f KB |
198 | case wxSYS_COLOUR_HIGHLIGHTTEXT: |
199 | { | |
74f55195 VS |
200 | if (!g_systemHighlightTextColour) |
201 | { | |
202 | wxColour hclr = GetSystemColour(wxSYS_COLOUR_HIGHLIGHT); | |
203 | if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200) | |
204 | g_systemHighlightTextColour = new wxColour(*wxBLACK); | |
205 | else | |
206 | g_systemHighlightTextColour = new wxColour(*wxWHITE); | |
207 | } | |
208 | return *g_systemHighlightTextColour; | |
ff7b1510 | 209 | } |
c801d85f KB |
210 | case wxSYS_COLOUR_INFOBK: |
211 | case wxSYS_COLOUR_APPWORKSPACE: | |
212 | { | |
213 | return *wxWHITE; // ? | |
ff7b1510 RR |
214 | } |
215 | } | |
c801d85f | 216 | return *wxWHITE; |
ff7b1510 | 217 | } |
c801d85f | 218 | |
c801d85f KB |
219 | wxFont wxSystemSettings::GetSystemFont( int index ) |
220 | { | |
2d17d68f | 221 | switch (index) |
c801d85f | 222 | { |
2d17d68f RR |
223 | case wxSYS_OEM_FIXED_FONT: |
224 | case wxSYS_ANSI_FIXED_FONT: | |
225 | case wxSYS_SYSTEM_FIXED_FONT: | |
226 | { | |
227 | return *wxNORMAL_FONT; | |
228 | } | |
229 | case wxSYS_ANSI_VAR_FONT: | |
230 | case wxSYS_SYSTEM_FONT: | |
231 | case wxSYS_DEVICE_DEFAULT_FONT: | |
232 | case wxSYS_DEFAULT_GUI_FONT: | |
233 | { | |
234 | if (!g_systemFont) | |
d06b34a7 RR |
235 | { |
236 | GdkFont *gdk_font = (GdkFont*) NULL; | |
237 | GtkWidget *widget = gtk_button_new(); | |
238 | #if 0 | |
239 | GtkStyle *def = gtk_rc_get_style( widget ); | |
240 | if (def) | |
241 | gdk_font = def->font; | |
242 | else | |
243 | { | |
244 | def = gtk_widget_get_default_style(); | |
245 | if (def) | |
246 | gdk_font = def->font; | |
247 | } | |
248 | #endif | |
249 | if (gdk_font) | |
250 | { | |
251 | GSList *font_list = ((GdkFontPrivate*)gdk_font)->names; | |
252 | char *name = (char*)font_list->data; | |
253 | wxString font_string( name ); | |
254 | wxFontData font_data; | |
255 | g_systemFont = new wxFont( font_string, font_data ); | |
256 | } | |
257 | else | |
258 | { | |
259 | g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); | |
260 | } | |
261 | ||
262 | gtk_widget_destroy( widget ); | |
263 | } | |
2d17d68f RR |
264 | return *g_systemFont; |
265 | } | |
ff7b1510 | 266 | } |
c801d85f | 267 | |
2d17d68f | 268 | return wxNullFont; |
c801d85f | 269 | } |
c801d85f KB |
270 | |
271 | int wxSystemSettings::GetSystemMetric( int index ) | |
272 | { | |
1ecc4d80 RR |
273 | switch (index) |
274 | { | |
275 | case wxSYS_SCREEN_X: return gdk_screen_width(); | |
276 | case wxSYS_SCREEN_Y: return gdk_screen_height(); | |
277 | case wxSYS_HSCROLL_Y: return 15; | |
278 | case wxSYS_VSCROLL_X: return 15; | |
279 | } | |
280 | ||
223d09f6 | 281 | wxCHECK_MSG( index, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") ); |
1ecc4d80 RR |
282 | |
283 | return 0; | |
c67daf87 | 284 | } |