From accf7ab117c0a5fafffaccff6000ead4c121afbf Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Tue, 22 Nov 2016 02:31:11 +0100 Subject: [PATCH] Add wxFontPickerCtrl::SetMinPointSize() Allow setting the minimal, as well as maximal, point size. Closes #17126. --- docs/changes.txt | 1 + include/wx/fontpicker.h | 20 ++++++++++++++------ interface/wx/fontpicker.h | 16 ++++++++++++++++ src/common/fontpickercmn.cpp | 16 ++++++++++++++++ 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 2fc8fefdb8..3ba68e3d10 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -157,6 +157,7 @@ All (GUI): - Fix escaping/unescaping characters in wxLongStringProperty in wxPG (mikek). - Ensure that navigation order reflects layout of wxStdDialogButtonSizer. - Add Scintilla FineTicker methods to wxSTC (NewPagodi). +- Add wxFontPickerCtrl::SetMinPointSize() (Andreas Falkenhahn). wxGTK: diff --git a/include/wx/fontpicker.h b/include/wx/fontpicker.h index 2de3c0fa66..323ab8df40 100644 --- a/include/wx/fontpicker.h +++ b/include/wx/fontpicker.h @@ -88,7 +88,8 @@ protected: #define wxFNTP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL) #define wxFNTP_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL) -// not a style but rather the default value of the maximum pointsize allowed +// not a style but rather the default value of the minimum/maximum pointsize allowed +#define wxFNTP_MINPOINT_SIZE 0 #define wxFNTP_MAXPOINT_SIZE 100 @@ -101,8 +102,8 @@ protected: class WXDLLIMPEXP_CORE wxFontPickerCtrl : public wxPickerBase { public: - wxFontPickerCtrl() - : m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) + wxFontPickerCtrl() + : m_nMinPointSize(wxFNTP_MINPOINT_SIZE), m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) { } @@ -117,7 +118,7 @@ public: long style = wxFNTP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxFontPickerCtrlNameStr) - : m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) + : m_nMinPointSize(wxFNTP_MINPOINT_SIZE), m_nMaxPointSize(wxFNTP_MAXPOINT_SIZE) { Create(parent, id, initial, pos, size, style, validator, name); } @@ -149,9 +150,13 @@ public: // public API void SetSelectedColour(const wxColour& colour) { GetPickerWidget()->SetSelectedColour(colour); } + // set/get the min point size + void SetMinPointSize(unsigned int min); + unsigned int GetMinPointSize() const + { return m_nMinPointSize; } + // set/get the max point size - void SetMaxPointSize(unsigned int max) - { m_nMaxPointSize=max; } + void SetMaxPointSize(unsigned int max); unsigned int GetMaxPointSize() const { return m_nMaxPointSize; } @@ -173,6 +178,9 @@ protected: long GetPickerStyle(long style) const wxOVERRIDE { return (style & (wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL)); } + // the minimum pointsize allowed to the user + unsigned int m_nMinPointSize; + // the maximum pointsize allowed to the user unsigned int m_nMaxPointSize; diff --git a/interface/wx/fontpicker.h b/interface/wx/fontpicker.h index 61bcae95f6..7282c4f4cc 100644 --- a/interface/wx/fontpicker.h +++ b/interface/wx/fontpicker.h @@ -109,6 +109,13 @@ public: */ unsigned int GetMaxPointSize() const; + /** + Returns the minimum point size value allowed for the user-chosen font. + + @since 3.1.1 + */ + unsigned int GetMinPointSize() const; + /** Returns the currently selected colour. @@ -137,6 +144,15 @@ public: */ void SetMaxPointSize(unsigned int max); + /** + Sets the minimum point size value allowed for the user-chosen font. + + The default value is 0. + + @since 3.1.1 + */ + void SetMinPointSize(unsigned int min); + /** Sets the font colour. diff --git a/src/common/fontpickercmn.cpp b/src/common/fontpickercmn.cpp index 3e7e1f849c..40b96f9432 100644 --- a/src/common/fontpickercmn.cpp +++ b/src/common/fontpickercmn.cpp @@ -38,6 +38,12 @@ // implementation // ============================================================================ +#if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__) + #define SetMinMaxPointSize(min, max) +#else + #define SetMinMaxPointSize(min, max) GetPickerWidget()->GetFontData()->SetRange((min), (max)) +#endif + const char wxFontPickerCtrlNameStr[] = "fontpicker"; const char wxFontPickerWidgetNameStr[] = "fontpickerwidget"; @@ -150,7 +156,17 @@ void wxFontPickerCtrl::UpdateTextCtrlFromPicker() m_text->ChangeValue(Font2String(GetPickerWidget()->GetSelectedFont())); } +void wxFontPickerCtrl::SetMinPointSize(unsigned int min) +{ + m_nMinPointSize = min; + SetMinMaxPointSize(m_nMinPointSize, m_nMaxPointSize); +} +void wxFontPickerCtrl::SetMaxPointSize(unsigned int max) +{ + m_nMaxPointSize = max; + SetMinMaxPointSize(m_nMinPointSize, m_nMaxPointSize); +} // ---------------------------------------------------------------------------- // wxFontPickerCtrl - event handlers