2 * Acess2 Window Manager v3 (axwin3)
3 * - By John Hodge (thePowersGang)
10 #include <decorator.h>
11 #include <wm_messages.h>
14 extern tWindow *gpWM_FocusedWindow;
17 void Decorator_UpdateBorderSize(tWindow *Window);
18 void Decorator_Redraw(tWindow *Window);
19 int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data);
22 tColour cColourActive_Titlebar = 0x00CC44;
23 tColour cColourActive_TitleText = 0x000000;
24 tColour cColourInactive_Titlebar = 0xD0D0D0;
25 tColour cColourInactive_TitleText= 0x000000;
26 tColour cColour_TitleTopBorder = 0xFFFFFF;
27 tColour cColour_SideBorder = 0x008000;
28 tColour cColour_BottomBorder = 0x008000;
29 int ciTitlebarHeight = 18;
30 int ciSideBorderWidth = 2;
31 int ciBottomBorderWidth = 4;
34 void Decorator_UpdateBorderSize(tWindow *Window)
36 Window->BorderT = ciTitlebarHeight;
41 if( Window->Flags & WINFLAG_MAXIMIZED )
44 Window->BorderB = ciBottomBorderWidth;
45 Window->BorderR = ciSideBorderWidth;
46 Window->BorderL = ciSideBorderWidth;
49 void Decorator_Redraw(tWindow *Window)
52 int text_width, text_height;
54 // TODO: This could possibly be expensive, but is there a better way?
57 for(win = gpWM_FocusedWindow; win; win = win->Owner)
68 WM_Render_FillRect(Window,
69 0, -ciTitlebarHeight, Window->W, ciTitlebarHeight,
70 (bActive ? cColourActive_Titlebar : cColourInactive_Titlebar)
73 WM_Render_FillRect(Window,
74 0, -ciTitlebarHeight, Window->W, 1,
75 cColour_TitleTopBorder
78 WM_Render_FillRect(Window,
79 0, -ciTitlebarHeight, 1, ciTitlebarHeight,
82 WM_Render_FillRect(Window,
83 Window->W, -ciTitlebarHeight, 1, ciTitlebarHeight,
87 // Get the font height
88 WM_Render_GetTextDims(
89 NULL, // TODO: Select font
90 Window->Title ? Window->Title : "jI", -1,
91 &text_width, &text_height
93 // - Use that to draw the window title on the left of the window
94 WM_Render_DrawText(Window,
95 ciTitlebarHeight + 4, -(ciTitlebarHeight - (ciTitlebarHeight/2 - text_height/2)),
96 Window->W - ciTitlebarHeight - 4, text_height,
97 NULL, // TODO: Select font
98 (bActive ? cColourActive_TitleText : cColourInactive_TitleText),
99 Window->Title ? Window->Title : "--", -1
102 // TODO: Minimise, Maximise and Close
104 // Maximized windows don't have any other borders
105 if( Window->Flags & WINFLAG_MAXIMIZED )
109 WM_Render_FillRect(Window,
110 -ciSideBorderWidth, -ciTitlebarHeight,
111 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
115 WM_Render_FillRect(Window,
116 Window->W, -ciTitlebarHeight,
117 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
120 // Bottom Border (hard line)
121 WM_Render_FillRect(Window,
122 -ciSideBorderWidth, Window->H,
123 ciSideBorderWidth*2+Window->W, 1,
127 WM_Render_FillRect(Window,
128 -ciSideBorderWidth, Window->H+1,
129 ciSideBorderWidth*2+Window->W, ciBottomBorderWidth-1,
134 int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data)
138 case WNDMSG_MOUSEMOVE: {
139 const struct sWndMsg_MouseMove *msg = Data;
140 if(msg->Y >= 0) return 1; // Pass
144 case WNDMSG_MOUSEBTN: {
145 const struct sWndMsg_MouseButton *msg = Data;
146 if(msg->Y >= 0) return 1; // Pass
150 default: // Anything unhandled is passed on