]>
Commit | Line | Data |
---|---|---|
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 | |
83624f79 RR |
18 | #include "gdk/gdk.h" |
19 | #include "gtk/gtk.h" | |
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 | ||
c67daf87 UR |
59 | wxColour *g_systemBtnFaceColour = (wxColour *) NULL; |
60 | wxColour *g_systemBtnShadowColour = (wxColour *) NULL; | |
61 | wxColour *g_systemBtnHighlightColour = (wxColour *) NULL; | |
62 | wxColour *g_systemHighlightColour = (wxColour *) NULL; | |
c801d85f | 63 | |
c67daf87 | 64 | wxFont *g_systemFont = (wxFont *) NULL; |
a3622daa | 65 | |
1ecc4d80 RR |
66 | void wxSystemSettings::Done() |
67 | { | |
68 | wxDELETE(g_systemBtnFaceColour); | |
69 | wxDELETE(g_systemBtnShadowColour); | |
70 | wxDELETE(g_systemBtnHighlightColour); | |
71 | wxDELETE(g_systemHighlightColour); | |
72 | wxDELETE(g_systemFont); | |
a3622daa VZ |
73 | } |
74 | ||
c801d85f KB |
75 | wxColour wxSystemSettings::GetSystemColour( int index ) |
76 | { | |
77 | switch (index) | |
78 | { | |
79 | case wxSYS_COLOUR_SCROLLBAR: | |
80 | case wxSYS_COLOUR_BACKGROUND: | |
81 | case wxSYS_COLOUR_ACTIVECAPTION: | |
82 | case wxSYS_COLOUR_INACTIVECAPTION: | |
83 | case wxSYS_COLOUR_MENU: | |
84 | case wxSYS_COLOUR_WINDOW: | |
85 | case wxSYS_COLOUR_WINDOWFRAME: | |
86 | case wxSYS_COLOUR_ACTIVEBORDER: | |
87 | case wxSYS_COLOUR_INACTIVEBORDER: | |
88 | case wxSYS_COLOUR_BTNFACE: | |
89 | { | |
90 | GtkStyle *style = gtk_widget_get_default_style(); | |
91 | if (!g_systemBtnFaceColour) | |
92 | { | |
93 | g_systemBtnFaceColour = | |
94 | new wxColour( style->bg[0].red >> SHIFT, | |
95 | style->bg[0].green >> SHIFT, | |
96 | style->bg[0].blue >> SHIFT ); | |
ff7b1510 | 97 | } |
c801d85f | 98 | return *g_systemBtnFaceColour; |
ff7b1510 | 99 | } |
c801d85f KB |
100 | case wxSYS_COLOUR_BTNSHADOW: |
101 | { | |
102 | GtkStyle *style = gtk_widget_get_default_style(); | |
103 | if (!g_systemBtnShadowColour) | |
104 | { | |
105 | g_systemBtnShadowColour = | |
106 | new wxColour( style->dark[0].red >> SHIFT, | |
107 | style->dark[0].green >> SHIFT, | |
108 | style->dark[0].blue >> SHIFT ); | |
ff7b1510 | 109 | } |
c801d85f | 110 | return *g_systemBtnShadowColour; |
ff7b1510 | 111 | } |
c801d85f KB |
112 | case wxSYS_COLOUR_GRAYTEXT: |
113 | case wxSYS_COLOUR_BTNHIGHLIGHT: | |
114 | { | |
115 | GtkStyle *style = gtk_widget_get_default_style(); | |
116 | if (!g_systemBtnHighlightColour) | |
117 | { | |
118 | g_systemBtnHighlightColour = | |
119 | new wxColour( style->light[0].red >> SHIFT, | |
120 | style->light[0].green >> SHIFT, | |
121 | style->light[0].blue >> SHIFT ); | |
ff7b1510 | 122 | } |
c801d85f | 123 | return *g_systemBtnHighlightColour; |
ff7b1510 | 124 | } |
c801d85f KB |
125 | case wxSYS_COLOUR_HIGHLIGHT: |
126 | { | |
127 | GtkStyle *style = gtk_widget_get_default_style(); | |
128 | if (!g_systemHighlightColour) | |
129 | { | |
130 | g_systemHighlightColour = | |
131 | new wxColour( style->bg[GTK_STATE_SELECTED].red >> SHIFT, | |
132 | style->bg[GTK_STATE_SELECTED].green >> SHIFT, | |
133 | style->bg[GTK_STATE_SELECTED].blue >> SHIFT ); | |
ff7b1510 | 134 | } |
c801d85f | 135 | return *g_systemHighlightColour; |
ff7b1510 | 136 | } |
c801d85f KB |
137 | case wxSYS_COLOUR_MENUTEXT: |
138 | case wxSYS_COLOUR_WINDOWTEXT: | |
139 | case wxSYS_COLOUR_CAPTIONTEXT: | |
140 | case wxSYS_COLOUR_INACTIVECAPTIONTEXT: | |
141 | case wxSYS_COLOUR_INFOTEXT: | |
142 | { | |
143 | return *wxBLACK; | |
ff7b1510 | 144 | } |
c801d85f KB |
145 | case wxSYS_COLOUR_HIGHLIGHTTEXT: |
146 | { | |
147 | return *wxWHITE; | |
ff7b1510 | 148 | } |
c801d85f KB |
149 | case wxSYS_COLOUR_INFOBK: |
150 | case wxSYS_COLOUR_APPWORKSPACE: | |
151 | { | |
152 | return *wxWHITE; // ? | |
ff7b1510 RR |
153 | } |
154 | } | |
c801d85f | 155 | return *wxWHITE; |
ff7b1510 | 156 | } |
c801d85f | 157 | |
c801d85f KB |
158 | wxFont wxSystemSettings::GetSystemFont( int index ) |
159 | { | |
2d17d68f | 160 | switch (index) |
c801d85f | 161 | { |
2d17d68f RR |
162 | case wxSYS_OEM_FIXED_FONT: |
163 | case wxSYS_ANSI_FIXED_FONT: | |
164 | case wxSYS_SYSTEM_FIXED_FONT: | |
165 | { | |
166 | return *wxNORMAL_FONT; | |
167 | } | |
168 | case wxSYS_ANSI_VAR_FONT: | |
169 | case wxSYS_SYSTEM_FONT: | |
170 | case wxSYS_DEVICE_DEFAULT_FONT: | |
171 | case wxSYS_DEFAULT_GUI_FONT: | |
172 | { | |
173 | if (!g_systemFont) | |
174 | g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); | |
175 | return *g_systemFont; | |
176 | } | |
ff7b1510 | 177 | } |
c801d85f | 178 | |
2d17d68f | 179 | return wxNullFont; |
c801d85f | 180 | } |
c801d85f KB |
181 | |
182 | int wxSystemSettings::GetSystemMetric( int index ) | |
183 | { | |
1ecc4d80 RR |
184 | switch (index) |
185 | { | |
186 | case wxSYS_SCREEN_X: return gdk_screen_width(); | |
187 | case wxSYS_SCREEN_Y: return gdk_screen_height(); | |
188 | case wxSYS_HSCROLL_Y: return 15; | |
189 | case wxSYS_VSCROLL_X: return 15; | |
190 | } | |
191 | ||
192 | wxCHECK_MSG( index, 0, "wxSystemSettings::GetSystemMetric not fully implemented" ); | |
193 | ||
194 | return 0; | |
c67daf87 | 195 | } |