1 \section{\class{wxSymbolPickerDialog
}}\label{wxsymbolpickerdialog
}
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.
7 Although this dialog is contained in the rich text library, the dialog
8 is generic and can be used in other contexts.
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.
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.
23 Here's a realistic example, inserting the supplied symbol into a
24 rich text control in either the current font or specified font.
27 wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL);
30 attr.SetFlags(wxTEXT_ATTR_FONT);
31 ctrl->GetStyle(ctrl->GetInsertionPoint(), attr);
33 wxString currentFontName;
34 if (attr.HasFont() && attr.GetFont().Ok())
35 currentFontName = attr.GetFont().GetFaceName();
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.
41 wxSymbolPickerDialog dlg(wxT("*"), wxEmptyString, currentFontName, this);
43 if (dlg.ShowModal() == wxID_OK)
45 if (dlg.HasSelection())
47 long insertionPoint = ctrl->GetInsertionPoint();
49 ctrl->WriteText(dlg.GetSymbol());
51 if (!dlg.UseNormalFont())
53 wxFont font(attr.GetFont());
54 font.SetFaceName(dlg.GetFontName());
56 ctrl->SetStyle(insertionPoint, insertionPoint+
1, attr);
62 \wxheading{Derived from
}
64 \helpref{wxDialog
}{wxdialog
}\\
65 \helpref{wxTopLevelWindow
}{wxtoplevelwindow
}\\
66 \helpref{wxWindow
}{wxwindow
}\\
67 \helpref{wxEvtHandler
}{wxevthandler
}\\
68 \helpref{wxObject
}{wxobject
}
70 \wxheading{Include files
}
72 <wx/richtext/richtextsymboldlg.h>
76 \helpref{wxRichtext
}{librarieslist
}
78 \wxheading{Data structures
}
80 \latexignore{\rtfignore{\wxheading{Members
}}}
83 \membersection{wxSymbolPickerDialog::wxSymbolPickerDialog
}\label{wxsymbolpickerdialogwxsymbolpickerdialog
}
85 \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}}
87 \func{}{wxSymbolPickerDialog
}{\void}
91 \wxheading{Parameters
}
93 \docparam{symbol
}{The initial symbol to show. Specify a single character in a string, or an empty string.
}
95 \docparam{initialFont
}{The initial font to be displayed in the font list. If empty, the item
{\it normal text
} will be selected.
}
97 \docparam{normalTextFont
}{The font the dialog will use to display the symbols if the initial font is empty.
}
99 \docparam{parent
}{The dialog's parent.
}
101 \docparam{id
}{The dialog's identifier.
}
103 \docparam{title
}{The dialog's caption.
}
105 \docparam{pos
}{The dialog's position.
}
107 \docparam{size
}{The dialog's size.
}
109 \docparam{style
}{The dialog's window style.
}
111 \membersection{wxSymbolPickerDialog::Create
}\label{wxsymbolpickerdialogcreate
}
113 \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}}
115 Creation: see
\helpref{the constructor
}{wxsymbolpickerdialogwxsymbolpickerdialog
} for details about the parameters.
117 \membersection{wxSymbolPickerDialog::GetFontName
}\label{wxsymbolpickerdialoggetfontname
}
119 \constfunc{wxString
}{GetFontName
}{\void}
121 Returns the font name (the font reflected in the font list).
123 \membersection{wxSymbolPickerDialog::GetFromUnicode
}\label{wxsymbolpickerdialoggetfromunicode
}
125 \constfunc{bool
}{GetFromUnicode
}{\void}
127 Returns
\true if the dialog is showing the full range of Unicode characters.
129 \membersection{wxSymbolPickerDialog::GetNormalTextFontName
}\label{wxsymbolpickerdialoggetnormaltextfontname
}
131 \constfunc{wxString
}{GetNormalTextFontName
}{\void}
133 Gets the font name used for displaying symbols in the absence of a selected font.
135 \membersection{wxSymbolPickerDialog::GetSymbol
}\label{wxsymbolpickerdialoggetsymbol
}
137 \constfunc{wxString
}{GetSymbol
}{\void}
139 Gets the current or initial symbol as a string.
141 \membersection{wxSymbolPickerDialog::GetSymbolChar
}\label{wxsymbolpickerdialoggetsymbolchar
}
143 \constfunc{int
}{GetSymbolChar
}{\void}
145 Gets the selected symbol character as an integer.
147 \membersection{wxSymbolPickerDialog::HasSelection
}\label{wxsymbolpickerdialoghasselection
}
149 \constfunc{bool
}{HasSelection
}{\void}
151 Returns
\true if a symbol is selected.
153 \membersection{wxSymbolPickerDialog::SetFontName
}\label{wxsymbolpickerdialogsetfontname
}
155 \func{void
}{SetFontName
}{\param{const wxString\&
}{value
}}
157 Sets the initial/selected font name.
159 \membersection{wxSymbolPickerDialog::SetFromUnicode
}\label{wxsymbolpickerdialogsetfromunicode
}
161 \func{void
}{SetFromUnicode
}{\param{bool
}{value
}}
163 Sets the internal flag indicating that the full Unicode range should be displayed.
165 \membersection{wxSymbolPickerDialog::SetNormalTextFontName
}\label{wxsymbolpickerdialogsetnormaltextfontname
}
167 \func{void
}{SetNormalTextFontName
}{\param{const wxString\&
}{value
}}
169 Sets the name of the font to be used in the absence of a selected font.
171 \membersection{wxSymbolPickerDialog::SetSymbol
}\label{wxsymbolpickerdialogsetsymbol
}
173 \func{void
}{SetSymbol
}{\param{const wxString\&
}{value
}}
175 Sets the symbol as a one or zero character string.
177 \membersection{wxSymbolPickerDialog::SetUnicodeMode
}\label{wxsymbolpickerdialogsetunicodemode
}
179 \func{void
}{SetUnicodeMode
}{\param{bool
}{unicodeMode
}}
181 Sets Unicode display mode.
183 \membersection{wxSymbolPickerDialog::UseNormalFont
}\label{wxsymbolpickerdialogusenormalfont
}
185 \constfunc{bool
}{UseNormalFont
}{\void}
187 Returns true if the has specified normal text - that is, there is no selected font.