2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: fontpicker.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxFontPickerCtrl
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-12 05:33:29 +00:00
|
|
|
|
|
|
|
#define wxFNTP_FONTDESC_AS_LABEL 0x0008
|
|
|
|
#define wxFNTP_USEFONT_FOR_LABEL 0x0010
|
|
|
|
#define wxFONTBTN_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL)
|
|
|
|
#define wxFNTP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
|
|
|
|
#define wxFNTP_DEFAULT_STYLE (wxFNTP_FONTDESC_AS_LABEL|wxFNTP_USEFONT_FOR_LABEL)
|
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
wxEventType wxEVT_FONTPICKER_CHANGED;
|
2012-04-12 05:33:29 +00:00
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxFontPickerCtrl
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This control allows the user to select a font. The generic implementation is
|
|
|
|
a button which brings up a wxFontDialog when clicked. Native implementation
|
|
|
|
may differ but this is usually a (small) widget which give access to the
|
2008-09-25 20:00:31 +00:00
|
|
|
font-chooser dialog.
|
2008-03-08 13:52:38 +00:00
|
|
|
It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@beginStyleTable
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxFNTP_DEFAULT_STYLE}
|
2008-09-25 20:00:31 +00:00
|
|
|
The default style: wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxFNTP_USE_TEXTCTRL}
|
2008-03-08 13:52:38 +00:00
|
|
|
Creates a text control to the left of the picker button which is
|
|
|
|
completely managed by the wxFontPickerCtrl and which can be used by
|
|
|
|
the user to specify a font (see SetSelectedFont). The text control
|
|
|
|
is automatically synchronized with button's value. Use functions
|
|
|
|
defined in wxPickerBase to modify the text control.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxFNTP_FONTDESC_AS_LABEL}
|
2008-03-08 13:52:38 +00:00
|
|
|
Keeps the label of the button updated with the fontface name and
|
|
|
|
the font size. E.g. choosing "Times New Roman bold, italic with
|
|
|
|
size 10" from the fontdialog, will update the label (overwriting
|
|
|
|
any previous label) with the "Times New Roman, 10" text.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxFNTP_USEFONT_FOR_LABEL}
|
2008-03-08 13:52:38 +00:00
|
|
|
Uses the currently selected font to draw the label of the button.
|
|
|
|
@endStyleTable
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2009-02-18 17:58:51 +00:00
|
|
|
@beginEventEmissionTable{wxFontPickerEvent}
|
2008-09-25 20:00:31 +00:00
|
|
|
@event{EVT_FONTPICKER_CHANGED(id, func)}
|
|
|
|
The user changed the font selected in the control either using the button
|
|
|
|
or using text control (see wxFNTP_USE_TEXTCTRL; note that in this case the
|
|
|
|
event is fired only if the user's input is valid, i.e. recognizable).
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
2008-04-08 05:34:11 +00:00
|
|
|
@category{pickers}
|
2012-11-03 18:32:50 +00:00
|
|
|
@appearance{fontpickerctrl}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
@see wxFontDialog, wxFontPickerEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxFontPickerCtrl : public wxPickerBase
|
|
|
|
{
|
|
|
|
public:
|
2012-04-12 05:33:29 +00:00
|
|
|
wxFontPickerCtrl();
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Initializes the object and calls Create() with
|
|
|
|
all the parameters.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxFontPickerCtrl(wxWindow* parent, wxWindowID id,
|
2008-03-08 13:52:38 +00:00
|
|
|
const wxFont& font = wxNullFont,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxFNTP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-11-09 16:46:52 +00:00
|
|
|
const wxString& name = wxFontPickerCtrlNameStr);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-09-25 20:00:31 +00:00
|
|
|
Creates this widget with given parameters.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param parent
|
2008-03-09 12:33:59 +00:00
|
|
|
Parent window, must not be non-@NULL.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param id
|
2008-03-09 12:33:59 +00:00
|
|
|
The identifier for the control.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param font
|
2008-09-25 20:00:31 +00:00
|
|
|
The initial font shown in the control.
|
|
|
|
If ::wxNullFont is given, the default font is used.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param pos
|
2008-03-09 12:33:59 +00:00
|
|
|
Initial position.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param size
|
2008-03-09 12:33:59 +00:00
|
|
|
Initial size.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param style
|
2008-03-09 12:33:59 +00:00
|
|
|
The window style, see wxFNTP_* flags.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param validator
|
2008-03-09 12:33:59 +00:00
|
|
|
Validator which can be used for additional date checks.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param name
|
2008-03-09 12:33:59 +00:00
|
|
|
Control name.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return @true if the control was successfully created or @false if
|
2008-03-09 12:33:59 +00:00
|
|
|
creation failed.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-03-08 13:52:38 +00:00
|
|
|
const wxFont& font = wxNullFont,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxFNTP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-10-29 15:34:31 +00:00
|
|
|
const wxString& name = wxFontPickerCtrlNameStr);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum point size value allowed for the user-chosen font.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
unsigned int GetMaxPointSize() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2016-11-22 01:31:11 +00:00
|
|
|
/**
|
|
|
|
Returns the minimum point size value allowed for the user-chosen font.
|
|
|
|
|
|
|
|
@since 3.1.1
|
|
|
|
*/
|
|
|
|
unsigned int GetMinPointSize() const;
|
|
|
|
|
2014-03-18 17:23:13 +00:00
|
|
|
/**
|
|
|
|
Returns the currently selected colour.
|
|
|
|
|
|
|
|
Note that the colour of the font can only be set by the user under
|
|
|
|
Windows currently, elsewhere this method simply returns the colour
|
|
|
|
previously set by SetSelectedColour() or black if it hadn't been called.
|
|
|
|
|
|
|
|
@since 3.1.0
|
|
|
|
*/
|
|
|
|
wxColour GetSelectedColour() const;
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Returns the currently selected font.
|
|
|
|
Note that this function is completely different from wxWindow::GetFont.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxFont GetSelectedFont() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the maximum point size value allowed for the user-chosen font.
|
2008-09-25 20:00:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The default value is 100. Note that big fonts can require a lot of memory and
|
2008-09-25 20:00:31 +00:00
|
|
|
CPU time both for creation and for rendering; thus, specially because the user
|
|
|
|
has the option to specify the fontsize through a text control
|
|
|
|
(see wxFNTP_USE_TEXTCTRL), it's a good idea to put a limit to the maximum
|
|
|
|
font size when huge fonts do not make much sense.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-30 10:53:56 +00:00
|
|
|
void SetMaxPointSize(unsigned int max);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2016-11-22 01:31:11 +00:00
|
|
|
/**
|
|
|
|
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);
|
|
|
|
|
2014-03-18 17:23:13 +00:00
|
|
|
/**
|
|
|
|
Sets the font colour.
|
|
|
|
|
|
|
|
The font colour is actually only used under Windows currently, but this
|
|
|
|
function is available under all platforms for consistency.
|
|
|
|
|
|
|
|
@since 3.1.0
|
|
|
|
*/
|
|
|
|
void SetSelectedColour(const wxColour& colour);
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Sets the currently selected font.
|
|
|
|
Note that this function is completely different from wxWindow::SetFont.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
void SetSelectedFont(const wxFont& font);
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
@class wxFontPickerEvent
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This event class is used for the events generated by
|
|
|
|
wxFontPickerCtrl.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-25 20:00:31 +00:00
|
|
|
@beginEventTable{wxFontPickerEvent}
|
|
|
|
@event{EVT_FONTPICKER_CHANGED(id, func)}
|
|
|
|
Generated whenever the selected font changes.
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
2008-09-25 20:00:31 +00:00
|
|
|
@category{events}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-10 15:24:38 +00:00
|
|
|
@see wxFontPickerCtrl
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxFontPickerEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
The constructor is not normally used by the user code.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxFontPickerEvent(wxObject* generator, int id,
|
2008-03-08 13:52:38 +00:00
|
|
|
const wxFont& font);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Retrieve the font the user has just selected.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxFont GetFont() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the font associated with the event.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
void SetFont(const wxFont& f);
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|