35 #include <string.h> |
35 #include <string.h> |
36 |
36 |
37 #ifdef __cplusplus |
37 #ifdef __cplusplus |
38 extern "C" { |
38 extern "C" { |
39 #endif |
39 #endif |
|
40 |
|
41 #define UI_APPLY_LAYOUT(layout, args) \ |
|
42 layout.fill = args.fill; \ |
|
43 layout.hexpand = args.hexpand; \ |
|
44 layout.vexpand = args.vexpand; \ |
|
45 layout.hfill = args.hfill; \ |
|
46 layout.vfill = args.vfill; \ |
|
47 layout.colspan = args.colspan; \ |
|
48 layout.rowspan = args.rowspan |
|
49 |
|
50 typedef enum UiBoxOrientation UiBoxOrientation; |
|
51 |
|
52 #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) |
|
53 #define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) |
|
54 #define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) |
40 |
55 |
41 #define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) |
56 #define ui_obj_container(obj) (UiContainerPrivate*)obj->container_end |
42 |
57 |
43 typedef struct MotifTabbedPane MotifTabbedPane; |
58 typedef struct UiLayout UiLayout; |
44 typedef struct UiTab UiTab; |
|
45 typedef struct UiBoxContainer UiBoxContainer; |
|
46 typedef struct UiGridContainer UiGridContainer; |
|
47 typedef struct UiTabViewContainer UiTabViewContainer; |
|
48 typedef struct UiLayout UiLayout; |
|
49 |
59 |
50 typedef Widget (*ui_container_add_f)(UiContainer*, Arg*, int*, UiBool); |
60 struct UiLayout { |
51 |
61 UiTri fill; |
52 typedef enum UiLayoutBool UiLayoutBool; |
62 UiBool newline; |
53 typedef enum UiBoxOrientation UiBoxOrientation; |
63 char *label; |
54 |
64 UiBool hexpand; |
55 |
65 UiBool vexpand; |
56 enum UiLayoutBool { |
66 UiBool hfill; |
57 UI_LAYOUT_UNDEFINED = 0, |
67 UiBool vfill; |
58 UI_LAYOUT_TRUE, |
68 int width; |
59 UI_LAYOUT_FALSE, |
69 int colspan; |
|
70 int rowspan; |
60 }; |
71 }; |
61 |
72 |
62 enum UiBoxOrientation { |
73 enum UiBoxOrientation { |
63 UI_BOX_VERTICAL = 0, |
74 UI_BOX_VERTICAL = 0, |
64 UI_BOX_HORIZONTAL |
75 UI_BOX_HORIZONTAL |
65 }; |
76 }; |
66 |
77 |
67 struct UiLayout { |
78 typedef struct UiContainerPrivate UiContainerPrivate; |
68 UiLayoutBool fill; |
79 |
69 UiBool newline; |
80 |
70 char *label; |
81 struct UiContainerPrivate { |
71 UiBool hexpand; |
82 UiContainerX container; |
72 UiBool vexpand; |
83 Widget (*prepare)(UiContainerPrivate*, Arg *, int*); |
73 int gridwidth; |
84 void (*add)(UiContainerPrivate*, Widget); |
|
85 Widget widget; |
|
86 UiLayout layout; |
74 }; |
87 }; |
75 |
88 |
76 struct UiContainer { |
89 typedef struct UiBoxContainer { |
77 Widget widget; |
90 UiContainerPrivate container; |
78 Widget (*prepare)(UiContainer*, Arg *, int*, UiBool); |
91 Dimension n; |
79 void (*add)(UiContainer*, Widget); |
92 } UiBoxContainer; |
80 UiLayout layout; |
|
81 Widget current; |
|
82 Widget menu; |
|
83 }; |
|
84 |
93 |
85 struct UiBoxContainer { |
94 typedef struct UiGridContainer { |
86 UiContainer container; |
95 UiContainerPrivate container; |
87 Widget prev_widget; |
96 int x; |
88 UiBool has_fill; |
97 int y; |
89 UiBoxOrientation orientation; |
98 } UiGridContainer; |
90 int margin; |
|
91 int spacing; |
|
92 }; |
|
93 |
99 |
94 struct UiGridContainer { |
100 UiContainerX* ui_box_container(UiObject *obj, Widget grid, UiBoxOrientation orientation); |
95 UiContainer container; |
101 Widget ui_vbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n); |
96 CxList *lines; |
102 Widget ui_hbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n); |
97 CxList *current; |
103 void ui_box_container_add(UiContainerPrivate *ctn, Widget widget); |
98 int columnspacing; |
|
99 int rowspacing; |
|
100 }; |
|
101 |
|
102 struct UiTabViewContainer { |
|
103 UiContainer container; |
|
104 UiContext *context; |
|
105 Widget widget; |
|
106 CxList *tabs; |
|
107 Widget current; |
|
108 }; |
|
109 |
|
110 struct MotifTabbedPane { |
|
111 UiTabbedPane view; |
|
112 Widget tabbar; |
|
113 CxList *tabs; |
|
114 UiTab *current; |
|
115 int index; |
|
116 Pixel bg1; |
|
117 Pixel bg2; |
|
118 int height; |
|
119 }; |
|
120 |
|
121 struct UiTab { |
|
122 MotifTabbedPane *tabbedpane; |
|
123 UiObject *content; |
|
124 Widget tab_button; |
|
125 }; |
|
126 |
|
127 |
|
128 UiContainer* ui_frame_container(UiObject *obj, Widget frame); |
|
129 Widget ui_frame_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); |
|
130 void ui_frame_container_add(UiContainer *ct, Widget widget); |
|
131 |
|
132 UiContainer* ui_box_container(UiObject *obj, Widget box, int margin, int spacing, UiBoxOrientation orientation); |
|
133 Widget ui_box_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); |
|
134 void ui_box_container_add(UiContainer *ct, Widget widget); |
|
135 |
|
136 UiContainer* ui_grid_container(UiObject *obj, Widget form, int columnspacing, int rowspacing); |
|
137 Widget ui_grid_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); |
|
138 void ui_grid_container_add(UiContainer *ct, Widget widget); |
|
139 |
|
140 UiContainer* ui_scrolledwindow_container(UiObject *obj, Widget scrolledwindow); |
|
141 Widget ui_scrolledwindow_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); |
|
142 void ui_scrolledwindow_container_add(UiContainer *ct, Widget widget); |
|
143 |
|
144 UiContainer* ui_tabview_container(UiObject *obj, Widget rowcolumn); |
|
145 Widget ui_tabview_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); |
|
146 void ui_tabview_container_add(UiContainer *ct, Widget widget); |
|
147 |
|
148 void ui_tab_button_callback(Widget widget, UiTab *tab, XtPointer d); |
|
149 void ui_change_tab(MotifTabbedPane *pane, UiTab *tab); |
|
150 |
|
151 void ui_tab_set_document(UiContext *ctx, void *document); |
|
152 void ui_tab_detach_document(UiContext *ctx); |
|
153 |
|
154 |
104 |
155 #ifdef __cplusplus |
105 #ifdef __cplusplus |
156 } |
106 } |
157 #endif |
107 #endif |
158 |
108 |