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 _SysDebug("BorderL = %i", ciSideBorderWidth);
46 Window->BorderB = ciBottomBorderWidth;
47 Window->BorderR = ciSideBorderWidth;
48 Window->BorderL = ciSideBorderWidth;
51 void Decorator_Redraw(tWindow *Window)
54 int text_width, text_height;
56 // TODO: This could possibly be expensive, but is there a better way?
59 for(win = gpWM_FocusedWindow; win; win = win->Owner)
69 WM_Render_FillRect(Window,
70 0, -ciTitlebarHeight, Window->W, ciTitlebarHeight,
71 (bActive ? cColourActive_Titlebar : cColourInactive_Titlebar)
73 WM_Render_FillRect(Window,
74 0, -ciTitlebarHeight, Window->W, 1,
75 cColour_TitleTopBorder
77 WM_Render_FillRect(Window,
78 0, -ciTitlebarHeight, 1, ciTitlebarHeight,
81 WM_Render_FillRect(Window,
82 Window->W, -ciTitlebarHeight, 1, ciTitlebarHeight,
86 WM_Render_GetTextDims(
87 NULL, // TODO: Select font
88 Window->Title ? Window->Title : "jI",
89 &text_width, &text_height
91 WM_Render_DrawText(Window,
92 ciTitlebarHeight + 4, -(ciTitlebarHeight - (ciTitlebarHeight/2 - text_height/2)),
93 Window->W - ciTitlebarHeight - 4, text_height,
94 NULL, // TODO: Select font
95 (bActive ? cColourActive_TitleText : cColourInactive_TitleText),
96 Window->Title ? Window->Title : "--"
99 // Maximized windows don't have any other borders
100 if( Window->Flags & WINFLAG_MAXIMIZED )
104 WM_Render_FillRect(Window,
105 -ciSideBorderWidth, -ciTitlebarHeight,
106 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
110 WM_Render_FillRect(Window,
111 Window->W, -ciTitlebarHeight,
112 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
116 WM_Render_FillRect(Window,
117 -ciSideBorderWidth, Window->H,
118 ciSideBorderWidth*2+Window->W, 1,
121 WM_Render_FillRect(Window,
122 -ciSideBorderWidth, Window->H+1,
123 ciSideBorderWidth*2+Window->W, ciBottomBorderWidth-1,
128 int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data)
132 case WNDMSG_MOUSEMOVE: {
133 const struct sWndMsg_MouseMove *msg = Data;
134 if(msg->Y >= 0) return 1; // Pass
138 case WNDMSG_MOUSEBTN: {
139 const struct sWndMsg_MouseButton *msg = Data;
140 if(msg->Y >= 0) return 1; // Pass
144 default: // Anything unhandled is passed on