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
)
103 return wxAtoi(GetOption(name
));
106 bool wxSystemOptions::HasOption(const wxString
& name
)
108 return !GetOption(name
).empty();
111 #endif // wxUSE_SYSTEM_OPTIONS