1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/sysopt.cpp
3 // Purpose: wxSystemOptions
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
23 #if defined(__BORLANDC__)
27 #if wxUSE_SYSTEM_OPTIONS
29 #include "wx/sysopt.h"
34 #include "wx/string.h"
35 #include "wx/arrstr.h"
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 static wxArrayString gs_optionNames,
45 // ============================================================================
46 // wxSystemOptions implementation
47 // ============================================================================
49 // Option functions (arbitrary name/value mapping)
50 void wxSystemOptions::SetOption(const wxString& name, const wxString& value)
52 int idx = gs_optionNames.Index(name, false);
53 if (idx == wxNOT_FOUND)
55 gs_optionNames.Add(name);
56 gs_optionValues.Add(value);
60 gs_optionNames[idx] = name;
61 gs_optionValues[idx] = value;
65 void wxSystemOptions::SetOption(const wxString& name, int value)
67 SetOption(name, wxString::Format(wxT("%d"), value));
70 wxString wxSystemOptions::GetOption(const wxString& name)
74 int idx = gs_optionNames.Index(name, false);
75 if ( idx != wxNOT_FOUND )
77 val = gs_optionValues[idx];
79 else // not set explicitely
81 // look in the environment: first for a variable named "wx_appname_name"
82 // which can be set to affect the behaviour or just this application
83 // and then for "wx_name" which can be set to change the option globally
85 var.Replace(_T("."), _T("_")); // '.'s not allowed in env var names
89 appname = wxTheApp->GetAppName();
91 if ( !appname.empty() )
92 val = wxGetenv(_T("wx_") + appname + _T('_') + var);
95 val = wxGetenv(_T("wx_") + var);
101 int wxSystemOptions::GetOptionInt(const wxString& name)
104 // work around the PalmOS pacc compiler bug
105 return wxAtoi (GetOption(name).data());
107 return wxAtoi (GetOption(name));
111 bool wxSystemOptions::HasOption(const wxString& name)
113 return !GetOption(name).empty();
116 #endif // wxUSE_SYSTEM_OPTIONS