]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/settings.cpp
Fixed wxListCtrl::GetNextItem()
[wxWidgets.git] / src / gtk / settings.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: settings.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifdef __GNUG__
12 #pragma implementation "settings.h"
13 #endif
14
15 #include "wx/settings.h"
16 #include "wx/debug.h"
17
18 #include <gdk/gdk.h>
19 #include <gtk/gtk.h>
20
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
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
65 wxFont *g_systemFont = (wxFont *) NULL;
66
67 void wxSystemSettings::Done()
68 {
69 // delete g_systemWinColour;
70 delete g_systemBtnFaceColour;
71 delete g_systemBtnShadowColour;
72 delete g_systemBtnHighlightColour;
73 delete g_systemHighlightColour;
74 delete g_systemFont;
75 }
76
77 wxColour wxSystemSettings::GetSystemColour( int index )
78 {
79 switch (index)
80 {
81 case wxSYS_COLOUR_SCROLLBAR:
82 case wxSYS_COLOUR_BACKGROUND:
83 case wxSYS_COLOUR_ACTIVECAPTION:
84 case wxSYS_COLOUR_INACTIVECAPTION:
85 case wxSYS_COLOUR_MENU:
86 case wxSYS_COLOUR_WINDOWFRAME:
87 case wxSYS_COLOUR_ACTIVEBORDER:
88 case wxSYS_COLOUR_INACTIVEBORDER:
89 case wxSYS_COLOUR_BTNFACE:
90 {
91 if (!g_systemBtnFaceColour)
92 {
93 g_systemBtnFaceColour =
94 new wxColour( 0xd6d6 >> SHIFT,
95 0xd6d6 >> SHIFT,
96 0xd6d6 >> SHIFT );
97 }
98 return *g_systemBtnFaceColour;
99 }
100 case wxSYS_COLOUR_WINDOW:
101 {
102 return *wxWHITE;
103 }
104 case wxSYS_COLOUR_GRAYTEXT:
105 case wxSYS_COLOUR_BTNSHADOW:
106 {
107 if (!g_systemBtnShadowColour)
108 {
109 g_systemBtnShadowColour =
110 new wxColour( 0x7530 >> SHIFT,
111 0x7530 >> SHIFT,
112 0x7530 >> SHIFT );
113 }
114 return *g_systemBtnShadowColour;
115 }
116 case wxSYS_COLOUR_BTNHIGHLIGHT:
117 {
118 if (!g_systemBtnHighlightColour)
119 {
120 g_systemBtnHighlightColour =
121 new wxColour( 0xea60 >> SHIFT,
122 0xea60 >> SHIFT,
123 0xea60 >> SHIFT );
124 }
125 return *g_systemBtnHighlightColour;
126 }
127 case wxSYS_COLOUR_HIGHLIGHT:
128 {
129 if (!g_systemHighlightColour)
130 {
131 GtkWidget *widget = gtk_button_new();
132 GtkStyle *def = gtk_rc_get_style( widget );
133 if (!def)
134 def = gtk_widget_get_default_style();
135 if (def)
136 {
137 int red = def->bg[GTK_STATE_SELECTED].red;
138 int green = def->bg[GTK_STATE_SELECTED].green;
139 int blue = def->bg[GTK_STATE_SELECTED].blue;
140 g_systemHighlightColour =
141 new wxColour( red >> SHIFT,
142 green >> SHIFT,
143 blue >> SHIFT );
144 }
145 else
146 {
147 g_systemHighlightColour =
148 new wxColour( 0 >> SHIFT,
149 0 >> SHIFT,
150 0x9c40 >> SHIFT );
151 }
152 gtk_widget_destroy( widget );
153
154 }
155 return *g_systemHighlightColour;
156 }
157 case wxSYS_COLOUR_MENUTEXT:
158 case wxSYS_COLOUR_WINDOWTEXT:
159 case wxSYS_COLOUR_CAPTIONTEXT:
160 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
161 case wxSYS_COLOUR_BTNTEXT:
162 case wxSYS_COLOUR_INFOTEXT:
163 {
164 return *wxBLACK;
165 }
166 case wxSYS_COLOUR_HIGHLIGHTTEXT:
167 {
168 return *wxWHITE;
169 }
170 case wxSYS_COLOUR_INFOBK:
171 case wxSYS_COLOUR_APPWORKSPACE:
172 {
173 return *wxWHITE; // ?
174 }
175 }
176 return *wxWHITE;
177 }
178
179 wxFont wxSystemSettings::GetSystemFont( int index )
180 {
181 switch (index)
182 {
183 case wxSYS_OEM_FIXED_FONT:
184 case wxSYS_ANSI_FIXED_FONT:
185 case wxSYS_SYSTEM_FIXED_FONT:
186 {
187 return *wxNORMAL_FONT;
188 }
189 case wxSYS_ANSI_VAR_FONT:
190 case wxSYS_SYSTEM_FONT:
191 case wxSYS_DEVICE_DEFAULT_FONT:
192 case wxSYS_DEFAULT_GUI_FONT:
193 {
194 if (!g_systemFont)
195 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
196 return *g_systemFont;
197 }
198 }
199
200 return wxNullFont;
201 }
202
203 int wxSystemSettings::GetSystemMetric( int index )
204 {
205 switch (index)
206 {
207 case wxSYS_SCREEN_X: return gdk_screen_width();
208 case wxSYS_SCREEN_Y: return gdk_screen_height();
209 case wxSYS_HSCROLL_Y: return 15;
210 case wxSYS_VSCROLL_X: return 15;
211 }
212
213 wxCHECK_MSG( index, 0, wxT("wxSystemSettings::GetSystemMetric not fully implemented") );
214
215 return 0;
216 }