]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/settings.cpp
Added OLE automation sample, changed BC++ makefiles
[wxWidgets.git] / src / gtk1 / 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
17 /*
18 #define wxSYS_COLOUR_SCROLLBAR 0
19 #define wxSYS_COLOUR_BACKGROUND 1
20 #define wxSYS_COLOUR_ACTIVECAPTION 2
21 #define wxSYS_COLOUR_INACTIVECAPTION 3
22 #define wxSYS_COLOUR_MENU 4
23 #define wxSYS_COLOUR_WINDOW 5
24 #define wxSYS_COLOUR_WINDOWFRAME 6
25 #define wxSYS_COLOUR_MENUTEXT 7
26 #define wxSYS_COLOUR_WINDOWTEXT 8
27 #define wxSYS_COLOUR_CAPTIONTEXT 9
28 #define wxSYS_COLOUR_ACTIVEBORDER 10
29 #define wxSYS_COLOUR_INACTIVEBORDER 11
30 #define wxSYS_COLOUR_APPWORKSPACE 12
31 #define wxSYS_COLOUR_HIGHLIGHT 13
32 #define wxSYS_COLOUR_HIGHLIGHTTEXT 14
33 #define wxSYS_COLOUR_BTNFACE 15
34 #define wxSYS_COLOUR_BTNSHADOW 16
35 #define wxSYS_COLOUR_GRAYTEXT 17
36 #define wxSYS_COLOUR_BTNTEXT 18
37 #define wxSYS_COLOUR_INACTIVECAPTIONTEXT 19
38 #define wxSYS_COLOUR_BTNHIGHLIGHT 20
39
40 #define wxSYS_COLOUR_3DDKSHADOW 21
41 #define wxSYS_COLOUR_3DLIGHT 22
42 #define wxSYS_COLOUR_INFOTEXT 23
43 #define wxSYS_COLOUR_INFOBK 24
44
45 #define wxSYS_COLOUR_DESKTOP wxSYS_COLOUR_BACKGROUND
46 #define wxSYS_COLOUR_3DFACE wxSYS_COLOUR_BTNFACE
47 #define wxSYS_COLOUR_3DSHADOW wxSYS_COLOUR_BTNSHADOW
48 #define wxSYS_COLOUR_3DHIGHLIGHT wxSYS_COLOUR_BTNHIGHLIGHT
49 #define wxSYS_COLOUR_3DHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
50 #define wxSYS_COLOUR_BTNHILIGHT wxSYS_COLOUR_BTNHIGHLIGHT
51 */
52
53 #define SHIFT (8*(sizeof(short int)-sizeof(char)))
54
55 wxColour *g_systemBtnFaceColour = (wxColour *) NULL;
56 wxColour *g_systemBtnShadowColour = (wxColour *) NULL;
57 wxColour *g_systemBtnHighlightColour = (wxColour *) NULL;
58 wxColour *g_systemHighlightColour = (wxColour *) NULL;
59
60 wxFont *g_systemFont = (wxFont *) NULL;
61
62 void wxSystemSettings::Done() {
63 wxDELETE(g_systemBtnFaceColour);
64 wxDELETE(g_systemBtnShadowColour);
65 wxDELETE(g_systemBtnHighlightColour);
66 wxDELETE(g_systemHighlightColour);
67 wxDELETE(g_systemFont);
68 }
69
70 wxColour wxSystemSettings::GetSystemColour( int index )
71 {
72 switch (index)
73 {
74 case wxSYS_COLOUR_SCROLLBAR:
75 case wxSYS_COLOUR_BACKGROUND:
76 case wxSYS_COLOUR_ACTIVECAPTION:
77 case wxSYS_COLOUR_INACTIVECAPTION:
78 case wxSYS_COLOUR_MENU:
79 case wxSYS_COLOUR_WINDOW:
80 case wxSYS_COLOUR_WINDOWFRAME:
81 case wxSYS_COLOUR_ACTIVEBORDER:
82 case wxSYS_COLOUR_INACTIVEBORDER:
83 case wxSYS_COLOUR_BTNFACE:
84 {
85 GtkStyle *style = gtk_widget_get_default_style();
86 if (!g_systemBtnFaceColour)
87 {
88 g_systemBtnFaceColour =
89 new wxColour( style->bg[0].red >> SHIFT,
90 style->bg[0].green >> SHIFT,
91 style->bg[0].blue >> SHIFT );
92 }
93 return *g_systemBtnFaceColour;
94 }
95 case wxSYS_COLOUR_BTNSHADOW:
96 {
97 GtkStyle *style = gtk_widget_get_default_style();
98 if (!g_systemBtnShadowColour)
99 {
100 g_systemBtnShadowColour =
101 new wxColour( style->dark[0].red >> SHIFT,
102 style->dark[0].green >> SHIFT,
103 style->dark[0].blue >> SHIFT );
104 }
105 return *g_systemBtnShadowColour;
106 }
107 case wxSYS_COLOUR_GRAYTEXT:
108 case wxSYS_COLOUR_BTNHIGHLIGHT:
109 {
110 GtkStyle *style = gtk_widget_get_default_style();
111 if (!g_systemBtnHighlightColour)
112 {
113 g_systemBtnHighlightColour =
114 new wxColour( style->light[0].red >> SHIFT,
115 style->light[0].green >> SHIFT,
116 style->light[0].blue >> SHIFT );
117 }
118 return *g_systemBtnHighlightColour;
119 }
120 case wxSYS_COLOUR_HIGHLIGHT:
121 {
122 GtkStyle *style = gtk_widget_get_default_style();
123 if (!g_systemHighlightColour)
124 {
125 g_systemHighlightColour =
126 new wxColour( style->bg[GTK_STATE_SELECTED].red >> SHIFT,
127 style->bg[GTK_STATE_SELECTED].green >> SHIFT,
128 style->bg[GTK_STATE_SELECTED].blue >> SHIFT );
129 }
130 return *g_systemHighlightColour;
131 }
132 case wxSYS_COLOUR_MENUTEXT:
133 case wxSYS_COLOUR_WINDOWTEXT:
134 case wxSYS_COLOUR_CAPTIONTEXT:
135 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
136 case wxSYS_COLOUR_INFOTEXT:
137 {
138 return *wxBLACK;
139 }
140 case wxSYS_COLOUR_HIGHLIGHTTEXT:
141 {
142 return *wxWHITE;
143 }
144 case wxSYS_COLOUR_INFOBK:
145 case wxSYS_COLOUR_APPWORKSPACE:
146 {
147 return *wxWHITE; // ?
148 }
149 }
150 return *wxWHITE;
151 }
152
153 wxFont wxSystemSettings::GetSystemFont( int index )
154 {
155 switch (index)
156 {
157 case wxSYS_OEM_FIXED_FONT:
158 case wxSYS_ANSI_FIXED_FONT:
159 case wxSYS_SYSTEM_FIXED_FONT:
160 {
161 return *wxNORMAL_FONT;
162 }
163 case wxSYS_ANSI_VAR_FONT:
164 case wxSYS_SYSTEM_FONT:
165 case wxSYS_DEVICE_DEFAULT_FONT:
166 case wxSYS_DEFAULT_GUI_FONT:
167 {
168 if (!g_systemFont)
169 g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL );
170 return *g_systemFont;
171 }
172 }
173
174 return wxNullFont;
175 }
176
177 int wxSystemSettings::GetSystemMetric( int index )
178 {
179 switch (index)
180 {
181 case wxSYS_SCREEN_X:
182 return gdk_screen_width();
183 case wxSYS_SCREEN_Y:
184 return gdk_screen_height();
185 }
186 return 0;
187 }