1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextstyledlg.h
4 // Author: Julian Smart
6 // Created: 10/5/2006 12:05:31 PM
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _RICHTEXTSTYLEDLG_H_
13 #define _RICHTEXTSTYLEDLG_H_
22 #include "wx/richtext/richtextbuffer.h"
23 #include "wx/richtext/richtextstyles.h"
24 #include "wx/richtext/richtextctrl.h"
27 * Forward declarations
30 ////@begin forward declarations
32 class wxRichTextStyleListCtrl
;
34 ////@end forward declarations
40 ////@begin control identifiers
41 #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
42 #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_TITLE _("Style Organiser")
43 #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_IDNAME ID_RICHTEXTSTYLEORGANISERDIALOG
44 #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_SIZE wxSize(400, 300)
45 #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_POSITION wxDefaultPosition
46 ////@end control identifiers
49 * Flags for specifying permitted operations
52 #define wxRICHTEXT_ORGANISER_DELETE_STYLES 0x0001
53 #define wxRICHTEXT_ORGANISER_CREATE_STYLES 0x0002
54 #define wxRICHTEXT_ORGANISER_APPLY_STYLES 0x0004
55 #define wxRICHTEXT_ORGANISER_EDIT_STYLES 0x0008
56 #define wxRICHTEXT_ORGANISER_RENAME_STYLES 0x0010
57 #define wxRICHTEXT_ORGANISER_OK_CANCEL 0x0020
58 #define wxRICHTEXT_ORGANISER_RENUMBER 0x0040
60 // The permitted style types to show
61 #define wxRICHTEXT_ORGANISER_SHOW_CHARACTER 0x0100
62 #define wxRICHTEXT_ORGANISER_SHOW_PARAGRAPH 0x0200
63 #define wxRICHTEXT_ORGANISER_SHOW_LIST 0x0400
64 #define wxRICHTEXT_ORGANISER_SHOW_ALL 0x0800
66 // Common combinations
67 #define wxRICHTEXT_ORGANISER_ORGANISE (wxRICHTEXT_ORGANISER_SHOW_ALL|wxRICHTEXT_ORGANISER_DELETE_STYLES|wxRICHTEXT_ORGANISER_CREATE_STYLES|wxRICHTEXT_ORGANISER_APPLY_STYLES|wxRICHTEXT_ORGANISER_EDIT_STYLES|wxRICHTEXT_ORGANISER_RENAME_STYLES)
68 #define wxRICHTEXT_ORGANISER_BROWSE (wxRICHTEXT_ORGANISER_SHOW_ALL|wxRICHTEXT_ORGANISER_OK_CANCEL)
69 #define wxRICHTEXT_ORGANISER_BROWSE_NUMBERING (wxRICHTEXT_ORGANISER_SHOW_LIST|wxRICHTEXT_ORGANISER_OK_CANCEL|wxRICHTEXT_ORGANISER_RENUMBER)
72 * wxRichTextStyleOrganiserDialog class declaration
75 class WXDLLIMPEXP_RICHTEXT wxRichTextStyleOrganiserDialog
: public wxDialog
77 DECLARE_DYNAMIC_CLASS( wxRichTextStyleOrganiserDialog
)
82 wxRichTextStyleOrganiserDialog( );
83 wxRichTextStyleOrganiserDialog( int flags
, wxRichTextStyleSheet
* sheet
, wxRichTextCtrl
* ctrl
, wxWindow
* parent
, wxWindowID id
= wxID_ANY
, const wxString
& caption
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_TITLE
, const wxPoint
& pos
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_POSITION
, const wxSize
& size
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_SIZE
, long style
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_STYLE
);
86 bool Create( int flags
, wxRichTextStyleSheet
* sheet
, wxRichTextCtrl
* ctrl
, wxWindow
* parent
, wxWindowID id
= wxID_ANY
, const wxString
& caption
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_TITLE
, const wxPoint
& pos
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_POSITION
, const wxSize
& size
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_SIZE
, long style
= SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_STYLE
);
88 /// Creates the controls and sizers
89 void CreateControls();
91 /// Initialise member variables
94 /// Transfer data from/to window
95 virtual bool TransferDataFromWindow();
96 virtual bool TransferDataToWindow();
98 /// Set/get style sheet
99 void SetStyleSheet(wxRichTextStyleSheet
* sheet
) { m_richTextStyleSheet
= sheet
; }
100 wxRichTextStyleSheet
* GetStyleSheet() const { return m_richTextStyleSheet
; }
103 void SetRichTextCtrl(wxRichTextCtrl
* ctrl
) { m_richTextCtrl
= ctrl
; }
104 wxRichTextCtrl
* GetRichTextCtrl() const { return m_richTextCtrl
; }
107 void SetFlags(int flags
) { m_flags
= flags
; }
108 int GetFlags() const { return m_flags
; }
110 /// Show preview for given or selected preview
111 void ShowPreview(int sel
= -1);
113 /// Clears the preview
117 void OnListSelection(wxCommandEvent
& event
);
119 /// Get/set restart numbering boolean
120 bool GetRestartNumbering() const { return m_restartNumbering
; }
121 void SetRestartNumbering(bool restartNumbering
) { m_restartNumbering
= restartNumbering
; }
123 /// Get selected style name or definition
124 wxString
GetSelectedStyle() const;
125 wxRichTextStyleDefinition
* GetSelectedStyleDefinition() const;
128 bool ApplyStyle(wxRichTextCtrl
* ctrl
= NULL
);
130 /// Should we show tooltips?
131 static bool ShowToolTips() { return sm_showToolTips
; }
133 /// Determines whether tooltips will be shown
134 static void SetShowToolTips(bool show
) { sm_showToolTips
= show
; }
136 ////@begin wxRichTextStyleOrganiserDialog event handler declarations
138 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR
139 void OnNewCharClick( wxCommandEvent
& event
);
141 /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR
142 void OnNewCharUpdate( wxUpdateUIEvent
& event
);
144 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA
145 void OnNewParaClick( wxCommandEvent
& event
);
147 /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA
148 void OnNewParaUpdate( wxUpdateUIEvent
& event
);
150 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST
151 void OnNewListClick( wxCommandEvent
& event
);
153 /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST
154 void OnNewListUpdate( wxUpdateUIEvent
& event
);
156 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY
157 void OnApplyClick( wxCommandEvent
& event
);
159 /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY
160 void OnApplyUpdate( wxUpdateUIEvent
& event
);
162 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME
163 void OnRenameClick( wxCommandEvent
& event
);
165 /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME
166 void OnRenameUpdate( wxUpdateUIEvent
& event
);
168 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT
169 void OnEditClick( wxCommandEvent
& event
);
171 /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT
172 void OnEditUpdate( wxUpdateUIEvent
& event
);
174 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE
175 void OnDeleteClick( wxCommandEvent
& event
);
177 /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE
178 void OnDeleteUpdate( wxUpdateUIEvent
& event
);
180 ////@end wxRichTextStyleOrganiserDialog event handler declarations
182 ////@begin wxRichTextStyleOrganiserDialog member function declarations
184 /// Retrieves bitmap resources
185 wxBitmap
GetBitmapResource( const wxString
& name
);
187 /// Retrieves icon resources
188 wxIcon
GetIconResource( const wxString
& name
);
189 ////@end wxRichTextStyleOrganiserDialog member function declarations
191 ////@begin wxRichTextStyleOrganiserDialog member variables
192 wxBoxSizer
* m_innerSizer
;
193 wxBoxSizer
* m_buttonSizerParent
;
194 wxRichTextStyleListCtrl
* m_stylesListBox
;
195 wxRichTextCtrl
* m_previewCtrl
;
196 wxBoxSizer
* m_buttonSizer
;
197 wxButton
* m_newCharacter
;
198 wxButton
* m_newParagraph
;
200 wxButton
* m_applyStyle
;
201 wxButton
* m_renameStyle
;
202 wxButton
* m_editStyle
;
203 wxButton
* m_deleteStyle
;
204 wxButton
* m_closeButton
;
205 wxBoxSizer
* m_bottomButtonSizer
;
206 wxCheckBox
* m_restartNumberingCtrl
;
207 wxButton
* m_okButton
;
208 wxButton
* m_cancelButton
;
209 /// Control identifiers
211 ID_RICHTEXTSTYLEORGANISERDIALOG
= 10500,
212 ID_RICHTEXTSTYLEORGANISERDIALOG_STYLES
= 10501,
213 ID_RICHTEXTSTYLEORGANISERDIALOG_CURRENT_STYLE
= 10510,
214 ID_RICHTEXTSTYLEORGANISERDIALOG_PREVIEW
= 10509,
215 ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR
= 10504,
216 ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA
= 10505,
217 ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST
= 10508,
218 ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY
= 10503,
219 ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME
= 10502,
220 ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT
= 10506,
221 ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE
= 10507,
222 ID_RICHTEXTSTYLEORGANISERDIALOG_RESTART_NUMBERING
= 10511
224 ////@end wxRichTextStyleOrganiserDialog member variables
228 wxRichTextCtrl
* m_richTextCtrl
;
229 wxRichTextStyleSheet
* m_richTextStyleSheet
;
233 static bool sm_showToolTips
;
234 bool m_restartNumbering
;
238 // _RICHTEXTSTYLEDLG_H_