1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/settings.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
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.
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #include "wx/settings.h"
25 #include "wx/gdicmn.h"
28 #pragma message disable nosimpint
33 #pragma message enable nosimpint
36 #include "wx/x11/privx.h"
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.
41 static Widget but_setting_wid
= NULL
;
43 wxColour
wxSystemSettingsNative::GetColour(wxSystemColour index
)
45 if (NULL
== but_setting_wid
&& wxTheApp
&& wxTheApp
->GetTopLevelWidget())
47 but_setting_wid
= XtVaCreateWidget("settings_button", xmPushButtonWidgetClass
,
48 (Widget
)wxTheApp
->GetTopLevelWidget(), NULL
);
53 case wxSYS_COLOUR_WINDOW
:
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
:
63 case wxSYS_COLOUR_MENUBAR
:
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
:
74 XtVaGetValues(but_setting_wid
,
75 XtVaTypedArg
, XmNbackground
, XtRColor
, &bg
, sizeof(bg
),
77 return wxColor((unsigned char)(bg
.red
>> 8),
78 (unsigned char)(bg
.green
>> 8),
79 (unsigned char)(bg
.blue
>> 8));
83 return wxColour("LIGHT GREY");
86 case wxSYS_COLOUR_BTNSHADOW
:
87 // case wxSYS_COLOUR_3DSHADOW: // Same as wxSYS_COLOUR_BTNSHADOW
89 return wxColour("GREY");
91 case wxSYS_COLOUR_3DDKSHADOW
:
95 case wxSYS_COLOUR_HIGHLIGHT
:
99 case wxSYS_COLOUR_BTNHIGHLIGHT
:
100 case wxSYS_COLOUR_LISTBOX
:
101 // case wxSYS_COLOUR_3DHIGHLIGHT: // Same as wxSYS_COLOUR_BTNHIGHLIGHT
105 case wxSYS_COLOUR_3DLIGHT
:
107 return wxColour("LIGHT GREY");
109 case wxSYS_COLOUR_MENUTEXT
:
110 case wxSYS_COLOUR_WINDOWTEXT
:
111 case wxSYS_COLOUR_CAPTIONTEXT
:
112 case wxSYS_COLOUR_INACTIVECAPTIONTEXT
:
113 case wxSYS_COLOUR_BTNTEXT
:
114 case wxSYS_COLOUR_INFOTEXT
:
119 XtVaGetValues(but_setting_wid
,
120 XtVaTypedArg
, XmNforeground
, XtRColor
, &fg
, sizeof(fg
),
122 return wxColor((unsigned char)(fg
.red
>> 8),
123 (unsigned char)(fg
.green
>> 8),
124 (unsigned char)(fg
.blue
>> 8));
131 case wxSYS_COLOUR_HIGHLIGHTTEXT
:
135 case wxSYS_COLOUR_INFOBK
:
136 case wxSYS_COLOUR_APPWORKSPACE
:
141 XtVaGetValues(but_setting_wid
,
142 XtVaTypedArg
, XmNbackground
, XtRColor
, &bg
, sizeof(bg
),
144 return wxColor((unsigned char)(bg
.red
>> 8),
145 (unsigned char)(bg
.green
>> 8),
146 (unsigned char)(bg
.blue
>> 8));
150 return wxColour("LIGHT GREY");
154 case wxSYS_COLOUR_HOTLIGHT
:
155 case wxSYS_COLOUR_GRADIENTACTIVECAPTION
:
156 case wxSYS_COLOUR_GRADIENTINACTIVECAPTION
:
157 case wxSYS_COLOUR_MENUHILIGHT
:
159 return wxColour("LIGHT GREY");
162 case wxSYS_COLOUR_MAX
:
163 wxFAIL_MSG( _T("unknown colour") );
168 wxFont
wxSystemSettingsNative::GetFont(wxSystemFont index
)
172 if ( wxFont::GetDefaultEncoding() == wxFONTENCODING_SHIFT_JIS
173 || wxFont::GetDefaultEncoding() == wxFONTENCODING_EUC_JP
)
180 case wxSYS_SYSTEM_FIXED_FONT
:
182 font
= wxFont(pointSize
, wxMODERN
, wxNORMAL
, wxNORMAL
, false);
185 case wxSYS_DEVICE_DEFAULT_FONT
:
186 case wxSYS_SYSTEM_FONT
:
187 case wxSYS_DEFAULT_GUI_FONT
:
190 font
= wxFont(pointSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false);
198 // Get a system metric, e.g. scrollbar size
199 int wxSystemSettingsNative::GetMetric(wxSystemMetric index
, wxWindow
* WXUNUSED(win
))
201 int return_value
= 0;
205 case wxSYS_HSCROLL_Y
:
206 case wxSYS_VSCROLL_X
:
210 return_value
= DisplayWidth( wxGlobalDisplay(), 0 );
213 return_value
= DisplayHeight( wxGlobalDisplay(), 0 );
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:
251 return_value
= -1; // unsuported metric
257 bool wxSystemSettingsNative::HasFeature(wxSystemFeature index
)
261 case wxSYS_CAN_ICONIZE_FRAME
:
262 case wxSYS_CAN_DRAW_FRAME_DECORATIONS
: