OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
hlpmanag.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Declares THelpContext and THelpFileManager.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_HLPMANAG_H)
10#define OWL_HLPMANAG_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/window.h>
18#include <htmlhelp.h>
19
20namespace owl {
21
22class _OWLCLASS THelpContext;
23class _OWLCLASS TWindow;
24
25#include <owl/preclass.h>
26
27
28// moved from owl/signatur.h
29
38
39
40class _OWLCLASS THlpNotify : public HHN_NOTIFY{
41 public:
43
44 operator NMHDR&() { return hdr; }
45};
46
47class _OWLCLASS THlpPopup : public HH_POPUP {
48 public:
49 THlpPopup(uint id = 0);
50};
51
52class _OWLCLASS THlpAklink : public HH_AKLINK {
53 public:
55 {
56 ZeroMemory(this,sizeof(HH_AKLINK));
57 cbStruct = sizeof(HH_AKLINK);
58 }
59};
60
61class _OWLCLASS THlpEnumIt : public HH_ENUM_IT {
62 public:
64 {
65 ZeroMemory(this,sizeof(HH_ENUM_IT));
66 cbStruct = sizeof(HH_ENUM_IT);
67 }
68};
69
70class _OWLCLASS THlpSetInfoType : public HH_SET_INFOTYPE {
71 public:
73 {
74 ZeroMemory(this,sizeof(HH_SET_INFOTYPE));
75 cbStruct = sizeof(HH_SET_INFOTYPE);
76 }
77};
78
79class _OWLCLASS THlpFtsQuery : public HH_FTS_QUERY {
80 public:
82 {
83 ZeroMemory(this,sizeof(HH_FTS_QUERY));
84 cbStruct = sizeof(HH_FTS_QUERY);
85 }
86};
87
88class _OWLCLASS THlpWinType : public HH_WINTYPE {
89 public:
91 {
92 ZeroMemory(this,sizeof(HH_WINTYPE));
93 cbStruct = sizeof(HH_WINTYPE);
94 }
95 void SetStyle(int style);
96 void SetProperties(int prop);
97 void SetToolBarFlags(int flags);
98 void SetWindowsPos(const TRect& rect);
99};
100
101class _OWLCLASS THlpTrack : public HHNTRACK {
102 public:
104
105 operator NMHDR&() { return hdr; }
106};
107
108//
109/// \class THelpContext
110// ~~~~~ ~~~~~~~~~~~~
111/// THelpContext is a class that maintains information about a menu item id and
112/// a child control id with a help context id.
113/// As particular windows get and lose focus, their context tables are removed
114/// from a global context table.
115//
117 public:
118 THelpContext();
119 THelpContext(TWindow* window, int helpId, int menuId, int controlId);
122
124 bool operator ==(const THelpContext&) const;
125 // not implemented just to make happy STL
126 bool operator <(const THelpContext&) const;
127
128 int GetHelpFileContextId() const;
129 int GetMenuContextId() const;
130 int GetControlContextId() const;
131 TWindow* GetWindow() const;
132 void SetWindow(TWindow* window);
133
134 private:
135 TWindow* Window;
136 int HelpFileContextId;
137 int MenuContextId;
138 int ControlContextId;
139};
140
141// Forward declarations
142template <class T> class TBaseList;
143template<class T> class TBaseListIterator;
144
145//
146/// \class THelpFileManager
147// ~~~~~ ~~~~~~~~~~~~~~~~
148/// THelpFileManager, which is designed to be a mix-in for TApplication, uses the
149/// global context table. THelpFileManager looks for the WM_HELP message and calls
150/// the help file with the associated context ID.
151/// \todo HTMLHelp should be by default, and discourage using old WinHelp files
152/// as they are not well supported under Windows Vista and later
153//
155 public:
158 virtual ~THelpFileManager();
159
160 virtual void ActivateHelp(TWindow*, int helpFileContextId, uint hlpCmd = HELP_CONTEXT);
161 virtual void DeactivateHelp();
162
163 void SetHelpFile(const tstring& helpFileName);
164 tstring GetHelpFile() const;
165
166 bool GetHelpContextFromControl(THelpContext&, int controlId, HWND ctrl) const;
167 bool GetHelpContextFromMenu(THelpContext&, int menuId) const;
168
169 void AddContextInfo(TWindow*, int helpId, int menuId, int controlId);
170 void RemoveContextInfo(TWindow*);
171
172 protected:
173 virtual bool ProcessHelpMsg (MSG& msg);
174 virtual void SetHelpCursor();
175
176 void EvHelp(const HELPINFO&);
177 void EvHelpHit(const THelpHitInfo&);
178
179 void CmContextHelp ();
180 void CeContextHelp (TCommandEnabler& ce);
181 void CmWhatIsThis();
182
183 // not finished wil be changed ???????????????
184 public:
186
188 {return HtmlHelp(w, helpFile.c_str(), hlpCmd, data);}
189
190 void TranslateWinToHTML(bool translate) { WinToHTML = translate;}
191
192 protected:
195
196 protected:
200
203
206
209
211};
212
213/// \class THtmlHelpDll
214// ~~~~~ ~~~~~~~~~~~~
215/// Wrapper for the HHCTRL.OCX itself
224
225//
226/// Loader for the HHCTRL.OCX
228
229#if defined(_OWLDLL) || defined(BI_APP_DLL)
230 //
231 /// Export template of TDllLoader<THtmlHelpDll> when building ObjectWindows
232 /// DLL and provide import declaration of DLL instance for users of the class.
233 //
234 template class _OWLCLASS TDllLoader<THtmlHelpDll>;
235#endif
236
237#include <owl/posclass.h>
238
239//----------------------------------------------------------------------------
240// Macros to simplify usage of THelpContext
241//
242
243#define DECLARE_HELPCONTEXT(cls) \
244 static THelpContext __hcEntries[]
245
246#define DEFINE_HELPCONTEXT(cls)\
247 THelpContext cls::__hcEntries[] = {
248
249#define END_HELPCONTEXT \
250 THelpContext(0, 0, 0, 0) \
251 }
252
253#define HCENTRY_MENU(hcId, menuId) \
254 THelpContext(0, hcId, menuId, 0)
255
256#define HCENTRY_CONTROL(hcId, ctlId) \
257 THelpContext(0, hcId, 0, ctlId)
258
259#define HCENTRY_MENU_AND_CONTROL(hcId, menuId, ctlId) \
260 THelpContext(0, hcId, menuId, ctlId)
261
262#define SETUP_HELPCONTEXT(appCls, cls) \
263 { \
264 appCls* app = TYPESAFE_DOWNCAST(GetApplication(), appCls); \
265 if (app) { \
266 for (THelpContext* hc = &__hcEntries[0]; !IsLastIndirectContext(*hc); hc++) { \
267 app->AddContextInfo(this, \
268 hc->GetHelpFileContextId(), \
269 hc->GetMenuContextId(), \
270 hc->GetControlContextId()); \
271 } \
272 } \
273 }
274
275#define CLEANUP_HELPCONTEXT(appCls, cls) \
276 { \
277 appCls* app = TYPESAFE_DOWNCAST(GetApplication(), appCls); \
278 if (app) \
279 app->RemoveContextInfo(this); \
280 }
281
282const int TablePtr = -1;
283
284//----------------------------------------------------------------------------
285// Inline implementations
286//
287
288//
289/// Return true if the context entry is a pointer to another table.
290//
291inline bool
293{
294 if (context.GetMenuContextId() == TablePtr &&
295 context.GetHelpFileContextId() == TablePtr &&
296 context.GetControlContextId() == TablePtr)
297 return true;
298 return false;
299}
300
301//
302/// Return true if this entry is the last entry.
303//
304inline bool
306{
307 if (context.GetMenuContextId() == 0 &&
308 context.GetHelpFileContextId() == 0 &&
309 context.GetControlContextId() == 0)
310 return true;
311 return false;
312}
313
314//
315/// Returns the name of the help file.
316//
317inline tstring
319{
320 return HelpFileName;
321}
322
323//
324//
325//
326inline void
328{
329 LastHit = hit.Point;
330 LastParent = hit.Window;
331}
332
333//
334/// Returns the help file context id for the context entry.
335//
336inline int
338{
339 return HelpFileContextId;
340}
341
342//
343/// Returns the menu id for this context entry.
344//
345inline int
347{
348 return MenuContextId;
349}
350
351//
352/// Returns the child control id for this context entry.
353//
354inline int
356{
357 return ControlContextId;
358}
359
360//
361/// Returns the window this entry is associated with.
362//
363inline TWindow*
365{
366 return Window;
367}
368
369//
370/// Sets the window for this context entry.
371//
372inline void
374{
375 Window = window;
376}
377
378
379} // OWL namespace
380
381
382#endif // OWL_HLPMANAG_H
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
TCursor, derived from TGdiBase, represents the GDI cursor object class.
Definition gdiobjec.h:730
TEventHandler is a base class from which you can derive classes that handle messages.
Definition eventhan.h:162
THelpContext is a class that maintains information about a menu item id and a child control id with a...
Definition hlpmanag.h:116
void SetWindow(TWindow *window)
Sets the window for this context entry.
Definition hlpmanag.h:373
int GetHelpFileContextId() const
Returns the help file context id for the context entry.
Definition hlpmanag.h:337
int GetControlContextId() const
Returns the child control id for this context entry.
Definition hlpmanag.h:355
TWindow * GetWindow() const
Returns the window this entry is associated with.
Definition hlpmanag.h:364
int GetMenuContextId() const
Returns the menu id for this context entry.
Definition hlpmanag.h:346
THelpFileManager, which is designed to be a mix-in for TApplication, uses the global context table.
Definition hlpmanag.h:154
DECLARE_RESPONSE_TABLE(THelpFileManager)
TBaseList< THelpContext > TContextList
Definition hlpmanag.h:197
void TranslateWinToHTML(bool translate)
Definition hlpmanag.h:190
void EvHelpHit(const THelpHitInfo &)
Definition hlpmanag.h:327
TBaseListIterator< THelpContext > TContextListIterator
Definition hlpmanag.h:198
tstring GetHelpFile() const
Returns the name of the help file.
Definition hlpmanag.h:318
TContextList * ContextTable
Definition hlpmanag.h:199
HWND HtmlHelp(TWindow *w, const tstring &helpFile, uint hlpCmd, DWORD_PTR data)
Definition hlpmanag.h:187
Wrapper for the HHCTRL.OCX itself.
Definition hlpmanag.h:216
TModuleProc4< HWND, HWND, LPCTSTR, uint, DWORD_PTR > HtmlHelp
Definition hlpmanag.h:222
TModuleProc0< HRESULT > DllCanUnloadNow
Definition hlpmanag.h:220
TModuleProc3< HRESULT, REFCLSID, REFIID, void ** > DllGetClassObject
Definition hlpmanag.h:221
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
TDllLoader< THtmlHelpDll > THtmlHelp
Loader for the HHCTRL.OCX.
Definition hlpmanag.h:227
bool IsLastIndirectContext(const THelpContext &context)
Return true if this entry is the last entry.
Definition hlpmanag.h:305
bool IsIndirectHelpContext(const THelpContext &context)
Return true if the context entry is a pointer to another table.
Definition hlpmanag.h:292
const int TablePtr
Definition hlpmanag.h:282
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338
THelpHitInfo(const TPoint &pt, TWindow *wnd)
Definition hlpmanag.h:32
THelpHitInfo(int x, int y, TWindow *wnd)
Definition hlpmanag.h:33
TWindow * Window
Definition hlpmanag.h:36
Base window class TWindow definition, including HWND encapsulation.