]>
Commit | Line | Data |
---|---|---|
603f702b JS |
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 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows Licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_RICHTEXTUICUSTOMIZATION_H_ | |
13 | #define _WX_RICHTEXTUICUSTOMIZATION_H_ | |
14 | ||
15 | #if wxUSE_RICHTEXT | |
16 | ||
2be72ac2 JS |
17 | #include "wx/window.h" |
18 | ||
603f702b JS |
19 | /** |
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. | |
24 | ||
25 | The application will typically have calls like this in its initialisation: | |
26 | ||
ad8f9137 JS |
27 | wxRichTextFormattingDialog::GetHelpInfo().SetHelpId(ID_HELP_FORMATTINGDIALOG); |
28 | wxRichTextFormattingDialog::GetHelpInfo().SetUICustomization(& wxGetApp().GetRichTextUICustomization()); | |
29 | wxRichTextBordersPage::GetHelpInfo().SetHelpId(ID_HELP_BORDERSPAGE); | |
603f702b JS |
30 | |
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. | |
33 | **/ | |
34 | ||
35 | class WXDLLIMPEXP_RICHTEXT wxRichTextUICustomization | |
36 | { | |
37 | public: | |
38 | wxRichTextUICustomization() {} | |
39 | virtual ~wxRichTextUICustomization() {} | |
40 | ||
41 | /// Show the help given the current active window, and a help topic id. | |
42 | virtual bool ShowHelp(wxWindow* win, long id) = 0; | |
43 | }; | |
44 | ||
45 | /** | |
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. | |
49 | **/ | |
50 | ||
51 | class WXDLLIMPEXP_RICHTEXT wxRichTextHelpInfo | |
52 | { | |
53 | public: | |
54 | wxRichTextHelpInfo() | |
55 | { | |
56 | m_helpTopic = -1; | |
57 | m_uiCustomization = NULL; | |
58 | } | |
59 | virtual ~wxRichTextHelpInfo() {} | |
60 | ||
61 | virtual bool ShowHelp(wxWindow* win) | |
62 | { | |
decd390a | 63 | if ( !m_uiCustomization || m_helpTopic == -1 ) |
603f702b | 64 | return false; |
decd390a VZ |
65 | |
66 | return m_uiCustomization->ShowHelp(win, m_helpTopic); | |
603f702b JS |
67 | } |
68 | ||
69 | /// Get the help topic identifier. | |
70 | long GetHelpId() const { return m_helpTopic; } | |
71 | ||
72 | /// Set the help topic identifier. | |
73 | void SetHelpId(long id) { m_helpTopic = id; } | |
74 | ||
75 | /// Get the UI customization object. | |
76 | wxRichTextUICustomization* GetUICustomization() const { return m_uiCustomization; } | |
77 | ||
78 | /// Set the UI customization object. | |
79 | void SetUICustomization(wxRichTextUICustomization* customization) { m_uiCustomization = customization; } | |
80 | ||
81 | /// Is there a valid help topic id? | |
82 | bool HasHelpId() const { return m_helpTopic != -1; } | |
83 | ||
84 | /// Is there a valid customization object? | |
85 | bool HasUICustomization() const { return m_uiCustomization != NULL; } | |
86 | ||
87 | protected: | |
88 | wxRichTextUICustomization* m_uiCustomization; | |
89 | long m_helpTopic; | |
90 | }; | |
91 | ||
92 | /// Add this to the base class of dialogs | |
93 | ||
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; | |
98 | ||
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. | |
105 | ||
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); } \ | |
ad8f9137 JS |
112 | public: \ |
113 | static wxRichTextHelpInfo& GetHelpInfo() { return sm_helpInfo; }\ | |
603f702b JS |
114 | protected: \ |
115 | static wxRichTextHelpInfo sm_helpInfo; \ | |
116 | public: | |
117 | ||
118 | /// Add this to the implementation file for each dialog that needs help provision. | |
119 | ||
120 | #define IMPLEMENT_HELP_PROVISION(theClass) \ | |
121 | wxRichTextHelpInfo theClass::sm_helpInfo; | |
122 | ||
123 | #endif | |
124 | // wxUSE_RICHTEXT | |
125 | ||
126 | #endif | |
127 | // _WX_RICHTEXTUICUSTOMIZATION_H_ |