]> git.decadent.org.uk Git - ion3.git/blob - ioncore/basicpholder.c
Update cfg_kludge_flash for Flash 10
[ion3.git] / ioncore / basicpholder.c
1 /*
2  * ion/ioncore/basicpholder.c
3  *
4  * Copyright (c) Tuomo Valkonen 2005-2009. 
5  *
6  * See the included file LICENSE for details.
7  */
8
9 #include <libtu/objp.h>
10 #include <libtu/obj.h>
11 #include <libtu/pointer.h>
12
13 #include "basicpholder.h"
14
15
16 /*{{{ Init/deinit */
17
18
19 bool basicpholder_init(WBasicPHolder *ph, WRegion *reg, 
20                        WBasicPHolderHandler *hnd)
21 {
22     assert(reg!=NULL && hnd!=NULL);
23     
24     pholder_init(&(ph->ph));
25
26     watch_init(&(ph->reg_watch));
27     
28     if(!watch_setup(&(ph->reg_watch), (Obj*)reg, NULL)){
29         pholder_deinit(&(ph->ph));
30         return FALSE;
31     }
32     
33     ph->hnd=hnd;
34     
35     return TRUE;
36 }
37  
38
39 WBasicPHolder *create_basicpholder(WRegion *reg, 
40                                    WBasicPHolderHandler *hnd)
41 {
42     CREATEOBJ_IMPL(WBasicPHolder, basicpholder, (p, reg, hnd));
43 }
44
45
46 void basicpholder_deinit(WBasicPHolder *ph)
47 {
48     watch_reset(&(ph->reg_watch));
49     pholder_deinit(&(ph->ph));
50 }
51
52
53 /*}}}*/
54
55
56 /*{{{ Dynfuns */
57
58
59 WRegion *basicpholder_do_attach(WBasicPHolder *ph, int flags,
60                                 WRegionAttachData *data)
61 {
62     WRegion *reg=(WRegion*)ph->reg_watch.obj;
63
64     if(reg==NULL || ph->hnd==NULL)
65         return FALSE;
66
67     return ph->hnd(reg, flags, data);
68 }
69
70
71 bool basicpholder_do_goto(WBasicPHolder *ph)
72 {
73     WRegion *reg=(WRegion*)ph->reg_watch.obj;
74     
75     if(reg!=NULL)
76         return region_goto((WRegion*)reg);
77     
78     return FALSE;
79 }
80
81
82 WRegion *basicpholder_do_target(WBasicPHolder *ph)
83 {
84     return (WRegion*)ph->reg_watch.obj;
85 }
86
87
88 /*}}}*/
89
90
91 /*{{{ Class information */
92
93
94 static DynFunTab basicpholder_dynfuntab[]={
95     {(DynFun*)pholder_do_attach, 
96      (DynFun*)basicpholder_do_attach},
97
98     {(DynFun*)pholder_do_goto, 
99      (DynFun*)basicpholder_do_goto},
100
101     {(DynFun*)pholder_do_target, 
102      (DynFun*)basicpholder_do_target},
103     
104     END_DYNFUNTAB
105 };
106
107 IMPLCLASS(WBasicPHolder, WPHolder, basicpholder_deinit, 
108           basicpholder_dynfuntab);
109
110
111 /*}}}*/
112