1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextuicustomization.h
3 // Purpose: UI customization base class for wxRTC
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows Licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_RICHTEXTUICUSTOMIZATION_H_
12 #define _WX_RICHTEXTUICUSTOMIZATION_H_
16 #include "wx/window.h"
19 @class wxRichTextUICustomization
20 The base class for functionality to plug in to various rich text control dialogs,
21 currently allowing the application to respond to Help button clicks without the
22 need to derive new dialog classes.
24 The application will typically have calls like this in its initialisation:
26 wxRichTextFormattingDialog::GetHelpInfo().SetHelpId(ID_HELP_FORMATTINGDIALOG);
27 wxRichTextFormattingDialog::GetHelpInfo().SetUICustomization(& wxGetApp().GetRichTextUICustomization());
28 wxRichTextBordersPage::GetHelpInfo().SetHelpId(ID_HELP_BORDERSPAGE);
30 Only the wxRichTextFormattingDialog class needs to have its customization object and help id set,
31 though the application set them for individual pages if it wants.
34 class WXDLLIMPEXP_RICHTEXT wxRichTextUICustomization
37 wxRichTextUICustomization() {}
38 virtual ~wxRichTextUICustomization() {}
40 /// Show the help given the current active window, and a help topic id.
41 virtual bool ShowHelp(wxWindow
* win
, long id
) = 0;
45 @class wxRichTextHelpInfo
46 This class is used as a static member of dialogs, to store the help topic for the dialog
47 and also the customization object that will allow help to be shown appropriately for the application.
50 class WXDLLIMPEXP_RICHTEXT wxRichTextHelpInfo
56 m_uiCustomization
= NULL
;
58 virtual ~wxRichTextHelpInfo() {}
60 virtual bool ShowHelp(wxWindow
* win
)
62 if ( !m_uiCustomization
|| m_helpTopic
== -1 )
65 return m_uiCustomization
->ShowHelp(win
, m_helpTopic
);
68 /// Get the help topic identifier.
69 long GetHelpId() const { return m_helpTopic
; }
71 /// Set the help topic identifier.
72 void SetHelpId(long id
) { m_helpTopic
= id
; }
74 /// Get the UI customization object.
75 wxRichTextUICustomization
* GetUICustomization() const { return m_uiCustomization
; }
77 /// Set the UI customization object.
78 void SetUICustomization(wxRichTextUICustomization
* customization
) { m_uiCustomization
= customization
; }
80 /// Is there a valid help topic id?
81 bool HasHelpId() const { return m_helpTopic
!= -1; }
83 /// Is there a valid customization object?
84 bool HasUICustomization() const { return m_uiCustomization
!= NULL
; }
87 wxRichTextUICustomization
* m_uiCustomization
;
91 /// Add this to the base class of dialogs
93 #define DECLARE_BASE_CLASS_HELP_PROVISION() \
94 virtual long GetHelpId() const = 0; \
95 virtual wxRichTextUICustomization* GetUICustomization() const = 0; \
96 virtual bool ShowHelp(wxWindow* win) = 0;
98 /// A macro to make it easy to add help topic provision and UI customization
99 /// to a class. Optionally, add virtual functions to a base class
100 /// using DECLARE_BASE_CLASS_HELP_PROVISION. This means that the formatting dialog
101 /// can obtain help topics from its individual pages without needing
102 /// to know in advance what page classes are being used, allowing for extension
103 /// of the formatting dialog.
105 #define DECLARE_HELP_PROVISION() \
106 virtual long GetHelpId() const { return sm_helpInfo.GetHelpId(); } \
107 virtual void SetHelpId(long id) { sm_helpInfo.SetHelpId(id); } \
108 virtual wxRichTextUICustomization* GetUICustomization() const { return sm_helpInfo.GetUICustomization(); } \
109 virtual void SetUICustomization(wxRichTextUICustomization* customization) { sm_helpInfo.SetUICustomization(customization); } \
110 virtual bool ShowHelp(wxWindow* win) { return sm_helpInfo.ShowHelp(win); } \
112 static wxRichTextHelpInfo& GetHelpInfo() { return sm_helpInfo; }\
114 static wxRichTextHelpInfo sm_helpInfo; \
117 /// Add this to the implementation file for each dialog that needs help provision.
119 #define IMPLEMENT_HELP_PROVISION(theClass) \
120 wxRichTextHelpInfo theClass::sm_helpInfo;
126 // _WX_RICHTEXTUICUSTOMIZATION_H_