Work on WM's sizing code, not quite complete yet
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / wm.h
1
2 #ifndef _WM_H_
3 #define _WM_H_
4
5 typedef struct sElement
6 {
7          int    Type;
8         
9         struct sElement *Parent;
10         struct sElement *FirstChild;
11         struct sElement *LastChild;
12         struct sElement *NextSibling;
13         
14         short   PaddingL, PaddingR;
15         short   PaddingT, PaddingB;
16         short   GapSize;
17         
18         short   FixedWith;      // Fixed Long Size attribute (height)
19         short   FixedCross;     // Fixed Cross Size attribute (width)
20         
21         char    *Text;
22         
23         // -- Attributes maitained by the element code
24         // Not touched by the user
25         short   MinWith;        // Minimum long size
26         short   MinCross;       // Minimum cross size
27         void    *Data;
28         
29         uint32_t        Flags;
30         
31         // -- Render Cache
32         short   CachedX, CachedY;
33         short   CachedW, CachedH;
34 }       tElement;
35
36 typedef struct sTab
37 {
38          int    Type;   // Should be zero, allows a tab to be the parent of an element
39         
40         struct sElement *Parent;
41         struct sElement *FirstChild;
42         struct sElement *LastChild;
43         
44         char    *Name;
45         
46         tElement        *RootElement;
47 }       tTab;
48
49 typedef struct sApplication
50 {
51         pid_t   PID;
52         
53          int    nTabs;
54         tTab    *Tabs;
55         
56         char    Name[];
57 }       tApplication;
58
59 // === CONSTANTS ===
60 enum eElementFlags
61 {
62         /**
63          * \brief Rendered
64          * 
65          * If set, the element will be ignored in calculating sizes and
66          * rendering.
67          */
68         ELEFLAG_NORENDER    = 0x001,
69         /**
70          * \brief Element visibility
71          * 
72          * If set, the element is not drawn.
73          */
74         ELEFLAG_INVISIBLE   = 0x002,
75         
76         /**
77          * \brief Position an element absulutely
78          */
79         ELEFLAG_ABSOLUTEPOS = 0x004,
80         
81         /**
82          * \brief Fixed size element
83          */
84         ELEFLAG_FIXEDSIZE   = 0x008,
85         
86         /**
87          * \brief Element "orientation"
88          */
89         ELEFLAG_VERTICAL    = 0x010,//  ELEFLAG_HORIZONTAL  = 0x000,
90         /**
91          * \brief Action for text that overflows
92          */
93         ELEFLAG_WRAP        = 0x020,//  ELEFLAG_NOWRAP      = 0x000,
94         /**
95          * \brief Cross size action
96          * 
97          * If this flag is set, the element will only be as large (across
98          * its parent) as is needed to encase the contents of the element.
99          * Otherwise, the element will expand to fill all avaliable space.
100          */
101         ELEFLAG_NOEXPAND    = 0x040,    //      ELEFLAG_EXPAND      = 0x000
102         
103         /**
104          * \brief Center alignment
105          */
106         ELEFLAG_ALIGN_CENTER= 0x080,
107         /**
108          * \brief Right/Bottom alignment
109          */
110         ELEFLAG_ALIGN_END = 0x100
111 };
112
113 /**
114  */
115 enum eElementTypes
116 {
117         ELETYPE_NONE,
118         
119         ELETYPE_BOX,    //!< Content box
120         ELETYPE_TABBAR, //!< Tab Bar
121         ELETYPE_TOOLBAR,        //!< Tool Bar
122         
123         ELETYPE_BUTTON, //!< Push Button
124         ELETYPE_TEXT,   //!< Text
125         ELETYPE_IMAGE,  //!< Image
126         
127         ELETYPE_SPACER, //!< Visual Spacer
128         
129         MAX_ELETYPES    = 0x100
130 };
131
132 // === FUNCTIONS ===
133 /**
134  * \brief Create a new element as a child of \a Parent
135  */
136 extern tElement *WM_CreateElement(tElement *Parent, int Type, int Flags);
137 extern void     WM_SetFlags(tElement *Element, int Flags);
138 extern void     WM_SetSize(tElement *Element, int Size);
139 extern void     WM_SetText(tElement *Element, char *Text);
140
141 #endif

UCC git Repository :: git.ucc.asn.au