]> git.saurik.com Git - wxWidgets.git/blob - src/motif/settings.cpp
removed #errors in 2.7 compilation
[wxWidgets.git] / src / motif / settings.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: motif/settings.cpp
3 // Purpose: wxSettings
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // TODO: these settings should probably be configurable from some central or
13 // per-user file, which can be edited using a Windows-control-panel clone.
14 // Also they should be documented better. Some are very MS Windows-ish.
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #include "wx/settings.h"
20 #include "wx/gdicmn.h"
21 #include "wx/app.h"
22
23 #ifdef __VMS__
24 #pragma message disable nosimpint
25 #endif
26 #include <Xm/Xm.h>
27 #include <Xm/PushB.h>
28 #ifdef __VMS__
29 #pragma message enable nosimpint
30 #endif
31
32 #include "wx/x11/privx.h"
33
34 // To correctly read the resources from the database, we create a
35 // sample widget. This has the application shell as the parent and
36 // so will be destroyed when the applicaion is closed.
37 static Widget but_setting_wid = NULL;
38
39 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
40 {
41 if (NULL == but_setting_wid && wxTheApp && wxTheApp->GetTopLevelWidget())
42 {
43 but_setting_wid = XtVaCreateWidget("settings_button", xmPushButtonWidgetClass,
44 (Widget)wxTheApp->GetTopLevelWidget(), NULL);
45 }
46
47 switch (index)
48 {
49 case wxSYS_COLOUR_WINDOW:
50 {
51 return *wxWHITE;
52 }
53 case wxSYS_COLOUR_SCROLLBAR:
54 // case wxSYS_COLOUR_DESKTOP: // Same as wxSYS_COLOUR_BACKGROUND
55 case wxSYS_COLOUR_BACKGROUND:
56 case wxSYS_COLOUR_ACTIVECAPTION:
57 case wxSYS_COLOUR_INACTIVECAPTION:
58 case wxSYS_COLOUR_MENU:
59 case wxSYS_COLOUR_MENUBAR:
60 case wxSYS_COLOUR_WINDOWFRAME:
61 case wxSYS_COLOUR_ACTIVEBORDER:
62 case wxSYS_COLOUR_INACTIVEBORDER:
63 case wxSYS_COLOUR_BTNFACE:
64 // case wxSYS_COLOUR_3DFACE: // Same as wxSYS_COLOUR_BTNFACE
65 case wxSYS_COLOUR_GRAYTEXT:
66 {
67 if (but_setting_wid)
68 {
69 XColor bg;
70 XtVaGetValues(but_setting_wid,
71 XtVaTypedArg, XmNbackground, XtRColor, &bg, sizeof(bg),
72 NULL);
73 return wxColor(bg.red >> 8, bg.green >> 8, bg.blue >> 8);
74 }
75 else
76 {
77 return wxColour("LIGHT GREY");
78 }
79 }
80 case wxSYS_COLOUR_BTNSHADOW:
81 // case wxSYS_COLOUR_3DSHADOW: // Same as wxSYS_COLOUR_BTNSHADOW
82 {
83 return wxColour("GREY");
84 }
85 case wxSYS_COLOUR_3DDKSHADOW:
86 {
87 return *wxBLACK;
88 }
89 case wxSYS_COLOUR_HIGHLIGHT:
90 {
91 return *wxBLUE;
92 }
93 case wxSYS_COLOUR_BTNHIGHLIGHT:
94 case wxSYS_COLOUR_LISTBOX:
95 // case wxSYS_COLOUR_3DHIGHLIGHT: // Same as wxSYS_COLOUR_BTNHIGHLIGHT
96 {
97 return *wxWHITE;
98 }
99 case wxSYS_COLOUR_3DLIGHT:
100 {
101 return wxColour("LIGHT GREY");
102 }
103 case wxSYS_COLOUR_MENUTEXT:
104 case wxSYS_COLOUR_WINDOWTEXT:
105 case wxSYS_COLOUR_CAPTIONTEXT:
106 case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
107 case wxSYS_COLOUR_BTNTEXT:
108 case wxSYS_COLOUR_INFOTEXT:
109 {
110 if (but_setting_wid)
111 {
112 XColor fg;
113 XtVaGetValues(but_setting_wid,
114 XtVaTypedArg, XmNforeground, XtRColor, &fg, sizeof(fg),
115 NULL);
116 return wxColor(fg.red >> 8, fg.green >> 8, fg.blue >> 8);
117 }
118 else
119 {
120 return *wxBLACK;
121 }
122 }
123 case wxSYS_COLOUR_HIGHLIGHTTEXT:
124 {
125 return *wxWHITE;
126 }
127 case wxSYS_COLOUR_INFOBK:
128 case wxSYS_COLOUR_APPWORKSPACE:
129 {
130 if (but_setting_wid)
131 {
132 XColor bg;
133 XtVaGetValues(but_setting_wid,
134 XtVaTypedArg, XmNbackground, XtRColor, &bg, sizeof(bg),
135 NULL);
136 return wxColor(bg.red >> 8, bg.green >> 8, bg.blue >> 8);
137 }
138 else
139 {
140 return wxColour("LIGHT GREY");
141 }
142 }
143
144 case wxSYS_COLOUR_HOTLIGHT:
145 case wxSYS_COLOUR_GRADIENTACTIVECAPTION:
146 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION:
147 case wxSYS_COLOUR_MENUHILIGHT:
148 // TODO
149 return wxColour("LIGHT GREY");
150
151 default:
152 case wxSYS_COLOUR_MAX:
153 wxFAIL_MSG( _T("unknown colour") );
154 }
155 return *wxWHITE;
156 }
157
158 wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
159 {
160 int pointSize = 12;
161
162 if ( wxFont::GetDefaultEncoding() == wxFONTENCODING_SHIFT_JIS
163 || wxFont::GetDefaultEncoding() == wxFONTENCODING_EUC_JP)
164 pointSize = 15;
165
166 switch (index)
167 {
168 case wxSYS_SYSTEM_FIXED_FONT:
169 {
170 return wxFont(pointSize, wxMODERN, wxNORMAL, wxNORMAL, false);
171 break;
172 }
173 case wxSYS_DEVICE_DEFAULT_FONT:
174 case wxSYS_SYSTEM_FONT:
175 case wxSYS_DEFAULT_GUI_FONT:
176 default:
177 {
178 return wxFont(pointSize, wxSWISS, wxNORMAL, wxNORMAL, false);
179 break;
180 }
181 }
182
183 return wxFont();
184 }
185
186 // Get a system metric, e.g. scrollbar size
187 int wxSystemSettingsNative::GetMetric(wxSystemMetric index, wxWindow* WXUNUSED(win))
188 {
189 int return_value = 0;
190
191 switch ( index)
192 {
193 case wxSYS_HSCROLL_Y:
194 case wxSYS_VSCROLL_X:
195 return 15;
196
197 case wxSYS_SCREEN_X:
198 return_value = DisplayWidth( wxGlobalDisplay(), 0 );
199 break;
200 case wxSYS_SCREEN_Y:
201 return_value = DisplayHeight( wxGlobalDisplay(), 0 );
202 break;
203
204 // TODO case wxSYS_MOUSE_BUTTONS:
205 // TODO case wxSYS_BORDER_X:
206 // TODO case wxSYS_BORDER_Y:
207 // TODO case wxSYS_CURSOR_X:
208 // TODO case wxSYS_CURSOR_Y:
209 // TODO case wxSYS_DCLICK_X:
210 // TODO case wxSYS_DCLICK_Y:
211 // TODO case wxSYS_DRAG_X:
212 // TODO case wxSYS_DRAG_Y:
213 // TODO case wxSYS_EDGE_X:
214 // TODO case wxSYS_EDGE_Y:
215 // TODO case wxSYS_HSCROLL_ARROW_X:
216 // TODO case wxSYS_HSCROLL_ARROW_Y:
217 // TODO case wxSYS_HTHUMB_X:
218 // TODO case wxSYS_ICON_X:
219 // TODO case wxSYS_ICON_Y:
220 // TODO case wxSYS_ICONSPACING_X:
221 // TODO case wxSYS_ICONSPACING_Y:
222 // TODO case wxSYS_WINDOWMIN_X:
223 // TODO case wxSYS_WINDOWMIN_Y:
224 // TODO case wxSYS_FRAMESIZE_X:
225 // TODO case wxSYS_FRAMESIZE_Y:
226 // TODO case wxSYS_SMALLICON_X:
227 // TODO case wxSYS_SMALLICON_Y:
228 // TODO case wxSYS_VSCROLL_ARROW_X:
229 // TODO case wxSYS_VSCROLL_ARROW_Y:
230 // TODO case wxSYS_VTHUMB_Y:
231 // TODO case wxSYS_CAPTION_Y:
232 // TODO case wxSYS_MENU_Y:
233 // TODO case wxSYS_NETWORK_PRESENT:
234 // TODO case wxSYS_PENWINDOWS_PRESENT:
235 // TODO case wxSYS_SHOW_SOUNDS:
236 // TODO case wxSYS_SWAP_BUTTONS:
237
238 default:
239 return_value = -1; // unsuported metric
240 }
241
242 return return_value;
243 }
244
245 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
246 {
247 switch (index)
248 {
249 case wxSYS_CAN_ICONIZE_FRAME:
250 case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
251 return true;
252
253 default:
254 return false;
255 }
256 }