ui/cocoa/container.m

Thu, 12 Dec 2024 16:34:39 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 12 Dec 2024 16:34:39 +0100
branch
newapi
changeset 413
b8e41d42f400
parent 404
384f6d1f5784
permissions
-rw-r--r--

fix gtk3 sourcelist styling

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

mercurial