]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/richtext/richtextsymboldlg.h
Don't create multiple parent-less top level frames in layout sample.
[wxWidgets.git] / include / wx / richtext / richtextsymboldlg.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/richtext/richtextsymboldlg.h
3// Purpose:
4// Author: Julian Smart
5// Modified by:
6// Created: 10/5/2006 3:11:58 PM
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _RICHTEXTSYMBOLDLG_H_
13#define _RICHTEXTSYMBOLDLG_H_
14
15/*!
16 * Includes
17 */
18
19#include "wx/richtext/richtextuicustomization.h"
20#include "wx/dialog.h"
21#include "wx/vscroll.h"
22
23/*!
24 * Forward declarations
25 */
26
27class WXDLLIMPEXP_FWD_CORE wxStaticText;
28class WXDLLIMPEXP_FWD_CORE wxComboBox;
29class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
30
31////@begin forward declarations
32class wxSymbolListCtrl;
33class wxStdDialogButtonSizer;
34////@end forward declarations
35
36// __UNICODE__ is a symbol used by DialogBlocks-generated code.
37#ifndef __UNICODE__
38#if wxUSE_UNICODE
39#define __UNICODE__
40#endif
41#endif
42
43/*!
44 * Symbols
45 */
46
47#define SYMBOL_WXSYMBOLPICKERDIALOG_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX)
48#define SYMBOL_WXSYMBOLPICKERDIALOG_TITLE wxGetTranslation("Symbols")
49#define SYMBOL_WXSYMBOLPICKERDIALOG_IDNAME ID_SYMBOLPICKERDIALOG
50#define SYMBOL_WXSYMBOLPICKERDIALOG_SIZE wxSize(400, 300)
51#define SYMBOL_WXSYMBOLPICKERDIALOG_POSITION wxDefaultPosition
52
53/*!
54 * wxSymbolPickerDialog class declaration
55 */
56
57class WXDLLIMPEXP_RICHTEXT wxSymbolPickerDialog: public wxDialog
58{
59 DECLARE_DYNAMIC_CLASS( wxSymbolPickerDialog )
60 DECLARE_EVENT_TABLE()
61 DECLARE_HELP_PROVISION()
62
63public:
64 /// Constructors
65 wxSymbolPickerDialog( );
66 wxSymbolPickerDialog( const wxString& symbol, const wxString& fontName, const wxString& normalTextFont,
67 wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& caption = SYMBOL_WXSYMBOLPICKERDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXSYMBOLPICKERDIALOG_POSITION, const wxSize& size = SYMBOL_WXSYMBOLPICKERDIALOG_SIZE, long style = SYMBOL_WXSYMBOLPICKERDIALOG_STYLE );
68
69 /// Creation
70 bool Create( const wxString& symbol, const wxString& fontName, const wxString& normalTextFont,
71 wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& caption = SYMBOL_WXSYMBOLPICKERDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXSYMBOLPICKERDIALOG_POSITION, const wxSize& size = SYMBOL_WXSYMBOLPICKERDIALOG_SIZE, long style = SYMBOL_WXSYMBOLPICKERDIALOG_STYLE );
72
73 /// Initialises members variables
74 void Init();
75
76 /// Creates the controls and sizers
77 void CreateControls();
78
79 /// Update the display
80 void UpdateSymbolDisplay(bool updateSymbolList = true, bool showAtSubset = true);
81
82 /// Respond to symbol selection
83 void OnSymbolSelected( wxCommandEvent& event );
84
85 /// Set Unicode mode
86 void SetUnicodeMode(bool unicodeMode);
87
88 /// Show at the current subset selection
89 void ShowAtSubset();
90
91 /// Get the selected symbol character
92 int GetSymbolChar() const;
93
94 /// Is there a selection?
95 bool HasSelection() const { return !m_symbol.IsEmpty(); }
96
97 /// Specifying normal text?
98 bool UseNormalFont() const { return m_fontName.IsEmpty(); }
99
100 /// Should we show tooltips?
101 static bool ShowToolTips() { return sm_showToolTips; }
102
103 /// Determines whether tooltips will be shown
104 static void SetShowToolTips(bool show) { sm_showToolTips = show; }
105
106 /// Data transfer
107 virtual bool TransferDataToWindow();
108
109////@begin wxSymbolPickerDialog event handler declarations
110
111 /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FONT
112 void OnFontCtrlSelected( wxCommandEvent& event );
113
114#if defined(__UNICODE__)
115 /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_SUBSET
116 void OnSubsetSelected( wxCommandEvent& event );
117
118 /// wxEVT_UPDATE_UI event handler for ID_SYMBOLPICKERDIALOG_SUBSET
119 void OnSymbolpickerdialogSubsetUpdate( wxUpdateUIEvent& event );
120
121#endif
122#if defined(__UNICODE__)
123 /// wxEVT_COMBOBOX event handler for ID_SYMBOLPICKERDIALOG_FROM
124 void OnFromUnicodeSelected( wxCommandEvent& event );
125
126#endif
127 /// wxEVT_UPDATE_UI event handler for wxID_OK
128 void OnOkUpdate( wxUpdateUIEvent& event );
129
130 /// wxEVT_BUTTON event handler for wxID_HELP
131 void OnHelpClick( wxCommandEvent& event );
132
133 /// wxEVT_UPDATE_UI event handler for wxID_HELP
134 void OnHelpUpdate( wxUpdateUIEvent& event );
135
136////@end wxSymbolPickerDialog event handler declarations
137
138////@begin wxSymbolPickerDialog member function declarations
139
140 wxString GetFontName() const { return m_fontName ; }
141 void SetFontName(wxString value) { m_fontName = value ; }
142
143 bool GetFromUnicode() const { return m_fromUnicode ; }
144 void SetFromUnicode(bool value) { m_fromUnicode = value ; }
145
146 wxString GetNormalTextFontName() const { return m_normalTextFontName ; }
147 void SetNormalTextFontName(wxString value) { m_normalTextFontName = value ; }
148
149 wxString GetSymbol() const { return m_symbol ; }
150 void SetSymbol(wxString value) { m_symbol = value ; }
151
152 /// Retrieves bitmap resources
153 wxBitmap GetBitmapResource( const wxString& name );
154
155 /// Retrieves icon resources
156 wxIcon GetIconResource( const wxString& name );
157////@end wxSymbolPickerDialog member function declarations
158
159////@begin wxSymbolPickerDialog member variables
160 wxComboBox* m_fontCtrl;
161#if defined(__UNICODE__)
162 wxComboBox* m_subsetCtrl;
163#endif
164 wxSymbolListCtrl* m_symbolsCtrl;
165 wxStaticText* m_symbolStaticCtrl;
166 wxTextCtrl* m_characterCodeCtrl;
167#if defined(__UNICODE__)
168 wxComboBox* m_fromUnicodeCtrl;
169#endif
170 wxStdDialogButtonSizer* m_stdButtonSizer;
171 wxString m_fontName;
172 bool m_fromUnicode;
173 wxString m_normalTextFontName;
174 wxString m_symbol;
175 /// Control identifiers
176 enum {
177 ID_SYMBOLPICKERDIALOG = 10600,
178 ID_SYMBOLPICKERDIALOG_FONT = 10602,
179 ID_SYMBOLPICKERDIALOG_SUBSET = 10605,
180 ID_SYMBOLPICKERDIALOG_LISTCTRL = 10608,
181 ID_SYMBOLPICKERDIALOG_CHARACTERCODE = 10601,
182 ID_SYMBOLPICKERDIALOG_FROM = 10603
183 };
184////@end wxSymbolPickerDialog member variables
185
186 bool m_dontUpdate;
187 static bool sm_showToolTips;
188};
189
190/*!
191 * The scrolling symbol list.
192 */
193
194class WXDLLIMPEXP_RICHTEXT wxSymbolListCtrl : public wxVScrolledWindow
195{
196public:
197 // constructors and such
198 // ---------------------
199
200 // default constructor, you must call Create() later
201 wxSymbolListCtrl() { Init(); }
202
203 // normal constructor which calls Create() internally
204 wxSymbolListCtrl(wxWindow *parent,
205 wxWindowID id = wxID_ANY,
206 const wxPoint& pos = wxDefaultPosition,
207 const wxSize& size = wxDefaultSize,
208 long style = 0,
209 const wxString& name = wxPanelNameStr)
210 {
211 Init();
212
213 (void)Create(parent, id, pos, size, style, name);
214 }
215
216 // really creates the control and sets the initial number of items in it
217 // (which may be changed later with SetItemCount())
218 //
219 // returns true on success or false if the control couldn't be created
220 bool Create(wxWindow *parent,
221 wxWindowID id = wxID_ANY,
222 const wxPoint& pos = wxDefaultPosition,
223 const wxSize& size = wxDefaultSize,
224 long style = 0,
225 const wxString& name = wxPanelNameStr);
226
227 // dtor does some internal cleanup
228 virtual ~wxSymbolListCtrl();
229
230
231 // accessors
232 // ---------
233
234 // set the current font
235 virtual bool SetFont(const wxFont& font);
236
237 // set Unicode/ASCII mode
238 void SetUnicodeMode(bool unicodeMode);
239
240 // get the index of the currently selected item or wxNOT_FOUND if there is no selection
241 int GetSelection() const;
242
243 // is this item selected?
244 bool IsSelected(int item) const;
245
246 // is this item the current one?
247 bool IsCurrentItem(int item) const { return item == m_current; }
248
249 // get the margins around each cell
250 wxPoint GetMargins() const { return m_ptMargins; }
251
252 // get the background colour of selected cells
253 const wxColour& GetSelectionBackground() const { return m_colBgSel; }
254
255 // operations
256 // ----------
257
258 // set the selection to the specified item, if it is wxNOT_FOUND the
259 // selection is unset
260 void SetSelection(int selection);
261
262 // make this item visible
263 void EnsureVisible(int item);
264
265 // set the margins: horizontal margin is the distance between the window
266 // border and the item contents while vertical margin is half of the
267 // distance between items
268 //
269 // by default both margins are 0
270 void SetMargins(const wxPoint& pt);
271 void SetMargins(wxCoord x, wxCoord y) { SetMargins(wxPoint(x, y)); }
272
273 // set the cell size
274 void SetCellSize(const wxSize& sz) { m_cellSize = sz; }
275 const wxSize& GetCellSize() const { return m_cellSize; }
276
277 // change the background colour of the selected cells
278 void SetSelectionBackground(const wxColour& col);
279
280 virtual wxVisualAttributes GetDefaultAttributes() const
281 {
282 return GetClassDefaultAttributes(GetWindowVariant());
283 }
284
285 static wxVisualAttributes
286 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
287
288 // Get min/max symbol values
289 int GetMinSymbolValue() const { return m_minSymbolValue; }
290 int GetMaxSymbolValue() const { return m_maxSymbolValue; }
291
292 // Respond to size change
293 void OnSize(wxSizeEvent& event);
294
295protected:
296
297 // draws a line of symbols
298 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
299
300 // gets the line height
301 virtual wxCoord OnGetRowHeight(size_t line) const;
302
303 // event handlers
304 void OnPaint(wxPaintEvent& event);
305 void OnKeyDown(wxKeyEvent& event);
306 void OnLeftDown(wxMouseEvent& event);
307 void OnLeftDClick(wxMouseEvent& event);
308
309 // common part of all ctors
310 void Init();
311
312 // send the wxEVT_LISTBOX event
313 void SendSelectedEvent();
314
315 // change the current item (in single selection listbox it also implicitly
316 // changes the selection); current may be wxNOT_FOUND in which case there
317 // will be no current item any more
318 //
319 // return true if the current item changed, false otherwise
320 bool DoSetCurrent(int current);
321
322 // flags for DoHandleItemClick
323 enum
324 {
325 ItemClick_Shift = 1, // item shift-clicked
326 ItemClick_Ctrl = 2, // ctrl
327 ItemClick_Kbd = 4 // item selected from keyboard
328 };
329
330 // common part of keyboard and mouse handling processing code
331 void DoHandleItemClick(int item, int flags);
332
333 // calculate line number from symbol value
334 int SymbolValueToLineNumber(int item);
335
336 // initialise control from current min/max values
337 void SetupCtrl(bool scrollToSelection = true);
338
339 // hit testing
340 int HitTest(const wxPoint& pt);
341
342private:
343 // the current item or wxNOT_FOUND
344 int m_current;
345
346 // margins
347 wxPoint m_ptMargins;
348
349 // the selection bg colour
350 wxColour m_colBgSel;
351
352 // double buffer
353 wxBitmap* m_doubleBuffer;
354
355 // cell size
356 wxSize m_cellSize;
357
358 // minimum and maximum symbol value
359 int m_minSymbolValue;
360
361 // minimum and maximum symbol value
362 int m_maxSymbolValue;
363
364 // number of items per line
365 int m_symbolsPerLine;
366
367 // Unicode/ASCII mode
368 bool m_unicodeMode;
369
370 DECLARE_EVENT_TABLE()
371 wxDECLARE_NO_COPY_CLASS(wxSymbolListCtrl);
372 DECLARE_ABSTRACT_CLASS(wxSymbolListCtrl)
373};
374
375#endif
376 // _RICHTEXTSYMBOLDLG_H_