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