wxFontData doesn't need to be static in wxGenericFontButton (unlike wxColourData in wxGenericColourButton where it was copied from) (patch 1883375)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
#include "wx/cmndata.h"
|
#include "wx/cmndata.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxGenericFontButton: a button which brings up a wxColourDialog
|
// wxGenericFontButton: a button which brings up a wxFontDialog
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxGenericFontButton : public wxButton,
|
class WXDLLIMPEXP_CORE wxGenericFontButton : public wxButton,
|
||||||
@@ -44,8 +44,8 @@ public: // API extensions specific for wxGenericFontButton
|
|||||||
// user can override this to init font data in a different way
|
// user can override this to init font data in a different way
|
||||||
virtual void InitFontData();
|
virtual void InitFontData();
|
||||||
|
|
||||||
// returns the font data shown in wxColourDialog
|
// returns the font data shown in wxFontDialog
|
||||||
wxFontData *GetFontData() { return &ms_data; }
|
wxFontData *GetFontData() { return &m_data; }
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -66,10 +66,7 @@ protected:
|
|||||||
|
|
||||||
void UpdateFont();
|
void UpdateFont();
|
||||||
|
|
||||||
// the colour data shown in wxColourPickerCtrlGeneric
|
wxFontData m_data;
|
||||||
// controls. This member is static so that all colour pickers
|
|
||||||
// in the program share the same set of custom colours.
|
|
||||||
static wxFontData ms_data;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxGenericFontButton)
|
DECLARE_DYNAMIC_CLASS(wxGenericFontButton)
|
||||||
|
@@ -35,7 +35,6 @@
|
|||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
wxFontData wxGenericFontButton::ms_data;
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxGenericFontButton, wxButton)
|
IMPLEMENT_DYNAMIC_CLASS(wxGenericFontButton, wxButton)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -73,22 +72,22 @@ bool wxGenericFontButton::Create( wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
void wxGenericFontButton::InitFontData()
|
void wxGenericFontButton::InitFontData()
|
||||||
{
|
{
|
||||||
ms_data.SetAllowSymbols(true);
|
m_data.SetAllowSymbols(true);
|
||||||
ms_data.SetColour(*wxBLACK);
|
m_data.SetColour(*wxBLACK);
|
||||||
ms_data.EnableEffects(true);
|
m_data.EnableEffects(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericFontButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
|
void wxGenericFontButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
|
||||||
{
|
{
|
||||||
// update the wxFontData to be shown in the the dialog
|
// update the wxFontData to be shown in the the dialog
|
||||||
ms_data.SetInitialFont(m_selectedFont);
|
m_data.SetInitialFont(m_selectedFont);
|
||||||
|
|
||||||
// create the font dialog and display it
|
// create the font dialog and display it
|
||||||
wxFontDialog dlg(this, ms_data);
|
wxFontDialog dlg(this, m_data);
|
||||||
if (dlg.ShowModal() == wxID_OK)
|
if (dlg.ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
ms_data = dlg.GetFontData();
|
m_data = dlg.GetFontData();
|
||||||
SetSelectedFont(ms_data.GetChosenFont());
|
SetSelectedFont(m_data.GetChosenFont());
|
||||||
|
|
||||||
// fire an event
|
// fire an event
|
||||||
wxFontPickerEvent event(this, GetId(), m_selectedFont);
|
wxFontPickerEvent event(this, GetId(), m_selectedFont);
|
||||||
@@ -101,7 +100,7 @@ void wxGenericFontButton::UpdateFont()
|
|||||||
if ( !m_selectedFont.Ok() )
|
if ( !m_selectedFont.Ok() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetForegroundColour(ms_data.GetColour());
|
SetForegroundColour(m_data.GetColour());
|
||||||
|
|
||||||
if (HasFlag(wxFNTP_USEFONT_FOR_LABEL))
|
if (HasFlag(wxFNTP_USEFONT_FOR_LABEL))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user