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