1-- This file only exists because of circular type dependencies in the C
2-- library. Types must therefore be collected here, imported and renamed
3-- in each package to prevent loops.
4
5with agar.core.tail_queue;
6with agar.core.types;
7with agar.gui.rect;
8with agar.gui.widget.box;
9with agar.gui.widget.button;
10with agar.gui.widget.label;
11with agar.gui.widget;
12
13package agar.gui.types is
14
15  -- widget.icon
16
17  type widget_icon_t is limited private;
18  type widget_icon_access_t is access all widget_icon_t;
19  pragma convention (c, widget_icon_access_t);
20
21  type widget_icon_flags_t is new c.unsigned;
22  pragma convention (c, widget_icon_flags_t);
23
24  function widget_icon_widget (icon : widget_icon_access_t) return agar.gui.widget.widget_access_t;
25  pragma inline (widget_icon_widget);
26
27  -- window
28
29  type window_t is limited private;
30  type window_access_t is access all window_t;
31  pragma convention (c, window_access_t);
32
33  type window_flags_t is new c.unsigned;
34  pragma convention (c, window_flags_t);
35
36  package window_tail_queue is new agar.core.tail_queue
37    (entry_type => window_access_t);
38
39  type window_alignment_t is (
40    WINDOW_TL,
41    WINDOW_TC,
42    WINDOW_TR,
43    WINDOW_ML,
44    WINDOW_MC,
45    WINDOW_MR,
46    WINDOW_BL,
47    WINDOW_BC,
48    WINDOW_BR
49  );
50  for window_alignment_t use (
51    WINDOW_TL => 0,
52    WINDOW_TC => 1,
53    WINDOW_TR => 2,
54    WINDOW_ML => 3,
55    WINDOW_MC => 4,
56    WINDOW_MR => 5,
57    WINDOW_BL => 6,
58    WINDOW_BC => 7,
59    WINDOW_BR => 8
60  );
61  for window_alignment_t'size use c.unsigned'size;
62  pragma convention (c, window_alignment_t);
63
64  window_caption_max : constant c.unsigned := 512;
65
66  function window_widget (window : window_access_t) return agar.gui.widget.widget_access_t;
67  pragma inline (window_widget);
68
69  -- widget.titlebar
70
71  type widget_titlebar_t is limited private;
72  type widget_titlebar_access_t is access all widget_titlebar_t;
73  pragma convention (c, widget_titlebar_access_t);
74
75  type widget_titlebar_flags_t is new c.unsigned;
76
77  function widget_titlebar_widget (titlebar : widget_titlebar_access_t)
78    return agar.gui.widget.widget_access_t;
79  pragma inline (widget_titlebar_widget);
80
81private
82
83  type widget_icon_name_t is array (1 .. agar.gui.widget.label.max) of aliased c.char;
84  pragma convention (c, widget_icon_name_t);
85
86  type widget_icon_t is record
87    widget        : aliased agar.gui.widget.widget_t;
88    flags         : widget_icon_flags_t;
89    surface       : c.int;
90    label_text    : widget_icon_name_t;
91    label_surface : c.int;
92    label_pad     : c.int;
93    window        : window_access_t;
94    socket        : agar.core.types.void_ptr_t;
95    x_saved       : c.int;
96    y_saved       : c.int;
97    w_saved       : c.int;
98    h_saved       : c.int;
99    c_background  : agar.core.types.uint32_t;
100  end record;
101  pragma convention (c, widget_icon_t);
102
103  type window_caption_t is array (1 .. window_caption_max) of aliased c.char;
104  pragma convention (c, window_caption_t);
105
106  type window_t is record
107    widget      : aliased agar.gui.widget.widget_t;
108    flags       : window_flags_t;
109
110    caption     : window_caption_t;
111    visible     : c.int;
112
113    tbar        : widget_titlebar_access_t;
114    alignment   : window_alignment_t;
115    spacing     : c.int;
116    tpad        : c.int;
117    bpad        : c.int;
118    lpad        : c.int;
119    rpad        : c.int;
120
121    reqw        : c.int;
122    reqh        : c.int;
123
124    minw        : c.int;
125    minh        : c.int;
126
127    border_bot  : c.int;
128    border_side : c.int;
129    resize_ctrl : c.int;
130
131    r_saved     : agar.gui.rect.rect_t;
132    min_pct     : c.int;
133
134    subwins     : window_tail_queue.head_t;
135    windows     : window_tail_queue.entry_t;
136    swins       : window_tail_queue.entry_t;
137    detach      : window_tail_queue.entry_t;
138
139    icon        : widget_icon_access_t;
140    r           : agar.gui.rect.rect_t;
141  end record;
142  pragma convention (c, window_t);
143
144  type widget_titlebar_t is record
145    box             : aliased agar.gui.widget.box.box_t;
146    flags           : widget_titlebar_flags_t;
147    pressed         : c.int;
148    window          : window_access_t;
149    label           : agar.gui.widget.label.label_access_t;
150    close_button    : agar.gui.widget.button.button_access_t;
151    minimize_button : agar.gui.widget.button.button_access_t;
152    maximize_button : agar.gui.widget.button.button_access_t;
153  end record;
154  pragma convention (c, widget_titlebar_t);
155
156end agar.gui.types;
157