ui/common/object.c

changeset 801
e096c441e874
parent 797
47008843b468
child 802
cc73993a3ff9
equal deleted inserted replaced
800:814d374fb689 801:e096c441e874
98 UiContainerX *rm = obj->container_end; 98 UiContainerX *rm = obj->container_end;
99 uic_object_pop_container(obj); 99 uic_object_pop_container(obj);
100 ui_free(obj->ctx, rm); 100 ui_free(obj->ctx, rm);
101 } 101 }
102 102
103 void ui_newline(UiObject *obj) {
104 UiContainerX *container = obj->container_end;
105 if(container) {
106 container->newline = TRUE;
107 }
108 }
109
103 void ui_object_ref(UiObject *obj) { 110 void ui_object_ref(UiObject *obj) {
104 obj->ref++; 111 obj->ref++;
105 } 112 }
106 113
107 int ui_object_unref(UiObject *obj) { 114 int ui_object_unref(UiObject *obj) {
139 obj->ctx->parent = ui_global_context(); 146 obj->ctx->parent = ui_global_context();
140 uic_object_created(obj); 147 uic_object_created(obj);
141 return obj; 148 return obj;
142 } 149 }
143 150
144 UiObject* uic_object_new(UiObject *toplevel, UIWIDGET widget) {
145 return uic_ctx_object_new(toplevel->ctx, widget);
146 }
147
148 UiObject* uic_ctx_object_new(UiContext *ctx, UIWIDGET widget) { 151 UiObject* uic_ctx_object_new(UiContext *ctx, UIWIDGET widget) {
149 UiObject *newobj = cxCalloc(ctx->allocator, 1, sizeof(UiObject)); 152 UiObject *newobj = cxCalloc(ctx->allocator, 1, sizeof(UiObject));
150 newobj->ctx = ctx; 153 newobj->ctx = ctx;
151 newobj->widget = widget; 154 newobj->widget = widget;
152 uic_object_created(newobj); 155 uic_object_created(newobj);
153 return newobj; 156 return newobj;
154 }
155
156 void uic_obj_add(UiObject *toplevel, UiObject *ctobj) {
157 UiObject *current = uic_current_obj(toplevel);
158 current->next = ctobj;
159 }
160
161 UiObject* uic_current_obj(UiObject *toplevel) {
162 if(!toplevel) {
163 return NULL;
164 }
165 UiObject *obj = toplevel;
166 while(obj->next) {
167 obj = obj->next;
168 }
169 return obj;
170 }
171
172 UiContainer* uic_get_current_container(UiObject *obj) {
173 return uic_current_obj(obj)->container;
174 } 157 }
175 158
176 void uic_object_push_container(UiObject *toplevel, UiContainerX *newcontainer) { 159 void uic_object_push_container(UiObject *toplevel, UiContainerX *newcontainer) {
177 newcontainer->prev = toplevel->container_end; 160 newcontainer->prev = toplevel->container_end;
178 if(toplevel->container_end) { 161 if(toplevel->container_end) {

mercurial