]>
Commit | Line | Data |
---|---|---|
fb896a32 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/cocoa/ObjcPose.h | |
3 | // Purpose: Macros for initializing poseAs, among other things | |
4 | // Author: David Elliott | |
5 | // Modified by: | |
6 | // Created: 2002/12/03 | |
7 | // RCS-ID: $Id: | |
8 | // Copyright: (c) 2002 David Elliott <dfe@cox.net> | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef __WX_COCOA_PRIVATE_POSER_H__ | |
13 | #define __WX_COCOA_PRIVATE_POSER_H__ | |
14 | ||
15 | /*------------------------------------------------------------------------- | |
16 | Objective-C Poser class initialization | |
17 | -------------------------------------------------------------------------*/ | |
18 | #ifdef __OBJC__ | |
19 | #import <objc/objc-class.h> | |
462bc048 | 20 | #import <Foundation/NSObjcRuntime.h> |
fb896a32 DE |
21 | |
22 | class wxPoseAsInitializer | |
23 | { | |
24 | public: | |
462bc048 DE |
25 | wxPoseAsInitializer() |
26 | : m_next(sm_first) | |
fb896a32 DE |
27 | { |
28 | sm_first = this; | |
29 | } | |
462bc048 | 30 | virtual ~wxPoseAsInitializer() |
fb896a32 | 31 | { |
fb896a32 DE |
32 | sm_first = m_next; |
33 | } | |
34 | static void InitializePosers() | |
35 | { | |
36 | while(sm_first) | |
37 | { | |
38 | delete sm_first; | |
39 | } | |
40 | }; | |
41 | protected: | |
fb896a32 DE |
42 | wxPoseAsInitializer *m_next; |
43 | static wxPoseAsInitializer *sm_first; | |
44 | }; | |
45 | ||
46 | class wxDummyForPoseAsInitializer | |
47 | { | |
48 | public: | |
49 | wxDummyForPoseAsInitializer(void*) {} | |
50 | }; | |
51 | ||
52 | #define WX_IMPLEMENT_POSER(poser) \ | |
462bc048 DE |
53 | class wxPoseAsInitializerFor##poser: public wxPoseAsInitializer \ |
54 | { \ | |
55 | protected: \ | |
56 | virtual ~wxPoseAsInitializerFor##poser() \ | |
57 | { \ | |
58 | class_poseAs([poser class],[poser superclass]); \ | |
59 | } \ | |
60 | }; \ | |
61 | wxDummyForPoseAsInitializer wxDummyPoseAsInitializerFor##poser(new wxPoseAsInitializerFor##poser) | |
fb896a32 | 62 | |
e6686511 DE |
63 | #else // __OBJC__ |
64 | #warning "Objective-C++ Only!" | |
fb896a32 DE |
65 | #endif // __OBJC__ |
66 | ||
fb896a32 DE |
67 | #endif // __WX_COCOA_PRIVATE_POSER_H__ |
68 |