OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
eventhan.h
Go to the documentation of this file.
1//
2/// \file
3/// Definition of TEventHandler and related classes & macros
4//
5// Part of OWLNext - the next generation Object Windows Library
6// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
7// Copyright (c) 2013 Vidar Hasfjord
8//
9// For more information, including license details, see
10// http://owlnext.sourceforge.net
11//
12//----------------------------------------------------------------------------
13
14#if !defined(OWL_EVENTHAN_H)
15#define OWL_EVENTHAN_H
16
17#include <owl/private/defs.h>
18#if defined(BI_HAS_PRAGMA_ONCE)
19# pragma once
20#endif
21
22#include <owl/signatur.h>
23#include <owl/dispatch.h>
24
25#if (defined(__TRACE) || defined(__WARN))
27#endif
28
29namespace owl {
30
31#include <owl/preclass.h>
32
33/// \addtogroup base
34/// @{
35
36#if OWL_NEW_RESPONSE_TABLE // New response table implementation:
37
38//
39/// \class TResponseTableEntry
40/// Consists of the information needed to lookup and dispatch a message to a selected handler.
41///
42/// See DECLARE_RESPONSE_TABLE and DEFINE_RESPONSE_TABLE for additional information
43/// about the macros in the response tables.
44//
45class _OWLCLASS TResponseTableEntry
46{
47public:
48
49 union
50 {
51 /// Stores the ID of the message handled by this entry.
52 /// This can be a general message, command message or notification message, for example,
53 /// WM_LBUTTONDOWN or LBN_SELCHANGE.
54 //
55 TMsgId Msg;
56
57 /// Stores the control notification code (for example, ID_LISTBOX) handled by this entry.
58 /// This can be a button, combo box, edit control or list box notification code.
59 //
60 uint NotifyCode;
61 };
62
63 /// Stores the menu or accelerator resource ID (CM_xxxx) handled by this entry.
64 //
65 uint Id;
66
67 /// Stores the dispatcher used to handle messages by this entry.
68 //
69 TDispatchFunction Dispatcher;
70};
71
72typedef TResponseTableEntry TGenericTableEntry; // For backwards compatibility.
73
74//
75/// \class TEventHandler
76/// TEventHandler is a base class from which you can derive classes that handle messages.
77/// Specifically, TEventHandler performs the following event-handling tasks:
78///
79/// - 1. Analyzes a window message.
80/// - 2. Searches the class's response table for an appropriate event-handling function.
81/// - 3. Dispatches the message to the designated event-handling function.
82///
83/// Most of ObjectWindows' classes are derived from TEventHandler and, therefore, inherit this
84/// event-handling machinery. In addition, any user-defined class derived from TEventHandler can
85/// handle particular Windows messages using a response table and member function handlers.
86//
87class _OWLCLASS TEventHandler
88{
89public:
90
91 /// A nested class, TEventInfo provides specific information about the type of message sent, the
92 /// class that contains the function to be handled, the corresponding response table entry, and
93 /// the dispatch function that forwards the message.
94 //
95 class TEventInfo
96 {
97 public:
98
99 /// Contains the type of message sent. These can be command messages, child ID
100 /// messages, notify-based messages such as LBN_SELCHANGE, or windows messages such
101 /// as LBUTTONDOWN.
102 //
103 const TMsgId Msg;
104
105 /// Contains the menu or accelerator resource ID (CM_xxxx) for the message response
106 /// member function.
107 //
108 const uint Id;
109
110 /// Points to the object that contains the function to be handled.
111 //
112 void* Object;
113
114 /// Points to the response table entry (for example, EvActivate).
115 //
116 const TResponseTableEntry* Entry;
117
118 /// Constructs a TEventInfo object with the specified ID and message type.
119 //
120 TEventInfo(TMsgId msg, uint id = 0)
121 : Msg(msg), Id(id), Entry(nullptr) {}
122 };
123
124 typedef bool (*TEqualOperator)(const TResponseTableEntry&, const TEventInfo&);
125
126 /// Searches the list of response table entries looking for a match
127 //
128 virtual bool Find(TEventInfo& info, TEqualOperator op = 0);
129
130 TResult Dispatch(TEventInfo& info, TParam1, TParam2 = 0);
131 TResult DispatchMsg(TMsgId, uint id, TParam1, TParam2);
132
133protected:
134
135 bool SearchEntries(const TResponseTableEntry* entries, TEventInfo& info, TEqualOperator op);
136};
137
138#else // Old response table implementation:
139
140//
141// Forward declarations
142//
143template <class T> class _OWLCLASS TResponseTableEntry;
145
146//
147/// \class TEventHandler
148// ~~~~~ ~~~~~~~~~~~~~
149/// TEventHandler is a base class from which you can derive classes that handle
150/// messages. Specifically, TEventHandler performs the following event-handling
151/// tasks:
152/// - 1. Analyzes a window message.
153/// - 2. Searches the class's response table entries for an appropriate
154/// event-handling function.
155/// - 3. Dispatches the message to the designated event-handling function.
156///
157/// Most of ObjectWindows' classes are derived from TEventHandler and, therefore,
158/// inherit this event-handling behavior. In addition, any user-defined class
159/// derived from TEventHandler can handle message response functions that are
160/// associated with a particular window message.
161//
163 public:
164
165 /// A nested class, TEventInfo provides specific information about the type of
166 /// message sent, the class that contains the function to be handled, the
167 /// corresponding response table entry, and the dispatch function that processes the
168 /// message.
170 {
171 public:
172
173 /// Contains the type of message sent. These can be command messages, child ID
174 /// messages, notify-based messages such as LBN_SELCHANGE, or windows messages such
175 /// as LBUTTONDOWN.
176 //
177 const TMsgId Msg;
178
179 /// Contains the menu or accelerator resource ID (CM_xxxx) for the message response
180 /// member function.
181 const uint Id;
182
183 /// Points to the object that contains the function to be handled.
185
186 /// Points to the response table entry (for example, EvActivate).
188
189 /// Constructs a TEventInfo object with the specified ID and message type.
190 TEventInfo(TMsgId msg, uint id=0) : Msg(msg), Id(id) {Entry = 0;}
191 };
192
193 typedef bool(*TEqualOperator)(const TGenericTableEntry &, const TEventInfo&);
194
195 /// Searches the list of response table entries looking for a match
196 //
197 virtual bool Find(TEventInfo& info, TEqualOperator op = 0);
198
199 TResult Dispatch(TEventInfo& info, TParam1, TParam2 = 0);
200 TResult DispatchMsg(TMsgId, uint id, TParam1, TParam2);
201
202 protected:
203 bool SearchEntries(const TGenericTableEntry * entries,
205 TEqualOperator op);
206};
207
208//
209/// \class TResponseTableEntry<>
210// ~~~~~ ~~~~~~~~~~~~~~~~~~~~~
211/// A template class, TResponseTableEntry lets you define a pattern for entries into
212/// a response table. Entries consist of a message, a notification code, a resource
213/// ID, a dispatcher type, and a pointer to a member function.
214/// See DECLARE_RESPONSE_TABLE and DEFINE_RESPONSE_TABLE for additional information
215/// about the macros in the response tables.
216//
217template <class T> class _OWLCLASS TResponseTableEntry {
218 public:
219
220 /// Type for a generic member function that responds to notification messages. T is
221 /// the template for the response table.
222 typedef void (T::*PMF)();
223
224 union {
225 /// Contains the ID of the message sent. These can be command messages, child id
226 /// messages, notify-based messages such as LBN_SELCHANGE, or messages such as
227 /// LBUTTONDOWN.
229
230 /// Stores the control notification code (for example, ID_LISTBOX) for the response
231 /// table entry. These can be button, combo box, edit control, or list box
232 /// notification codes.
234 };
235
236 /// Contains the menu or accelerator resource ID (CM_xxxx) for the message response
237 /// member function.
239
240 /// An abstract dispatcher type that points to one of the dispatcher functions.
242
243 /// Points to the actual handler or member function.
244 PMF Pmf;
245};
246
247#endif
248
249#if defined(__TRACE) || defined(__WARN)
250
251//
252// Class/operator which converts a Windows message to its string equivalent for
253// use with the diagnostic library
254//
256{
257public:
258 TMsgName(TMsgId msg) : Message(msg) {}
259
260private:
261 TMsgId Message;
262
263 friend _OWLCFUNC(tostream &) operator <<(tostream& os, const TMsgName& msg);
264};
265
267
268#endif
269
270/// @}
271
272#include <owl/posclass.h>
273
274} // OWL namespace
275
276#if OWL_NEW_RESPONSE_TABLE // New response table implementation:
277
278//
279// Macros to declare a response table
280//
281#define DECLARE_RESPONSE_TABLE(cls)\
282 private: static ::owl::TResponseTableEntry __entries[];\
283 private: typedef cls TMyClass;\
284 public: auto Find(TEventInfo&, TEqualOperator = 0) -> bool override
285
286#define DECLARE_EXPORT_RESPONSE_TABLE(cls)\
287 private: static ::owl::TResponseTableEntry __entries[];\
288 private: typedef cls TMyClass;\
289 public: auto __declspec(dllexport) Find(TEventInfo&, TEqualOperator = 0) -> bool override
290
291#define DECLARE_IMPORT_RESPONSE_TABLE(cls)\
292 private: static ::owl::TResponseTableEntry __entries[];\
293 private: typedef cls TMyClass;\
294 public: auto __declspec(dllimport) Find(TEventInfo&, TEqualOperator = 0) -> bool override
295
296//
297// Macros to define the response table entries
298//
299#define DEFINE_RESPONSE_TABLE_ENTRIES(cls)\
300 ::owl::TResponseTableEntry cls::__entries[] = {
301
302#define END_RESPONSE_TABLE\
303 {{0}, 0, nullptr}}
304
305//
306/// Macro to define a response table for a class with no base response tables
307/// Use it like this:
308///
309/// \code
310/// DEFINE_RESPONSE_TABLE(cls)
311/// EV_WM_PAINT,
312/// EV_WM_LBUTTONDOWN,
313/// END_RESPONSE_TABLE;
314/// \endcode
315//
316#define DEFINE_RESPONSE_TABLE(cls)\
317 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
318 {\
319 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal);\
320 }\
321 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
322
323#define DEFINE_RESPONSE_TABLE1(cls, base1)\
324 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
325 {\
326 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
327 base1::Find(eventInfo, equal);\
328 }\
329 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
330
331#define DEFINE_RESPONSE_TABLE2(cls, base1, base2)\
332 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
333 {\
334 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
335 base1::Find(eventInfo, equal) ||\
336 base2::Find(eventInfo, equal);\
337 }\
338 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
339
340#define DEFINE_RESPONSE_TABLE3(cls, base1, base2, base3)\
341 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
342 {\
343 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
344 base1::Find(eventInfo, equal) ||\
345 base2::Find(eventInfo, equal) ||\
346 base3::Find(eventInfo, equal);\
347 }\
348 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
349
350#define DEFINE_RESPONSE_TABLE4(cls, base1, base2, base3, base4)\
351 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
352 {\
353 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
354 base1::Find(eventInfo, equal) ||\
355 base2::Find(eventInfo, equal) ||\
356 base3::Find(eventInfo, equal) ||\
357 base4::Find(eventInfo, equal);\
358 }\
359 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
360
361#define DEFINE_RESPONSE_TABLE5(cls, base1, base2, base3, base4, base5)\
362 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
363 {\
364 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
365 base1::Find(eventInfo, equal) ||\
366 base2::Find(eventInfo, equal) ||\
367 base3::Find(eventInfo, equal) ||\
368 base4::Find(eventInfo, equal) ||\
369 base5::Find(eventInfo, equal);\
370 }\
371 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
372
373#define DEFINE_RESPONSE_TABLE6(cls, base1, base2, base3, base4, base5, base6)\
374 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
375 {\
376 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
377 base1::Find(eventInfo, equal) ||\
378 base2::Find(eventInfo, equal) ||\
379 base3::Find(eventInfo, equal) ||\
380 base4::Find(eventInfo, equal) ||\
381 base5::Find(eventInfo, equal) ||\
382 base6::Find(eventInfo, equal);\
383 }\
384 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
385
386#define DEFINE_RESPONSE_TABLE7(cls, base1, base2, base3, base4, base5, base6, base7)\
387 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
388 {\
389 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
390 base1::Find(eventInfo, equal) ||\
391 base2::Find(eventInfo, equal) ||\
392 base3::Find(eventInfo, equal) ||\
393 base4::Find(eventInfo, equal) ||\
394 base5::Find(eventInfo, equal) ||\
395 base6::Find(eventInfo, equal) ||\
396 base7::Find(eventInfo, equal);\
397 }\
398 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
399
400#define DEFINE_RESPONSE_TABLE8(cls, base1, base2, base3, base4, base5, base6, base7, base8)\
401 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
402 {\
403 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
404 base1::Find(eventInfo, equal) ||\
405 base2::Find(eventInfo, equal) ||\
406 base3::Find(eventInfo, equal) ||\
407 base4::Find(eventInfo, equal) ||\
408 base5::Find(eventInfo, equal) ||\
409 base6::Find(eventInfo, equal) ||\
410 base7::Find(eventInfo, equal) ||\
411 base8::Find(eventInfo, equal);\
412 }\
413 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
414
415#define DEFINE_RESPONSE_TABLE9(cls, base1, base2, base3, base4, base5, base6, base7, base8, base9)\
416 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
417 {\
418 return SearchEntries(&__entries[0], (eventInfo.Object = this, eventInfo), equal) ||\
419 base1::Find(eventInfo, equal) ||\
420 base2::Find(eventInfo, equal) ||\
421 base3::Find(eventInfo, equal) ||\
422 base4::Find(eventInfo, equal) ||\
423 base5::Find(eventInfo, equal) ||\
424 base6::Find(eventInfo, equal) ||\
425 base7::Find(eventInfo, equal) ||\
426 base8::Find(eventInfo, equal) ||\
427 base9::Find(eventInfo, equal);\
428 }\
429 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
430
431#else // Old response table implementation:
432
433//
434// Macros to declare a response table
435//
436#define DECLARE_RESPONSE_TABLE(cls)\
437 private:\
438 static ::owl::TResponseTableEntry< cls > __entries[];\
439 typedef ::owl::TResponseTableEntry< cls >::PMF TMyPMF;\
440 typedef cls TMyClass;\
441 public:\
442 auto Find(TEventInfo&, TEqualOperator = 0) -> bool override
443
444#define DECLARE_EXPORT_RESPONSE_TABLE(cls)\
445 private:\
446 static ::owl::TResponseTableEntry< cls > __entries[];\
447 typedef ::owl::TResponseTableEntry< cls >::PMF TMyPMF;\
448 typedef cls TMyClass;\
449 public:\
450 auto __declspec(dllexport) Find(TEventInfo&, TEqualOperator = 0) -> bool override
451
452#define DECLARE_IMPORT_RESPONSE_TABLE(cls)\
453 private:\
454 static ::owl::TResponseTableEntry< cls > __entries[];\
455 typedef ::owl::TResponseTableEntry< cls >::PMF TMyPMF;\
456 typedef cls TMyClass;\
457 public:\
458 auto __declspec(dllimport) Find(TEventInfo&, TEqualOperator = 0) -> bool override
459
460//
461// Macros to define the response table entries
462//
463#define DEFINE_RESPONSE_TABLE_ENTRIES(cls)\
464 ::owl::TResponseTableEntry< cls > cls::__entries[] = {
465
466#define END_RESPONSE_TABLE\
467 {{0}, 0, 0, 0}}
468
469//
470/// Macro to define a response table for a class with no base response tables
471//
472/// Use it like this:
473/// \code
474/// DEFINE_RESPONSE_TABLE(cls)
475/// EV_WM_PAINT,
476/// EV_WM_LBUTTONDOWN,
477/// END_RESPONSE_TABLE;
478/// \endcode
479#define DEFINE_RESPONSE_TABLE(cls)\
480 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
481 {\
482 using namespace ::owl;\
483 eventInfo.Object = (TGeneric*)this;\
484 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal);\
485 }\
486 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
487
488//
489/// Macro to define a response table for a class with one base. Use this macro
490/// exactly like macro DEFINE_RESPONSE_TABLE
491//
492#define DEFINE_RESPONSE_TABLE1(cls, base)\
493 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
494 {\
495 using namespace ::owl;\
496 eventInfo.Object = (TGeneric*)this;\
497 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
498 base::Find(eventInfo, equal);\
499 }\
500 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
501
502//
503/// Macro to define a response table for a class with two bases. Use this macro
504/// exactly like macro DEFINE_RESPONSE_TABLE
505//
506#define DEFINE_RESPONSE_TABLE2(cls, base1, base2)\
507 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
508 {\
509 using namespace ::owl;\
510 eventInfo.Object = (TGeneric*)this;\
511 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
512 base1::Find(eventInfo, equal) ||\
513 base2::Find(eventInfo, equal);\
514 }\
515 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
516
517//
518/// Macro to define a response table for a class with three bases. Use this macro
519/// exactly like macro DEFINE_RESPONSE_TABLE
520//
521#define DEFINE_RESPONSE_TABLE3(cls, base1, base2, base3)\
522 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
523 {\
524 using namespace ::owl;\
525 eventInfo.Object = (TGeneric*)this;\
526 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
527 base1::Find(eventInfo, equal) ||\
528 base2::Find(eventInfo, equal) ||\
529 base3::Find(eventInfo, equal);\
530 }\
531 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
532
533//
534/// Macro to define a response table for a class with three bases. Use this macro
535/// exactly like macro DEFINE_RESPONSE_TABLE
536//
537#define DEFINE_RESPONSE_TABLE4(cls, base1, base2, base3, base4)\
538 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
539 {\
540 using namespace ::owl;\
541 eventInfo.Object = (TGeneric*)this;\
542 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
543 base1::Find(eventInfo, equal) ||\
544 base2::Find(eventInfo, equal) ||\
545 base3::Find(eventInfo, equal) ||\
546 base4::Find(eventInfo, equal);\
547 }\
548 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
549
550//
551/// Macro to define a response table for a class with three bases. Use this macro
552/// exactly like macro DEFINE_RESPONSE_TABLE
553//
554#define DEFINE_RESPONSE_TABLE5(cls, base1, base2, base3, base4, base5)\
555 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
556 {\
557 using namespace ::owl;\
558 eventInfo.Object = (TGeneric*)this;\
559 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
560 base1::Find(eventInfo, equal) ||\
561 base2::Find(eventInfo, equal) ||\
562 base3::Find(eventInfo, equal) ||\
563 base4::Find(eventInfo, equal) ||\
564 base5::Find(eventInfo, equal);\
565 }\
566 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
567
568//
569/// Macro to define a response table for a class with three bases. Use this macro
570/// exactly like macro DEFINE_RESPONSE_TABLE
571//
572#define DEFINE_RESPONSE_TABLE6(cls, base1, base2, base3, base4, base5, base6)\
573 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
574 {\
575 using namespace ::owl;\
576 eventInfo.Object = (TGeneric*)this;\
577 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
578 base1::Find(eventInfo, equal) ||\
579 base2::Find(eventInfo, equal) ||\
580 base3::Find(eventInfo, equal) ||\
581 base4::Find(eventInfo, equal) ||\
582 base5::Find(eventInfo, equal) ||\
583 base6::Find(eventInfo, equal);\
584 }\
585 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
586
587//
588/// Macro to define a response table for a class with three bases. Use this macro
589/// exactly like macro DEFINE_RESPONSE_TABLE
590//
591#define DEFINE_RESPONSE_TABLE7(cls, base1, base2, base3, base4, base5, base6, base7)\
592 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
593 {\
594 using namespace ::owl;\
595 eventInfo.Object = (TGeneric*)this;\
596 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
597 base1::Find(eventInfo, equal) ||\
598 base2::Find(eventInfo, equal) ||\
599 base3::Find(eventInfo, equal) ||\
600 base4::Find(eventInfo, equal) ||\
601 base5::Find(eventInfo, equal) ||\
602 base6::Find(eventInfo, equal) ||\
603 base7::Find(eventInfo, equal);\
604 }\
605 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
606
607//
608/// Macro to define a response table for a class with three bases. Use this macro
609/// exactly like macro DEFINE_RESPONSE_TABLE
610//
611#define DEFINE_RESPONSE_TABLE8(cls, base1, base2, base3, base4, base5, base6, base7, base8)\
612 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
613 {\
614 using namespace ::owl;\
615 eventInfo.Object = (TGeneric*)this;\
616 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
617 base1::Find(eventInfo, equal) ||\
618 base2::Find(eventInfo, equal) ||\
619 base3::Find(eventInfo, equal) ||\
620 base4::Find(eventInfo, equal) ||\
621 base5::Find(eventInfo, equal) ||\
622 base6::Find(eventInfo, equal) ||\
623 base7::Find(eventInfo, equal) ||\
624 base8::Find(eventInfo, equal);\
625 }\
626 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
627
628//
629/// Macro to define a response table for a class with three bases. Use this macro
630/// exactly like macro DEFINE_RESPONSE_TABLE
631//
632#define DEFINE_RESPONSE_TABLE9(cls, base1, base2, base3, base4, base5, base6, base7, base8, base9)\
633 bool cls::Find(TEventInfo& eventInfo, TEqualOperator equal)\
634 {\
635 using namespace ::owl;\
636 eventInfo.Object = (TGeneric*)this;\
637 return SearchEntries((TGenericTableEntry *)&__entries[0], eventInfo, equal) ||\
638 base1::Find(eventInfo, equal) ||\
639 base2::Find(eventInfo, equal) ||\
640 base3::Find(eventInfo, equal) ||\
641 base4::Find(eventInfo, equal) ||\
642 base5::Find(eventInfo, equal) ||\
643 base6::Find(eventInfo, equal) ||\
644 base7::Find(eventInfo, equal) ||\
645 base8::Find(eventInfo, equal) ||\
646 base9::Find(eventInfo, equal);\
647 }\
648 DEFINE_RESPONSE_TABLE_ENTRIES(cls)
649
650#endif
651
652//-----------------------------------------------------------------------------
653// Common helper macros for response table entries
654
655#if OWL_EV_SIGNATURE_CHECK
656
657#define OWL_ID_EV_GENERIC_(msgId, key, id, method, dispatchTemplate)\
658 {{static_cast<::owl::TMsgId>(key)}, static_cast<::owl::uint>(id),\
659 (::owl::CheckSignature<TMyClass, static_cast<::owl::TMsgId>(msgId), dispatchTemplate>(&TMyClass::method),\
660 OWL_DISPATCH(dispatchTemplate<static_cast<::owl::TMsgId>(msgId)>::Decode, method))}
661
662#define OWL_ID_EV_(msgId, id, method) OWL_ID_EV_GENERIC_(msgId, msgId, id, method, ::owl::TDispatch)
663
664#else
665
666#define OWL_ID_EV_(msgId, id, method)\
667 {{static_cast<::owl::TMsgId>(msgId)}, static_cast<::owl::uint>(id),\
668 OWL_DISPATCH(::owl::TDispatch<static_cast<::owl::TMsgId>(msgId)>::Decode, method)}
669
670#endif
671
672#define OWL_EV_(msgId, method) OWL_ID_EV_(msgId, 0, method)
673
674#endif // OWL_EVENTHAN_H
A nested class, TEventInfo provides specific information about the type of message sent,...
Definition eventhan.h:170
const TMsgId Msg
Contains the type of message sent.
Definition eventhan.h:177
TGeneric * Object
Points to the object that contains the function to be handled.
Definition eventhan.h:184
TEventInfo(TMsgId msg, uint id=0)
Constructs a TEventInfo object with the specified ID and message type.
Definition eventhan.h:190
const uint Id
Contains the menu or accelerator resource ID (CM_xxxx) for the message response member function.
Definition eventhan.h:181
const TGenericTableEntry * Entry
Points to the response table entry (for example, EvActivate).
Definition eventhan.h:187
TEventHandler is a base class from which you can derive classes that handle messages.
Definition eventhan.h:162
A template class, TResponseTableEntry lets you define a pattern for entries into a response table.
Definition eventhan.h:217
uint Id
Contains the menu or accelerator resource ID (CM_xxxx) for the message response member function.
Definition eventhan.h:238
PMF Pmf
Points to the actual handler or member function.
Definition eventhan.h:244
uint NotifyCode
Stores the control notification code (for example, ID_LISTBOX) for the response table entry.
Definition eventhan.h:233
TAnyDispatcher Dispatcher
An abstract dispatcher type that points to one of the dispatcher functions.
Definition eventhan.h:241
TMsgId Msg
Contains the ID of the message sent.
Definition eventhan.h:228
Dispatch functions (crackers) to crack a Windows message and pass control to a member function via a ...
TResponseTableEntry< TGeneric > TGenericTableEntry
Definition eventhan.h:144
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
UINT TMsgId
Message ID type.
Definition dispatch.h:53
owl::opstream & operator<<(owl::opstream &os, const TColor &c)
Insert the color value into a persistent output stream.
Definition color.h:498
TResult(* TAnyDispatcher)(TGeneric &, TAnyPMF, TParam1, TParam2)
Definition dispatch.h:119
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
LRESULT TResult
Result type.
Definition dispatch.h:52
unsigned int uint
Definition number.h:25
std::ostream tostream
Definition strmdefs.h:40
#define _RTTI
Definition defs.h:223
#define _OWLCFUNC(p)
Definition defs.h:342
#define _OWLCLASS
Definition defs.h:338
Message handler signature templates.