]>
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 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
32 #include "wx/artprov.h"
34 #include "wx/univ/renderer.h"
35 #include "wx/univ/inphand.h"
36 #include "wx/univ/theme.h"
38 // ============================================================================
40 // ============================================================================
42 wxThemeInfo
*wxTheme::ms_allThemes
= (wxThemeInfo
*)NULL
;
43 wxTheme
*wxTheme::ms_theme
= (wxTheme
*)NULL
;
45 // ----------------------------------------------------------------------------
46 // "dynamic" theme creation
47 // ----------------------------------------------------------------------------
49 wxThemeInfo::wxThemeInfo(Constructor c
,
52 : name(n
), desc(d
), ctor(c
)
54 // insert us (in the head of) the linked list
55 next
= wxTheme::ms_allThemes
;
56 wxTheme::ms_allThemes
= this;
59 /* static */ wxTheme
*wxTheme::Create(const wxString
& name
)
61 // find the theme in the list by name
62 wxThemeInfo
*info
= ms_allThemes
;
65 if ( name
.CmpNoCase(info
->name
) == 0 )
73 return (wxTheme
*)NULL
;
76 // ----------------------------------------------------------------------------
77 // the default theme (called by wxApp::OnInitGui)
78 // ----------------------------------------------------------------------------
80 /* static */ bool wxTheme::CreateDefault()
84 // we already have a theme
88 wxString nameDefTheme
;
90 // use the environment variable first
91 const wxChar
*p
= wxGetenv(_T("WXTHEME"));
96 else // use native theme by default
98 #if defined(__WXGTK__)
99 nameDefTheme
= _T("gtk");
100 #elif defined(__WXX11__)
101 nameDefTheme
= _T("win32");
103 nameDefTheme
= _T("win32");
107 wxTheme
*theme
= Create(nameDefTheme
);
109 // fallback to the first one in the list
110 if ( !theme
&& ms_allThemes
)
112 theme
= ms_allThemes
->ctor();
115 // abort if still nothing
118 wxLogError(_("Failed to initialize GUI: no built-in themes found."));
123 // Set the theme as current.
129 /* static */ wxTheme
*wxTheme::Set(wxTheme
*theme
)
131 wxTheme
*themeOld
= ms_theme
;
136 // automatically start using the art provider of the new theme if it
138 wxArtProvider
*art
= ms_theme
->GetArtProvider();
140 wxArtProvider::PushProvider(art
);
146 // ----------------------------------------------------------------------------
147 // assorted trivial dtors
148 // ----------------------------------------------------------------------------