47 // TODO: free last obj |
47 // TODO: free last obj |
48 prev->next = NULL; |
48 prev->next = NULL; |
49 } |
49 } |
50 } |
50 } |
51 |
51 |
|
52 void ui_object_ref(UiObject *obj) { |
|
53 obj->ref++; |
|
54 } |
|
55 |
|
56 void ui_object_unref(UiObject *obj) { |
|
57 // it is possible to have 0 references, in case |
|
58 // a window was created but ui_show was never called |
|
59 if(obj->ref == 0 || --obj->ref == 0) { |
|
60 if(obj->destroy) { |
|
61 obj->destroy(obj); |
|
62 } else { |
|
63 uic_object_destroy(obj); |
|
64 } |
|
65 } |
|
66 } |
|
67 |
|
68 void uic_object_destroy(UiObject *obj) { |
|
69 if(obj->ctx->close_callback) { |
|
70 UiEvent ev; |
|
71 ev.window = obj->window; |
|
72 ev.document = obj->ctx->document; |
|
73 ev.obj = obj; |
|
74 ev.eventdata = NULL; |
|
75 ev.intval = 0; |
|
76 obj->ctx->close_callback(&ev, obj->ctx->close_data); |
|
77 } |
|
78 cxMempoolDestroy(obj->ctx->mp); |
|
79 } |
52 |
80 |
53 UiObject* uic_object_new(UiObject *toplevel, UIWIDGET widget) { |
81 UiObject* uic_object_new(UiObject *toplevel, UIWIDGET widget) { |
54 return uic_ctx_object_new(toplevel->ctx, widget); |
82 return uic_ctx_object_new(toplevel->ctx, widget); |
55 } |
83 } |
56 |
84 |