From: John Hodge Date: Tue, 14 Feb 2012 07:34:50 +0000 (+0800) Subject: Usermode/AxWin3 - Fixed bug with underlined items in menus X-Git-Tag: rel0.15~772 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=7c00f2f9205aeb803f0499c9e88c98048830bea6;p=tpg%2Facess2.git Usermode/AxWin3 - Fixed bug with underlined items in menus --- diff --git a/Usermode/Applications/axwin3_src/Interface/main.c b/Usermode/Applications/axwin3_src/Interface/main.c index 2fcb98fa..80bf3292 100644 --- a/Usermode/Applications/axwin3_src/Interface/main.c +++ b/Usermode/Applications/axwin3_src/Interface/main.c @@ -83,7 +83,11 @@ void create_sidebar(void) AxWin3_Widget_SetSize(ele, 4); // > Version/Time - ele = AxWin3_Widget_AddWidget(gSidebarRoot, ELETYPE_BOX, ELEFLAG_VERTICAL|ELEFLAG_ALIGN_CENTER|ELEFLAG_NOSTRETCH, "Version/Time"); + ele = AxWin3_Widget_AddWidget(gSidebarRoot, + ELETYPE_BOX, + ELEFLAG_VERTICAL|ELEFLAG_ALIGN_CENTER|ELEFLAG_NOSTRETCH, + "Version/Time" + ); txt = AxWin3_Widget_AddWidget(ele, ELETYPE_TEXT, ELEFLAG_NOSTRETCH, "Version String"); AxWin3_Widget_SetSize(txt, 20); AxWin3_Widget_SetText(txt, "3.0"); @@ -116,9 +120,9 @@ void create_mainmenu(void) gSystemMenu = AxWin3_Menu_Create(NULL); AxWin3_Menu_AddItem(gSystemMenu, "Text &Editor\tWin+E", mainmenu_app_textedit, NULL, 0, NULL); - AxWin3_Menu_AddItem(gSystemMenu, "Terminal Emulator\tWin+T", mainmenu_app_terminal, NULL, 0, NULL); + AxWin3_Menu_AddItem(gSystemMenu, "&Terminal Emulator\tWin+T", mainmenu_app_terminal, NULL, 0, NULL); AxWin3_Menu_AddItem(gSystemMenu, NULL, NULL, NULL, 0, NULL); - AxWin3_Menu_AddItem(gSystemMenu, "Run\tWin+R", mainmenu_run_dialog, NULL, 0, NULL); + AxWin3_Menu_AddItem(gSystemMenu, "&Run\tWin+R", mainmenu_run_dialog, NULL, 0, NULL); } int run_dorun(tAxWin3_Widget *unused) diff --git a/Usermode/Applications/axwin3_src/WM/main.c b/Usermode/Applications/axwin3_src/WM/main.c index b8f3065c..b6fcf497 100644 --- a/Usermode/Applications/axwin3_src/WM/main.c +++ b/Usermode/Applications/axwin3_src/WM/main.c @@ -53,7 +53,6 @@ int main(int argc, char *argv[]) } Video_Setup(); -// Interface_Init(); IPC_Init(); Input_Init(); diff --git a/Usermode/Applications/axwin3_src/WM/renderers/menu.c b/Usermode/Applications/axwin3_src/WM/renderers/menu.c index ffd1db0d..a183de00 100644 --- a/Usermode/Applications/axwin3_src/WM/renderers/menu.c +++ b/Usermode/Applications/axwin3_src/WM/renderers/menu.c @@ -275,17 +275,14 @@ int Renderer_Menu_int_AddItem(tWindow *Window, int Length, const tMenuMsg_AddIte } else { - char tmp = item->Label[item->KeyOffset]; // Get width of preceding substring WM_Render_GetTextDims(NULL, item->Label, item->KeyOffset, &item->UnderlineX, NULL); // Get the width of the underlined character - item->Label[item->KeyOffset] = tmp; // NOTE: 1 makes only one character be parsed, even if it is >1 byte long WM_Render_GetTextDims( NULL, item->Label+item->KeyOffset, 1, &item->UnderlineW, NULL ); - item->Label[item->KeyOffset+1] = tmp; } // - Labels WM_Render_GetTextDims(NULL, item->Label, -1, &item->LabelWidth, NULL); @@ -293,12 +290,16 @@ int Renderer_Menu_int_AddItem(tWindow *Window, int Length, const tMenuMsg_AddIte WM_Render_GetTextDims(NULL, item->Shortcut, -1, &item->ShortcutWidth, NULL); else item->ShortcutWidth = 0; - + + // Get maximum lengths (to determine the size of the menu if( item->LabelWidth > info->MaxLabelWidth ) info->MaxLabelWidth = item->LabelWidth; if( item->ShortcutWidth > info->MaxShortcutWidth ) info->MaxShortcutWidth = item->ShortcutWidth; + // Update width + // TODO: Check, do I want to resize down too? + // TODO: Take into account padding too if( info->MaxLabelWidth + info->MaxShortcutWidth + ciMenu_Gap > info->CachedW ) { info->CachedW = ciMenu_LeftPadding + info->MaxLabelWidth @@ -310,6 +311,9 @@ int Renderer_Menu_int_AddItem(tWindow *Window, int Length, const tMenuMsg_AddIte return 0; } +/** + * \brief Convert coordinates into an item index + */ int Renderer_Menu_int_GetItemByPos(tWindow *Window, tMenuWindowInfo *Info, int X, int Y) { int i;