]>
Commit | Line | Data |
---|---|---|
1 | \section{\class{wxSymbolPickerDialog}}\label{wxsymbolpickerdialog} | |
2 | ||
3 | wxSymbolPickerDialog presents the user with a choice of fonts and a grid | |
4 | of available characters. This modal dialog provides the application with | |
5 | a selected symbol and optional font selection. | |
6 | ||
7 | Although this dialog is contained in the rich text library, the dialog | |
8 | is generic and can be used in other contexts. | |
9 | ||
10 | To use the dialog, pass a default symbol specified as a string, an initial font name, | |
11 | and a current font name. The difference between the initial font and | |
12 | current font is that the initial font determines what the font control will be | |
13 | set to when the dialog shows - an empty string will show the selection {\it normal text}. | |
14 | The current font, on the other hand, is used by the dialog to determine what font | |
15 | to display the characters in, even when no initial font is selected. | |
16 | This allows the user (and application) to distinguish between inserting a | |
17 | symbol in the current font, and inserting it with a specified font. | |
18 | ||
19 | When the dialog is dismissed, the application can get the selected symbol | |
20 | with GetSymbol and test whether a font was specified with UseNormalFont, | |
21 | fetching the specified font with GetFontName. | |
22 | ||
23 | Here's a realistic example, inserting the supplied symbol into a | |
24 | rich text control in either the current font or specified font. | |
25 | ||
26 | \begin{verbatim} | |
27 | wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL); | |
28 | ||
29 | wxTextAttrEx attr; | |
30 | attr.SetFlags(wxTEXT_ATTR_FONT); | |
31 | ctrl->GetStyle(ctrl->GetInsertionPoint(), attr); | |
32 | ||
33 | wxString currentFontName; | |
34 | if (attr.HasFont() && attr.GetFont().Ok()) | |
35 | currentFontName = attr.GetFont().GetFaceName(); | |
36 | ||
37 | // Don't set the initial font in the dialog (so the user is choosing | |
38 | // 'normal text', i.e. the current font) but do tell the dialog | |
39 | // what 'normal text' is. | |
40 | ||
41 | wxSymbolPickerDialog dlg(wxT("*"), wxEmptyString, currentFontName, this); | |
42 | ||
43 | if (dlg.ShowModal() == wxID_OK) | |
44 | { | |
45 | if (dlg.HasSelection()) | |
46 | { | |
47 | long insertionPoint = ctrl->GetInsertionPoint(); | |
48 | ||
49 | ctrl->WriteText(dlg.GetSymbol()); | |
50 | ||
51 | if (!dlg.UseNormalFont()) | |
52 | { | |
53 | wxFont font(attr.GetFont()); | |
54 | font.SetFaceName(dlg.GetFontName()); | |
55 | attr.SetFont(font); | |
56 | ctrl->SetStyle(insertionPoint, insertionPoint+1, attr); | |
57 | } | |
58 | } | |
59 | } | |
60 | \end{verbatim} | |
61 | ||
62 | \wxheading{Derived from} | |
63 | ||
64 | \helpref{wxDialog}{wxdialog} | |
65 | ||
66 | \wxheading{Include files} | |
67 | ||
68 | <wx/richtext/richtextsymboldlg.h> | |
69 | ||
70 | \wxheading{Data structures} | |
71 | ||
72 | \latexignore{\rtfignore{\wxheading{Members}}} | |
73 | ||
74 | ||
75 | \membersection{wxSymbolPickerDialog::wxSymbolPickerDialog}\label{wxsymbolpickerdialogwxsymbolpickerdialog} | |
76 | ||
77 | \func{}{wxSymbolPickerDialog}{\param{const wxString\& }{symbol}, \param{const wxString\& }{initialFont}, \param{const wxString\& }{normalTextFont}, \param{wxWindow* }{parent}, \param{wxWindowID }{id = wxID\_ANY}, \param{const wxString\& }{title = \_("Symbols")}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX}} | |
78 | ||
79 | \func{}{wxSymbolPickerDialog}{\void} | |
80 | ||
81 | Constructors. | |
82 | ||
83 | \wxheading{Parameters} | |
84 | ||
85 | \docparam{symbol}{The initial symbol to show. Specify a single character in a string, or an empty string.} | |
86 | ||
87 | \docparam{initialFont}{The initial font to be displayed in the font list. If empty, the item {\it normal text} will be selected.} | |
88 | ||
89 | \docparam{normalTextFont}{The font the dialog will use to display the symbols if the initial font is empty.} | |
90 | ||
91 | \docparam{parent}{The dialog's parent.} | |
92 | ||
93 | \docparam{id}{The dialog's identifier.} | |
94 | ||
95 | \docparam{title}{The dialog's caption.} | |
96 | ||
97 | \docparam{pos}{The dialog's position.} | |
98 | ||
99 | \docparam{size}{The dialog's size.} | |
100 | ||
101 | \docparam{style}{The dialog's window style.} | |
102 | ||
103 | \membersection{wxSymbolPickerDialog::Create}\label{wxsymbolpickerdialogcreate} | |
104 | ||
105 | \func{bool}{Create}{\param{const wxString\& }{symbol}, \param{const wxString\& }{initialFont}, \param{const wxString\& }{normalTextFont}, \param{wxWindow* }{parent}, \param{wxWindowID }{id = wxID\_ANY}, \param{const wxString\& }{title = \_("Symbols")}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX}} | |
106 | ||
107 | Creation: see \helpref{the constructor}{wxsymbolpickerdialogwxsymbolpickerdialog} for details about the parameters. | |
108 | ||
109 | \membersection{wxSymbolPickerDialog::GetFontName}\label{wxsymbolpickerdialoggetfontname} | |
110 | ||
111 | \constfunc{wxString}{GetFontName}{\void} | |
112 | ||
113 | Returns the font name (the font reflected in the font list). | |
114 | ||
115 | \membersection{wxSymbolPickerDialog::GetFromUnicode}\label{wxsymbolpickerdialoggetfromunicode} | |
116 | ||
117 | \constfunc{bool}{GetFromUnicode}{\void} | |
118 | ||
119 | Returns \true if the dialog is showing the full range of Unicode characters. | |
120 | ||
121 | \membersection{wxSymbolPickerDialog::GetNormalTextFontName}\label{wxsymbolpickerdialoggetnormaltextfontname} | |
122 | ||
123 | \constfunc{wxString}{GetNormalTextFontName}{\void} | |
124 | ||
125 | Gets the font name used for displaying symbols in the absence of a selected font. | |
126 | ||
127 | \membersection{wxSymbolPickerDialog::GetSymbol}\label{wxsymbolpickerdialoggetsymbol} | |
128 | ||
129 | \constfunc{wxString}{GetSymbol}{\void} | |
130 | ||
131 | Gets the current or initial symbol as a string. | |
132 | ||
133 | \membersection{wxSymbolPickerDialog::GetSymbolChar}\label{wxsymbolpickerdialoggetsymbolchar} | |
134 | ||
135 | \constfunc{int}{GetSymbolChar}{\void} | |
136 | ||
137 | Gets the selected symbol character as an integer. | |
138 | ||
139 | \membersection{wxSymbolPickerDialog::HasSelection}\label{wxsymbolpickerdialoghasselection} | |
140 | ||
141 | \constfunc{bool}{HasSelection}{\void} | |
142 | ||
143 | Returns \true if a symbol is selected. | |
144 | ||
145 | \membersection{wxSymbolPickerDialog::SetFontName}\label{wxsymbolpickerdialogsetfontname} | |
146 | ||
147 | \func{void}{SetFontName}{\param{const wxString\& }{value}} | |
148 | ||
149 | Sets the initial/selected font name. | |
150 | ||
151 | \membersection{wxSymbolPickerDialog::SetFromUnicode}\label{wxsymbolpickerdialogsetfromunicode} | |
152 | ||
153 | \func{void}{SetFromUnicode}{\param{bool }{value}} | |
154 | ||
155 | Sets the internal flag indicating that the full Unicode range should be displayed. | |
156 | ||
157 | \membersection{wxSymbolPickerDialog::SetNormalTextFontName}\label{wxsymbolpickerdialogsetnormaltextfontname} | |
158 | ||
159 | \func{void}{SetNormalTextFontName}{\param{const wxString\& }{value}} | |
160 | ||
161 | Sets the name of the font to be used in the absence of a selected font. | |
162 | ||
163 | \membersection{wxSymbolPickerDialog::SetSymbol}\label{wxsymbolpickerdialogsetsymbol} | |
164 | ||
165 | \func{void}{SetSymbol}{\param{const wxString\& }{value}} | |
166 | ||
167 | Sets the symbol as a one or zero character string. | |
168 | ||
169 | \membersection{wxSymbolPickerDialog::SetUnicodeMode}\label{wxsymbolpickerdialogsetunicodemode} | |
170 | ||
171 | \func{void}{SetUnicodeMode}{\param{bool }{unicodeMode}} | |
172 | ||
173 | Sets Unicode display mode. | |
174 | ||
175 | \membersection{wxSymbolPickerDialog::UseNormalFont}\label{wxsymbolpickerdialogusenormalfont} | |
176 | ||
177 | \constfunc{bool}{UseNormalFont}{\void} | |
178 | ||
179 | Returns true if the has specified normal text - that is, there is no selected font. | |
180 |