]> git.saurik.com Git - wxWidgets.git/blob - include/wx/richtext/richtextuicustomization.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / richtext / richtextuicustomization.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextuicustomization.h
3 // Purpose: UI customization base class for wxRTC
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 2010-11-14
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows Licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_RICHTEXTUICUSTOMIZATION_H_
12 #define _WX_RICHTEXTUICUSTOMIZATION_H_
13
14 #if wxUSE_RICHTEXT
15
16 #include "wx/window.h"
17
18 /**
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.
23
24 The application will typically have calls like this in its initialisation:
25
26 wxRichTextFormattingDialog::GetHelpInfo().SetHelpId(ID_HELP_FORMATTINGDIALOG);
27 wxRichTextFormattingDialog::GetHelpInfo().SetUICustomization(& wxGetApp().GetRichTextUICustomization());
28 wxRichTextBordersPage::GetHelpInfo().SetHelpId(ID_HELP_BORDERSPAGE);
29
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.
32 **/
33
34 class WXDLLIMPEXP_RICHTEXT wxRichTextUICustomization
35 {
36 public:
37 wxRichTextUICustomization() {}
38 virtual ~wxRichTextUICustomization() {}
39
40 /// Show the help given the current active window, and a help topic id.
41 virtual bool ShowHelp(wxWindow* win, long id) = 0;
42 };
43
44 /**
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.
48 **/
49
50 class WXDLLIMPEXP_RICHTEXT wxRichTextHelpInfo
51 {
52 public:
53 wxRichTextHelpInfo()
54 {
55 m_helpTopic = -1;
56 m_uiCustomization = NULL;
57 }
58 virtual ~wxRichTextHelpInfo() {}
59
60 virtual bool ShowHelp(wxWindow* win)
61 {
62 if ( !m_uiCustomization || m_helpTopic == -1 )
63 return false;
64
65 return m_uiCustomization->ShowHelp(win, m_helpTopic);
66 }
67
68 /// Get the help topic identifier.
69 long GetHelpId() const { return m_helpTopic; }
70
71 /// Set the help topic identifier.
72 void SetHelpId(long id) { m_helpTopic = id; }
73
74 /// Get the UI customization object.
75 wxRichTextUICustomization* GetUICustomization() const { return m_uiCustomization; }
76
77 /// Set the UI customization object.
78 void SetUICustomization(wxRichTextUICustomization* customization) { m_uiCustomization = customization; }
79
80 /// Is there a valid help topic id?
81 bool HasHelpId() const { return m_helpTopic != -1; }
82
83 /// Is there a valid customization object?
84 bool HasUICustomization() const { return m_uiCustomization != NULL; }
85
86 protected:
87 wxRichTextUICustomization* m_uiCustomization;
88 long m_helpTopic;
89 };
90
91 /// Add this to the base class of dialogs
92
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;
97
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.
104
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); } \
111 public: \
112 static wxRichTextHelpInfo& GetHelpInfo() { return sm_helpInfo; }\
113 protected: \
114 static wxRichTextHelpInfo sm_helpInfo; \
115 public:
116
117 /// Add this to the implementation file for each dialog that needs help provision.
118
119 #define IMPLEMENT_HELP_PROVISION(theClass) \
120 wxRichTextHelpInfo theClass::sm_helpInfo;
121
122 #endif
123 // wxUSE_RICHTEXT
124
125 #endif
126 // _WX_RICHTEXTUICUSTOMIZATION_H_