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
}
66 \wxheading{Include files
}
68 <wx/richtext/richtextsymboldlg.h>
70 \wxheading{Data structures
}
72 \latexignore{\rtfignore{\wxheading{Members
}}}
75 \membersection{wxSymbolPickerDialog::wxSymbolPickerDialog
}\label{wxsymbolpickerdialogwxsymbolpickerdialog
}
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
}}
79 \func{}{wxSymbolPickerDialog
}{\void}
83 \wxheading{Parameters
}
85 \docparam{symbol
}{The initial symbol to show. Specify a single character in a string, or an empty string.
}
87 \docparam{initialFont
}{The initial font to be displayed in the font list. If empty, the item
{\it normal text
} will be selected.
}
89 \docparam{normalTextFont
}{The font the dialog will use to display the symbols if the initial font is empty.
}
91 \docparam{parent
}{The dialog's parent.
}
93 \docparam{id
}{The dialog's identifier.
}
95 \docparam{title
}{The dialog's caption.
}
97 \docparam{pos
}{The dialog's position.
}
99 \docparam{size
}{The dialog's size.
}
101 \docparam{style
}{The dialog's window style.
}
103 \membersection{wxSymbolPickerDialog::Create
}\label{wxsymbolpickerdialogcreate
}
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
}}
107 Creation: see
\helpref{the constructor
}{wxsymbolpickerdialogwxsymbolpickerdialog
} for details about the parameters.
109 \membersection{wxSymbolPickerDialog::GetFontName
}\label{wxsymbolpickerdialoggetfontname
}
111 \constfunc{wxString
}{GetFontName
}{\void}
113 Returns the font name (the font reflected in the font list).
115 \membersection{wxSymbolPickerDialog::GetFromUnicode
}\label{wxsymbolpickerdialoggetfromunicode
}
117 \constfunc{bool
}{GetFromUnicode
}{\void}
119 Returns
\true if the dialog is showing the full range of Unicode characters.
121 \membersection{wxSymbolPickerDialog::GetNormalTextFontName
}\label{wxsymbolpickerdialoggetnormaltextfontname
}
123 \constfunc{wxString
}{GetNormalTextFontName
}{\void}
125 Gets the font name used for displaying symbols in the absence of a selected font.
127 \membersection{wxSymbolPickerDialog::GetSymbol
}\label{wxsymbolpickerdialoggetsymbol
}
129 \constfunc{wxString
}{GetSymbol
}{\void}
131 Gets the current or initial symbol as a string.
133 \membersection{wxSymbolPickerDialog::GetSymbolChar
}\label{wxsymbolpickerdialoggetsymbolchar
}
135 \constfunc{int
}{GetSymbolChar
}{\void}
137 Gets the selected symbol character as an integer.
139 \membersection{wxSymbolPickerDialog::HasSelection
}\label{wxsymbolpickerdialoghasselection
}
141 \constfunc{bool
}{HasSelection
}{\void}
143 Returns
\true if a symbol is selected.
145 \membersection{wxSymbolPickerDialog::SetFontName
}\label{wxsymbolpickerdialogsetfontname
}
147 \func{void
}{SetFontName
}{\param{const wxString\&
}{value
}}
149 Sets the initial/selected font name.
151 \membersection{wxSymbolPickerDialog::SetFromUnicode
}\label{wxsymbolpickerdialogsetfromunicode
}
153 \func{void
}{SetFromUnicode
}{\param{bool
}{value
}}
155 Sets the internal flag indicating that the full Unicode range should be displayed.
157 \membersection{wxSymbolPickerDialog::SetNormalTextFontName
}\label{wxsymbolpickerdialogsetnormaltextfontname
}
159 \func{void
}{SetNormalTextFontName
}{\param{const wxString\&
}{value
}}
161 Sets the name of the font to be used in the absence of a selected font.
163 \membersection{wxSymbolPickerDialog::SetSymbol
}\label{wxsymbolpickerdialogsetsymbol
}
165 \func{void
}{SetSymbol
}{\param{const wxString\&
}{value
}}
167 Sets the symbol as a one or zero character string.
169 \membersection{wxSymbolPickerDialog::SetUnicodeMode
}\label{wxsymbolpickerdialogsetunicodemode
}
171 \func{void
}{SetUnicodeMode
}{\param{bool
}{unicodeMode
}}
173 Sets Unicode display mode.
175 \membersection{wxSymbolPickerDialog::UseNormalFont
}\label{wxsymbolpickerdialogusenormalfont
}
177 \constfunc{bool
}{UseNormalFont
}{\void}
179 Returns true if the has specified normal text - that is, there is no selected font.