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