Add wxFontPickerCtrl::SetMinPointSize()

Allow setting the minimal, as well as maximal, point size.

Closes #17126.
This commit is contained in:
Andreas Falkenhahn 2016-11-22 02:31:11 +01:00 committed by Vadim Zeitlin
parent 60c93971b3
commit accf7ab117
4 changed files with 47 additions and 6 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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.

View File

@ -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