X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3b3dc8019a520ce5e166c8ae9098ba020f8b3f94..fb8d7eb7a880f1f2e32d8830f9c5e12b2536e05f:/src/univ/themes/metal.cpp diff --git a/src/univ/themes/metal.cpp b/src/univ/themes/metal.cpp index 0b88fbed9a..1273d59cd6 100644 --- a/src/univ/themes/metal.cpp +++ b/src/univ/themes/metal.cpp @@ -24,6 +24,10 @@ #pragma hdrstop #endif +#include "wx/univ/theme.h" + +#if wxUSE_THEME_METAL + #ifndef WX_PRECOMP #include "wx/timer.h" #include "wx/intl.h" @@ -41,25 +45,22 @@ #include "wx/textctrl.h" #include "wx/toolbar.h" - #ifdef __WXMSW__ - // for COLOR_* constants - #include "wx/msw/private.h" - #endif #include "wx/menu.h" + #include "wx/settings.h" + #include "wx/toplevel.h" #endif // WX_PRECOMP #include "wx/notebook.h" #include "wx/spinbutt.h" -#include "wx/settings.h" #include "wx/artprov.h" -#include "wx/toplevel.h" #include "wx/univ/scrtimer.h" #include "wx/univ/renderer.h" +#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 // ---------------------------------------------------------------------------- @@ -142,92 +143,42 @@ private: // wxMetalTheme // ---------------------------------------------------------------------------- -WX_DEFINE_ARRAY_PTR(wxInputHandler *, wxArrayHandlers); - -class wxMetalTheme : public wxTheme +class wxMetalTheme : public wxDelegateTheme { public: - wxMetalTheme(); - virtual ~wxMetalTheme(); + wxMetalTheme() : wxDelegateTheme(wxT("win32")), m_renderer(NULL) {} + ~wxMetalTheme() { delete m_renderer; } - virtual wxRenderer *GetRenderer(); - virtual wxArtProvider *GetArtProvider(); - virtual wxInputHandler *GetInputHandler(const wxString& control); - virtual wxColourScheme *GetColourScheme(); -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; } -private: - 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) -{ - if ( !GetOrCreateTheme() ) - return 0; - return m_win32Theme->GetInputHandler(control); -} - -wxColourScheme *wxMetalTheme::GetColourScheme() -{ - if ( !GetOrCreateTheme() ) - return 0; - return m_win32Theme->GetColourScheme(); -} +// ============================================================================ +// implementation +// ============================================================================ // ---------------------------------------------------------------------------- // wxMetalRenderer // ---------------------------------------------------------------------------- wxMetalRenderer::wxMetalRenderer(wxRenderer *renderer, wxColourScheme *scheme) - : wxDelegateRenderer(renderer) + : wxDelegateRenderer(renderer) { // init colours and pens m_penBlack = wxPen(wxSCHEME_COLOUR(scheme, SHADOW_DARK), 0, wxSOLID); @@ -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; } @@ -593,3 +544,5 @@ void wxMetalRenderer::DrawMetal(wxDC &dc, const wxRect &rect ) dc.DrawRectangle( rect.x, y, rect.width, 1 ); } } + +#endif // wxUSE_THEME_METAL