X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4353a8df6eb0c743f42a85364235195246225b76..3225a4b8b8656f25dac6cb20684a3c2c273cf796:/src/univ/themes/metal.cpp diff --git a/src/univ/themes/metal.cpp b/src/univ/themes/metal.cpp index 252a6d7bb1..1273d59cd6 100644 --- a/src/univ/themes/metal.cpp +++ b/src/univ/themes/metal.cpp @@ -24,7 +24,9 @@ #pragma hdrstop #endif -#if wxUSE_ALL_THEMES || wxUSE_THEME_METAL +#include "wx/univ/theme.h" + +#if wxUSE_THEME_METAL #ifndef WX_PRECOMP #include "wx/timer.h" @@ -57,8 +59,8 @@ #include "wx/univ/inpcons.h" #include "wx/univ/inphand.h" #include "wx/univ/colschem.h" -#include "wx/univ/theme.h" +// ---------------------------------------------------------------------------- // wxMetalRenderer: draw the GUI elements in Metal style // ---------------------------------------------------------------------------- @@ -141,86 +143,35 @@ private: // wxMetalTheme // ---------------------------------------------------------------------------- -class wxMetalTheme : public wxTheme +class wxMetalTheme : public wxDelegateTheme { public: - wxMetalTheme(); - virtual ~wxMetalTheme(); - - virtual wxRenderer *GetRenderer(); - virtual wxArtProvider *GetArtProvider(); - virtual wxInputHandler *GetInputHandler(const wxString& control, - wxInputConsumer *consumer); - virtual wxColourScheme *GetColourScheme(); + wxMetalTheme() : wxDelegateTheme(wxT("win32")), m_renderer(NULL) {} + ~wxMetalTheme() { delete m_renderer; } -private: - bool GetOrCreateTheme() +protected: + virtual wxRenderer *GetRenderer() { - if ( !m_win32Theme ) - m_win32Theme = wxTheme::Create( wxT("win32") ); - return m_win32Theme != NULL; + if ( !m_renderer ) + { + m_renderer = new wxMetalRenderer(m_theme->GetRenderer(), + GetColourScheme()); + } + + return m_renderer; } - wxTheme *m_win32Theme; - wxMetalRenderer *m_renderer; + wxRenderer *m_renderer; WX_DECLARE_THEME(Metal) }; -// ============================================================================ -// implementation -// ============================================================================ - WX_IMPLEMENT_THEME(wxMetalTheme, Metal, wxTRANSLATE("Metal theme")); -// ---------------------------------------------------------------------------- -// wxMetalTheme -// ---------------------------------------------------------------------------- - -wxMetalTheme::wxMetalTheme() -{ - m_win32Theme = NULL; - m_renderer = NULL; -} - -wxMetalTheme::~wxMetalTheme() -{ - delete m_win32Theme; - delete m_renderer; -} - -wxRenderer *wxMetalTheme::GetRenderer() -{ - if ( !GetOrCreateTheme() ) - return 0; - if ( !m_renderer ) - m_renderer = new wxMetalRenderer(m_win32Theme->GetRenderer(), - m_win32Theme->GetColourScheme()); - - return m_renderer; -} -wxArtProvider *wxMetalTheme::GetArtProvider() -{ - if ( !GetOrCreateTheme() ) - return 0; - return m_win32Theme->GetArtProvider(); -} - -wxInputHandler *wxMetalTheme::GetInputHandler(const wxString& control, - wxInputConsumer *consumer) -{ - if ( !GetOrCreateTheme() ) - return 0; - return m_win32Theme->GetInputHandler(control, consumer); -} - -wxColourScheme *wxMetalTheme::GetColourScheme() -{ - if ( !GetOrCreateTheme() ) - return 0; - return m_win32Theme->GetColourScheme(); -} +// ============================================================================ +// implementation +// ============================================================================ // ---------------------------------------------------------------------------- // wxMetalRenderer @@ -475,7 +426,7 @@ void wxMetalRenderer::DrawArrow(wxDC& dc, case wxDOWN: arrowDir = Arrow_Down; break; default: - wxFAIL_MSG(_T("unknown arrow direction")); + wxFAIL_MSG(wxT("unknown arrow direction")); return; } @@ -594,4 +545,4 @@ void wxMetalRenderer::DrawMetal(wxDC &dc, const wxRect &rect ) } } -#endif // wxUSE_ALL_THEMES || wxUSE_THEME_METAL +#endif // wxUSE_THEME_METAL