Sat, 30 Nov 2024 20:13:09 +0100
add textfield onactivate event (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 | |
174 | 34 | #include <cx/list.h> |
35 | #include <cx/array_list.h> | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
36 | #include "../ui/tree.h" |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | #include "types.h" |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
38 | #include "context.h" |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | |
378
d41b1ffc5f77
implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
40 | |
d41b1ffc5f77
implement some missing WinUI functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
41 | |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | 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
|
43 | UiObserver *observer = malloc(sizeof(UiObserver)); |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | observer->callback = f; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | observer->data = data; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | observer->next = NULL; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | return observer; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | UiObserver* ui_obsvlist_add(UiObserver *list, UiObserver *observer) { |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | if(!list) { |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | return observer; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | } else { |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | UiObserver *l = list; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | while(l->next) { |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | l = l->next; |
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 | l->next = observer; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | return list; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | 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
|
64 | UiObserver *observer = ui_observer_new(f, data); |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | return ui_obsvlist_add(list, observer); |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | } |
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 | void ui_notify(UiObserver *observer, void *data) { |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | ui_notify_except(observer, NULL, data); |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | void ui_notify_except(UiObserver *observer, UiObserver *exc, void *data) { |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
73 | UiEvent evt; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
74 | evt.obj = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
75 | evt.window = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
76 | evt.document = NULL; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
77 | evt.eventdata = data; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
78 | evt.intval = 0; |
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
79 | |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | while(observer) { |
167
161511838ea6
add new toolbar toggle button
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
157
diff
changeset
|
81 | if(observer != exc) { |
16
a499c8a72c15
added menu item lists (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
14
diff
changeset
|
82 | observer->callback(&evt, observer->data); |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | observer = observer->next; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | |
142
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
88 | 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
|
89 | while(observer) { |
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
90 | observer->callback(event, observer->data); |
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
91 | observer = observer->next; |
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
92 | } |
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
93 | } |
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
94 | |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | /* --------------------------- UiList --------------------------- */ |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
97 | UiList* ui_list_new(UiContext *ctx, char *name) { |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | UiList *list = malloc(sizeof(UiList)); |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | list->first = ui_list_first; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | list->next = ui_list_next; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | list->get = ui_list_get; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | list->count = ui_list_count; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | list->observers = NULL; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | |
174 | 105 | list->data = cxArrayListCreate(cxDefaultAllocator, NULL, CX_STORE_POINTERS, 32); |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | list->iter = NULL; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
108 | list->update = NULL; |
248
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
109 | list->getselection = NULL; |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
110 | list->obj = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
111 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
112 | if(name) { |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
113 | uic_reg_var(ctx, name, UI_VAR_LIST, list); |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
114 | } |
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
115 | |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | return list; |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | void ui_list_free(UiList *list) { |
174 | 120 | cxListDestroy(list->data); |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | free(list); |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | void* ui_list_first(UiList *list) { |
174 | 125 | list->iter = (void*)(intptr_t)0; |
126 | return cxListAt(list->data, 0); | |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | } |
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 | void* ui_list_next(UiList *list) { |
174 | 130 | intptr_t iter = (intptr_t)list->iter; |
131 | iter++; | |
132 | void *elm = cxListAt(list->data, iter); | |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | if(elm) { |
174 | 134 | list->iter = (void*)iter; |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | } |
174 | 136 | return elm; |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | void* ui_list_get(UiList *list, int i) { |
174 | 140 | return cxListAt(list->data, i); |
14
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) { |
325 | 144 | return cxListSize(list->data); |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | } |
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 | void ui_list_append(UiList *list, void *data) { |
174 | 148 | cxListAdd(list->data, data); |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | } |
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 | void ui_list_prepend(UiList *list, void *data) { |
174 | 152 | cxListInsert(list->data, 0, data); |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | |
251
22dc0b739dd8
add list remove function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
248
diff
changeset
|
155 | void ui_list_remove(UiList *list, int i) { |
22dc0b739dd8
add list remove function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
248
diff
changeset
|
156 | cxListRemove(list->data, i); |
22dc0b739dd8
add list remove function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
248
diff
changeset
|
157 | } |
22dc0b739dd8
add list remove function
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
248
diff
changeset
|
158 | |
152
62921b370c60
fixes use after free when a GtkTreeView was destroyed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
159 | void ui_list_clear(UiList *list) { |
174 | 160 | cxListClear(list->data); |
152
62921b370c60
fixes use after free when a GtkTreeView was destroyed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
161 | } |
62921b370c60
fixes use after free when a GtkTreeView was destroyed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
146
diff
changeset
|
162 | |
342
99f83fbf48e9
implement context destroy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
337
diff
changeset
|
163 | UIEXPORT void ui_list_update(UiList *list) { |
361
16c8b9ea3aa3
allow ui_list_update called with unbound lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
164 | if(list->update) { |
16c8b9ea3aa3
allow ui_list_update called with unbound lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
165 | list->update(list, 0); |
16c8b9ea3aa3
allow ui_list_update called with unbound lists
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
360
diff
changeset
|
166 | } |
342
99f83fbf48e9
implement context destroy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
337
diff
changeset
|
167 | } |
99f83fbf48e9
implement context destroy
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
337
diff
changeset
|
168 | |
14
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
169 | 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
|
170 | 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
|
171 | } |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
173 | void ui_list_notify(UiList *list) { |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | ui_notify(list->observers, list); |
e2fd132ab781
added menu item lists (Cocoa implementation)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | } |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
176 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
177 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
178 | typedef struct { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
179 | int type; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
180 | char *name; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
181 | } UiColumn; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
182 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
183 | UiModel* ui_model(UiContext *ctx, ...) { |
142
46448d38885c
new checkbox and radionbutton features and more refactoring
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
184 | UiModel *info = ui_calloc(ctx, 1, sizeof(UiModel)); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
185 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
186 | va_list ap; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
187 | va_start(ap, ctx); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
188 | |
174 | 189 | CxList *cols = cxArrayListCreate(cxDefaultAllocator, NULL, sizeof(UiColumn), 32); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
190 | int type; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
191 | while((type = va_arg(ap, int)) != -1) { |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
192 | char *name = va_arg(ap, char*); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
193 | |
174 | 194 | UiColumn column; |
195 | column.type = type; | |
196 | column.name = name; | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
197 | |
174 | 198 | cxListAdd(cols, &column); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
199 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
200 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
201 | va_end(ap); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
202 | |
325 | 203 | size_t len = cxListSize(cols); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
204 | info->columns = len; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
205 | info->types = ui_calloc(ctx, len, sizeof(UiModelType)); |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
206 | info->titles = ui_calloc(ctx, len, sizeof(char*)); |
380
aad99285865c
make table column sizes adjustable (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
378
diff
changeset
|
207 | info->columnsize = ui_calloc(ctx, len, sizeof(int)); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
208 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
209 | int i = 0; |
174 | 210 | CxIterator iter = cxListIterator(cols); |
211 | cx_foreach(UiColumn*, c, iter) { | |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
212 | info->types[i] = c->type; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
213 | info->titles[i] = c->name; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
214 | i++; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
215 | } |
174 | 216 | cxListDestroy(cols); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
217 | |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
218 | return info; |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
219 | } |
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
220 | |
215
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
221 | UiModel* ui_model_copy(UiContext *ctx, UiModel* model) { |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
222 | const CxAllocator* a = ctx ? ctx->allocator : cxDefaultAllocator; |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
223 | |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
224 | UiModel* newmodel = cxMalloc(a, sizeof(UiModel)); |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
225 | *newmodel = *model; |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
226 | |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
227 | newmodel->types = cxCalloc(a, model->columns, sizeof(UiModelType)); |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
228 | memcpy(newmodel->types, model->types, model->columns); |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
229 | |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
230 | newmodel->titles = cxCalloc(a, model->columns, sizeof(char*)); |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
231 | for (int i = 0; i < model->columns; i++) { |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
232 | newmodel->titles[i] = model->titles[i] ? cx_strdup_a(a, cx_str(model->titles[i])).ptr : NULL; |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
233 | } |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
234 | |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
235 | return newmodel; |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
236 | } |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
237 | |
146
dd0ae1c62a72
new icon/image api and pixbuf support in treeview (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
145
diff
changeset
|
238 | void ui_model_free(UiContext *ctx, UiModel *mi) { |
215
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
239 | const CxAllocator* a = ctx ? ctx->allocator : cxDefaultAllocator; |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
240 | cxFree(a, mi->types); |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
241 | cxFree(a, mi->titles); |
1bd5534c395d
add support for icons in the table widget (WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
174
diff
changeset
|
242 | cxFree(a, mi); |
39
4e66271541e8
added table view (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
16
diff
changeset
|
243 | } |
140
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 | // types |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
246 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
247 | // public functions |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
248 | UiInteger* ui_int_new(UiContext *ctx, char *name) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
249 | UiInteger *i = ui_malloc(ctx, sizeof(UiInteger)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
250 | memset(i, 0, sizeof(UiInteger)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
251 | if(name) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
252 | uic_reg_var(ctx, name, UI_VAR_INTEGER, i); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
253 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
254 | return i; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
255 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
256 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
257 | UiDouble* ui_double_new(UiContext *ctx, char *name) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
258 | UiDouble *d = ui_malloc(ctx, sizeof(UiDouble)); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
259 | memset(d, 0, sizeof(UiDouble)); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
260 | if(name) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
261 | uic_reg_var(ctx, name, UI_VAR_DOUBLE, d); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
262 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
263 | return d; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
264 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
265 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
266 | UiString* ui_string_new(UiContext *ctx, char *name) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
267 | UiString *s = ui_malloc(ctx, sizeof(UiString)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
268 | memset(s, 0, sizeof(UiString)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
269 | if(name) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
270 | uic_reg_var(ctx, name, UI_VAR_STRING, s); |
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 | return s; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
273 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
274 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
275 | UiText* ui_text_new(UiContext *ctx, char *name) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
276 | UiText *t = ui_malloc(ctx, sizeof(UiText)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
277 | memset(t, 0, sizeof(UiText)); |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
278 | if(name) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
279 | uic_reg_var(ctx, name, UI_VAR_TEXT, t); |
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 | return t; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
282 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
283 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
284 | UiRange* ui_range_new(UiContext *ctx, char *name) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
285 | UiRange *r = ui_malloc(ctx, sizeof(UiRange)); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
286 | memset(r, 0, sizeof(UiRange)); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
287 | if(name) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
288 | uic_reg_var(ctx, name, UI_VAR_RANGE, r); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
289 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
290 | return r; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
291 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
292 | |
337
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
293 | UIEXPORT UiGeneric* ui_generic_new(UiContext *ctx, char *name) { |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
294 | UiGeneric *g = ui_malloc(ctx, sizeof(UiGeneric)); |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
295 | memset(g, 0, sizeof(UiGeneric)); |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
296 | if(name) { |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
297 | uic_reg_var(ctx, name, UI_VAR_GENERIC, g); |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
298 | } |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
299 | return g; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
300 | } |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
301 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
302 | |
231
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
303 | void ui_int_set(UiInteger* i, int64_t value) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
304 | if (i && i->set) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
305 | i->set(i, value); |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
306 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
307 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
308 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
309 | int64_t ui_int_get(UiInteger* i) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
310 | if (i) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
311 | return i->get ? i->get(i) : i->value; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
312 | } else { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
313 | return 0; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
314 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
315 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
316 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
317 | void ui_double_set(UiDouble* d, double value) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
318 | if (d && d->set) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
319 | d->set(d, value); |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
320 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
321 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
322 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
323 | double ui_double_get(UiDouble* d) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
324 | if (d) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
325 | return d->get ? d->get(d) : d->value; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
326 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
327 | else { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
328 | return 0; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
329 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
330 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
331 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
332 | void ui_string_set(UiString* s, const char* value) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
333 | if (s && s->set) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
334 | s->set(s, value); |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
335 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
336 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
337 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
338 | char* ui_string_get(UiString* s) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
339 | if (s) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
340 | return s->get ? s->get(s) : s->value.ptr; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
341 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
342 | else { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
343 | return 0; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
344 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
345 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
346 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
347 | void ui_text_set(UiText* s, const char* value) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
348 | if (s && s->set) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
349 | s->set(s, value); |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
350 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
351 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
352 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
353 | char* ui_text_get(UiText* s) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
354 | if (s) { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
355 | return s->get ? s->get(s) : s->value.ptr; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
356 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
357 | else { |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
358 | return 0; |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
359 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
360 | } |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
361 | |
e160bb392148
add getter/setter for ui number/string types
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
215
diff
changeset
|
362 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
363 | // private functions |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
364 | void uic_int_copy(UiInteger *from, UiInteger *to) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
365 | to->get = from->get; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
366 | to->set = from->set; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
367 | to->obj = from->obj; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
368 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
369 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
370 | void uic_double_copy(UiDouble *from, UiDouble *to) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
371 | to->get = from->get; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
372 | to->set = from->set; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
373 | to->obj = from->obj; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
374 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
375 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
376 | void uic_string_copy(UiString *from, UiString *to) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
377 | to->get = from->get; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
378 | to->set = from->set; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
379 | to->obj = from->obj; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
380 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
381 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
382 | void uic_text_copy(UiText *from, UiText *to) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
383 | to->get = from->get; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
384 | to->set = from->set; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
385 | to->getsubstr = from->getsubstr; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
386 | to->insert = from->insert; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
387 | to->setposition = from->setposition; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
388 | to->position = from->position; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
389 | to->selection = from->selection; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
390 | to->length = from->length; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
391 | to->remove = from->remove; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
392 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
393 | to->obj = from->obj; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
394 | // do not copy the undo manager |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
395 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
396 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
397 | void uic_range_copy(UiRange *from, UiRange *to) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
398 | to->get = from->get; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
399 | to->set = from->set; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
400 | to->setrange = from->setrange; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
401 | to->setextent = from->setextent; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
402 | to->obj = from->obj; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
403 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
404 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
405 | void uic_list_copy(UiList *from, UiList *to) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
406 | to->update = from->update; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
407 | to->obj = from->obj; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
408 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
409 | |
337
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
410 | void uic_generic_copy(UiGeneric *from, UiGeneric *to) { |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
411 | to->get = from->get; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
412 | to->get_type = from->get_type; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
413 | to->set = from->set; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
414 | to->obj = from->obj; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
415 | } |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
416 | |
141
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
417 | 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
|
418 | if(!i->obj) return; |
141
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
419 | i->value = i->get(i); |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
420 | } |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
421 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
422 | void uic_double_save(UiDouble *d) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
423 | if(!d->obj) return; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
424 | d->value = d->get(d); |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
425 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
426 | |
141
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
427 | 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
|
428 | if(!s->obj) return; |
141
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
429 | s->get(s); |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
430 | } |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
431 | |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
432 | 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
|
433 | if(!t->obj) return; |
141
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
434 | t->get(t); |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
435 | t->position(t); |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
436 | } |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
437 | |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
438 | 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
|
439 | if(!r->obj) return; |
141
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
440 | r->get(r); |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
441 | } |
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
442 | |
337
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
443 | void uic_generic_save(UiGeneric *g) { |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
444 | if(!g->obj) return; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
445 | g->get(g); |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
446 | } |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
447 | |
141
cc2170ea05ad
improves doc detach and string value handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
140
diff
changeset
|
448 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
449 | void uic_int_unbind(UiInteger *i) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
450 | i->get = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
451 | i->set = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
452 | i->obj = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
453 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
454 | |
145
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
455 | void uic_double_unbind(UiDouble *d) { |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
456 | d->get = NULL; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
457 | d->set = NULL; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
458 | d->obj = NULL; |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
459 | } |
853685152c1d
adds spinner widget (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
143
diff
changeset
|
460 | |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
461 | void uic_string_unbind(UiString *s) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
462 | s->get = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
463 | s->set = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
464 | s->obj = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
465 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
466 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
467 | void uic_text_unbind(UiText *t) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
468 | t->set = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
469 | t->get = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
470 | t->getsubstr = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
471 | t->insert = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
472 | t->setposition = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
473 | t->position = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
474 | t->selection = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
475 | t->length = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
476 | t->remove = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
477 | t->obj = NULL; |
155
b907d8059290
fixes document switching with textareas (Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
152
diff
changeset
|
478 | t->undomgr = NULL; |
140
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
479 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
480 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
481 | void uic_range_unbind(UiRange *r) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
482 | r->get = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
483 | r->set = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
484 | r->setextent = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
485 | r->setrange = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
486 | r->obj = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
487 | } |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
488 | |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
489 | void uic_list_unbind(UiList *l) { |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
490 | l->update = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
491 | l->obj = NULL; |
c03c338a7dcf
refactors value binding system
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
116
diff
changeset
|
492 | } |
241
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
493 | |
337
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
494 | void uic_generic_unbind(UiGeneric *g) { |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
495 | g->get = NULL; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
496 | g->get_type = NULL; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
497 | g->set = NULL; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
498 | g->obj = NULL; |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
499 | } |
2904fba2708b
add UiGeneric var type
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
325
diff
changeset
|
500 | |
241
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
501 | |
248
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
502 | UIEXPORT UiListSelection ui_list_getselection(UiList *list) { |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
503 | if (list->getselection) { |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
504 | return list->getselection(list); |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
505 | } |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
506 | return (UiListSelection){ 0, NULL }; |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
507 | } |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
508 | |
360
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
509 | UIEXPORT void ui_list_setselection(UiList *list, int index) { |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
510 | if (list->setselection && index >= 0) { |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
511 | UiListSelection sel; |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
512 | sel.count = 1; |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
513 | sel.rows = &index; |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
514 | list->setselection(list, sel); |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
515 | } |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
516 | } |
681b930abe84
implement combobox get/set selection (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
342
diff
changeset
|
517 | |
248
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
518 | UIEXPORT void ui_listselection_free(UiListSelection selection) { |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
519 | if (selection.rows) { |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
520 | free(selection.rows); |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
521 | } |
22257f5f4019
add getter for list selections (Common, WinUI3)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
246
diff
changeset
|
522 | } |
241
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
523 | |
246
b19f3098dd11
add missing UIEXPORT
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
243
diff
changeset
|
524 | UIEXPORT UiStr ui_str(char *cstr) { |
241
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
525 | return (UiStr) { cstr, NULL }; |
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
526 | } |
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
527 | |
246
b19f3098dd11
add missing UIEXPORT
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
243
diff
changeset
|
528 | UIEXPORT UiStr ui_str_free(char *str, void (*freefunc)(void *v)) { |
241
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
529 | return (UiStr) { str, freefunc }; |
c51dd0e9ecb7
add support for table string values, that need to be freed
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
530 | } |
243
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
531 | |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
532 | |
246
b19f3098dd11
add missing UIEXPORT
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
243
diff
changeset
|
533 | UIEXPORT UiFileList ui_filelist_copy(UiFileList list) { |
243
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
534 | char **newlist = calloc(sizeof(char*), list.nfiles); |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
535 | for (int i = 0; i < list.nfiles; i++) { |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
536 | newlist[i] = strdup(list.files[i]); |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
537 | } |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
538 | return (UiFileList) { newlist, list.nfiles }; |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
539 | } |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
540 | |
246
b19f3098dd11
add missing UIEXPORT
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
243
diff
changeset
|
541 | UIEXPORT void ui_filelist_free(UiFileList list) { |
243
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
542 | for (int i = 0; i < list.nfiles; i++) { |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
543 | free(list.files[i]); |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
544 | } |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
545 | free(list.files); |
9f66c31a27ed
implement table dnd drop
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
241
diff
changeset
|
546 | } |
395
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
547 | |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
548 | |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
549 | typedef struct UiObserverDestructor { |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
550 | UiList *list; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
551 | UiObserver *observer; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
552 | } UiObserverDestructor; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
553 | |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
554 | static void observer_destructor(UiObserverDestructor *destr) { |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
555 | UiObserver *remove_obs = destr->observer; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
556 | UiObserver *obs = destr->list->observers; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
557 | UiObserver *prev = NULL; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
558 | while(obs) { |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
559 | if(obs == remove_obs) { |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
560 | if(prev) { |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
561 | prev->next = obs->next; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
562 | } else { |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
563 | destr->list->observers = obs->next; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
564 | } |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
565 | break; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
566 | } |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
567 | prev = obs; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
568 | obs = obs->next; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
569 | } |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
570 | free(remove_obs); |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
571 | } |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
572 | |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
573 | void uic_list_register_observer_destructor(UiContext *ctx, UiList *list, UiObserver *observer) { |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
574 | CxMempool *mp = ctx->mp; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
575 | UiObserverDestructor *destr = cxMalloc(mp->allocator, sizeof(UiObserverDestructor)); |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
576 | destr->list = list; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
577 | destr->observer = observer; |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
578 | cxMempoolSetDestructor(destr, (cx_destructor_func)observer_destructor); |
b8277deb75b8
remove global menu observer when destroying a window
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
380
diff
changeset
|
579 | } |