richtextstyledlg.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/richtext/richtextstyledlg.h
  3. // Purpose:
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 10/5/2006 12:05:31 PM
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _RICHTEXTSTYLEDLG_H_
  11. #define _RICHTEXTSTYLEDLG_H_
  12. /*!
  13. * Includes
  14. */
  15. #include "wx/richtext/richtextuicustomization.h"
  16. ////@begin includes
  17. ////@end includes
  18. #include "wx/richtext/richtextbuffer.h"
  19. #include "wx/richtext/richtextstyles.h"
  20. #include "wx/richtext/richtextctrl.h"
  21. /*!
  22. * Forward declarations
  23. */
  24. ////@begin forward declarations
  25. class wxBoxSizer;
  26. class wxRichTextStyleListCtrl;
  27. class wxRichTextCtrl;
  28. class wxStdDialogButtonSizer;
  29. ////@end forward declarations
  30. class WXDLLIMPEXP_FWD_CORE wxButton;
  31. class WXDLLIMPEXP_FWD_CORE wxCheckBox;
  32. /*!
  33. * Control identifiers
  34. */
  35. #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX
  36. #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_TITLE wxGetTranslation("Style Organiser")
  37. #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_IDNAME ID_RICHTEXTSTYLEORGANISERDIALOG
  38. #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_SIZE wxSize(400, 300)
  39. #define SYMBOL_WXRICHTEXTSTYLEORGANISERDIALOG_POSITION wxDefaultPosition
  40. /*!
  41. * Flags for specifying permitted operations
  42. */
  43. #define wxRICHTEXT_ORGANISER_DELETE_STYLES 0x0001
  44. #define wxRICHTEXT_ORGANISER_CREATE_STYLES 0x0002
  45. #define wxRICHTEXT_ORGANISER_APPLY_STYLES 0x0004
  46. #define wxRICHTEXT_ORGANISER_EDIT_STYLES 0x0008
  47. #define wxRICHTEXT_ORGANISER_RENAME_STYLES 0x0010
  48. #define wxRICHTEXT_ORGANISER_OK_CANCEL 0x0020
  49. #define wxRICHTEXT_ORGANISER_RENUMBER 0x0040
  50. // The permitted style types to show
  51. #define wxRICHTEXT_ORGANISER_SHOW_CHARACTER 0x0100
  52. #define wxRICHTEXT_ORGANISER_SHOW_PARAGRAPH 0x0200
  53. #define wxRICHTEXT_ORGANISER_SHOW_LIST 0x0400
  54. #define wxRICHTEXT_ORGANISER_SHOW_BOX 0x0800
  55. #define wxRICHTEXT_ORGANISER_SHOW_ALL 0x1000
  56. // Common combinations
  57. #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)
  58. #define wxRICHTEXT_ORGANISER_BROWSE (wxRICHTEXT_ORGANISER_SHOW_ALL|wxRICHTEXT_ORGANISER_OK_CANCEL)
  59. #define wxRICHTEXT_ORGANISER_BROWSE_NUMBERING (wxRICHTEXT_ORGANISER_SHOW_LIST|wxRICHTEXT_ORGANISER_OK_CANCEL|wxRICHTEXT_ORGANISER_RENUMBER)
  60. /*!
  61. * wxRichTextStyleOrganiserDialog class declaration
  62. */
  63. class WXDLLIMPEXP_RICHTEXT wxRichTextStyleOrganiserDialog: public wxDialog
  64. {
  65. DECLARE_DYNAMIC_CLASS( wxRichTextStyleOrganiserDialog )
  66. DECLARE_EVENT_TABLE()
  67. DECLARE_HELP_PROVISION()
  68. public:
  69. /// Constructors
  70. wxRichTextStyleOrganiserDialog( );
  71. 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 );
  72. /// Creation
  73. 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 );
  74. /// Creates the controls and sizers
  75. void CreateControls();
  76. /// Initialise member variables
  77. void Init();
  78. /// Transfer data from/to window
  79. virtual bool TransferDataFromWindow();
  80. virtual bool TransferDataToWindow();
  81. /// Set/get style sheet
  82. void SetStyleSheet(wxRichTextStyleSheet* sheet) { m_richTextStyleSheet = sheet; }
  83. wxRichTextStyleSheet* GetStyleSheet() const { return m_richTextStyleSheet; }
  84. /// Set/get control
  85. void SetRichTextCtrl(wxRichTextCtrl* ctrl) { m_richTextCtrl = ctrl; }
  86. wxRichTextCtrl* GetRichTextCtrl() const { return m_richTextCtrl; }
  87. /// Set/get flags
  88. void SetFlags(int flags) { m_flags = flags; }
  89. int GetFlags() const { return m_flags; }
  90. /// Show preview for given or selected preview
  91. void ShowPreview(int sel = -1);
  92. /// Clears the preview
  93. void ClearPreview();
  94. /// List selection
  95. void OnListSelection(wxCommandEvent& event);
  96. /// Get/set restart numbering boolean
  97. bool GetRestartNumbering() const { return m_restartNumbering; }
  98. void SetRestartNumbering(bool restartNumbering) { m_restartNumbering = restartNumbering; }
  99. /// Get selected style name or definition
  100. wxString GetSelectedStyle() const;
  101. wxRichTextStyleDefinition* GetSelectedStyleDefinition() const;
  102. /// Apply the style
  103. bool ApplyStyle(wxRichTextCtrl* ctrl = NULL);
  104. /// Should we show tooltips?
  105. static bool ShowToolTips() { return sm_showToolTips; }
  106. /// Determines whether tooltips will be shown
  107. static void SetShowToolTips(bool show) { sm_showToolTips = show; }
  108. ////@begin wxRichTextStyleOrganiserDialog event handler declarations
  109. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR
  110. void OnNewCharClick( wxCommandEvent& event );
  111. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR
  112. void OnNewCharUpdate( wxUpdateUIEvent& event );
  113. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA
  114. void OnNewParaClick( wxCommandEvent& event );
  115. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA
  116. void OnNewParaUpdate( wxUpdateUIEvent& event );
  117. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST
  118. void OnNewListClick( wxCommandEvent& event );
  119. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST
  120. void OnNewListUpdate( wxUpdateUIEvent& event );
  121. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX
  122. void OnNewBoxClick( wxCommandEvent& event );
  123. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX
  124. void OnNewBoxUpdate( wxUpdateUIEvent& event );
  125. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY
  126. void OnApplyClick( wxCommandEvent& event );
  127. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY
  128. void OnApplyUpdate( wxUpdateUIEvent& event );
  129. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME
  130. void OnRenameClick( wxCommandEvent& event );
  131. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME
  132. void OnRenameUpdate( wxUpdateUIEvent& event );
  133. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT
  134. void OnEditClick( wxCommandEvent& event );
  135. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT
  136. void OnEditUpdate( wxUpdateUIEvent& event );
  137. /// wxEVT_BUTTON event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE
  138. void OnDeleteClick( wxCommandEvent& event );
  139. /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE
  140. void OnDeleteUpdate( wxUpdateUIEvent& event );
  141. /// wxEVT_BUTTON event handler for wxID_HELP
  142. void OnHelpClick( wxCommandEvent& event );
  143. ////@end wxRichTextStyleOrganiserDialog event handler declarations
  144. ////@begin wxRichTextStyleOrganiserDialog member function declarations
  145. /// Retrieves bitmap resources
  146. wxBitmap GetBitmapResource( const wxString& name );
  147. /// Retrieves icon resources
  148. wxIcon GetIconResource( const wxString& name );
  149. ////@end wxRichTextStyleOrganiserDialog member function declarations
  150. ////@begin wxRichTextStyleOrganiserDialog member variables
  151. wxBoxSizer* m_innerSizer;
  152. wxBoxSizer* m_buttonSizerParent;
  153. wxRichTextStyleListCtrl* m_stylesListBox;
  154. wxRichTextCtrl* m_previewCtrl;
  155. wxBoxSizer* m_buttonSizer;
  156. wxButton* m_newCharacter;
  157. wxButton* m_newParagraph;
  158. wxButton* m_newList;
  159. wxButton* m_newBox;
  160. wxButton* m_applyStyle;
  161. wxButton* m_renameStyle;
  162. wxButton* m_editStyle;
  163. wxButton* m_deleteStyle;
  164. wxButton* m_closeButton;
  165. wxBoxSizer* m_bottomButtonSizer;
  166. wxCheckBox* m_restartNumberingCtrl;
  167. wxStdDialogButtonSizer* m_stdButtonSizer;
  168. wxButton* m_okButton;
  169. wxButton* m_cancelButton;
  170. /// Control identifiers
  171. enum {
  172. ID_RICHTEXTSTYLEORGANISERDIALOG = 10500,
  173. ID_RICHTEXTSTYLEORGANISERDIALOG_STYLES = 10501,
  174. ID_RICHTEXTSTYLEORGANISERDIALOG_CURRENT_STYLE = 10510,
  175. ID_RICHTEXTSTYLEORGANISERDIALOG_PREVIEW = 10509,
  176. ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_CHAR = 10504,
  177. ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_PARA = 10505,
  178. ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_LIST = 10508,
  179. ID_RICHTEXTSTYLEORGANISERDIALOG_NEW_BOX = 10512,
  180. ID_RICHTEXTSTYLEORGANISERDIALOG_APPLY = 10503,
  181. ID_RICHTEXTSTYLEORGANISERDIALOG_RENAME = 10502,
  182. ID_RICHTEXTSTYLEORGANISERDIALOG_EDIT = 10506,
  183. ID_RICHTEXTSTYLEORGANISERDIALOG_DELETE = 10507,
  184. ID_RICHTEXTSTYLEORGANISERDIALOG_RESTART_NUMBERING = 10511
  185. };
  186. ////@end wxRichTextStyleOrganiserDialog member variables
  187. private:
  188. wxRichTextCtrl* m_richTextCtrl;
  189. wxRichTextStyleSheet* m_richTextStyleSheet;
  190. bool m_dontUpdate;
  191. int m_flags;
  192. static bool sm_showToolTips;
  193. bool m_restartNumbering;
  194. };
  195. #endif
  196. // _RICHTEXTSTYLEDLG_H_