]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cocoa/ObjcPose.h
#define WINVER as 0x400 if it is not defined at all
[wxWidgets.git] / include / wx / cocoa / ObjcPose.h
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>
20
21 class wxPoseAsInitializer
22 {
23 public:
24 wxPoseAsInitializer(Class poser)
25 : m_poser(poser)
26 , m_next(sm_first)
27 {
28 sm_first = this;
29 }
30 ~wxPoseAsInitializer()
31 {
32 class_poseAs(m_poser,m_poser->super_class);
33 sm_first = m_next;
34 }
35 static void InitializePosers()
36 {
37 while(sm_first)
38 {
39 delete sm_first;
40 }
41 };
42 protected:
43 Class m_poser;
44 wxPoseAsInitializer *m_next;
45 static wxPoseAsInitializer *sm_first;
46 };
47
48 class wxDummyForPoseAsInitializer
49 {
50 public:
51 wxDummyForPoseAsInitializer(void*) {}
52 };
53
54 #define WX_IMPLEMENT_POSER(poser) \
55 wxDummyForPoseAsInitializer wxDummyPoseAsInitializerFor##poser(new wxPoseAsInitializer([poser class]))
56
57 #else // __OBJC__
58 #warning "Objective-C++ Only!"
59 #endif // __OBJC__
60
61 #endif // __WX_COCOA_PRIVATE_POSER_H__
62