1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/common/sysopt.cpp 
   3 // Purpose:     wxSystemOptions 
   4 // Author:      Julian Smart 
   7 // Copyright:   (c) Julian Smart 
   8 // Licence:     wxWindows licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  11 // ============================================================================ 
  13 // ============================================================================ 
  15 // --------------------------------------------------------------------------- 
  17 // --------------------------------------------------------------------------- 
  19 // For compilers that support precompilation, includes "wx.h". 
  20 #include "wx/wxprec.h" 
  22 #if defined(__BORLANDC__) 
  26 #if wxUSE_SYSTEM_OPTIONS 
  28 #include "wx/sysopt.h" 
  33     #include "wx/string.h" 
  34     #include "wx/arrstr.h" 
  37 // ---------------------------------------------------------------------------- 
  39 // ---------------------------------------------------------------------------- 
  41 static wxArrayString gs_optionNames
, 
  44 // ============================================================================ 
  45 // wxSystemOptions implementation 
  46 // ============================================================================ 
  48 // Option functions (arbitrary name/value mapping) 
  49 void wxSystemOptions::SetOption(const wxString
& name
, const wxString
& value
) 
  51     int idx 
= gs_optionNames
.Index(name
, false); 
  52     if (idx 
== wxNOT_FOUND
) 
  54         gs_optionNames
.Add(name
); 
  55         gs_optionValues
.Add(value
); 
  59         gs_optionNames
[idx
] = name
; 
  60         gs_optionValues
[idx
] = value
; 
  64 void wxSystemOptions::SetOption(const wxString
& name
, int value
) 
  66     SetOption(name
, wxString::Format(wxT("%d"), value
)); 
  69 wxString 
wxSystemOptions::GetOption(const wxString
& name
) 
  73     int idx 
= gs_optionNames
.Index(name
, false); 
  74     if ( idx 
!= wxNOT_FOUND 
) 
  76         val 
= gs_optionValues
[idx
]; 
  78     else // not set explicitly 
  80         // look in the environment: first for a variable named "wx_appname_name" 
  81         // which can be set to affect the behaviour or just this application 
  82         // and then for "wx_name" which can be set to change the option globally 
  84         var
.Replace(wxT("."), wxT("_"));  // '.'s not allowed in env var names 
  85         var
.Replace(wxT("-"), wxT("_"));  // and neither are '-'s 
  89             appname 
= wxTheApp
->GetAppName(); 
  91         if ( !appname
.empty() ) 
  92             val 
= wxGetenv(wxT("wx_") + appname 
+ wxT('_') + var
); 
  95             val 
= wxGetenv(wxT("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