ui/common/types.c

Sat, 11 Nov 2017 11:59:06 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 11 Nov 2017 11:59:06 +0100
changeset 143
d499b29d7cb6
parent 142
46448d38885c
child 145
853685152c1d
permissions
-rw-r--r--

adds observer support for textarea and textfield (GTK)

14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
4 * Copyright 2017 Olaf Wintermann. All rights reserved.
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
31 #include <string.h>
39
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
32 #include <stdarg.h>
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "../../ucx/list.h"
39
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
35 #include "../ui/tree.h"
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include "types.h"
39
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
37 #include "context.h"
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 UiObserver* ui_observer_new(ui_callback f, void *data) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 UiObserver *observer = malloc(sizeof(UiObserver));
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 observer->callback = f;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 observer->data = data;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 observer->next = NULL;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 return observer;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 UiObserver* ui_obsvlist_add(UiObserver *list, UiObserver *observer) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 if(!list) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 return observer;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 } else {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 UiObserver *l = list;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 while(l->next) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 l = l->next;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 l->next = observer;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 return list;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 UiObserver* ui_add_observer(UiObserver *list, ui_callback f, void *data) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 UiObserver *observer = ui_observer_new(f, data);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 return ui_obsvlist_add(list, observer);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 void ui_notify(UiObserver *observer, void *data) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 ui_notify_except(observer, NULL, data);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 void ui_notify_except(UiObserver *observer, UiObserver *exc, void *data) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 while(observer) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 if(observer != exc) {
16
a499c8a72c15 added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
72 UiEvent evt;
a499c8a72c15 added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
73 evt.obj = NULL;
a499c8a72c15 added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
74 evt.window = NULL;
a499c8a72c15 added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
75 evt.document = NULL;
a499c8a72c15 added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
76 evt.eventdata = data;
a499c8a72c15 added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
77 evt.intval = 0;
a499c8a72c15 added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 14
diff changeset
78 observer->callback(&evt, observer->data);
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 observer = observer->next;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
142
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
84 void ui_notify_evt(UiObserver *observer, UiEvent *event) {
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
85 while(observer) {
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
86 observer->callback(event, observer->data);
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
87 observer = observer->next;
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
88 }
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
89 }
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
90
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 /* --------------------------- UiList --------------------------- */
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92
116
480354705c2f added combobox (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 39
diff changeset
93 UiList* ui_list_new(void) {
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 UiList *list = malloc(sizeof(UiList));
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 list->first = ui_list_first;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 list->next = ui_list_next;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 list->get = ui_list_get;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 list->count = ui_list_count;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 list->observers = NULL;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 list->data = NULL;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 list->iter = NULL;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
104 list->update = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
105 list->obj = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
106
14
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 return list;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 void ui_list_free(UiList *list) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 ucx_list_free(list->data);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 free(list);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 void* ui_list_first(UiList *list) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 UcxList *elm = list->data;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 list->iter = elm;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 return elm ? elm->data : NULL;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 void* ui_list_next(UiList *list) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 UcxList *elm = list->iter;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 if(elm) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 elm = elm->next;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 if(elm) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 list->iter = elm;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 return elm->data;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 return NULL;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 void* ui_list_get(UiList *list, int i) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 UcxList *elm = ucx_list_get(list->data, i);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 if(elm) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 list->iter = elm;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 return elm->data;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 } else {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 return NULL;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 int ui_list_count(UiList *list) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 UcxList *elm = list->data;
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 return (int)ucx_list_size(elm);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 void ui_list_append(UiList *list, void *data) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 list->data = ucx_list_append(list->data, data);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 void ui_list_prepend(UiList *list, void *data) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 list->data = ucx_list_prepend(list->data, data);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 void ui_list_addobsv(UiList *list, ui_callback f, void *data) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 list->observers = ui_add_observer(list->observers, f, data);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 }
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 void ui_list_notify(UiList *list) {
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 ui_notify(list->observers, list);
e2fd132ab781 added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 }
39
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
163
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
164
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
165 typedef struct {
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
166 int type;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
167 char *name;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
168 } UiColumn;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
169
142
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
170 UiModel* ui_model_info(UiContext *ctx, ...) {
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
171 UiModel *info = ui_calloc(ctx, 1, sizeof(UiModel));
39
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
172
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
173 va_list ap;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
174 va_start(ap, ctx);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
175
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
176 UcxList *cols = NULL;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
177 int type;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
178 while((type = va_arg(ap, int)) != -1) {
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
179 char *name = va_arg(ap, char*);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
180
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
181 UiColumn *column = malloc(sizeof(UiColumn));
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
182 column->type = type;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
183 column->name = name;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
184
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
185 cols = ucx_list_append(cols, column);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
186 }
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
187
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
188 va_end(ap);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
189
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
190 size_t len = ucx_list_size(cols);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
191 info->columns = len;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
192 info->types = ui_calloc(ctx, len, sizeof(UiModelType));
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
193 info->titles = ui_calloc(ctx, len, sizeof(char*));
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
194
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
195 int i = 0;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
196 UCX_FOREACH(elm, cols) {
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
197 UiColumn *c = elm->data;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
198 info->types[i] = c->type;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
199 info->titles[i] = c->name;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
200 free(c);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
201 i++;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
202 }
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
203 ucx_list_free(cols);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
204
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
205 return info;
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
206 }
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
207
142
46448d38885c new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 141
diff changeset
208 void ui_model_info_free(UiContext *ctx, UiModel *mi) {
39
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
209 ucx_mempool_free(ctx->mempool, mi->types);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
210 ucx_mempool_free(ctx->mempool, mi->titles);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
211 ucx_mempool_free(ctx->mempool, mi);
4e66271541e8 added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
212 }
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
213
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
214 // types
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
215
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
216 // public functions
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
217 UiInteger* ui_int_new(UiContext *ctx, char *name) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
218 UiInteger *i = ui_malloc(ctx, sizeof(UiInteger));
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
219 memset(i, 0, sizeof(UiInteger));
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
220 if(name) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
221 uic_reg_var(ctx, name, UI_VAR_INTEGER, i);
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
222 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
223 return i;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
224 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
225
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
226 UiString* ui_string_new(UiContext *ctx, char *name) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
227 UiString *s = ui_malloc(ctx, sizeof(UiString));
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
228 memset(s, 0, sizeof(UiString));
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
229 if(name) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
230 uic_reg_var(ctx, name, UI_VAR_STRING, s);
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
231 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
232 return s;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
233 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
234
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
235 UiText* ui_text_new(UiContext *ctx, char *name) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
236 UiText *t = ui_malloc(ctx, sizeof(UiText));
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
237 memset(t, 0, sizeof(UiText));
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
238 if(name) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
239 uic_reg_var(ctx, name, UI_VAR_TEXT, t);
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
240 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
241 return t;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
242 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
243
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
244
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
245 // private functions
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
246 void uic_int_copy(UiInteger *from, UiInteger *to) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
247 to->get = from->get;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
248 to->set = from->set;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
249 to->obj = from->obj;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
250 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
251
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
252 void uic_string_copy(UiString *from, UiString *to) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
253 to->get = from->get;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
254 to->set = from->set;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
255 to->obj = from->obj;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
256 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
257
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
258 void uic_text_copy(UiText *from, UiText *to) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
259 to->get = from->get;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
260 to->set = from->set;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
261 to->getsubstr = from->getsubstr;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
262 to->insert = from->insert;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
263 to->setposition = from->setposition;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
264 to->position = from->position;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
265 to->selection = from->selection;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
266 to->length = from->length;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
267 to->remove = from->remove;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
268
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
269 to->obj = from->obj;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
270 // do not copy the undo manager
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
271 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
272
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
273 void uic_range_copy(UiRange *from, UiRange *to) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
274 to->get = from->get;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
275 to->set = from->set;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
276 to->setrange = from->setrange;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
277 to->setextent = from->setextent;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
278 to->obj = from->obj;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
279 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
280
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
281 void uic_list_copy(UiList *from, UiList *to) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
282 to->update = from->update;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
283 to->obj = from->obj;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
284 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
285
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
286
141
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
287 void uic_int_save(UiInteger *i) {
143
d499b29d7cb6 adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 142
diff changeset
288 if(!i->obj) return;
141
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
289 i->value = i->get(i);
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
290 }
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
291
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
292 void uic_string_save(UiString *s) {
143
d499b29d7cb6 adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 142
diff changeset
293 if(!s->obj) return;
141
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
294 s->get(s);
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
295 }
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
296
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
297 void uic_text_save(UiText *t) {
143
d499b29d7cb6 adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 142
diff changeset
298 if(!t->obj) return;
141
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
299 t->get(t);
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
300 t->position(t);
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
301 }
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
302
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
303 void uic_range_save(UiRange *r) {
143
d499b29d7cb6 adds observer support for textarea and textfield (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 142
diff changeset
304 if(!r->obj) return;
141
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
305 r->get(r);
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
306 }
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
307
cc2170ea05ad improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 140
diff changeset
308
140
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
309 void uic_int_unbind(UiInteger *i) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
310 i->get = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
311 i->set = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
312 i->obj = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
313 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
314
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
315 void uic_string_unbind(UiString *s) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
316 s->get = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
317 s->set = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
318 s->obj = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
319 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
320
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
321 void uic_text_unbind(UiText *t) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
322 t->set = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
323 t->get = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
324 t->getsubstr = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
325 t->insert = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
326 t->setposition = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
327 t->position = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
328 t->selection = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
329 t->length = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
330 t->remove = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
331 t->obj = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
332 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
333
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
334 void uic_range_unbind(UiRange *r) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
335 r->get = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
336 r->set = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
337 r->setextent = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
338 r->setrange = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
339 r->obj = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
340 }
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
341
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
342 void uic_list_unbind(UiList *l) {
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
343 l->update = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
344 l->obj = NULL;
c03c338a7dcf refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 116
diff changeset
345 }

mercurial