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: ObjcPose.h 42046 2006-10-16 09:30:01Z ABX $ 8// Copyright: (c) 2002 David Elliott <dfe@cox.net> 9// Licence: wxWindows licence 10///////////////////////////////////////////////////////////////////////////// 11 12#ifndef __WX_COCOA_PRIVATE_POSER_H__ 13#define __WX_COCOA_PRIVATE_POSER_H__ 14 15/*------------------------------------------------------------------------- 16Objective-C Poser class initialization 17-------------------------------------------------------------------------*/ 18#ifdef __OBJC__ 19#import <objc/objc-class.h> 20#import <Foundation/NSObjCRuntime.h> 21 22class wxPoseAsInitializer 23{ 24public: 25 wxPoseAsInitializer() 26 : m_next(sm_first) 27 { 28 sm_first = this; 29 } 30 virtual ~wxPoseAsInitializer() 31 { 32 sm_first = m_next; 33 } 34 static void InitializePosers() 35 { 36 while(sm_first) 37 { 38 delete sm_first; 39 } 40 }; 41protected: 42 wxPoseAsInitializer *m_next; 43 static wxPoseAsInitializer *sm_first; 44}; 45 46class wxDummyForPoseAsInitializer 47{ 48public: 49 wxDummyForPoseAsInitializer(void*) {} 50}; 51 52#define WX_IMPLEMENT_POSER(poser) \ 53class wxPoseAsInitializerFor##poser: public wxPoseAsInitializer \ 54{ \ 55protected: \ 56 virtual ~wxPoseAsInitializerFor##poser() \ 57 { \ 58 class_poseAs([poser class],[poser superclass]); \ 59 } \ 60}; \ 61wxDummyForPoseAsInitializer wxDummyPoseAsInitializerFor##poser(new wxPoseAsInitializerFor##poser) 62 63#else // __OBJC__ 64#warning "Objective-C++ Only!" 65#endif // __OBJC__ 66 67#endif // __WX_COCOA_PRIVATE_POSER_H__ 68