]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/settings.cpp
Various VC++ 1.5 and other corrections
[wxWidgets.git] / src / gtk / 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
aed8ac3f
RR
18#include <gdk/gdk.h>
19#include <gtk/gtk.h>
83624f79 20
c801d85f
KB
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
94129723 59//wxColour *g_systemWinColour = (wxColour *) NULL;
74f55195
VS
60wxColour *g_systemBtnFaceColour = (wxColour *) NULL;
61wxColour *g_systemBtnShadowColour = (wxColour *) NULL;
62wxColour *g_systemBtnHighlightColour = (wxColour *) NULL;
63wxColour *g_systemHighlightColour = (wxColour *) NULL;
64wxColour *g_systemHighlightTextColour = (wxColour *) NULL;
65wxColour *g_systemListBoxColour = (wxColour *) NULL;
c801d85f 66
c67daf87 67wxFont *g_systemFont = (wxFont *) NULL;
a3622daa 68
1ecc4d80
RR
69void wxSystemSettings::Done()
70{
94129723 71// delete g_systemWinColour;
72a16063
RR
72 delete g_systemBtnFaceColour;
73 delete g_systemBtnShadowColour;
74 delete g_systemBtnHighlightColour;
75 delete g_systemHighlightColour;
74f55195
VS
76 delete g_systemHighlightTextColour;
77 delete g_systemListBoxColour;
72a16063 78 delete g_systemFont;
a3622daa
VZ
79}
80
c801d85f
KB
81wxColour wxSystemSettings::GetSystemColour( int index )
82{
db434467 83 switch (index)
c801d85f 84 {
db434467
RR
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 {
db434467
RR
135 GtkWidget *widget = gtk_button_new();
136 GtkStyle *def = gtk_rc_get_style( widget );
e6527f9d
RR
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 }
db434467
RR
156 gtk_widget_destroy( widget );
157
db434467
RR
158 }
159 return *g_systemHighlightColour;
160 }
74f55195
VS
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->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,
176 green >> SHIFT,
177 blue >> SHIFT );
178 }
179 else
180 g_systemListBoxColour = new wxColour(*wxWHITE);
181 gtk_widget_destroy( widget );
182
183 }
184 return *g_systemListBoxColour;
185 }
c801d85f
KB
186 case wxSYS_COLOUR_MENUTEXT:
187 case wxSYS_COLOUR_WINDOWTEXT:
188 case wxSYS_COLOUR_CAPTIONTEXT:
189 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
cb0f2f54 190 case wxSYS_COLOUR_BTNTEXT:
c801d85f
KB
191 case wxSYS_COLOUR_INFOTEXT:
192 {
193 return *wxBLACK;
ff7b1510 194 }
c801d85f
KB
195 case wxSYS_COLOUR_HIGHLIGHTTEXT:
196 {
74f55195
VS
197 if (!g_systemHighlightTextColour)
198 {
199 wxColour hclr = GetSystemColour(wxSYS_COLOUR_HIGHLIGHT);
200 if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200)
201 g_systemHighlightTextColour = new wxColour(*wxBLACK);
202 else
203 g_systemHighlightTextColour = new wxColour(*wxWHITE);
204 }
205 return *g_systemHighlightTextColour;
ff7b1510 206 }
c801d85f
KB
207 case wxSYS_COLOUR_INFOBK:
208 case wxSYS_COLOUR_APPWORKSPACE:
209 {
210 return *wxWHITE; // ?
ff7b1510
RR
211 }
212 }
c801d85f 213 return *wxWHITE;
ff7b1510 214}
c801d85f 215
c801d85f
KB
216wxFont wxSystemSettings::GetSystemFont( int index )
217{
2d17d68f 218 switch (index)
c801d85f 219 {
2d17d68f
RR
220 case wxSYS_OEM_FIXED_FONT:
221 case wxSYS_ANSI_FIXED_FONT:
222 case wxSYS_SYSTEM_FIXED_FONT:
223 {
224 return *wxNORMAL_FONT;
225 }
226 case wxSYS_ANSI_VAR_FONT:
227 case wxSYS_SYSTEM_FONT:
228 case wxSYS_DEVICE_DEFAULT_FONT:
229 case wxSYS_DEFAULT_GUI_FONT:
230 {
231 if (!g_systemFont)
c7985368 232 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
2d17d68f
RR
233 return *g_systemFont;
234 }
ff7b1510 235 }
c801d85f 236
2d17d68f 237 return wxNullFont;
c801d85f 238}
c801d85f
KB
239
240int wxSystemSettings::GetSystemMetric( int index )
241{
1ecc4d80
RR
242 switch (index)
243 {
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;
248 }
249
223d09f6 250 wxCHECK_MSG( index, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );
1ecc4d80
RR
251
252 return 0;
c67daf87 253}