]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/settings.cpp
Small oops in redrawing code.
[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 );
410207c3 167 if (!def)
74f55195
VS
168 def = gtk_widget_get_default_style();
169 if (def)
170 {
410207c3
VS
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;
74f55195
VS
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 );
74f55195
VS
182 }
183 return *g_systemListBoxColour;
184 }
c801d85f
KB
185 case wxSYS_COLOUR_MENUTEXT:
186 case wxSYS_COLOUR_WINDOWTEXT:
187 case wxSYS_COLOUR_CAPTIONTEXT:
188 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
cb0f2f54 189 case wxSYS_COLOUR_BTNTEXT:
c801d85f
KB
190 case wxSYS_COLOUR_INFOTEXT:
191 {
192 return *wxBLACK;
ff7b1510 193 }
c801d85f
KB
194 case wxSYS_COLOUR_HIGHLIGHTTEXT:
195 {
74f55195
VS
196 if (!g_systemHighlightTextColour)
197 {
198 wxColour hclr = GetSystemColour(wxSYS_COLOUR_HIGHLIGHT);
199 if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200)
200 g_systemHighlightTextColour = new wxColour(*wxBLACK);
201 else
202 g_systemHighlightTextColour = new wxColour(*wxWHITE);
203 }
204 return *g_systemHighlightTextColour;
ff7b1510 205 }
c801d85f
KB
206 case wxSYS_COLOUR_INFOBK:
207 case wxSYS_COLOUR_APPWORKSPACE:
208 {
209 return *wxWHITE; // ?
ff7b1510
RR
210 }
211 }
c801d85f 212 return *wxWHITE;
ff7b1510 213}
c801d85f 214
c801d85f
KB
215wxFont wxSystemSettings::GetSystemFont( int index )
216{
2d17d68f 217 switch (index)
c801d85f 218 {
2d17d68f
RR
219 case wxSYS_OEM_FIXED_FONT:
220 case wxSYS_ANSI_FIXED_FONT:
221 case wxSYS_SYSTEM_FIXED_FONT:
222 {
223 return *wxNORMAL_FONT;
224 }
225 case wxSYS_ANSI_VAR_FONT:
226 case wxSYS_SYSTEM_FONT:
227 case wxSYS_DEVICE_DEFAULT_FONT:
228 case wxSYS_DEFAULT_GUI_FONT:
229 {
230 if (!g_systemFont)
c7985368 231 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
2d17d68f
RR
232 return *g_systemFont;
233 }
ff7b1510 234 }
c801d85f 235
2d17d68f 236 return wxNullFont;
c801d85f 237}
c801d85f
KB
238
239int wxSystemSettings::GetSystemMetric( int index )
240{
1ecc4d80
RR
241 switch (index)
242 {
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;
247 }
248
223d09f6 249 wxCHECK_MSG( index, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );
1ecc4d80
RR
250
251 return 0;
c67daf87 252}