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