]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/ObjcAssociate.h
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / include / wx / cocoa / ObjcAssociate.h
CommitLineData
e6686511
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/cocoa/ObjcAssociate.h
3// Purpose: Associates an Objective-C class with a C++ class
4// Author: David Elliott
1c4e8f38 5// Modified by:
e6686511 6// Created: 2002/12/03
e6686511 7// Copyright: (c) 2002 David Elliott <dfe@cox.net>
65571936 8// Licence: wxWindows licence
e6686511
DE
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef __WX_COCOA_OBJC_ASSOCIATE_H__
12#define __WX_COCOA_OBJC_ASSOCIATE_H__
13
14/*-------------------------------------------------------------------------
15Basic hashmap stuff, used by everything
16-------------------------------------------------------------------------*/
17#define WX_DECLARE_OBJC_HASHMAP(ObjcClass) \
18class wxCocoa##ObjcClass; \
19WX_DECLARE_HASH_MAP(WX_##ObjcClass,wxCocoa##ObjcClass*,wxPointerHash,wxPointerEqual,wxCocoa##ObjcClass##Hash)
20
21#define WX_DECLARE_OBJC_INTERFACE_HASHMAP(ObjcClass) \
22public: \
23 static inline wxCocoa##ObjcClass* GetFromCocoa(WX_##ObjcClass cocoaObjcClass) \
24 { \
25 wxCocoa##ObjcClass##Hash::iterator iter = sm_cocoaHash.find(cocoaObjcClass); \
26 if(iter!=sm_cocoaHash.end()) \
27 { \
28 return iter->second; \
29 } \
30 return NULL; \
31 } \
32protected: \
33 static wxCocoa##ObjcClass##Hash sm_cocoaHash;
34
35#define WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(ObjcClass) \
36wxCocoa##ObjcClass##Hash wxCocoa##ObjcClass::sm_cocoaHash;
37
38
39/*-------------------------------------------------------------------------
40The entire interface, including some boilerplate stuff
41-------------------------------------------------------------------------*/
42#define WX_DECLARE_OBJC_INTERFACE(ObjcClass) \
43WX_DECLARE_OBJC_INTERFACE_HASHMAP(ObjcClass) \
44public: \
45 inline void Associate##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
46 { \
bac6f234
DE
47 if(cocoaObjcClass) \
48 sm_cocoaHash.insert(wxCocoa##ObjcClass##Hash::value_type(cocoaObjcClass,this)); \
e6686511
DE
49 } \
50 inline void Disassociate##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
51 { \
bac6f234
DE
52 if(cocoaObjcClass) \
53 sm_cocoaHash.erase(cocoaObjcClass); \
e6686511
DE
54 }
55
56#define WX_IMPLEMENT_OBJC_INTERFACE(ObjcClass) \
57WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(ObjcClass)
58
59/*-------------------------------------------------------------------------
77ffb593 60Stuff to be used by the wxWidgets class (not the Cocoa interface)
e6686511
DE
61-------------------------------------------------------------------------*/
62#define WX_DECLARE_COCOA_OWNER(ObjcClass,ObjcBase,ObjcRoot) \
63public: \
64 inline WX_##ObjcClass Get##ObjcClass() { return (WX_##ObjcClass)m_cocoa##ObjcRoot; } \
65 inline const WX_##ObjcClass Get##ObjcClass() const { return (WX_##ObjcClass)m_cocoa##ObjcRoot; } \
66protected: \
67 void Set##ObjcClass(WX_##ObjcClass cocoaObjcClass);
68
69#define WX_IMPLEMENT_COCOA_OWNER(wxClass,ObjcClass,ObjcBase,ObjcRoot) \
70void wxClass::Set##ObjcClass(WX_##ObjcClass cocoaObjcClass) \
71{ \
bac6f234 72 Disassociate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
e6686511 73 Set##ObjcBase(cocoaObjcClass); \
bac6f234 74 Associate##ObjcClass((WX_##ObjcClass)m_cocoa##ObjcRoot); \
e6686511
DE
75}
76
77#endif // __WX_COCOA_OBJC_ASSOCIATE_H__