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