]> git.saurik.com Git - wxWidgets.git/blame - src/common/sysopt.cpp
added wxConvFileName which is a variable, not define as wxConvFile; added comments...
[wxWidgets.git] / src / common / sysopt.cpp
CommitLineData
0cbff120
JS
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
d775fa82 9// Licence: wxWindows licence
0cbff120
JS
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
14f355c2 20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
0cbff120
JS
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
410c3efc
VZ
31#if wxUSE_SYSTEM_OPTIONS
32
0cbff120
JS
33#ifndef WX_PRECOMP
34 #include "wx/list.h"
35#endif
36
0cbff120
JS
37#include "wx/string.h"
38#include "wx/sysopt.h"
df5168c4 39#include "wx/arrstr.h"
0cbff120
JS
40
41// ----------------------------------------------------------------------------
410c3efc 42// private globals
0cbff120
JS
43// ----------------------------------------------------------------------------
44
410c3efc
VZ
45static wxArrayString gs_optionNames,
46 gs_optionValues;
0cbff120 47
410c3efc
VZ
48// ============================================================================
49// wxSystemOptions implementation
50// ============================================================================
0cbff120
JS
51
52// Option functions (arbitrary name/value mapping)
53void wxSystemOptions::SetOption(const wxString& name, const wxString& value)
54{
410c3efc 55 int idx = gs_optionNames.Index(name, false);
0cbff120
JS
56 if (idx == wxNOT_FOUND)
57 {
410c3efc
VZ
58 gs_optionNames.Add(name);
59 gs_optionValues.Add(value);
0cbff120
JS
60 }
61 else
62 {
410c3efc
VZ
63 gs_optionNames[idx] = name;
64 gs_optionValues[idx] = value;
0cbff120
JS
65 }
66}
67
68void wxSystemOptions::SetOption(const wxString& name, int value)
69{
410c3efc 70 SetOption(name, wxString::Format(wxT("%d"), value));
0cbff120
JS
71}
72
73wxString wxSystemOptions::GetOption(const wxString& name)
74{
410c3efc 75 int idx = gs_optionNames.Index(name, false);
0cbff120
JS
76 if (idx == wxNOT_FOUND)
77 return wxEmptyString;
78 else
410c3efc 79 return gs_optionValues[idx];
0cbff120
JS
80}
81
82int wxSystemOptions::GetOptionInt(const wxString& name)
83{
84 return wxAtoi(GetOption(name));
85}
86
87bool wxSystemOptions::HasOption(const wxString& name)
88{
410c3efc 89 return gs_optionNames.Index(name, false) != wxNOT_FOUND;
0cbff120
JS
90}
91
410c3efc 92#endif // wxUSE_SYSTEM_OPTIONS
0cbff120 93