1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextuicustomization.h
3 // Purpose: UI customization base class for wxRTC
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RICHTEXTUICUSTOMIZATION_H_
13 #define _WX_RICHTEXTUICUSTOMIZATION_H_
18 @class wxRichTextUICustomization
19 The base class for functionality to plug in to various rich text control dialogs,
20 currently allowing the application to respond to Help button clicks without the
21 need to derive new dialog classes.
23 The application will typically have calls like this in its initialisation:
25 wxRichTextFormattingDialog::SetHelpId(ID_HELP_FORMATTINGDIALOG);
26 wxRichTextFormattingDialog::SetUICustomization(& wxGetApp().GetRichTextUICustomization());
27 wxRichTextBordersPage::SetHelpId(ID_HELP_BORDERSPAGE);
29 Only the wxRichTextFormattingDialog class needs to have its customization object and help id set,
30 though the application set them for individual pages if it wants.
33 class WXDLLIMPEXP_RICHTEXT wxRichTextUICustomization
36 wxRichTextUICustomization() {}
37 virtual ~wxRichTextUICustomization() {}
39 /// Show the help given the current active window, and a help topic id.
40 virtual bool ShowHelp(wxWindow
* win
, long id
) = 0;
44 @class wxRichTextHelpInfo
45 This class is used as a static member of dialogs, to store the help topic for the dialog
46 and also the customization object that will allow help to be shown appropriately for the application.
49 class WXDLLIMPEXP_RICHTEXT wxRichTextHelpInfo
55 m_uiCustomization
= NULL
;
57 virtual ~wxRichTextHelpInfo() {}
59 virtual bool ShowHelp(wxWindow
* win
)
61 if (m_uiCustomization
&& m_helpTopic
!= -1)
62 return m_uiCustomization
->ShowHelp(win
, m_helpTopic
);
67 /// Get the help topic identifier.
68 long GetHelpId() const { return m_helpTopic
; }
70 /// Set the help topic identifier.
71 void SetHelpId(long id
) { m_helpTopic
= id
; }
73 /// Get the UI customization object.
74 wxRichTextUICustomization
* GetUICustomization() const { return m_uiCustomization
; }
76 /// Set the UI customization object.
77 void SetUICustomization(wxRichTextUICustomization
* customization
) { m_uiCustomization
= customization
; }
79 /// Is there a valid help topic id?
80 bool HasHelpId() const { return m_helpTopic
!= -1; }
82 /// Is there a valid customization object?
83 bool HasUICustomization() const { return m_uiCustomization
!= NULL
; }
86 wxRichTextUICustomization
* m_uiCustomization
;
90 /// Add this to the base class of dialogs
92 #define DECLARE_BASE_CLASS_HELP_PROVISION() \
93 virtual long GetHelpId() const = 0; \
94 virtual wxRichTextUICustomization* GetUICustomization() const = 0; \
95 virtual bool ShowHelp(wxWindow* win) = 0;
97 /// A macro to make it easy to add help topic provision and UI customization
98 /// to a class. Optionally, add virtual functions to a base class
99 /// using DECLARE_BASE_CLASS_HELP_PROVISION. This means that the formatting dialog
100 /// can obtain help topics from its individual pages without needing
101 /// to know in advance what page classes are being used, allowing for extension
102 /// of the formatting dialog.
104 #define DECLARE_HELP_PROVISION() \
105 virtual long GetHelpId() const { return sm_helpInfo.GetHelpId(); } \
106 virtual void SetHelpId(long id) { sm_helpInfo.SetHelpId(id); } \
107 virtual wxRichTextUICustomization* GetUICustomization() const { return sm_helpInfo.GetUICustomization(); } \
108 virtual void SetUICustomization(wxRichTextUICustomization* customization) { sm_helpInfo.SetUICustomization(customization); } \
109 virtual bool ShowHelp(wxWindow* win) { return sm_helpInfo.ShowHelp(win); } \
111 static wxRichTextHelpInfo sm_helpInfo; \
114 /// Add this to the implementation file for each dialog that needs help provision.
116 #define IMPLEMENT_HELP_PROVISION(theClass) \
117 wxRichTextHelpInfo theClass::sm_helpInfo;
123 // _WX_RICHTEXTUICUSTOMIZATION_H_