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