]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/fontpicker.h
general docview.cpp code cleanup; use wxVector<> instead of manually-allocated arrays...
[wxWidgets.git] / interface / wx / fontpicker.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fontpicker.h
3 // Purpose: interface of wxFontPickerCtrl
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxFontPickerCtrl
11
12 This control allows the user to select a font. The generic implementation is
13 a button which brings up a wxFontDialog when clicked. Native implementation
14 may differ but this is usually a (small) widget which give access to the
15 font-chooser
16 dialog.
17 It is only available if @c wxUSE_FONTPICKERCTRL is set to 1 (the default).
18
19 @beginStyleTable
20 @style{wxFNTP_DEFAULT_STYLE}
21 The default style: wxFNTP_FONTDESC_AS_LABEL |
22 wxFNTP_USEFONT_FOR_LABEL.
23 @style{wxFNTP_USE_TEXTCTRL}
24 Creates a text control to the left of the picker button which is
25 completely managed by the wxFontPickerCtrl and which can be used by
26 the user to specify a font (see SetSelectedFont). The text control
27 is automatically synchronized with button's value. Use functions
28 defined in wxPickerBase to modify the text control.
29 @style{wxFNTP_FONTDESC_AS_LABEL}
30 Keeps the label of the button updated with the fontface name and
31 the font size. E.g. choosing "Times New Roman bold, italic with
32 size 10" from the fontdialog, will update the label (overwriting
33 any previous label) with the "Times New Roman, 10" text.
34 @style{wxFNTP_USEFONT_FOR_LABEL}
35 Uses the currently selected font to draw the label of the button.
36 @endStyleTable
37
38 @library{wxcore}
39 @category{pickers}
40 <!-- @appearance{fontpickerctrl.png} -->
41
42 @see wxFontDialog, wxFontPickerEvent
43 */
44 class wxFontPickerCtrl : public wxPickerBase
45 {
46 public:
47 /**
48 Initializes the object and calls Create() with
49 all the parameters.
50 */
51 wxFontPickerCtrl(wxWindow* parent, wxWindowID id,
52 const wxFont& font = wxNullFont,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = wxFNTP_DEFAULT_STYLE,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = "fontpickerctrl");
58
59 /**
60 @param parent
61 Parent window, must not be non-@NULL.
62 @param id
63 The identifier for the control.
64 @param font
65 The initial font shown in the control. If wxNullFont
66 is given, the default font is used.
67 @param pos
68 Initial position.
69 @param size
70 Initial size.
71 @param style
72 The window style, see wxFNTP_* flags.
73 @param validator
74 Validator which can be used for additional date checks.
75 @param name
76 Control name.
77
78 @return @true if the control was successfully created or @false if
79 creation failed.
80 */
81 bool Create(wxWindow* parent, wxWindowID id,
82 const wxFont& font = wxNullFont,
83 const wxPoint& pos = wxDefaultPosition,
84 const wxSize& size = wxDefaultSize,
85 long style = wxFNTP_DEFAULT_STYLE,
86 const wxValidator& validator = wxDefaultValidator,
87 const wxString& name = "fontpickerctrl");
88
89 /**
90 Returns the maximum point size value allowed for the user-chosen font.
91 */
92 unsigned int GetMaxPointSize() const;
93
94 /**
95 Returns the currently selected font.
96 Note that this function is completely different from wxWindow::GetFont.
97 */
98 wxFont GetSelectedFont() const;
99
100 /**
101 Sets the maximum point size value allowed for the user-chosen font.
102 The default value is 100. Note that big fonts can require a lot of memory and
103 CPU time
104 both for creation and for rendering; thus, specially because the user has the
105 option to specify
106 the fontsize through a text control (see wxFNTP_USE_TEXTCTRL), it's a good idea
107 to put a limit
108 to the maximum font size when huge fonts do not make much sense.
109 */
110 void GetMaxPointSize(unsigned int max);
111
112 /**
113 Sets the currently selected font.
114 Note that this function is completely different from wxWindow::SetFont.
115 */
116 void SetSelectedFont(const wxFont& font);
117 };
118
119
120
121 /**
122 @class wxFontPickerEvent
123
124 This event class is used for the events generated by
125 wxFontPickerCtrl.
126
127 @library{wxcore}
128 @category{FIXME}
129
130 @see wxFontPickerCtrl
131 */
132 class wxFontPickerEvent : public wxCommandEvent
133 {
134 public:
135 /**
136 The constructor is not normally used by the user code.
137 */
138 wxFontPickerEvent(wxObject* generator, int id,
139 const wxFont& font);
140
141 /**
142 Retrieve the font the user has just selected.
143 */
144 wxFont GetFont() const;
145
146 /**
147 Set the font associated with the event.
148 */
149 void SetFont(const wxFont& f);
150 };
151