added wxDelegateTheme to accompany wxDelegateRenderer
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42455 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1b97b23d5f
commit
eef1a0cc63
@ -76,6 +76,34 @@ private:
|
||||
friend struct WXDLLEXPORT wxThemeInfo;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDelegateTheme: it is impossible to inherit from any of standard
|
||||
// themes as their declarations are in private code, but you can use this
|
||||
// class to override only some of their functions - all the other ones
|
||||
// will be left to the original theme
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxDelegateTheme : public wxTheme
|
||||
{
|
||||
public:
|
||||
wxDelegateTheme(const wxChar *theme);
|
||||
virtual ~wxDelegateTheme();
|
||||
|
||||
virtual wxRenderer *GetRenderer();
|
||||
virtual wxArtProvider *GetArtProvider();
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer);
|
||||
virtual wxColourScheme *GetColourScheme();
|
||||
|
||||
protected:
|
||||
// gets or creates theme and sets m_theme to point to it,
|
||||
// returns true on success
|
||||
bool GetOrCreateTheme();
|
||||
|
||||
wxString m_themeName;
|
||||
wxTheme *m_theme;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// dynamic theme creation helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -147,3 +147,58 @@ wxTheme::~wxTheme()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDelegateTheme
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxDelegateTheme::wxDelegateTheme(const wxChar *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();
|
||||
}
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/colschem.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMetalRenderer: draw the GUI elements in Metal style
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -142,87 +143,36 @@ private:
|
||||
// wxMetalTheme
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxMetalTheme : public wxTheme
|
||||
class wxMetalTheme : public wxDelegateTheme
|
||||
{
|
||||
public:
|
||||
wxMetalTheme();
|
||||
virtual ~wxMetalTheme();
|
||||
wxMetalTheme() : wxDelegateTheme(_T("win32")), m_renderer(NULL) {}
|
||||
~wxMetalTheme() { delete m_renderer; }
|
||||
|
||||
virtual wxRenderer *GetRenderer();
|
||||
virtual wxArtProvider *GetArtProvider();
|
||||
virtual wxInputHandler *GetInputHandler(const wxString& control,
|
||||
wxInputConsumer *consumer);
|
||||
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;
|
||||
}
|
||||
|
||||
wxTheme *m_win32Theme;
|
||||
wxMetalRenderer *m_renderer;
|
||||
wxRenderer *m_renderer;
|
||||
|
||||
WX_DECLARE_THEME(Metal)
|
||||
};
|
||||
|
||||
WX_IMPLEMENT_THEME(wxMetalTheme, Metal, wxTRANSLATE("Metal theme"));
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// 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();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxMetalRenderer
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user