2 * Acess2 Window Manager v3 (axwin3)
3 * - By John Hodge (thePowersGang)
10 #include <decorator.h>
11 #include <wm_messages.h>
14 void Decorator_UpdateBorderSize(tWindow *Window);
15 void Decorator_Redraw(tWindow *Window);
16 int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data);
19 tColour cColourActive_Titlebar = 0xFF8800;
20 tColour cColourActive_TitleText = 0x000000;
21 tColour cColourInactive_Titlebar = 0xD0D0D0;
22 tColour cColourInactive_TitleText= 0x000000;
23 tColour cColour_TitleTopBorder = 0xFFFFFF;
24 tColour cColour_SideBorder = 0xD0D0D0;
25 tColour cColour_BottomBorder = 0xD0D0D0;
26 int ciTitlebarHeight = 18;
27 int ciSideBorderWidth = 2;
28 int ciBottomBorderWidth = 4;
31 void Decorator_UpdateBorderSize(tWindow *Window)
38 Window->BorderT = ciTitlebarHeight;
39 if( Window->Flags & WINFLAG_MAXIMIZED )
42 Window->BorderB = ciBottomBorderWidth;
43 Window->BorderR = ciSideBorderWidth;
44 Window->BorderL = ciSideBorderWidth;
47 void Decorator_Redraw(tWindow *Window)
50 int text_width, text_height;
52 // TODO: Detect if window has focus
55 WM_Render_FillRect(Window,
56 0, -ciTitlebarHeight, Window->W, ciTitlebarHeight,
57 (bActive ? cColourActive_Titlebar : cColourInactive_Titlebar)
59 WM_Render_FillRect(Window,
60 0, -ciTitlebarHeight, Window->W, 1,
61 cColour_TitleTopBorder
63 WM_Render_FillRect(Window,
64 0, -ciTitlebarHeight, 1, ciTitlebarHeight,
67 WM_Render_FillRect(Window,
68 Window->W, -ciTitlebarHeight, 1, ciTitlebarHeight,
72 WM_Render_GetTextDims(
73 NULL, // TODO: Select font
74 Window->Title ? Window->Title : "jI",
75 &text_width, &text_height
77 WM_Render_DrawText(Window,
78 ciTitlebarHeight + 4, -(ciTitlebarHeight - (ciTitlebarHeight/2 - text_height/2)),
79 Window->W - ciTitlebarHeight - 4, text_height,
80 NULL, // TODO: Select font
81 (bActive ? cColourActive_TitleText : cColourInactive_TitleText),
82 Window->Title ? Window->Title : "--"
85 // Maximized windows don't have any other borders
86 if( Window->Flags & WINFLAG_MAXIMIZED )
90 WM_Render_FillRect(Window,
91 -ciSideBorderWidth, -ciTitlebarHeight,
92 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
96 WM_Render_FillRect(Window,
97 Window->W, -ciTitlebarHeight,
98 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
102 WM_Render_FillRect(Window,
103 -ciSideBorderWidth, Window->H,
104 ciSideBorderWidth*2+Window->W, ciBottomBorderWidth,
109 int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data)
113 case WNDMSG_MOUSEMOVE: {
114 const struct sWndMsg_MouseMove *msg = Data;
115 if(msg->Y >= 0) return 1; // Pass
119 case WNDMSG_MOUSEBTN: {
120 const struct sWndMsg_MouseButton *msg = Data;
121 if(msg->Y >= 0) return 1; // Pass
125 default: // Anything unhandled is passed on