]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/theme.cpp
RegisterAdditionalEditors() to work even if no wxPropertyGrids created, in sample...
[wxWidgets.git] / src / univ / theme.cpp
index 1ed1f57a20107d55719ca388a16744c793dba75c..8997f255a8859873449ff0337c94160a657c774a 100644 (file)
 // headers
 // ---------------------------------------------------------------------------
 
 // headers
 // ---------------------------------------------------------------------------
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-    #pragma implementation "theme.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
@@ -51,8 +47,8 @@ wxTheme *wxTheme::ms_theme = (wxTheme *)NULL;
 // ----------------------------------------------------------------------------
 
 wxThemeInfo::wxThemeInfo(Constructor c,
 // ----------------------------------------------------------------------------
 
 wxThemeInfo::wxThemeInfo(Constructor c,
-                         const wxChar *n,
-                         const wxChar *d)
+                         const wxString& n,
+                         const wxString& d)
            : name(n), desc(d), ctor(c)
 {
     // insert us (in the head of) the linked list
            : name(n), desc(d), ctor(c)
 {
     // insert us (in the head of) the linked list
@@ -86,7 +82,7 @@ wxThemeInfo::wxThemeInfo(Constructor c,
     if ( ms_theme )
     {
         // we already have a theme
     if ( ms_theme )
     {
         // we already have a theme
-        return TRUE;
+        return true;
     }
 
     wxString nameDefTheme;
     }
 
     wxString nameDefTheme;
@@ -97,16 +93,12 @@ wxThemeInfo::wxThemeInfo(Constructor c,
     {
         nameDefTheme = p;
     }
     {
         nameDefTheme = p;
     }
+#ifdef wxUNIV_DEFAULT_THEME
     else // use native theme by default
     {
     else // use native theme by default
     {
-        #if defined(__WXGTK__)
-            nameDefTheme = _T("gtk");
-        #elif defined(__WXX11__)
-            nameDefTheme = _T("win32");
-        #else
-            nameDefTheme = _T("win32");
-        #endif
+        nameDefTheme = wxSTRINGIZE_T(wxUNIV_DEFAULT_THEME);
     }
     }
+#endif // wxUNIV_DEFAULT_THEME
 
     wxTheme *theme = Create(nameDefTheme);
 
 
     wxTheme *theme = Create(nameDefTheme);
 
@@ -121,13 +113,13 @@ wxThemeInfo::wxThemeInfo(Constructor c,
     {
         wxLogError(_("Failed to initialize GUI: no built-in themes found."));
 
     {
         wxLogError(_("Failed to initialize GUI: no built-in themes found."));
 
-        return FALSE;
+        return false;
     }
 
     // Set the theme as current.
     wxTheme::Set(theme);
 
     }
 
     // Set the theme as current.
     wxTheme::Set(theme);
 
-    return TRUE;
+    return true;
 }
 
 /* static */ wxTheme *wxTheme::Set(wxTheme *theme)
 }
 
 /* static */ wxTheme *wxTheme::Set(wxTheme *theme)
@@ -141,7 +133,7 @@ wxThemeInfo::wxThemeInfo(Constructor c,
         // has one
         wxArtProvider *art = ms_theme->GetArtProvider();
         if ( art )
         // has one
         wxArtProvider *art = ms_theme->GetArtProvider();
         if ( art )
-            wxArtProvider::PushProvider(art);
+            wxArtProvider::Push(art);
     }
 
     return themeOld;
     }
 
     return themeOld;
@@ -155,3 +147,58 @@ wxTheme::~wxTheme()
 {
 }
 
 {
 }
 
+
+// ----------------------------------------------------------------------------
+// wxDelegateTheme
+// ----------------------------------------------------------------------------
+
+wxDelegateTheme::wxDelegateTheme(const wxString& theme)
+{
+    m_themeName = theme;
+    m_theme = NULL;
+}
+
+wxDelegateTheme::~wxDelegateTheme()
+{
+    delete m_theme;
+}
+
+bool wxDelegateTheme::GetOrCreateTheme()
+{
+    if ( !m_theme )
+        m_theme = wxTheme::Create(m_themeName);
+    return m_theme != NULL;
+}
+
+wxRenderer *wxDelegateTheme::GetRenderer()
+{
+    if ( !GetOrCreateTheme() )
+        return NULL;
+
+    return m_theme->GetRenderer();
+}
+
+wxArtProvider *wxDelegateTheme::GetArtProvider()
+{
+    if ( !GetOrCreateTheme() )
+        return NULL;
+
+    return m_theme->GetArtProvider();
+}
+
+wxInputHandler *wxDelegateTheme::GetInputHandler(const wxString& control,
+                                                 wxInputConsumer *consumer)
+{
+    if ( !GetOrCreateTheme() )
+        return NULL;
+
+    return m_theme->GetInputHandler(control, consumer);
+}
+
+wxColourScheme *wxDelegateTheme::GetColourScheme()
+{
+    if ( !GetOrCreateTheme() )
+        return NULL;
+
+    return m_theme->GetColourScheme();
+}