]> git.saurik.com Git - wxWidgets.git/blame - src/msw/settings.cpp
Added wxYieldIfNeeded
[wxWidgets.git] / src / msw / settings.cpp
CommitLineData
2bda0e17
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: settings.cpp
3// Purpose: wxSettings
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
019a60d6 9// Licence: wxWindows license
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "settings.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
23#ifndef WX_PRECOMP
24#include <stdio.h>
25#include "wx/defs.h"
26#include "wx/pen.h"
27#include "wx/brush.h"
28#include "wx/gdicmn.h"
29#endif
30
31#include "wx/settings.h"
32#include "wx/window.h"
33#include "wx/msw/private.h"
34
35// TODO: see ::SystemParametersInfo for all sorts of Windows settings.
36// Different args are required depending on the id. How does this differ
37// from GetSystemMetric, and should it? Perhaps call it GetSystemParameter
38// and pass an optional void* arg to get further info.
39// Should also have SetSystemParameter.
40// Also implement WM_WININICHANGE (NT) / WM_SETTINGCHANGE (Win95)
41
42wxColour wxSystemSettings::GetSystemColour(int index)
43{
019a60d6
VS
44 switch (index)
45 {
46 case wxSYS_COLOUR_LISTBOX:
47 return *wxWHITE;
48 break;
49
50 default:
51 COLORREF ref = ::GetSysColor(index);
52 wxColour col(GetRValue(ref), GetGValue(ref), GetBValue(ref));
53 return col;
54 break;
55 }
2bda0e17
KB
56}
57
58wxFont wxSystemSettings::GetSystemFont(int index)
59{
019a60d6
VS
60 HFONT hFont = (HFONT) ::GetStockObject(index);
61 if ( hFont != (HFONT) NULL )
62 {
63 LOGFONT lf;
64 if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 )
65 {
66 // In fontdlg.cpp
67 return wxCreateFontFromLogFont(&lf);
68 }
69 else
70 {
71 return wxNullFont;
72 }
73 }
74 else
75 {
76 return wxNullFont;
77 }
2bda0e17
KB
78}
79
80// Get a system metric, e.g. scrollbar size
81int wxSystemSettings::GetSystemMetric(int index)
82{
019a60d6
VS
83 switch ( index)
84 {
2bda0e17
KB
85#ifdef __WIN32__
86 case wxSYS_MOUSE_BUTTONS:
019a60d6 87 return ::GetSystemMetrics(SM_CMOUSEBUTTONS);
2bda0e17
KB
88#endif
89
90 case wxSYS_BORDER_X:
019a60d6 91 return ::GetSystemMetrics(SM_CXBORDER);
2bda0e17 92 case wxSYS_BORDER_Y:
019a60d6 93 return ::GetSystemMetrics(SM_CYBORDER);
2bda0e17 94 case wxSYS_CURSOR_X:
019a60d6 95 return ::GetSystemMetrics(SM_CXCURSOR);
2bda0e17 96 case wxSYS_CURSOR_Y:
019a60d6 97 return ::GetSystemMetrics(SM_CYCURSOR);
2bda0e17 98 case wxSYS_DCLICK_X:
019a60d6 99 return ::GetSystemMetrics(SM_CXDOUBLECLK);
2bda0e17 100 case wxSYS_DCLICK_Y:
019a60d6 101 return ::GetSystemMetrics(SM_CYDOUBLECLK);
2432b92d 102#if defined(__WIN32__) && defined(SM_CXDRAG)
2bda0e17 103 case wxSYS_DRAG_X:
019a60d6 104 return ::GetSystemMetrics(SM_CXDRAG);
2bda0e17 105 case wxSYS_DRAG_Y:
019a60d6 106 return ::GetSystemMetrics(SM_CYDRAG);
2bda0e17 107 case wxSYS_EDGE_X:
019a60d6 108 return ::GetSystemMetrics(SM_CXEDGE);
2bda0e17 109 case wxSYS_EDGE_Y:
019a60d6 110 return ::GetSystemMetrics(SM_CYEDGE);
2bda0e17
KB
111#endif
112 case wxSYS_HSCROLL_ARROW_X:
019a60d6 113 return ::GetSystemMetrics(SM_CXHSCROLL);
2bda0e17 114 case wxSYS_HSCROLL_ARROW_Y:
019a60d6 115 return ::GetSystemMetrics(SM_CYHSCROLL);
2bda0e17 116 case wxSYS_HTHUMB_X:
019a60d6 117 return ::GetSystemMetrics(SM_CXHTHUMB);
2bda0e17 118 case wxSYS_ICON_X:
019a60d6 119 return ::GetSystemMetrics(SM_CXICON);
2bda0e17 120 case wxSYS_ICON_Y:
019a60d6 121 return ::GetSystemMetrics(SM_CYICON);
2bda0e17 122 case wxSYS_ICONSPACING_X:
019a60d6 123 return ::GetSystemMetrics(SM_CXICONSPACING);
2bda0e17 124 case wxSYS_ICONSPACING_Y:
019a60d6 125 return ::GetSystemMetrics(SM_CYICONSPACING);
2bda0e17 126 case wxSYS_WINDOWMIN_X:
019a60d6 127 return ::GetSystemMetrics(SM_CXMIN);
2bda0e17 128 case wxSYS_WINDOWMIN_Y:
019a60d6 129 return ::GetSystemMetrics(SM_CYMIN);
2bda0e17 130 case wxSYS_SCREEN_X:
019a60d6 131 return ::GetSystemMetrics(SM_CXSCREEN);
2bda0e17 132 case wxSYS_SCREEN_Y:
019a60d6 133 return ::GetSystemMetrics(SM_CYSCREEN);
2432b92d
JS
134
135#if defined(__WIN32__) && defined(SM_CXSIZEFRAME)
2bda0e17 136 case wxSYS_FRAMESIZE_X:
019a60d6 137 return ::GetSystemMetrics(SM_CXSIZEFRAME);
2bda0e17 138 case wxSYS_FRAMESIZE_Y:
019a60d6 139 return ::GetSystemMetrics(SM_CYSIZEFRAME);
2bda0e17 140 case wxSYS_SMALLICON_X:
019a60d6 141 return ::GetSystemMetrics(SM_CXSMICON);
2bda0e17 142 case wxSYS_SMALLICON_Y:
019a60d6 143 return ::GetSystemMetrics(SM_CYSMICON);
2bda0e17
KB
144#endif
145 case wxSYS_HSCROLL_Y:
019a60d6 146 return ::GetSystemMetrics(SM_CYHSCROLL);
2bda0e17 147 case wxSYS_VSCROLL_X:
019a60d6 148 return ::GetSystemMetrics(SM_CXVSCROLL);
2bda0e17 149 case wxSYS_VSCROLL_ARROW_X:
019a60d6 150 return ::GetSystemMetrics(SM_CXVSCROLL);
2bda0e17 151 case wxSYS_VSCROLL_ARROW_Y:
019a60d6 152 return ::GetSystemMetrics(SM_CYVSCROLL);
2bda0e17 153 case wxSYS_VTHUMB_Y:
019a60d6 154 return ::GetSystemMetrics(SM_CYVTHUMB);
2bda0e17 155 case wxSYS_CAPTION_Y:
019a60d6 156 return ::GetSystemMetrics(SM_CYCAPTION);
2bda0e17 157 case wxSYS_MENU_Y:
019a60d6 158 return ::GetSystemMetrics(SM_CYMENU);
2432b92d 159#if defined(__WIN32__) && defined(SM_NETWORK)
2bda0e17 160 case wxSYS_NETWORK_PRESENT:
019a60d6 161 return ::GetSystemMetrics(SM_NETWORK) & 0x0001;
2bda0e17
KB
162#endif
163 case wxSYS_PENWINDOWS_PRESENT:
019a60d6 164 return ::GetSystemMetrics(SM_PENWINDOWS);
2432b92d 165#if defined(__WIN32__) && defined(SM_SHOWSOUNDS)
2bda0e17 166 case wxSYS_SHOW_SOUNDS:
019a60d6 167 return ::GetSystemMetrics(SM_SHOWSOUNDS);
2bda0e17
KB
168#endif
169 case wxSYS_SWAP_BUTTONS:
019a60d6
VS
170 return ::GetSystemMetrics(SM_SWAPBUTTON);
171 default:
172 return 0;
173 }
2bda0e17
KB
174}
175