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