X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2FWM%2Fdecorator.c;h=14c041477b231ff377a74f024e6d560e19f17fe2;hb=507f19941f45bca7c1de783a394f56b15f10be4d;hp=52ffbfb608b5317eb9d42496dd5ce2cac34c5551;hpb=cee7338738f1a68c7eb7b956cab8d9fb83f95714;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/WM/decorator.c b/Usermode/Applications/axwin3_src/WM/decorator.c index 52ffbfb6..14c04147 100644 --- a/Usermode/Applications/axwin3_src/WM/decorator.c +++ b/Usermode/Applications/axwin3_src/WM/decorator.c @@ -8,19 +8,24 @@ #include #include #include +#include + +// === IMPORTS === +extern tWindow *gpWM_FocusedWindow; // === PROTOTYPES === void Decorator_UpdateBorderSize(tWindow *Window); void Decorator_Redraw(tWindow *Window); - int Decorator_HandleMessage(tWindow *Window, int Message, int Length, void *Data); + int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data); // === CONSTANTS === -tColour cColourActive_Titlebar = 0xFF8800; +tColour cColourActive_Titlebar = 0x00CC44; tColour cColourActive_TitleText = 0x000000; tColour cColourInactive_Titlebar = 0xD0D0D0; tColour cColourInactive_TitleText= 0x000000; -tColour cColour_SideBorder = 0xD0D0D0; -tColour cColour_BottomBorder = 0xD0D0D0; +tColour cColour_TitleTopBorder = 0xFFFFFF; +tColour cColour_SideBorder = 0x008000; +tColour cColour_BottomBorder = 0x008000; int ciTitlebarHeight = 18; int ciSideBorderWidth = 2; int ciBottomBorderWidth = 4; @@ -28,15 +33,14 @@ tColour cColour_BottomBorder = 0xD0D0D0; // === CODE === void Decorator_UpdateBorderSize(tWindow *Window) { - Window->BorderT = 0; + Window->BorderT = ciTitlebarHeight; Window->BorderB = 0; Window->BorderL = 0; Window->BorderR = 0; - Window->BorderT = ciTitlebarHeight; if( Window->Flags & WINFLAG_MAXIMIZED ) return ; - + Window->BorderB = ciBottomBorderWidth; Window->BorderR = ciSideBorderWidth; Window->BorderL = ciSideBorderWidth; @@ -44,58 +48,105 @@ void Decorator_UpdateBorderSize(tWindow *Window) void Decorator_Redraw(tWindow *Window) { - int bActive = 1; + int bActive = 0; int text_width, text_height; - // TODO: Detect if window has focus - + // TODO: This could possibly be expensive, but is there a better way? + { + tWindow *win; + for(win = gpWM_FocusedWindow; win; win = win->Owner) + { + if(win == Window) { + bActive = 1; + break; + } + } + } + // Draw title bar + // - Body WM_Render_FillRect(Window, 0, -ciTitlebarHeight, Window->W, ciTitlebarHeight, (bActive ? cColourActive_Titlebar : cColourInactive_Titlebar) ); + // - Top Border + WM_Render_FillRect(Window, + 0, -ciTitlebarHeight, Window->W, 1, + cColour_TitleTopBorder + ); + // - Sides + WM_Render_FillRect(Window, + 0, -ciTitlebarHeight, 1, ciTitlebarHeight, + cColour_SideBorder + ); + WM_Render_FillRect(Window, + Window->W, -ciTitlebarHeight, 1, ciTitlebarHeight, + cColour_SideBorder + ); + // Get the font height WM_Render_GetTextDims( NULL, // TODO: Select font - Window->Title ? Window->Title : "jI", + Window->Title ? Window->Title : "jI", -1, &text_width, &text_height ); + // - Use that to draw the window title on the left of the window WM_Render_DrawText(Window, ciTitlebarHeight + 4, -(ciTitlebarHeight - (ciTitlebarHeight/2 - text_height/2)), Window->W - ciTitlebarHeight - 4, text_height, NULL, // TODO: Select font (bActive ? cColourActive_TitleText : cColourInactive_TitleText), - Window->Title ? Window->Title : "--" + Window->Title ? Window->Title : "--", -1 ); - + + // TODO: Minimise, Maximise and Close + // Maximized windows don't have any other borders if( Window->Flags & WINFLAG_MAXIMIZED ) return ; - // Left + // Left Border WM_Render_FillRect(Window, -ciSideBorderWidth, -ciTitlebarHeight, ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth, cColour_SideBorder ); - // Right + // Right Border WM_Render_FillRect(Window, Window->W, -ciTitlebarHeight, ciSideBorderWidth, Window->H + ciTitlebarHeight + ciBottomBorderWidth, cColour_SideBorder ); - // Bottom + // Bottom Border (hard line) WM_Render_FillRect(Window, -ciSideBorderWidth, Window->H, - ciSideBorderWidth*2+Window->W, ciBottomBorderWidth, + ciSideBorderWidth*2+Window->W, 1, + 0x000000 + ); + // Bottom Border + WM_Render_FillRect(Window, + -ciSideBorderWidth, Window->H+1, + ciSideBorderWidth*2+Window->W, ciBottomBorderWidth-1, cColour_BottomBorder ); } -int Decorator_HandleMessage(tWindow *Window, int Message, int Length, void *Data) +int Decorator_HandleMessage(tWindow *Window, int Message, int Length, const void *Data) { switch(Message) { + case WNDMSG_MOUSEMOVE: { + const struct sWndMsg_MouseMove *msg = Data; + if(msg->Y >= 0) return 1; // Pass + + // TODO: Handle + return 0; } + case WNDMSG_MOUSEBTN: { + const struct sWndMsg_MouseButton *msg = Data; + if(msg->Y >= 0) return 1; // Pass + + // TODO: Handle + return 0; } default: // Anything unhandled is passed on return 1; }