]> git.saurik.com Git - wxWidgets.git/blob - src/common/sysopt.cpp
use wx/math.h for math constants - avoids redifinition warnings
[wxWidgets.git] / src / common / sysopt.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/sysopt.cpp
3 // Purpose: wxSystemOptions
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 2001-07-10
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "sysopt.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #if defined(__BORLANDC__)
28 #pragma hdrstop
29 #endif
30
31 #if wxUSE_SYSTEM_OPTIONS
32
33 #ifndef WX_PRECOMP
34 #include "wx/list.h"
35 #endif
36
37 #include "wx/string.h"
38 #include "wx/sysopt.h"
39 #include "wx/arrstr.h"
40
41 // ----------------------------------------------------------------------------
42 // private globals
43 // ----------------------------------------------------------------------------
44
45 static wxArrayString gs_optionNames,
46 gs_optionValues;
47
48 // ============================================================================
49 // wxSystemOptions implementation
50 // ============================================================================
51
52 // Option functions (arbitrary name/value mapping)
53 void wxSystemOptions::SetOption(const wxString& name, const wxString& value)
54 {
55 int idx = gs_optionNames.Index(name, false);
56 if (idx == wxNOT_FOUND)
57 {
58 gs_optionNames.Add(name);
59 gs_optionValues.Add(value);
60 }
61 else
62 {
63 gs_optionNames[idx] = name;
64 gs_optionValues[idx] = value;
65 }
66 }
67
68 void wxSystemOptions::SetOption(const wxString& name, int value)
69 {
70 SetOption(name, wxString::Format(wxT("%d"), value));
71 }
72
73 wxString wxSystemOptions::GetOption(const wxString& name)
74 {
75 int idx = gs_optionNames.Index(name, false);
76 if (idx == wxNOT_FOUND)
77 return wxEmptyString;
78 else
79 return gs_optionValues[idx];
80 }
81
82 int wxSystemOptions::GetOptionInt(const wxString& name)
83 {
84 return wxAtoi(GetOption(name));
85 }
86
87 bool wxSystemOptions::HasOption(const wxString& name)
88 {
89 return gs_optionNames.Index(name, false) != wxNOT_FOUND;
90 }
91
92 #endif // wxUSE_SYSTEM_OPTIONS
93