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"
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
44 #define wxSYS_COLOUR_3DDKSHADOW 21
45 #define wxSYS_COLOUR_3DLIGHT 22
46 #define wxSYS_COLOUR_INFOTEXT 23
47 #define wxSYS_COLOUR_INFOBK 24
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
57 #define SHIFT (8*(sizeof(short int)-sizeof(char)))
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
;
67 wxFont
*g_systemFont
= (wxFont
*) NULL
;
69 void wxSystemSettings::Done()
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
;
81 wxColour
wxSystemSettings::GetSystemColour( int index
)
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
:
95 if (!g_systemBtnFaceColour
)
97 g_systemBtnFaceColour
=
98 new wxColour( 0xd6d6 >> SHIFT
,
102 return *g_systemBtnFaceColour
;
104 case wxSYS_COLOUR_WINDOW
:
108 case wxSYS_COLOUR_GRAYTEXT
:
109 case wxSYS_COLOUR_BTNSHADOW
:
111 if (!g_systemBtnShadowColour
)
113 g_systemBtnShadowColour
=
114 new wxColour( 0x7530 >> SHIFT
,
118 return *g_systemBtnShadowColour
;
120 case wxSYS_COLOUR_BTNHIGHLIGHT
:
122 if (!g_systemBtnHighlightColour
)
124 g_systemBtnHighlightColour
=
125 new wxColour( 0xea60 >> SHIFT
,
129 return *g_systemBtnHighlightColour
;
131 case wxSYS_COLOUR_HIGHLIGHT
:
133 if (!g_systemHighlightColour
)
135 GtkWidget
*widget
= gtk_button_new();
136 GtkStyle
*def
= gtk_rc_get_style( widget
);
138 def
= gtk_widget_get_default_style();
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
,
151 g_systemHighlightColour
=
152 new wxColour( 0 >> SHIFT
,
156 gtk_widget_destroy( widget
);
159 return *g_systemHighlightColour
;
161 case wxSYS_COLOUR_LISTBOX
:
163 if (!g_systemListBoxColour
)
165 GtkWidget
*widget
= gtk_list_new();
166 GtkStyle
*def
= gtk_rc_get_style( widget
);
168 def
= gtk_widget_get_default_style();
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
,
180 g_systemListBoxColour
= new wxColour(*wxWHITE
);
181 gtk_widget_destroy( widget
);
183 return *g_systemListBoxColour
;
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
:
194 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
196 if (!g_systemHighlightTextColour
)
198 wxColour hclr
= GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
);
199 if (hclr
.Red() > 200 && hclr
.Green() > 200 && hclr
.Blue() > 200)
200 g_systemHighlightTextColour
= new wxColour(*wxBLACK
);
202 g_systemHighlightTextColour
= new wxColour(*wxWHITE
);
204 return *g_systemHighlightTextColour
;
206 case wxSYS_COLOUR_INFOBK
:
207 case wxSYS_COLOUR_APPWORKSPACE
:
209 return *wxWHITE
; // ?
215 wxFont
wxSystemSettings::GetSystemFont( int index
)
219 case wxSYS_OEM_FIXED_FONT
:
220 case wxSYS_ANSI_FIXED_FONT
:
221 case wxSYS_SYSTEM_FIXED_FONT
:
223 return *wxNORMAL_FONT
;
225 case wxSYS_ANSI_VAR_FONT
:
226 case wxSYS_SYSTEM_FONT
:
227 case wxSYS_DEVICE_DEFAULT_FONT
:
228 case wxSYS_DEFAULT_GUI_FONT
:
231 g_systemFont
= new wxFont( 12, wxSWISS
, wxNORMAL
, wxNORMAL
);
232 return *g_systemFont
;
239 int wxSystemSettings::GetSystemMetric( int index
)
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;
249 wxCHECK_MSG( index
, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );