]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/richtext/richtextsymboldlg.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / interface / wx / richtext / richtextsymboldlg.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: richtext/richtextsymboldlg.h
21b447dc 3// Purpose: interface of wxSymbolPickerDialog
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxSymbolPickerDialog
7c913512 10
23324ae1
FM
11 wxSymbolPickerDialog presents the user with a choice of fonts and a grid
12 of available characters. This modal dialog provides the application with
13 a selected symbol and optional font selection.
7c913512 14
23324ae1
FM
15 Although this dialog is contained in the rich text library, the dialog
16 is generic and can be used in other contexts.
7c913512 17
23324ae1 18 To use the dialog, pass a default symbol specified as a string, an initial font
9e7ad1ca 19 name, and a current font name. The difference between the initial font and
23324ae1 20 current font is that the initial font determines what the font control will be
9e7ad1ca
FM
21 set to when the dialog shows - an empty string will show the selection
22 @e normal text.
23324ae1 23 The current font, on the other hand, is used by the dialog to determine what
9e7ad1ca 24 font to display the characters in, even when no initial font is selected.
23324ae1
FM
25 This allows the user (and application) to distinguish between inserting a
26 symbol in the current font, and inserting it with a specified font.
7c913512 27
23324ae1 28 When the dialog is dismissed, the application can get the selected symbol
9e7ad1ca
FM
29 with wxSymbolPickerDialog::GetSymbol and test whether a font was specified
30 with wxSymbolPickerDialog::UseNormalFont,fetching the specified font with
31 wxSymbolPickerDialog::GetFontName.
7c913512 32
23324ae1
FM
33 Here's a realistic example, inserting the supplied symbol into a
34 rich text control in either the current font or specified font.
7c913512 35
23324ae1 36 @code
9e7ad1ca 37 wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL);
7c913512 38
23324ae1
FM
39 wxTextAttr attr;
40 attr.SetFlags(wxTEXT_ATTR_FONT);
9e7ad1ca 41 ctrl-GetStyle(ctrl->GetInsertionPoint(), attr);
7c913512 42
23324ae1 43 wxString currentFontName;
eb2b6166 44 if (attr.HasFont() && attr.GetFont().IsOk())
23324ae1 45 currentFontName = attr.GetFont().GetFaceName();
7c913512 46
23324ae1
FM
47 // Don't set the initial font in the dialog (so the user is choosing
48 // 'normal text', i.e. the current font) but do tell the dialog
49 // what 'normal text' is.
7c913512 50
f8ebb70d 51 wxSymbolPickerDialog dlg("*", wxEmptyString, currentFontName, this);
7c913512 52
23324ae1
FM
53 if (dlg.ShowModal() == wxID_OK)
54 {
55 if (dlg.HasSelection())
56 {
57 long insertionPoint = ctrl-GetInsertionPoint();
7c913512 58
9e7ad1ca 59 ctrl->WriteText(dlg.GetSymbol());
7c913512 60
23324ae1
FM
61 if (!dlg.UseNormalFont())
62 {
63 wxFont font(attr.GetFont());
64 font.SetFaceName(dlg.GetFontName());
65 attr.SetFont(font);
66 ctrl-SetStyle(insertionPoint, insertionPoint+1, attr);
67 }
68 }
69 }
70 @endcode
7c913512 71
23324ae1
FM
72 @library{wxrichtext}
73 @category{cmndlg}
74*/
75class wxSymbolPickerDialog : public wxDialog
76{
77public:
23324ae1 78 /**
9e7ad1ca
FM
79 Default ctor.
80 */
81 wxSymbolPickerDialog();
82
83 /**
84 Constructor.
85
7c913512 86 @param symbol
9e7ad1ca
FM
87 The initial symbol to show.
88 Specify a single character in a string, or an empty string.
7c913512 89 @param initialFont
9e7ad1ca
FM
90 The initial font to be displayed in the font list.
91 If empty, the item normal text will be selected.
7c913512 92 @param normalTextFont
9e7ad1ca
FM
93 The font the dialog will use to display the symbols if the
94 initial font is empty.
7c913512 95 @param parent
4cc4bfaf 96 The dialog's parent.
7c913512 97 @param id
4cc4bfaf 98 The dialog's identifier.
7c913512 99 @param title
4cc4bfaf 100 The dialog's caption.
7c913512 101 @param pos
4cc4bfaf 102 The dialog's position.
7c913512 103 @param size
4cc4bfaf 104 The dialog's size.
7c913512 105 @param style
4cc4bfaf 106 The dialog's window style.
23324ae1
FM
107 */
108 wxSymbolPickerDialog(const wxString& symbol,
109 const wxString& initialFont,
110 const wxString& normalTextFont,
111 wxWindow* parent,
9e7ad1ca
FM
112 wxWindowID id = wxID_ANY,
113 const wxString& title = _("Symbols"),
114 const wxPoint& pos = wxDefaultPosition,
115 const wxSize& size = wxDefaultSize,
116 long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX);
23324ae1
FM
117
118 /**
9e7ad1ca 119 Creation: see @ref wxSymbolPickerDialog() "the constructor" for details about
23324ae1
FM
120 the parameters.
121 */
5267aefd
FM
122 bool Create(const wxString& symbol, const wxString& initialFont,
123 const wxString& normalTextFont, wxWindow* parent,
9e7ad1ca 124 wxWindowID id = wxID_ANY,
5267aefd 125 const wxString& caption = wxGetTranslation("Symbols"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(400, 300), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX);
23324ae1
FM
126
127 /**
128 Returns the font name (the font reflected in the font list).
129 */
328f5751 130 wxString GetFontName() const;
23324ae1
FM
131
132 /**
133 Returns @true if the dialog is showing the full range of Unicode characters.
134 */
328f5751 135 bool GetFromUnicode() const;
23324ae1
FM
136
137 /**
9e7ad1ca 138 Gets the font name used for displaying symbols in the absence of a selected font.
23324ae1 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 */
5267aefd 160 void SetFontName(wxString value);
23324ae1
FM
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 */
5267aefd 171 void SetNormalTextFontName(wxString value);
23324ae1
FM
172
173 /**
174 Sets the symbol as a one or zero character string.
175 */
5267aefd 176 void SetSymbol(wxString value);
23324ae1
FM
177
178 /**
179 Sets Unicode display mode.
180 */
181 void SetUnicodeMode(bool unicodeMode);
182
183 /**
9e7ad1ca 184 Returns @true if the has specified normal text - that is, there is no selected font.
23324ae1 185 */
328f5751 186 bool UseNormalFont() const;
23324ae1 187};
e54c96f1 188