richtextstyledlg.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: richtext/richtextstyledlg.h
  3. // Purpose: interface of wxRichTextStyleOrganiserDialog
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /*!
  8. * Flags for specifying permitted operations
  9. */
  10. #define wxRICHTEXT_ORGANISER_DELETE_STYLES 0x0001
  11. #define wxRICHTEXT_ORGANISER_CREATE_STYLES 0x0002
  12. #define wxRICHTEXT_ORGANISER_APPLY_STYLES 0x0004
  13. #define wxRICHTEXT_ORGANISER_EDIT_STYLES 0x0008
  14. #define wxRICHTEXT_ORGANISER_RENAME_STYLES 0x0010
  15. #define wxRICHTEXT_ORGANISER_OK_CANCEL 0x0020
  16. #define wxRICHTEXT_ORGANISER_RENUMBER 0x0040
  17. // The permitted style types to show
  18. #define wxRICHTEXT_ORGANISER_SHOW_CHARACTER 0x0100
  19. #define wxRICHTEXT_ORGANISER_SHOW_PARAGRAPH 0x0200
  20. #define wxRICHTEXT_ORGANISER_SHOW_LIST 0x0400
  21. #define wxRICHTEXT_ORGANISER_SHOW_BOX 0x0800
  22. #define wxRICHTEXT_ORGANISER_SHOW_ALL 0x1000
  23. // Common combinations
  24. #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)
  25. #define wxRICHTEXT_ORGANISER_BROWSE (wxRICHTEXT_ORGANISER_SHOW_ALL|wxRICHTEXT_ORGANISER_OK_CANCEL)
  26. #define wxRICHTEXT_ORGANISER_BROWSE_NUMBERING (wxRICHTEXT_ORGANISER_SHOW_LIST|wxRICHTEXT_ORGANISER_OK_CANCEL|wxRICHTEXT_ORGANISER_RENUMBER)
  27. /**
  28. @class wxRichTextStyleOrganiserDialog
  29. This class shows a style sheet and allows the user to edit, add and remove styles.
  30. It can also be used as a style browser, for example if the application is not
  31. using a permanent wxRichTextStyleComboCtrl or wxRichTextStyleListCtrl to
  32. present styles.
  33. @library{wxrichtext}
  34. @category{richtext}
  35. */
  36. class wxRichTextStyleOrganiserDialog : public wxDialog
  37. {
  38. public:
  39. /**
  40. Default ctor.
  41. */
  42. wxRichTextStyleOrganiserDialog();
  43. /**
  44. Constructor.
  45. To create a dialog, pass a bitlist of @a flags (see below), a style sheet, a
  46. text control to apply a selected style to (or @NULL), followed by the usual
  47. window parameters.
  48. To specify the operations available to the user, pass a combination of these
  49. values to @e flags:
  50. - @b wxRICHTEXT_ORGANISER_DELETE_STYLES: Provides a button for deleting styles.
  51. - @b wxRICHTEXT_ORGANISER_CREATE_STYLES: Provides buttons for creating styles.
  52. - @b wxRICHTEXT_ORGANISER_APPLY_STYLES: Provides a button for applying the
  53. currently selected style to the selection.
  54. - @b wxRICHTEXT_ORGANISER_EDIT_STYLES: Provides a button for editing styles.
  55. - @b wxRICHTEXT_ORGANISER_RENAME_STYLES: Provides a button for renaming styles.
  56. - @b wxRICHTEXT_ORGANISER_OK_CANCEL: Provides OK and Cancel buttons.
  57. - @b wxRICHTEXT_ORGANISER_RENUMBER: Provides a checkbox for specifying that
  58. the selection should be renumbered.
  59. The following flags determine what will be displayed in the style list:
  60. - @b wxRICHTEXT_ORGANISER_SHOW_CHARACTER: Displays character styles only.
  61. - @b wxRICHTEXT_ORGANISER_SHOW_PARAGRAPH: Displays paragraph styles only.
  62. - @b wxRICHTEXT_ORGANISER_SHOW_LIST: Displays list styles only.
  63. - @b wxRICHTEXT_ORGANISER_SHOW_ALL: Displays all styles.
  64. The following symbols define commonly-used combinations of flags:
  65. - @b wxRICHTEXT_ORGANISER_ORGANISE:
  66. Enable all style editing operations so the dialog behaves as a style organiser.
  67. - @b wxRICHTEXT_ORGANISER_BROWSE:
  68. Show a list of all styles and their previews, but only allow application of a
  69. style or cancellation of the dialog. This makes the dialog behave as a style browser.
  70. - @b wxRICHTEXT_ORGANISER_BROWSE_NUMBERING:
  71. Enables only list style browsing, plus a control to specify renumbering.
  72. This allows the dialog to be used for applying list styles to the selection.
  73. */
  74. wxRichTextStyleOrganiserDialog(int flags,
  75. wxRichTextStyleSheet* sheet,
  76. wxRichTextCtrl* ctrl,
  77. wxWindow* parent,
  78. wxWindowID id = wxID_ANY,
  79. const wxString& caption = _("Style Organiser"),
  80. const wxPoint& pos = wxDefaultPosition,
  81. const wxSize& size = wxDefaultSize,
  82. long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX);
  83. /**
  84. Applies the selected style to selection in the given control or the control
  85. passed to the constructor.
  86. */
  87. bool ApplyStyle(wxRichTextCtrl* ctrl = NULL);
  88. /**
  89. Creates the dialog. See the ctor.
  90. */
  91. bool Create(int flags, wxRichTextStyleSheet* sheet, wxRichTextCtrl* ctrl,
  92. wxWindow* parent, wxWindowID id = wxID_ANY,
  93. const wxString& caption = wxGetTranslation("Style Organiser"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(400, 300), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX);
  94. /**
  95. Returns @true if the user has opted to restart numbering.
  96. */
  97. bool GetRestartNumbering() const;
  98. /**
  99. Returns the associated rich text control (if any).
  100. */
  101. wxRichTextCtrl* GetRichTextCtrl() const;
  102. /**
  103. Returns selected style name.
  104. */
  105. wxString GetSelectedStyle() const;
  106. /**
  107. Returns selected style definition.
  108. */
  109. wxRichTextStyleDefinition* GetSelectedStyleDefinition() const;
  110. /**
  111. Returns the associated style sheet.
  112. */
  113. wxRichTextStyleSheet* GetStyleSheet() const;
  114. /**
  115. Sets the flags used to control the interface presented to the user.
  116. */
  117. void SetFlags(int flags);
  118. /**
  119. Checks or unchecks the restart numbering checkbox.
  120. */
  121. void SetRestartNumbering(bool restartNumbering);
  122. /**
  123. Sets the control to be associated with the dialog, for the purposes of applying
  124. a style to the selection.
  125. */
  126. void SetRichTextCtrl(wxRichTextCtrl* ctrl);
  127. /**
  128. Determines whether tooltips will be shown.
  129. */
  130. static void SetShowToolTips(bool show);
  131. /**
  132. Sets the associated style sheet.
  133. */
  134. void SetStyleSheet(wxRichTextStyleSheet* sheet);
  135. /**
  136. Returns the flags used to control the interface presented to the user.
  137. */
  138. int GetFlags() const;
  139. };