]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: richtext/richtextsymboldlg.h | |
21b447dc | 3 | // Purpose: interface of wxSymbolPickerDialog |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxSymbolPickerDialog | |
7c913512 | 11 | |
23324ae1 FM |
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. | |
7c913512 | 15 | |
23324ae1 FM |
16 | Although this dialog is contained in the rich text library, the dialog |
17 | is generic and can be used in other contexts. | |
7c913512 | 18 | |
23324ae1 FM |
19 | To use the dialog, pass a default symbol specified as a string, an initial font |
20 | name, | |
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 | |
24 | normal text. | |
25 | The current font, on the other hand, is used by the dialog to determine what | |
26 | font | |
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. | |
7c913512 | 30 | |
23324ae1 FM |
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. | |
7c913512 | 34 | |
23324ae1 FM |
35 | Here's a realistic example, inserting the supplied symbol into a |
36 | rich text control in either the current font or specified font. | |
7c913512 | 37 | |
23324ae1 FM |
38 | @code |
39 | wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL); | |
7c913512 | 40 | |
23324ae1 FM |
41 | wxTextAttr attr; |
42 | attr.SetFlags(wxTEXT_ATTR_FONT); | |
43 | ctrl-GetStyle(ctrl-GetInsertionPoint(), attr); | |
7c913512 | 44 | |
23324ae1 FM |
45 | wxString currentFontName; |
46 | if (attr.HasFont() && attr.GetFont().Ok()) | |
47 | currentFontName = attr.GetFont().GetFaceName(); | |
7c913512 | 48 | |
23324ae1 FM |
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. | |
7c913512 | 52 | |
23324ae1 | 53 | wxSymbolPickerDialog dlg(wxT("*"), wxEmptyString, currentFontName, this); |
7c913512 | 54 | |
23324ae1 FM |
55 | if (dlg.ShowModal() == wxID_OK) |
56 | { | |
57 | if (dlg.HasSelection()) | |
58 | { | |
59 | long insertionPoint = ctrl-GetInsertionPoint(); | |
7c913512 | 60 | |
23324ae1 | 61 | ctrl-WriteText(dlg.GetSymbol()); |
7c913512 | 62 | |
23324ae1 FM |
63 | if (!dlg.UseNormalFont()) |
64 | { | |
65 | wxFont font(attr.GetFont()); | |
66 | font.SetFaceName(dlg.GetFontName()); | |
67 | attr.SetFont(font); | |
68 | ctrl-SetStyle(insertionPoint, insertionPoint+1, attr); | |
69 | } | |
70 | } | |
71 | } | |
72 | @endcode | |
7c913512 | 73 | |
23324ae1 FM |
74 | @library{wxrichtext} |
75 | @category{cmndlg} | |
76 | */ | |
77 | class wxSymbolPickerDialog : public wxDialog | |
78 | { | |
79 | public: | |
80 | //@{ | |
81 | /** | |
82 | Constructors. | |
83 | ||
7c913512 | 84 | @param symbol |
4cc4bfaf FM |
85 | The initial symbol to show. Specify a single character in a string, or an |
86 | empty string. | |
7c913512 | 87 | @param initialFont |
4cc4bfaf FM |
88 | The initial font to be displayed in the font list. If empty, the item |
89 | normal text will be selected. | |
7c913512 | 90 | @param normalTextFont |
4cc4bfaf | 91 | The font the dialog will use to display the symbols if the initial font is |
23324ae1 | 92 | empty. |
7c913512 | 93 | @param parent |
4cc4bfaf | 94 | The dialog's parent. |
7c913512 | 95 | @param id |
4cc4bfaf | 96 | The dialog's identifier. |
7c913512 | 97 | @param title |
4cc4bfaf | 98 | The dialog's caption. |
7c913512 | 99 | @param pos |
4cc4bfaf | 100 | The dialog's position. |
7c913512 | 101 | @param size |
4cc4bfaf | 102 | The dialog's size. |
7c913512 | 103 | @param style |
4cc4bfaf | 104 | The dialog's window style. |
23324ae1 FM |
105 | */ |
106 | wxSymbolPickerDialog(const wxString& symbol, | |
107 | const wxString& initialFont, | |
108 | const wxString& normalTextFont, | |
109 | wxWindow* parent, | |
110 | wxWindowID id = wxID_ANY); | |
7c913512 FM |
111 | const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX) |
112 | wxSymbolPickerDialog(); | |
23324ae1 FM |
113 | //@} |
114 | ||
115 | /** | |
328f5751 FM |
116 | , wxPoint&@e pos = wxDefaultPosition, wxSize&@e size = wxDefaultSize, @b |
117 | long@e style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX) | |
23324ae1 FM |
118 | Creation: see @ref wxsymbolpickerdialog() "the constructor" for details about |
119 | the parameters. | |
120 | */ | |
121 | bool Create(const wxString& symbol, const wxString& initialFont, | |
122 | const wxString& normalTextFont, | |
123 | wxWindow* parent, | |
328f5751 | 124 | wxWindowID id = wxID_ANY) const; |
23324ae1 FM |
125 | |
126 | /** | |
127 | Returns the font name (the font reflected in the font list). | |
128 | */ | |
328f5751 | 129 | wxString GetFontName() const; |
23324ae1 FM |
130 | |
131 | /** | |
132 | Returns @true if the dialog is showing the full range of Unicode characters. | |
133 | */ | |
328f5751 | 134 | bool GetFromUnicode() const; |
23324ae1 FM |
135 | |
136 | /** | |
137 | Gets the font name used for displaying symbols in the absence of a selected | |
138 | font. | |
139 | */ | |
328f5751 | 140 | wxString GetNormalTextFontName() const; |
23324ae1 FM |
141 | |
142 | /** | |
143 | Gets the current or initial symbol as a string. | |
144 | */ | |
328f5751 | 145 | wxString GetSymbol() const; |
23324ae1 FM |
146 | |
147 | /** | |
148 | Gets the selected symbol character as an integer. | |
149 | */ | |
328f5751 | 150 | int GetSymbolChar() const; |
23324ae1 FM |
151 | |
152 | /** | |
153 | Returns @true if a symbol is selected. | |
154 | */ | |
328f5751 | 155 | bool HasSelection() const; |
23324ae1 FM |
156 | |
157 | /** | |
158 | Sets the initial/selected font name. | |
159 | */ | |
160 | void SetFontName(const wxString& value); | |
161 | ||
162 | /** | |
163 | Sets the internal flag indicating that the full Unicode range should be | |
164 | displayed. | |
165 | */ | |
166 | void SetFromUnicode(bool value); | |
167 | ||
168 | /** | |
169 | Sets the name of the font to be used in the absence of a selected font. | |
170 | */ | |
171 | void SetNormalTextFontName(const wxString& value); | |
172 | ||
173 | /** | |
174 | Sets the symbol as a one or zero character string. | |
175 | */ | |
176 | void SetSymbol(const wxString& value); | |
177 | ||
178 | /** | |
179 | Sets Unicode display mode. | |
180 | */ | |
181 | void SetUnicodeMode(bool unicodeMode); | |
182 | ||
183 | /** | |
184 | Returns @true if the has specified normal text - that is, there is no selected | |
185 | font. | |
186 | */ | |
328f5751 | 187 | bool UseNormalFont() const; |
23324ae1 | 188 | }; |
e54c96f1 | 189 |