2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: fontpicker.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxFontPickerCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxFontPickerCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05: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 16:00:31 -04:00
|
|
|
font-chooser dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFNTP_DEFAULT_STYLE}
|
2008-09-25 16:00:31 -04:00
|
|
|
The default style: wxFNTP_FONTDESC_AS_LABEL | wxFNTP_USEFONT_FOR_LABEL.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFNTP_USE_TEXTCTRL}
|
2008-03-08 08:52:38 -05: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 10:43:04 -04:00
|
|
|
@style{wxFNTP_FONTDESC_AS_LABEL}
|
2008-03-08 08:52:38 -05: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 10:43:04 -04:00
|
|
|
@style{wxFNTP_USEFONT_FOR_LABEL}
|
2008-03-08 08:52:38 -05:00
|
|
|
Uses the currently selected font to draw the label of the button.
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 16:00:31 -04:00
|
|
|
@beginEventTable{wxFontPickerEvent}
|
|
|
|
@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 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-04-08 01:34:11 -04:00
|
|
|
@category{pickers}
|
2008-10-13 04:05:18 -04:00
|
|
|
@appearance{fontpickerctrl.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxFontDialog, wxFontPickerEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFontPickerCtrl : public wxPickerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Initializes the object and calls Create() with
|
|
|
|
all the parameters.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFontPickerCtrl(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxFont& font = wxNullFont,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxFNTP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = "fontpickerctrl");
|
|
|
|
|
|
|
|
/**
|
2008-09-25 16:00:31 -04:00
|
|
|
Creates this widget with given parameters.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window, must not be non-@NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
The identifier for the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param font
|
2008-09-25 16:00:31 -04:00
|
|
|
The initial font shown in the control.
|
|
|
|
If ::wxNullFont is given, the default font is used.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
The window style, see wxFNTP_* flags.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Validator which can be used for additional date checks.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Control name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the control was successfully created or @false if
|
2008-03-09 08:33:59 -04:00
|
|
|
creation failed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05: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 11:34:31 -04:00
|
|
|
const wxString& name = wxFontPickerCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the maximum point size value allowed for the user-chosen font.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
unsigned int GetMaxPointSize() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the currently selected font.
|
|
|
|
Note that this function is completely different from wxWindow::GetFont.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFont GetSelectedFont() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the maximum point size value allowed for the user-chosen font.
|
2008-09-25 16:00:31 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The default value is 100. Note that big fonts can require a lot of memory and
|
2008-09-25 16:00:31 -04: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 08:52:38 -05:00
|
|
|
*/
|
2008-10-29 12:00:56 -04:00
|
|
|
void SetMaxPointSize(unsigned int) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the currently selected font.
|
|
|
|
Note that this function is completely different from wxWindow::SetFont.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetSelectedFont(const wxFont& font);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFontPickerEvent
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This event class is used for the events generated by
|
|
|
|
wxFontPickerCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 16:00:31 -04:00
|
|
|
@beginEventTable{wxFontPickerEvent}
|
|
|
|
@event{EVT_FONTPICKER_CHANGED(id, func)}
|
|
|
|
Generated whenever the selected font changes.
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-09-25 16:00:31 -04:00
|
|
|
@category{events}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxFontPickerCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFontPickerEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
The constructor is not normally used by the user code.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFontPickerEvent(wxObject* generator, int id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxFont& font);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Retrieve the font the user has just selected.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFont GetFont() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the font associated with the event.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetFont(const wxFont& f);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|