More work on the GUI. Still useless tho
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / wm.c
1 /*
2  * Acess GUI (AxWin) Version 2
3  * By John Hodge (thePowersGang)
4  * 
5  * Window Manager and Widget Control
6  */
7 #include "common.h"
8 #include <stdlib.h>
9 #include <strings.h>
10 #include "wm.h"
11
12 tElement        gWM_RootElement;
13
14 // === PROTOTYPES ===
15 tElement        *WM_CreateElement(tElement *Parent, int Type, int Flags);
16 void    WM_SetFlags(tElement *Element, int Flags);
17 void    WM_SetSize(tElement *Element, int Size);
18 void    WM_SetText(tElement *Element, char *Text);
19
20 // === CODE ===
21 tElement *WM_CreateElement(tElement *Parent, int Type, int Flags)
22 {
23         tElement        *ret;
24         
25         if(Type < 0 || Type >= NUM_ELETYPES)    return NULL;
26         
27         ret = calloc(sizeof(tElement), 1);
28         if(!ret)        return NULL;
29         
30         // Prepare
31         ret->Type = Type;
32         ret->Parent = Parent;
33         
34         // Append to parent's list
35         ret->NextSibling = Parent->LastChild;
36         Parent->LastChild = ret;
37         if(!Parent->FirstChild) Parent->FirstChild = ret;
38         
39         return ret;
40 }
41
42 void WM_SetFlags(tElement *Element, int Flags)
43 {
44         // Permissions are handled in the message handler
45         if(!Element) {
46                 gWM_RootElement.Flags = Flags;
47                 return ;
48         }
49         
50         Element->Flags = Flags;
51         return ;
52 }
53
54 void WM_SetSize(tElement *Element, int Size)
55 {
56         if(!Element)    return ;
57         Element->Size = Size;
58         return ;
59 }
60
61 void WM_SetText(tElement *Element, char *Text)
62 {
63         if(!Element)    return ;
64         if(Element->Text)       free(Element->Text);
65         Element->Text = strdup(Text);
66         return ;
67 }

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