Usermode/AxWin3 - Added decorator support
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / decorator.c
1 /*
2  * Acess2 Window Manager v3 (axwin3)
3  * - By John Hodge (thePowersGang)
4  *
5  * decorator.c
6  * - Window Decorator
7  */
8 #include <common.h>
9 #include <wm.h>
10 #include <decorator.h>
11
12 // === PROTOTYPES ===
13 void    Decorator_UpdateBorderSize(tWindow *Window);
14 void    Decorator_Redraw(tWindow *Window);
15  int    Decorator_HandleMessage(tWindow *Window, int Message, int Length, void *Data);
16
17 // === CONSTANTS ===
18 tColour cColourActive_Titlebar   = 0xFF8800;
19 tColour cColourActive_TitleText  = 0x000000;
20 tColour cColourInactive_Titlebar = 0xD0D0D0;
21 tColour cColourInactive_TitleText= 0x000000;
22 tColour cColour_SideBorder       = 0xD0D0D0;
23 tColour cColour_BottomBorder     = 0xD0D0D0;
24  int    ciTitlebarHeight        = 18;
25  int    ciSideBorderWidth       = 2;
26  int    ciBottomBorderWidth     = 4;
27
28 // === CODE ===
29 void Decorator_UpdateBorderSize(tWindow *Window)
30 {
31         Window->BorderT = 0;
32         Window->BorderB = 0;
33         Window->BorderL = 0;
34         Window->BorderR = 0;
35         
36         Window->BorderT = ciTitlebarHeight;
37         if( Window->Flags & WINFLAG_MAXIMIZED )
38                 return ;
39         
40         Window->BorderB = ciBottomBorderWidth;
41         Window->BorderR = ciSideBorderWidth;
42         Window->BorderL = ciSideBorderWidth;
43 }
44
45 void Decorator_Redraw(tWindow *Window)
46 {
47          int    bActive = 1;
48          int    text_width, text_height;
49         
50         // TODO: Detect if window has focus
51         
52         // Draw title bar
53         WM_Render_FillRect(Window,
54                 0, -ciTitlebarHeight, Window->W, ciTitlebarHeight,
55                 (bActive ? cColourActive_Titlebar : cColourInactive_Titlebar)
56                 );
57
58         WM_Render_GetTextDims(
59                 NULL,   // TODO: Select font
60                 Window->Title ? Window->Title : "jI",
61                 &text_width, &text_height
62                 );
63         WM_Render_DrawText(Window,
64                 ciTitlebarHeight + 4, -(ciTitlebarHeight - (ciTitlebarHeight/2 - text_height/2)),
65                 Window->W - ciTitlebarHeight - 4, text_height,
66                 NULL,   // TODO: Select font
67                 (bActive ? cColourActive_TitleText : cColourInactive_TitleText),
68                 Window->Title ? Window->Title : "--"
69                 );
70         
71         // Maximized windows don't have any other borders
72         if( Window->Flags & WINFLAG_MAXIMIZED )
73                 return ;
74         
75         // Left
76         WM_Render_FillRect(Window,
77                 -ciSideBorderWidth, -ciTitlebarHeight,
78                 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
79                 cColour_SideBorder
80                 );
81         // Right
82         WM_Render_FillRect(Window,
83                 Window->W, -ciTitlebarHeight,
84                 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
85                 cColour_SideBorder
86                 );
87         // Bottom
88         WM_Render_FillRect(Window,
89                 -ciSideBorderWidth, Window->H,
90                 ciSideBorderWidth*2+Window->W, ciBottomBorderWidth,
91                 cColour_BottomBorder
92                 );
93 }
94
95 int Decorator_HandleMessage(tWindow *Window, int Message, int Length, void *Data)
96 {
97         switch(Message)
98         {
99         default:        // Anything unhandled is passed on
100                 return 1;
101         }
102 }
103

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