]>
git.saurik.com Git - wxWidgets.git/blob - src/univ/theme.cpp
   1 /////////////////////////////////////////////////////////////////////////////// 
   2 // Name:        univ/theme.cpp 
   3 // Purpose:     implementation of wxTheme 
   4 // Author:      Vadim Zeitlin 
   8 // Copyright:   (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) 
   9 // Licence:     wxWindows licence 
  10 /////////////////////////////////////////////////////////////////////////////// 
  12 // =========================================================================== 
  14 // =========================================================================== 
  16 // --------------------------------------------------------------------------- 
  18 // --------------------------------------------------------------------------- 
  20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  21     #pragma implementation "theme.h" 
  24 // For compilers that support precompilation, includes "wx.h". 
  25 #include "wx/wxprec.h" 
  36 #include "wx/artprov.h" 
  38 #include "wx/univ/renderer.h" 
  39 #include "wx/univ/inphand.h" 
  40 #include "wx/univ/theme.h" 
  42 // ============================================================================ 
  44 // ============================================================================ 
  46 wxThemeInfo 
*wxTheme::ms_allThemes 
= (wxThemeInfo 
*)NULL
; 
  47 wxTheme 
*wxTheme::ms_theme 
= (wxTheme 
*)NULL
; 
  49 // ---------------------------------------------------------------------------- 
  50 // "dynamic" theme creation 
  51 // ---------------------------------------------------------------------------- 
  53 wxThemeInfo::wxThemeInfo(Constructor c
, 
  56            : name(n
), desc(d
), ctor(c
) 
  58     // insert us (in the head of) the linked list 
  59     next 
= wxTheme::ms_allThemes
; 
  60     wxTheme::ms_allThemes 
= this; 
  63 /* static */ wxTheme 
*wxTheme::Create(const wxString
& name
) 
  65     // find the theme in the list by name 
  66     wxThemeInfo 
*info 
= ms_allThemes
; 
  69         if ( name
.CmpNoCase(info
->name
) == 0 ) 
  77     return (wxTheme 
*)NULL
; 
  80 // ---------------------------------------------------------------------------- 
  81 // the default theme (called by wxApp::OnInitGui) 
  82 // ---------------------------------------------------------------------------- 
  84 /* static */ bool wxTheme::CreateDefault() 
  88         // we already have a theme 
  92     wxString nameDefTheme
; 
  94     // use the environment variable first 
  95     const wxChar 
*p 
= wxGetenv(_T("WXTHEME")); 
 100     else // use native theme by default 
 102         #if defined(__WXGTK__) 
 103             nameDefTheme 
= _T("gtk"); 
 104         #elif defined(__WXX11__) 
 105             nameDefTheme 
= _T("win32"); 
 107             nameDefTheme 
= _T("win32"); 
 111     wxTheme 
*theme 
= Create(nameDefTheme
); 
 113     // fallback to the first one in the list 
 114     if ( !theme 
&& ms_allThemes 
) 
 116         theme 
= ms_allThemes
->ctor(); 
 119     // abort if still nothing 
 122         wxLogError(_("Failed to initialize GUI: no built-in themes found.")); 
 127     // Set the theme as current. 
 133 /* static */ wxTheme 
*wxTheme::Set(wxTheme 
*theme
) 
 135     wxTheme 
*themeOld 
= ms_theme
; 
 140         // automatically start using the art provider of the new theme if it 
 142         wxArtProvider 
*art 
= ms_theme
->GetArtProvider(); 
 144             wxArtProvider::PushProvider(art
); 
 150 // ---------------------------------------------------------------------------- 
 151 // assorted trivial dtors 
 152 // ----------------------------------------------------------------------------