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