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_
17 #include "wx/window.h"
20 @class wxRichTextUICustomization
21 The base class for functionality to plug in to various rich text control dialogs,
22 currently allowing the application to respond to Help button clicks without the
23 need to derive new dialog classes.
25 The application will typically have calls like this in its initialisation:
27 wxRichTextFormattingDialog::SetHelpId(ID_HELP_FORMATTINGDIALOG);
28 wxRichTextFormattingDialog::SetUICustomization(& wxGetApp().GetRichTextUICustomization());
29 wxRichTextBordersPage::SetHelpId(ID_HELP_BORDERSPAGE);
31 Only the wxRichTextFormattingDialog class needs to have its customization object and help id set,
32 though the application set them for individual pages if it wants.
35 class WXDLLIMPEXP_RICHTEXT wxRichTextUICustomization
38 wxRichTextUICustomization() {}
39 virtual ~wxRichTextUICustomization() {}
41 /// Show the help given the current active window, and a help topic id.
42 virtual bool ShowHelp(wxWindow
* win
, long id
) = 0;
46 @class wxRichTextHelpInfo
47 This class is used as a static member of dialogs, to store the help topic for the dialog
48 and also the customization object that will allow help to be shown appropriately for the application.
51 class WXDLLIMPEXP_RICHTEXT wxRichTextHelpInfo
57 m_uiCustomization
= NULL
;
59 virtual ~wxRichTextHelpInfo() {}
61 virtual bool ShowHelp(wxWindow
* win
)
63 if (m_uiCustomization
&& m_helpTopic
!= -1)
64 return m_uiCustomization
->ShowHelp(win
, m_helpTopic
);
69 /// Get the help topic identifier.
70 long GetHelpId() const { return m_helpTopic
; }
72 /// Set the help topic identifier.
73 void SetHelpId(long id
) { m_helpTopic
= id
; }
75 /// Get the UI customization object.
76 wxRichTextUICustomization
* GetUICustomization() const { return m_uiCustomization
; }
78 /// Set the UI customization object.
79 void SetUICustomization(wxRichTextUICustomization
* customization
) { m_uiCustomization
= customization
; }
81 /// Is there a valid help topic id?
82 bool HasHelpId() const { return m_helpTopic
!= -1; }
84 /// Is there a valid customization object?
85 bool HasUICustomization() const { return m_uiCustomization
!= NULL
; }
88 wxRichTextUICustomization
* m_uiCustomization
;
92 /// Add this to the base class of dialogs
94 #define DECLARE_BASE_CLASS_HELP_PROVISION() \
95 virtual long GetHelpId() const = 0; \
96 virtual wxRichTextUICustomization* GetUICustomization() const = 0; \
97 virtual bool ShowHelp(wxWindow* win) = 0;
99 /// A macro to make it easy to add help topic provision and UI customization
100 /// to a class. Optionally, add virtual functions to a base class
101 /// using DECLARE_BASE_CLASS_HELP_PROVISION. This means that the formatting dialog
102 /// can obtain help topics from its individual pages without needing
103 /// to know in advance what page classes are being used, allowing for extension
104 /// of the formatting dialog.
106 #define DECLARE_HELP_PROVISION() \
107 virtual long GetHelpId() const { return sm_helpInfo.GetHelpId(); } \
108 virtual void SetHelpId(long id) { sm_helpInfo.SetHelpId(id); } \
109 virtual wxRichTextUICustomization* GetUICustomization() const { return sm_helpInfo.GetUICustomization(); } \
110 virtual void SetUICustomization(wxRichTextUICustomization* customization) { sm_helpInfo.SetUICustomization(customization); } \
111 virtual bool ShowHelp(wxWindow* win) { return sm_helpInfo.ShowHelp(win); } \
113 static wxRichTextHelpInfo sm_helpInfo; \
116 /// Add this to the implementation file for each dialog that needs help provision.
118 #define IMPLEMENT_HELP_PROVISION(theClass) \
119 wxRichTextHelpInfo theClass::sm_helpInfo;
125 // _WX_RICHTEXTUICUSTOMIZATION_H_