]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/richtext/richtextsymboldlg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextsymboldlg.h
3 // Purpose: interface of wxSymbolPickerDialog
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxSymbolPickerDialog
12 wxSymbolPickerDialog presents the user with a choice of fonts and a grid
13 of available characters. This modal dialog provides the application with
14 a selected symbol and optional font selection.
16 Although this dialog is contained in the rich text library, the dialog
17 is generic and can be used in other contexts.
19 To use the dialog, pass a default symbol specified as a string, an initial font
21 and a current font name. The difference between the initial font and
22 current font is that the initial font determines what the font control will be
23 set to when the dialog shows - an empty string will show the selection @e
25 The current font, on the other hand, is used by the dialog to determine what
27 to display the characters in, even when no initial font is selected.
28 This allows the user (and application) to distinguish between inserting a
29 symbol in the current font, and inserting it with a specified font.
31 When the dialog is dismissed, the application can get the selected symbol
32 with GetSymbol and test whether a font was specified with UseNormalFont,
33 fetching the specified font with GetFontName.
35 Here's a realistic example, inserting the supplied symbol into a
36 rich text control in either the current font or specified font.
39 wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL);
42 attr.SetFlags(wxTEXT_ATTR_FONT);
43 ctrl-GetStyle(ctrl-GetInsertionPoint(), attr);
45 wxString currentFontName;
46 if (attr.HasFont() && attr.GetFont().Ok())
47 currentFontName = attr.GetFont().GetFaceName();
49 // Don't set the initial font in the dialog (so the user is choosing
50 // 'normal text', i.e. the current font) but do tell the dialog
51 // what 'normal text' is.
53 wxSymbolPickerDialog dlg(wxT("*"), wxEmptyString, currentFontName, this);
55 if (dlg.ShowModal() == wxID_OK)
57 if (dlg.HasSelection())
59 long insertionPoint = ctrl-GetInsertionPoint();
61 ctrl-WriteText(dlg.GetSymbol());
63 if (!dlg.UseNormalFont())
65 wxFont font(attr.GetFont());
66 font.SetFaceName(dlg.GetFontName());
68 ctrl-SetStyle(insertionPoint, insertionPoint+1, attr);
77 class wxSymbolPickerDialog
: public wxDialog
85 The initial symbol to show. Specify a single character in a string, or an
88 The initial font to be displayed in the font list. If empty, the item
89 normal text will be selected.
91 The font the dialog will use to display the symbols if the initial font is
96 The dialog's identifier.
100 The dialog's position.
104 The dialog's window style.
106 wxSymbolPickerDialog(const wxString
& symbol
,
107 const wxString
& initialFont
,
108 const wxString
& normalTextFont
,
110 wxWindowID id
= wxID_ANY
);
111 const wxSize
& size
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
|wxCLOSE_BOX
)
112 wxSymbolPickerDialog();
116 , wxPoint&@e pos = wxDefaultPosition, wxSize&@e size = wxDefaultSize, @b
117 long@e style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX)
118 Creation: see @ref wxsymbolpickerdialog() "the constructor" for details about
121 bool Create(const wxString
& symbol
, const wxString
& initialFont
,
122 const wxString
& normalTextFont
,
124 wxWindowID id
= wxID_ANY
) const;
127 Returns the font name (the font reflected in the font list).
129 wxString
GetFontName() const;
132 Returns @true if the dialog is showing the full range of Unicode characters.
134 bool GetFromUnicode() const;
137 Gets the font name used for displaying symbols in the absence of a selected
140 wxString
GetNormalTextFontName() const;
143 Gets the current or initial symbol as a string.
145 wxString
GetSymbol() const;
148 Gets the selected symbol character as an integer.
150 int GetSymbolChar() const;
153 Returns @true if a symbol is selected.
155 bool HasSelection() const;
158 Sets the initial/selected font name.
160 void SetFontName(const wxString
& value
);
163 Sets the internal flag indicating that the full Unicode range should be
166 void SetFromUnicode(bool value
);
169 Sets the name of the font to be used in the absence of a selected font.
171 void SetNormalTextFontName(const wxString
& value
);
174 Sets the symbol as a one or zero character string.
176 void SetSymbol(const wxString
& value
);
179 Sets Unicode display mode.
181 void SetUnicodeMode(bool unicodeMode
);
184 Returns @true if the has specified normal text - that is, there is no selected
187 bool UseNormalFont() const;