| 28 |
28 |
| 29 #import "toolkit.h" |
29 #import "toolkit.h" |
| 30 |
30 |
| 31 #import "../ui/container.h" |
31 #import "../ui/container.h" |
| 32 |
32 |
| 33 #define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) |
|
| 34 #define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) |
|
| 35 |
33 |
| 36 typedef struct UiLayout UiLayout; |
34 typedef struct UiLayout UiLayout; |
| 37 typedef enum UiLayoutBool UiLayoutBool; |
|
| 38 |
35 |
| 39 enum UiLayoutBool { |
|
| 40 UI_LAYOUT_UNDEFINED = 0, |
|
| 41 UI_LAYOUT_TRUE, |
|
| 42 UI_LAYOUT_FALSE, |
|
| 43 }; |
|
| 44 |
|
| 45 struct UiLayout { |
|
| 46 UiBool 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 }; |
|
| 57 |
36 |
| 58 #define UI_INIT_LAYOUT(args) (UiLayout) {\ |
37 #define UI_INIT_LAYOUT(args) (UiLayout) {\ |
| 59 .fill = args->fill, \ |
38 .fill = args->fill, \ |
| 60 .hexpand = args->hexpand, \ |
39 .hexpand = args->hexpand, \ |
| 61 .vexpand = args->vexpand, \ |
40 .vexpand = args->vexpand, \ |
| 62 .hfill = args->hfill, \ |
41 .hfill = args->hfill, \ |
| 63 .vfill = args->vfill, \ |
42 .vfill = args->vfill, \ |
| |
43 .margin = args->margin, \ |
| |
44 .margin_left = args->margin_left, \ |
| |
45 .margin_right = args->margin_right, \ |
| |
46 .margin_top = args->margin_top, \ |
| |
47 .margin_bottom = args->margin_bottom, \ |
| 64 .colspan = args->colspan, \ |
48 .colspan = args->colspan, \ |
| 65 .rowspan = args->rowspan } |
49 .rowspan = args->rowspan } |
| 66 |
50 |
| 67 |
51 |
| 68 @protocol Container |
52 @protocol Container |
| 69 |
53 |
| 70 @property UiLayout uilayout; |
54 @property UiContainerX *container; |
| 71 @property const char *label; |
|
| 72 @property UiBool newline; |
|
| 73 |
55 |
| 74 - (void) addView:(NSView*)view; |
56 - (void) addView:(NSView*)view layout:(UiLayout*)layout; |
| 75 |
57 |
| 76 @end |
58 @end |
| 77 |
59 |
| |
60 |
| |
61 @interface FrameContainer : NSBox<Container> |
| |
62 |
| |
63 - (id)init:(NSString*)title; |
| |
64 |
| |
65 @end |
| |
66 |
| |
67 @interface ScrollViewContainer : NSScrollView<Container> |
| |
68 |
| |
69 @property NSView<Container> *child; |
| |
70 |
| |
71 - (id)init:(UiSubContainerType)subContainer columnSpacing:(int)columnSpacing rowSpacing:(int)rowSpacing; |
| |
72 |
| |
73 @end |
| 78 |
74 |
| 79 |
75 |
| 80 UiContainerX* ui_create_container(UiObject *obj, id<Container> container); |
76 UiContainerX* ui_create_container(UiObject *obj, id<Container> container); |
| 81 |
77 |
| 82 void ui_container_add(UiObject *obj, NSView *view, UiLayout *layout); |
78 void ui_container_add(UiObject *obj, NSView *view, UiLayout *layout); |