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 explicitly
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(wxT("."), wxT("_")); // '.'s not allowed in env var names
86 var
.Replace(wxT("-"), wxT("_")); // and neither are '-'s
90 appname
= wxTheApp
->GetAppName();
92 if ( !appname
.empty() )
93 val
= wxGetenv(wxT("wx_") + appname
+ wxT('_') + var
);
96 val
= wxGetenv(wxT("wx_") + var
);
102 int wxSystemOptions::GetOptionInt(const wxString
& name
)
105 // work around the PalmOS pacc compiler bug
106 return wxAtoi (GetOption(name
).data());
108 return wxAtoi (GetOption(name
));
112 bool wxSystemOptions::HasOption(const wxString
& name
)
114 return !GetOption(name
).empty();
117 #endif // wxUSE_SYSTEM_OPTIONS