1 /* |
1 /* |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 * |
3 * |
4 * Copyright 2014 Olaf Wintermann. All rights reserved. |
4 * Copyright 2024 Olaf Wintermann. All rights reserved. |
5 * |
5 * |
6 * Redistribution and use in source and binary forms, with or without |
6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are met: |
7 * modification, are permitted provided that the following conditions are met: |
8 * |
8 * |
9 * 1. Redistributions of source code must retain the above copyright |
9 * 1. Redistributions of source code must retain the above copyright |
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #import "../ui/toolkit.h" |
|
30 #import "toolkit.h" |
29 #import "toolkit.h" |
31 |
30 |
32 typedef void(*ui_container_add_f)(UiContainer*, NSView*); |
31 #import "../ui/container.h" |
33 |
32 |
34 struct UiContainer { |
33 #define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) |
35 NSView* widget; |
34 #define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) |
36 void (*add)(UiContainer*, NSView*); |
35 |
37 NSRect (*getframe)(UiContainer*); |
36 typedef struct UiLayout UiLayout; |
|
37 typedef enum UiLayoutBool UiLayoutBool; |
|
38 |
|
39 enum UiLayoutBool { |
|
40 UI_LAYOUT_UNDEFINED = 0, |
|
41 UI_LAYOUT_TRUE, |
|
42 UI_LAYOUT_FALSE, |
38 }; |
43 }; |
39 |
44 |
40 UiContainer* ui_window_container(UiObject *obj, NSWindow *window); |
45 struct UiLayout { |
|
46 UiTri fill; |
|
47 //UiBool newline; |
|
48 //char *label; |
|
49 UiBool hexpand; |
|
50 UiBool vexpand; |
|
51 UiBool hfill; |
|
52 UiBool vfill; |
|
53 //int width; |
|
54 int colspan; |
|
55 int rowspan; |
|
56 }; |
41 |
57 |
42 NSRect ui_container_getframe(UiContainer *ct); |
58 #define UI_INIT_LAYOUT(args) (UiLayout) {\ |
43 void ui_container_add(UiContainer *ct, NSView *view); |
59 .fill = args.fill, \ |
|
60 .hexpand = args.hexpand, \ |
|
61 .vexpand = args.vexpand, \ |
|
62 .hfill = args.hfill, \ |
|
63 .vfill = args.vfill, \ |
|
64 .colspan = args.colspan, \ |
|
65 .rowspan = args.rowspan } |
44 |
66 |
|
67 |
|
68 @protocol Container |
|
69 |
|
70 @property UiLayout uilayout; |
|
71 @property const char *label; |
|
72 @property UiBool newline; |
|
73 |
|
74 - (void) addView:(NSView*)view fill:(BOOL)fill; |
|
75 |
|
76 @end |
|
77 |
|
78 @interface BoxContainer : NSStackView<Container> |
|
79 |
|
80 - (BoxContainer*)init:(NSUserInterfaceLayoutOrientation)orientation spacing:(int)spacing; |
|
81 |
|
82 @end |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 UiContainerX* ui_create_container(UiObject *obj, id<Container> container); |
|
89 |
|
90 void ui_container_add(UiObject *obj, NSView *view, UiLayout *layout, UiBool fill); |