Usermode/AxWin3 - Fixed bug with underlined items in menus
authorJohn Hodge <[email protected]>
Tue, 14 Feb 2012 07:34:50 +0000 (15:34 +0800)
committerJohn Hodge <[email protected]>
Tue, 14 Feb 2012 07:34:50 +0000 (15:34 +0800)
Usermode/Applications/axwin3_src/Interface/main.c
Usermode/Applications/axwin3_src/WM/main.c
Usermode/Applications/axwin3_src/WM/renderers/menu.c

index 2fcb98f..80bf329 100644 (file)
@@ -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)
index b8f3065..b6fcf49 100644 (file)
@@ -53,7 +53,6 @@ int main(int argc, char *argv[])
        }
        
        Video_Setup();
-//     Interface_Init();
        IPC_Init();
        Input_Init();
        
index ffd1db0..a183de0 100644 (file)
@@ -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;

UCC git Repository :: git.ucc.asn.au