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
->bg
[GTK_STATE_NORMAL
].red
;
172 int green
= def
->bg
[GTK_STATE_NORMAL
].green
;
173 int blue
= def
->bg
[GTK_STATE_NORMAL
].blue
;
174 g_systemListBoxColour
=
175 new wxColour( red
>> SHIFT
,
180 g_systemListBoxColour
= new wxColour(*wxWHITE
);
181 gtk_widget_destroy( widget
);
184 return *g_systemListBoxColour
;
186 case wxSYS_COLOUR_MENUTEXT
:
187 case wxSYS_COLOUR_WINDOWTEXT
:
188 case wxSYS_COLOUR_CAPTIONTEXT
:
189 case wxSYS_COLOUR_INACTIVECAPTIONTEXT
:
190 case wxSYS_COLOUR_BTNTEXT
:
191 case wxSYS_COLOUR_INFOTEXT
:
195 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
197 if (!g_systemHighlightTextColour
)
199 wxColour hclr
= GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
);
200 if (hclr
.Red() > 200 && hclr
.Green() > 200 && hclr
.Blue() > 200)
201 g_systemHighlightTextColour
= new wxColour(*wxBLACK
);
203 g_systemHighlightTextColour
= new wxColour(*wxWHITE
);
205 return *g_systemHighlightTextColour
;
207 case wxSYS_COLOUR_INFOBK
:
208 case wxSYS_COLOUR_APPWORKSPACE
:
210 return *wxWHITE
; // ?
216 wxFont
wxSystemSettings::GetSystemFont( int index
)
220 case wxSYS_OEM_FIXED_FONT
:
221 case wxSYS_ANSI_FIXED_FONT
:
222 case wxSYS_SYSTEM_FIXED_FONT
:
224 return *wxNORMAL_FONT
;
226 case wxSYS_ANSI_VAR_FONT
:
227 case wxSYS_SYSTEM_FONT
:
228 case wxSYS_DEVICE_DEFAULT_FONT
:
229 case wxSYS_DEFAULT_GUI_FONT
:
232 g_systemFont
= new wxFont( 12, wxSWISS
, wxNORMAL
, wxNORMAL
);
233 return *g_systemFont
;
240 int wxSystemSettings::GetSystemMetric( int index
)
244 case wxSYS_SCREEN_X
: return gdk_screen_width();
245 case wxSYS_SCREEN_Y
: return gdk_screen_height();
246 case wxSYS_HSCROLL_Y
: return 15;
247 case wxSYS_VSCROLL_X
: return 15;
250 wxCHECK_MSG( index
, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );