X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin3_src%2FWM%2Frenderer_menu.c;h=45c6a241b843fe5613d126697a75e00c6a710472;hb=a644ed9dc9954091daf616dfe93ab2e2a920bf5d;hp=b70016da2be1292a28c6d16253bb400881a27c31;hpb=086346323aae470047d375a12104872c899056d6;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin3_src/WM/renderer_menu.c b/Usermode/Applications/axwin3_src/WM/renderer_menu.c index b70016da..45c6a241 100644 --- a/Usermode/Applications/axwin3_src/WM/renderer_menu.c +++ b/Usermode/Applications/axwin3_src/WM/renderer_menu.c @@ -93,7 +93,10 @@ tWindow *Renderer_Menu_Create(int Argument) info->MaxItems = Argument; info->HilightedItem = -1; - _SysDebug("Renderer_Menu_Create: ->MaxItems = %i", info->MaxItems); + ret->Flags |= WINFLAG_NODECORATE; + ret->H = ciMenu_TopPadding + ciMenu_BottomPadding; + +// _SysDebug("Renderer_Menu_Create: ->MaxItems = %i", info->MaxItems); return ret; } @@ -104,6 +107,7 @@ void Renderer_Menu_Redraw(tWindow *Window) int w, h, y, i; w = info->CachedW; + #if 0 h = ciMenu_TopPadding + ciMenu_BottomPadding; for( i = 0; i < info->nItems; i ++ ) { @@ -114,12 +118,12 @@ void Renderer_Menu_Redraw(tWindow *Window) else h += ciMenu_SpacerHeight; } + #else + h = Window->H; + #endif // _SysDebug("w = %i, h = %i", w, h); - // - Resize window to contain all items - WM_ResizeWindow(Window, w, h); - // - Move the window such that it is on screen // > Make sure to catch if the menu can't fit fully onscreen @@ -170,7 +174,7 @@ void Renderer_Menu_Redraw(tWindow *Window) if(item->UnderlineW) { WM_Render_FillRect(Window, - ciMenu_LeftPadding + item->UnderlineX, y + ciMenu_FontHeight + 1, + ciMenu_LeftPadding + item->UnderlineX, y + ciMenu_FontHeight, item->UnderlineW, 1, cMenu_LabelColour ); @@ -212,7 +216,10 @@ int Renderer_Menu_int_AddItem(tWindow *Window, int Length, void *Data) } // Don't overwrite - if(info->Items[req->ID]) return 0; + if(info->Items[req->ID]) { + _SysDebug("- Caught overwrite of %i", req->ID); + return 0; + } // Bookkeeping if(req->ID >= info->nItems) info->nItems = req->ID + 1; // Allocate @@ -223,6 +230,7 @@ int Renderer_Menu_int_AddItem(tWindow *Window, int Length, void *Data) { // Spacer item->Label = NULL; + WM_ResizeWindow(Window, info->CachedW, Window->H+ciMenu_SpacerHeight); return 0; } @@ -300,9 +308,8 @@ int Renderer_Menu_int_AddItem(tWindow *Window, int Length, void *Data) info->CachedW = ciMenu_LeftPadding + info->MaxLabelWidth + ciMenu_Gap + info->MaxShortcutWidth + ciMenu_RightPadding; - // TODO: Smarter height? - WM_ResizeWindow(Window, info->CachedW, info->nItems*ciMenu_ItemHeight); } + WM_ResizeWindow(Window, info->CachedW, Window->H+ciMenu_ItemHeight); return 0; } @@ -320,7 +327,7 @@ int Renderer_Menu_int_GetItemByPos(tWindow *Window, tMenuWindowInfo *Info, int X if( !Info->Items[i]->Label ) { - // Spacer - doesn't hilight + // Spacer - not selectable if(Y < ciMenu_SpacerHeight) { return -1; } @@ -328,7 +335,7 @@ int Renderer_Menu_int_GetItemByPos(tWindow *Window, tMenuWindowInfo *Info, int X } else { - // Normal item, set the hilight + // Normal item, can be selected/hilighted if(Y < ciMenu_ItemHeight) { return i; } @@ -346,10 +353,12 @@ int Renderer_Menu_HandleMessage(tWindow *Window, int Msg, int Length, void *Data case WNDMSG_SHOW: { struct sWndMsg_Bool *msg = Data; if(Length < sizeof(*msg)) return -1; - if(msg->Val) { - // Take focus? - _SysDebug(" - Shown, take focus"); - WM_GiveFocus(Window); + if(msg->Val) + { +// _SysDebug(" - Shown, take focus"); + // TODO: This shouldn't really be done, instead focus should be given + // when the menu is shown. +// WM_FocusWindow(Window); } else { @@ -411,7 +420,7 @@ int Renderer_Menu_HandleMessage(tWindow *Window, int Msg, int Length, void *Data // Manipulation messages case MSG_MENU_ADDITEM: - _SysDebug("MSG_MENU_ADDITEM"); +// _SysDebug("MSG_MENU_ADDITEM"); return Renderer_Menu_int_AddItem(Window, Length, Data); // Only message to pass to client