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"
18 #include "wx/cmndata.h"
21 #include <gdk/gdkprivate.h>
24 extern GdkFont
*GtkGetDefaultGuiFont();
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
50 #define wxSYS_COLOUR_3DDKSHADOW 21
51 #define wxSYS_COLOUR_3DLIGHT 22
52 #define wxSYS_COLOUR_INFOTEXT 23
53 #define wxSYS_COLOUR_INFOBK 24
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
63 #define SHIFT (8*(sizeof(short int)-sizeof(char)))
65 //wxColour *g_systemWinColour = (wxColour *) NULL;
66 wxColour
*g_systemBtnFaceColour
= (wxColour
*) NULL
;
67 wxColour
*g_systemBtnShadowColour
= (wxColour
*) NULL
;
68 wxColour
*g_systemBtnHighlightColour
= (wxColour
*) NULL
;
69 wxColour
*g_systemHighlightColour
= (wxColour
*) NULL
;
70 wxColour
*g_systemHighlightTextColour
= (wxColour
*) NULL
;
71 wxColour
*g_systemListBoxColour
= (wxColour
*) NULL
;
73 wxFont
*g_systemFont
= (wxFont
*) NULL
;
75 void wxSystemSettings::Done()
77 // delete g_systemWinColour;
78 delete g_systemBtnFaceColour
;
79 delete g_systemBtnShadowColour
;
80 delete g_systemBtnHighlightColour
;
81 delete g_systemHighlightColour
;
82 delete g_systemHighlightTextColour
;
83 delete g_systemListBoxColour
;
87 wxColour
wxSystemSettings::GetSystemColour( int index
)
91 case wxSYS_COLOUR_SCROLLBAR
:
92 case wxSYS_COLOUR_BACKGROUND
:
93 case wxSYS_COLOUR_ACTIVECAPTION
:
94 case wxSYS_COLOUR_INACTIVECAPTION
:
95 case wxSYS_COLOUR_MENU
:
96 case wxSYS_COLOUR_WINDOWFRAME
:
97 case wxSYS_COLOUR_ACTIVEBORDER
:
98 case wxSYS_COLOUR_INACTIVEBORDER
:
99 case wxSYS_COLOUR_BTNFACE
:
100 case wxSYS_COLOUR_3DLIGHT
:
102 if (!g_systemBtnFaceColour
)
104 g_systemBtnFaceColour
=
105 new wxColour( 0xd6d6 >> SHIFT
,
109 return *g_systemBtnFaceColour
;
111 case wxSYS_COLOUR_WINDOW
:
115 case wxSYS_COLOUR_GRAYTEXT
:
116 case wxSYS_COLOUR_BTNSHADOW
:
118 if (!g_systemBtnShadowColour
)
120 g_systemBtnShadowColour
=
121 new wxColour( 0x7530 >> SHIFT
,
125 return *g_systemBtnShadowColour
;
127 case wxSYS_COLOUR_BTNHIGHLIGHT
:
129 if (!g_systemBtnHighlightColour
)
131 g_systemBtnHighlightColour
=
132 new wxColour( 0xea60 >> SHIFT
,
136 return *g_systemBtnHighlightColour
;
138 case wxSYS_COLOUR_HIGHLIGHT
:
140 if (!g_systemHighlightColour
)
142 GtkWidget
*widget
= gtk_button_new();
143 GtkStyle
*def
= gtk_rc_get_style( widget
);
145 def
= gtk_widget_get_default_style();
148 int red
= def
->bg
[GTK_STATE_SELECTED
].red
;
149 int green
= def
->bg
[GTK_STATE_SELECTED
].green
;
150 int blue
= def
->bg
[GTK_STATE_SELECTED
].blue
;
151 g_systemHighlightColour
=
152 new wxColour( red
>> SHIFT
,
158 g_systemHighlightColour
=
159 new wxColour( 0 >> SHIFT
,
163 gtk_widget_destroy( widget
);
166 return *g_systemHighlightColour
;
168 case wxSYS_COLOUR_LISTBOX
:
170 if (!g_systemListBoxColour
)
172 GtkWidget
*widget
= gtk_list_new();
173 GtkStyle
*def
= gtk_rc_get_style( widget
);
175 def
= gtk_widget_get_default_style();
178 int red
= def
->base
[GTK_STATE_NORMAL
].red
;
179 int green
= def
->base
[GTK_STATE_NORMAL
].green
;
180 int blue
= def
->base
[GTK_STATE_NORMAL
].blue
;
181 g_systemListBoxColour
=
182 new wxColour( red
>> SHIFT
,
187 g_systemListBoxColour
= new wxColour(*wxWHITE
);
188 gtk_widget_destroy( widget
);
190 return *g_systemListBoxColour
;
192 case wxSYS_COLOUR_MENUTEXT
:
193 case wxSYS_COLOUR_WINDOWTEXT
:
194 case wxSYS_COLOUR_CAPTIONTEXT
:
195 case wxSYS_COLOUR_INACTIVECAPTIONTEXT
:
196 case wxSYS_COLOUR_BTNTEXT
:
197 case wxSYS_COLOUR_INFOTEXT
:
201 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
203 if (!g_systemHighlightTextColour
)
205 wxColour hclr
= GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
);
206 if (hclr
.Red() > 200 && hclr
.Green() > 200 && hclr
.Blue() > 200)
207 g_systemHighlightTextColour
= new wxColour(*wxBLACK
);
209 g_systemHighlightTextColour
= new wxColour(*wxWHITE
);
211 return *g_systemHighlightTextColour
;
213 case wxSYS_COLOUR_INFOBK
:
214 case wxSYS_COLOUR_APPWORKSPACE
:
216 return *wxWHITE
; // ?
222 wxFont
wxSystemSettings::GetSystemFont( int index
)
226 case wxSYS_OEM_FIXED_FONT
:
227 case wxSYS_ANSI_FIXED_FONT
:
228 case wxSYS_SYSTEM_FIXED_FONT
:
230 return *wxNORMAL_FONT
;
232 case wxSYS_ANSI_VAR_FONT
:
233 case wxSYS_SYSTEM_FONT
:
234 case wxSYS_DEVICE_DEFAULT_FONT
:
235 case wxSYS_DEFAULT_GUI_FONT
:
240 GdkFont
*gdk_font
= GtkGetDefaultGuiFont();
243 GSList
*font_list
= ((GdkFontPrivate
*)gdk_font
)->names
;
244 char *name
= (char*)font_list
->data
;
245 wxString
font_string( name
);
246 wxFontData font_data
;
247 g_systemFont
= new wxFont( font_string
, font_data
);
249 gtk_widget_destroy( widget
);
252 g_systemFont
= new wxFont( 12, wxSWISS
, wxNORMAL
, wxNORMAL
);
255 return *g_systemFont
;
262 int wxSystemSettings::GetSystemMetric( int index
)
266 case wxSYS_SCREEN_X
: return gdk_screen_width();
267 case wxSYS_SCREEN_Y
: return gdk_screen_height();
268 case wxSYS_HSCROLL_Y
: return 15;
269 case wxSYS_VSCROLL_X
: return 15;
272 wxCHECK_MSG( index
, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );