]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/settings.cpp
Committing in .
[wxWidgets.git] / src / gtk1 / settings.cpp
CommitLineData
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
f6bcfd97
BP
24extern GdkFont *GtkGetDefaultGuiFont();
25
d06b34a7 26
c801d85f
KB
27/*
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
49
50#define wxSYS_COLOUR_3DDKSHADOW 21
51#define wxSYS_COLOUR_3DLIGHT 22
52#define wxSYS_COLOUR_INFOTEXT 23
53#define wxSYS_COLOUR_INFOBK 24
54
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
61*/
62
63#define SHIFT (8*(sizeof(short int)-sizeof(char)))
64
94129723 65//wxColour *g_systemWinColour = (wxColour *) NULL;
74f55195
VS
66wxColour *g_systemBtnFaceColour = (wxColour *) NULL;
67wxColour *g_systemBtnShadowColour = (wxColour *) NULL;
68wxColour *g_systemBtnHighlightColour = (wxColour *) NULL;
69wxColour *g_systemHighlightColour = (wxColour *) NULL;
70wxColour *g_systemHighlightTextColour = (wxColour *) NULL;
71wxColour *g_systemListBoxColour = (wxColour *) NULL;
c801d85f 72
c67daf87 73wxFont *g_systemFont = (wxFont *) NULL;
a3622daa 74
1ecc4d80
RR
75void wxSystemSettings::Done()
76{
94129723 77// delete g_systemWinColour;
72a16063
RR
78 delete g_systemBtnFaceColour;
79 delete g_systemBtnShadowColour;
80 delete g_systemBtnHighlightColour;
81 delete g_systemHighlightColour;
74f55195
VS
82 delete g_systemHighlightTextColour;
83 delete g_systemListBoxColour;
72a16063 84 delete g_systemFont;
a3622daa
VZ
85}
86
c801d85f
KB
87wxColour wxSystemSettings::GetSystemColour( int index )
88{
db434467 89 switch (index)
c801d85f 90 {
db434467
RR
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 {
101 if (!g_systemBtnFaceColour)
102 {
103 g_systemBtnFaceColour =
104 new wxColour( 0xd6d6 >> SHIFT,
105 0xd6d6 >> SHIFT,
106 0xd6d6 >> SHIFT );
107 }
108 return *g_systemBtnFaceColour;
109 }
110 case wxSYS_COLOUR_WINDOW:
111 {
112 return *wxWHITE;
113 }
114 case wxSYS_COLOUR_GRAYTEXT:
115 case wxSYS_COLOUR_BTNSHADOW:
116 {
117 if (!g_systemBtnShadowColour)
118 {
119 g_systemBtnShadowColour =
120 new wxColour( 0x7530 >> SHIFT,
121 0x7530 >> SHIFT,
122 0x7530 >> SHIFT );
123 }
124 return *g_systemBtnShadowColour;
125 }
126 case wxSYS_COLOUR_BTNHIGHLIGHT:
127 {
128 if (!g_systemBtnHighlightColour)
129 {
130 g_systemBtnHighlightColour =
131 new wxColour( 0xea60 >> SHIFT,
132 0xea60 >> SHIFT,
133 0xea60 >> SHIFT );
134 }
135 return *g_systemBtnHighlightColour;
136 }
137 case wxSYS_COLOUR_HIGHLIGHT:
138 {
139 if (!g_systemHighlightColour)
140 {
db434467
RR
141 GtkWidget *widget = gtk_button_new();
142 GtkStyle *def = gtk_rc_get_style( widget );
e6527f9d
RR
143 if (!def)
144 def = gtk_widget_get_default_style();
145 if (def)
146 {
147 int red = def->bg[GTK_STATE_SELECTED].red;
148 int green = def->bg[GTK_STATE_SELECTED].green;
149 int blue = def->bg[GTK_STATE_SELECTED].blue;
150 g_systemHighlightColour =
151 new wxColour( red >> SHIFT,
152 green >> SHIFT,
153 blue >> SHIFT );
154 }
155 else
156 {
157 g_systemHighlightColour =
158 new wxColour( 0 >> SHIFT,
159 0 >> SHIFT,
160 0x9c40 >> SHIFT );
161 }
db434467
RR
162 gtk_widget_destroy( widget );
163
db434467
RR
164 }
165 return *g_systemHighlightColour;
166 }
74f55195
VS
167 case wxSYS_COLOUR_LISTBOX:
168 {
169 if (!g_systemListBoxColour)
170 {
171 GtkWidget *widget = gtk_list_new();
172 GtkStyle *def = gtk_rc_get_style( widget );
410207c3 173 if (!def)
74f55195
VS
174 def = gtk_widget_get_default_style();
175 if (def)
176 {
410207c3
VS
177 int red = def->base[GTK_STATE_NORMAL].red;
178 int green = def->base[GTK_STATE_NORMAL].green;
179 int blue = def->base[GTK_STATE_NORMAL].blue;
74f55195
VS
180 g_systemListBoxColour =
181 new wxColour( red >> SHIFT,
182 green >> SHIFT,
183 blue >> SHIFT );
184 }
185 else
186 g_systemListBoxColour = new wxColour(*wxWHITE);
187 gtk_widget_destroy( widget );
74f55195
VS
188 }
189 return *g_systemListBoxColour;
190 }
c801d85f
KB
191 case wxSYS_COLOUR_MENUTEXT:
192 case wxSYS_COLOUR_WINDOWTEXT:
193 case wxSYS_COLOUR_CAPTIONTEXT:
194 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
cb0f2f54 195 case wxSYS_COLOUR_BTNTEXT:
c801d85f
KB
196 case wxSYS_COLOUR_INFOTEXT:
197 {
198 return *wxBLACK;
ff7b1510 199 }
c801d85f
KB
200 case wxSYS_COLOUR_HIGHLIGHTTEXT:
201 {
74f55195
VS
202 if (!g_systemHighlightTextColour)
203 {
204 wxColour hclr = GetSystemColour(wxSYS_COLOUR_HIGHLIGHT);
205 if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200)
206 g_systemHighlightTextColour = new wxColour(*wxBLACK);
207 else
208 g_systemHighlightTextColour = new wxColour(*wxWHITE);
209 }
210 return *g_systemHighlightTextColour;
ff7b1510 211 }
c801d85f
KB
212 case wxSYS_COLOUR_INFOBK:
213 case wxSYS_COLOUR_APPWORKSPACE:
214 {
215 return *wxWHITE; // ?
ff7b1510
RR
216 }
217 }
c801d85f 218 return *wxWHITE;
ff7b1510 219}
c801d85f 220
c801d85f
KB
221wxFont wxSystemSettings::GetSystemFont( int index )
222{
2d17d68f 223 switch (index)
c801d85f 224 {
2d17d68f
RR
225 case wxSYS_OEM_FIXED_FONT:
226 case wxSYS_ANSI_FIXED_FONT:
227 case wxSYS_SYSTEM_FIXED_FONT:
228 {
229 return *wxNORMAL_FONT;
230 }
231 case wxSYS_ANSI_VAR_FONT:
232 case wxSYS_SYSTEM_FONT:
233 case wxSYS_DEVICE_DEFAULT_FONT:
234 case wxSYS_DEFAULT_GUI_FONT:
235 {
236 if (!g_systemFont)
d06b34a7 237 {
d06b34a7 238#if 0
f6bcfd97 239 GdkFont *gdk_font = GtkGetDefaultGuiFont();
d06b34a7
RR
240 if (gdk_font)
241 {
242 GSList *font_list = ((GdkFontPrivate*)gdk_font)->names;
243 char *name = (char*)font_list->data;
244 wxString font_string( name );
245 wxFontData font_data;
246 g_systemFont = new wxFont( font_string, font_data );
247 }
d06b34a7 248 gtk_widget_destroy( widget );
f6bcfd97
BP
249#endif
250
251 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
252
d06b34a7 253 }
2d17d68f
RR
254 return *g_systemFont;
255 }
ff7b1510 256 }
c801d85f 257
2d17d68f 258 return wxNullFont;
c801d85f 259}
c801d85f
KB
260
261int wxSystemSettings::GetSystemMetric( int index )
262{
1ecc4d80
RR
263 switch (index)
264 {
265 case wxSYS_SCREEN_X: return gdk_screen_width();
266 case wxSYS_SCREEN_Y: return gdk_screen_height();
267 case wxSYS_HSCROLL_Y: return 15;
268 case wxSYS_VSCROLL_X: return 15;
269 }
270
223d09f6 271 wxCHECK_MSG( index, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );
1ecc4d80
RR
272
273 return 0;
c67daf87 274}