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