Add font colour support to wxFontPickerCtrl.

Currently this is only really implemented under Windows, just as the colour
support in wxFontDialog, but make the API available under all platforms for
consistency.

Closes #11614.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76160 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-03-18 17:23:13 +00:00
parent 9e7dbef726
commit 399371921f
7 changed files with 78 additions and 4 deletions

View File

@@ -41,6 +41,9 @@ public:
virtual void SetSelectedFont(const wxFont &f)
{ m_selectedFont = f; UpdateFont(); }
virtual wxColour GetSelectedColour() const = 0;
virtual void SetSelectedColour(const wxColour &colour) = 0;
protected:
virtual void UpdateFont() = 0;
@@ -138,7 +141,15 @@ public: // public API
// sets currently displayed font
void SetSelectedFont(const wxFont& f);
// set/get the max pointsize
// returns the selected color
wxColour GetSelectedColour() const
{ return GetPickerWidget()->GetSelectedColour(); }
// sets the currently selected color
void SetSelectedColour(const wxColour& colour)
{ GetPickerWidget()->SetSelectedColour(colour); }
// set/get the max point size
void SetMaxPointSize(unsigned int max)
{ m_nMaxPointSize=max; }
unsigned int GetMaxPointSize() const

View File

@@ -35,6 +35,12 @@ public:
Create(parent, id, initial, pos, size, style, validator, name);
}
virtual wxColour GetSelectedColour() const
{ return m_data.GetColour(); }
virtual void SetSelectedColour(const wxColour &colour)
{ m_data.SetColour(colour); UpdateFont(); }
virtual ~wxGenericFontButton() {}

View File

@@ -21,7 +21,7 @@ class WXDLLIMPEXP_CORE wxFontButton : public wxButton,
public wxFontPickerWidgetBase
{
public:
wxFontButton() {}
wxFontButton() { Init(); }
wxFontButton(wxWindow *parent,
wxWindowID id,
const wxFont& initial = wxNullFont,
@@ -31,7 +31,9 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxFontPickerWidgetNameStr)
{
Create(parent, id, initial, pos, size, style, validator, name);
Init();
Create(parent, id, initial, pos, size, style, validator, name);
}
bool Create(wxWindow *parent,
@@ -43,6 +45,12 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxFontPickerWidgetNameStr);
virtual wxColour GetSelectedColour() const
{ return m_selectedColour; }
void SetSelectedColour(const wxColour &colour)
{ m_selectedColour = colour; }
virtual ~wxFontButton();
protected:
@@ -55,6 +63,16 @@ public: // used by the GTK callback only
{ m_selectedFont.SetNativeFontInfo(wxString::FromAscii(gtkdescription)); }
private:
// Common part of both ctors.
void Init()
{
m_selectedColour = *wxBLACK;
}
// This can't be changed by the user, but is provided to
// satisfy the wxFontPickerWidgetBase interface.
wxColour m_selectedColour;
DECLARE_DYNAMIC_CLASS(wxFontButton)
};