ui/win32/grid.h

changeset 112
c3f2f16fa4b8
parent 108
77254bd6dccb
equal deleted inserted replaced
111:81c4f73236a4 112:c3f2f16fa4b8
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 #ifndef GRID_H 28 #ifndef GRID_H
29 #define GRID_H 29 #define GRID_H
30 30
31 #include "container.h" 31 #include "../ui/win32.h"
32 #include <stdbool.h> 32 #include <stdbool.h>
33 #include <cx/array_list.h> 33 #include <cx/array_list.h>
34 34
35 typedef struct GridElm { 35 #include "win32.h"
36 W32Widget *widget; 36
37 short x; 37 #define INSETS_ZERO (GridEdgeInsets){0}
38 short y; 38 typedef struct GridEdgeInsets {
39 GridLayoutInfo layout; 39 short top;
40 } GridElm; 40 short bottom;
41 short left;
42 short right;
43 } GridEdgeInsets;
41 44
42 typedef struct GridLayoutInfo { 45 typedef struct GridLayoutInfo {
43 short margin_left; 46 GridEdgeInsets margin;
44 short margin_right;
45 short margin_top;
46 short margin_bottom;
47 short colspan; 47 short colspan;
48 short rowspan; 48 short rowspan;
49 short preferred_width; 49 int preferred_width;
50 short preferred_height; 50 int preferred_height;
51 bool hexpand; 51 bool hexpand;
52 bool vexpand; 52 bool vexpand;
53 bool hfill; 53 bool hfill;
54 bool vfill; 54 bool vfill;
55 } GridLayoutInfo; 55 } GridLayoutInfo;
56 56
57 typedef struct GridElm {
58 W32Widget *widget;
59 short gridx;
60 short gridy;
61 GridLayoutInfo layout;
62 } GridElm;
63
57 typedef struct UiGridLayout { 64 typedef struct UiGridLayout {
58 HWND hwnd; 65 GridEdgeInsets padding;
59
60 short padding;
61 short columnspacing; 66 short columnspacing;
62 short rowspacing; 67 short rowspacing;
68
69 int preferred_width;
70 int preferred_height;
63 71
64 /* 72 /*
65 * list element type: GridElm 73 * list element type: GridElm
66 */ 74 */
67 CxList *widgets; 75 CxList *widgets;
68 76
77 int max_column;
78 int max_row;
69 } UiGridLayout; 79 } UiGridLayout;
70 80
71 UiGridLayout* ui_grid_container(UiObject *obj, HWND control, short padding, short columnspacing, short rowspacing); 81 typedef struct GridDef {
82 int size;
83 int pos;
84 int preferred_size;
85 BOOLEAN expand;
86 } GridDef;
87
88 UiGridLayout* ui_grid_layout_create(const CxAllocator *a, short columnspacing, short rowspacing);
72 89
73 void ui_grid_add_widget( 90 void ui_grid_add_widget(
74 UiGridLayout *grid, 91 UiGridLayout *grid,
75 short x, 92 short x,
76 short y, 93 short y,
77 W32Widget *widget, 94 W32Widget *widget,
78 GridLayoutInfo *layout); 95 GridLayoutInfo *layout);
79 96
80 void ui_grid_layout(UiGridLayout *grid); 97 void ui_grid_layout(UiGridLayout *grid, int width, int height);
81 98
82 #endif //GRID_H 99 #endif //GRID_H

mercurial