ui/cocoa/container.m

Thu, 12 Dec 2024 20:01:43 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 12 Dec 2024 20:01:43 +0100
changeset 100
d2bd73d28ff1
parent 0
2483f517c562
permissions
-rw-r--r--

update toolkit

0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
4 * Copyright 2024 Olaf Wintermann. All rights reserved.
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2483f517c562 add existing toolkit code
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
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
29 #import "Container.h"
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
30 #import "GridLayout.h"
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
31
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
32 /* ------------------------- container classes ------------------------- */
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
34 @implementation BoxContainer
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
36 @synthesize label=_label;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
37 @synthesize uilayout=_uilayout;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
38 @synthesize newline=_newline;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
40 - (BoxContainer*)init:(NSUserInterfaceLayoutOrientation)orientation spacing:(int)spacing {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
41 self = [super init];
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
42 _label = NULL;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
43 _uilayout = (UiLayout){ 0 };
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
44 _newline = false;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
45
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
46 self.distribution = NSStackViewDistributionFillProportionally;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
47 self.spacing = spacing;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
48
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
49 self.orientation = orientation;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
50 if(orientation == NSUserInterfaceLayoutOrientationHorizontal) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
51 self.alignment = NSLayoutAttributeHeight;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
52 } else {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
53 self.alignment = NSLayoutAttributeWidth;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
54 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
55
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
56
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
57 return self;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
60 - (void) addView:(NSView*)view fill:(BOOL)fill {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
61 if(_uilayout.fill != UI_LAYOUT_UNDEFINED) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
62 fill = ui_lb2bool(_uilayout.fill);
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
63 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
65 [self addArrangedSubview:view];
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
67 if(self.orientation == NSUserInterfaceLayoutOrientationHorizontal) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
68 [view.heightAnchor constraintEqualToAnchor:self.heightAnchor].active = YES;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
69 if(!fill) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
70 [view.widthAnchor constraintEqualToConstant:view.intrinsicContentSize.width].active = YES;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
71 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
72 } else {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
73 [view.widthAnchor constraintEqualToAnchor:self.widthAnchor].active = YES;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
74 if(!fill) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
75 [view.heightAnchor constraintEqualToConstant:view.intrinsicContentSize.height].active = YES;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
76 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
77 }
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
79 // at the moment, only the fill layout option needs to be reset
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
80 _uilayout.fill = UI_DEFAULT;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
81 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
82
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
83 @end
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
84
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
85
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
86
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
87 /* -------------------- public container functions --------------------- */
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
88
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
89 static UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs args, NSUserInterfaceLayoutOrientation orientation) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
90 BoxContainer *box = [[BoxContainer alloc] init:orientation spacing:args.spacing];
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
91 box.translatesAutoresizingMaskIntoConstraints = false;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
93 // add box to the parent
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
94 UiLayout layout = UI_INIT_LAYOUT(args);
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
95 ui_container_add(obj, box, &layout, TRUE);
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
96
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
97 // add new box to the obj container chain
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
98 uic_object_push_container(obj, ui_create_container(obj, box));
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
100 return (__bridge void*)box;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
101 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
102
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
103 UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs args) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
104 return ui_box_create(obj, args, NSUserInterfaceLayoutOrientationVertical);
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
105 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
106
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
107 UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
108 return ui_box_create(obj, args, NSUserInterfaceLayoutOrientationHorizontal);
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
109 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
110
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
111 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
112 GridLayout *grid = [[GridLayout alloc] init];
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
113 grid.translatesAutoresizingMaskIntoConstraints = false;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
115 // add box to the parent
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
116 UiLayout layout = UI_INIT_LAYOUT(args);
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
117 ui_container_add(obj, grid, &layout, TRUE);
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
119 // add new box to the obj container chain
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
120 uic_object_push_container(obj, ui_create_container(obj, grid));
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
121
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
122 return (__bridge void*)grid;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
126 void ui_container_begin_close(UiObject *obj) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
127 UiContainerX *ct = obj->container_end;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
128 ct->close = 1;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
129 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
130
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
131 int ui_container_finish(UiObject *obj) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
132 UiContainerX *ct = obj->container_end;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
133 if(ct->close) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
134 ui_end_new(obj);
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
135 return 0;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
136 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
137 return 1;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 }
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
140 /* ------------------------- private functions ------------------------- */
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
141
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
142 UiContainerX* ui_create_container(UiObject *obj, id<Container> container) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
143 UiContainerX *ctn = ui_malloc(obj->ctx, sizeof(UiContainerX));
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
144 ctn->container = (__bridge void*)container;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
145 ctn->close = 0;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
146 ctn->prev = NULL;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
147 ctn->next = NULL;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
148 return ctn;
0
2483f517c562 add existing toolkit code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 }
100
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
150
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
151 void ui_container_add(UiObject *obj, NSView *view, UiLayout *layout, UiBool fill) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
152 UiContainerX *ctn = obj->container_end;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
153 id<Container> container = (__bridge id<Container>)ctn->container;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
154 container.uilayout = *layout;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
155 [container addView:view fill:fill];
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
156 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
157
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
158 /* ---------------------- public layout functions ----------------------- */
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
159
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
160 void ui_newline(UiObject *obj) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
161 UiContainerX *ctn = obj->container_end;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
162 if(ctn) {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
163 id<Container> container = (__bridge id<Container>)ctn->container;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
164 container.newline = TRUE;
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
165 } else {
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
166 fprintf(stderr, "Error: obj has no container\n");
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
167 }
d2bd73d28ff1 update toolkit
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 0
diff changeset
168 }

mercurial