]>
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 license
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
21 #pragma implementation "theme.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/univ/renderer.h"
37 #include "wx/univ/inphand.h"
38 #include "wx/univ/theme.h"
40 // ============================================================================
42 // ============================================================================
44 wxThemeInfo
*wxTheme::ms_allThemes
= (wxThemeInfo
*)NULL
;
45 wxTheme
*wxTheme::ms_theme
= (wxTheme
*)NULL
;
47 // ----------------------------------------------------------------------------
48 // "dynamic" theme creation
49 // ----------------------------------------------------------------------------
51 wxThemeInfo::wxThemeInfo(Constructor c
,
54 : name(n
), desc(d
), ctor(c
)
56 // insert us (in the head of) the linked list
57 next
= wxTheme::ms_allThemes
;
58 wxTheme::ms_allThemes
= this;
61 /* static */ wxTheme
*wxTheme::Create(const wxString
& name
)
63 // find the theme in the list by name
64 wxThemeInfo
*info
= ms_allThemes
;
67 if ( name
== info
->name
)
75 return (wxTheme
*)NULL
;
78 // ----------------------------------------------------------------------------
79 // the default theme (called by wxApp::OnInitGui)
80 // ----------------------------------------------------------------------------
82 /* static */ bool wxTheme::CreateDefault()
86 // we already have a theme
90 wxString nameDefTheme
;
92 // use the environment variable first
93 const wxChar
*p
= wxGetenv(_T("WXTHEME"));
98 else // use native theme by default
100 #if defined(__WXGTK__)
101 nameDefTheme
= _T("gtk");
102 #elif defined(__WXX11__)
103 nameDefTheme
= _T("Metal");
105 nameDefTheme
= _T("win32");
109 ms_theme
= Create(nameDefTheme
);
111 // fallback to the first one in the list
112 if ( !ms_theme
&& ms_allThemes
)
114 ms_theme
= ms_allThemes
->ctor();
117 // abort if still nothing
120 wxLogError(_("Failed to initialize GUI: no built-in themes found."));
128 /* static */ wxTheme
*wxTheme::Set(wxTheme
*theme
)
130 wxTheme
*themeOld
= ms_theme
;
135 // ----------------------------------------------------------------------------
136 // assorted trivial dtors
137 // ----------------------------------------------------------------------------