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)
67 WM_Render_FillRect(Window,
68 0, -ciTitlebarHeight, Window->W, ciTitlebarHeight,
69 (bActive ? cColourActive_Titlebar : cColourInactive_Titlebar)
71 WM_Render_FillRect(Window,
72 0, -ciTitlebarHeight, Window->W, 1,
73 cColour_TitleTopBorder
75 WM_Render_FillRect(Window,
76 0, -ciTitlebarHeight, 1, ciTitlebarHeight,
79 WM_Render_FillRect(Window,
80 Window->W, -ciTitlebarHeight, 1, ciTitlebarHeight,
84 WM_Render_GetTextDims(
85 NULL, // TODO: Select font
86 Window->Title ? Window->Title : "jI", -1,
87 &text_width, &text_height
89 WM_Render_DrawText(Window,
90 ciTitlebarHeight + 4, -(ciTitlebarHeight - (ciTitlebarHeight/2 - text_height/2)),
91 Window->W - ciTitlebarHeight - 4, text_height,
92 NULL, // TODO: Select font
93 (bActive ? cColourActive_TitleText : cColourInactive_TitleText),
94 Window->Title ? Window->Title : "--", -1
97 // Maximized windows don't have any other borders
98 if( Window->Flags & WINFLAG_MAXIMIZED )
102 WM_Render_FillRect(Window,
103 -ciSideBorderWidth, -ciTitlebarHeight,
104 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
108 WM_Render_FillRect(Window,
109 Window->W, -ciTitlebarHeight,
110 ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth,
114 WM_Render_FillRect(Window,
115 -ciSideBorderWidth, Window->H,
116 ciSideBorderWidth*2+Window->W, 1,
119 WM_Render_FillRect(Window,
120 -ciSideBorderWidth, Window->H+1,
121 ciSideBorderWidth*2+Window->W, ciBottomBorderWidth-1,
126 int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data)
130 case WNDMSG_MOUSEMOVE: {
131 const struct sWndMsg_MouseMove *msg = Data;
132 if(msg->Y >= 0) return 1; // Pass
136 case WNDMSG_MOUSEBTN: {
137 const struct sWndMsg_MouseButton *msg = Data;
138 if(msg->Y >= 0) return 1; // Pass
142 default: // Anything unhandled is passed on