]> git.saurik.com Git - wxWidgets.git/blob - src/mac/ldef/extldef.h
applied (slightly modified) wxToggleButton patch from John Norris and Axel Schlueter
[wxWidgets.git] / src / mac / ldef / extldef.h
1 #pragma once
2
3 #include <Lists.h>
4 #include <stdlib.h>
5
6 #define kExtLDEFID 128 // resource id of our LDEF resource
7
8 typedef void (*ExtLDEFDrawProcType)(Rect *r, Cell cell, ListHandle lh, long refcon);
9
10 enum {
11 uppExtLDEFDrawProcInfo = kCStackBased
12 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Rect *)))
13 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Cell)))
14 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(ListHandle)))
15 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
16 };
17
18 #if USESROUTINEDESCRIPTORS
19 typedef UniversalProcPtr ExtLDEFDrawProcUPP;
20
21 #define CallExtLDEFDrawProc(userRoutine, r, cell, lh , refcon ) \
22 CallUniversalProc((UniversalProcPtr)(userRoutine), uppExtLDEFDrawProcInfo, r, cell, lh , refcon )
23 #define NewExtLDEFDrawProc(userRoutine) \
24 (ExtLDEFDrawProcUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppExtLDEFDrawProcInfo, GetCurrentISA())
25
26 #else
27 typedef ExtLDEFDrawProcType ExtLDEFDrawProcUPP;
28
29 #define CallExtLDEFDrawProc(userRoutine, r, cell, lh , refcon) \
30 (*(userRoutine))(r, cell, lh, refcon)
31 #define NewExtLDEFDrawProc(userRoutine) \
32 (ExtLDEFDrawProcUPP)(userRoutine)
33 #endif
34
35 typedef struct
36 {
37 long refCon ;
38 ExtLDEFDrawProcUPP drawProc ;
39 } ExtLDEFInfo ;
40
41 static void NewExtLDEFInfo( ListHandle lh , ExtLDEFDrawProcType drawproc , long refcon ) ;
42 static void NewExtLDEFInfo( ListHandle lh , ExtLDEFDrawProcType drawproc , long refcon )
43 {
44 ExtLDEFInfo* info = (ExtLDEFInfo* ) malloc( sizeof( ExtLDEFInfo ) ) ;
45 info->drawProc = NewExtLDEFDrawProc( drawproc ) ;
46 info->refCon = refcon ;
47 (**lh).refCon = (long) info ;
48 }
49
50 static void DisposeExtLDEFInfo( ListHandle lh) ;
51 static void DisposeExtLDEFInfo( ListHandle lh)
52 {
53 ExtLDEFInfo* info = (ExtLDEFInfo* ) (**lh).refCon ;
54 if ( info )
55 {
56 #if !TARGET_CARBON
57 DisposeRoutineDescriptor( (RoutineDescriptor*) info->drawProc ) ;
58 #endif
59 free( (void*) (**lh).refCon ) ;
60 }
61 }