diff --git a/include/wx/fontpicker.h b/include/wx/fontpicker.h index 1bacc3a4a0..6df6f950b5 100644 --- a/include/wx/fontpicker.h +++ b/include/wx/fontpicker.h @@ -133,7 +133,7 @@ public: // public API // get the font chosen wxFont GetSelectedFont() const - { return ((wxFontPickerWidget *)m_picker)->GetSelectedFont(); } + { return GetPickerWidget()->GetSelectedFont(); } // sets currently displayed font void SetSelectedFont(const wxFont& f); @@ -166,6 +166,9 @@ protected: unsigned int m_nMaxPointSize; private: + wxFontPickerWidget* GetPickerWidget() const + { return static_cast(m_picker); } + DECLARE_DYNAMIC_CLASS(wxFontPickerCtrl) }; diff --git a/src/common/fontpickercmn.cpp b/src/common/fontpickercmn.cpp index 83e6a36e17..bed2d90b42 100644 --- a/src/common/fontpickercmn.cpp +++ b/src/common/fontpickercmn.cpp @@ -49,8 +49,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxFontPickerEvent, wxCommandEvent) // wxFontPickerCtrl // ---------------------------------------------------------------------------- -#define M_PICKER ((wxFontPickerWidget*)m_picker) - bool wxFontPickerCtrl::Create( wxWindow *parent, wxWindowID id, const wxFont &initial, const wxPoint &pos, const wxSize &size, @@ -116,7 +114,7 @@ wxFont wxFontPickerCtrl::String2Font(const wxString &s) void wxFontPickerCtrl::SetSelectedFont(const wxFont &f) { - M_PICKER->SetSelectedFont(f); + GetPickerWidget()->SetSelectedFont(f); UpdateTextCtrlFromPicker(); } @@ -132,9 +130,9 @@ void wxFontPickerCtrl::UpdatePickerFromTextCtrl() if (!f.IsOk()) return; // invalid user input - if (M_PICKER->GetSelectedFont() != f) + if (GetPickerWidget()->GetSelectedFont() != f) { - M_PICKER->SetSelectedFont(f); + GetPickerWidget()->SetSelectedFont(f); // fire an event wxFontPickerEvent event(this, GetId(), f); @@ -149,7 +147,7 @@ void wxFontPickerCtrl::UpdateTextCtrlFromPicker() // Take care to use ChangeValue() here and not SetValue() to avoid // infinite recursion. - m_text->ChangeValue(Font2String(M_PICKER->GetSelectedFont())); + m_text->ChangeValue(Font2String(GetPickerWidget()->GetSelectedFont())); }