libc+AxWin3 - RichText rendering, scanf
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / renderers / menu.c
index 4506ad2..a183de0 100644 (file)
@@ -164,17 +164,17 @@ void Renderer_Menu_Redraw(tWindow *Window)
        
                // Text
                WM_Render_DrawText(Window,
-                       ciMenu_LeftPadding, y,
+                       ciMenu_LeftPadding, y+1,
                        w, ciMenu_ItemHeight,
                        gMenu_Font,
                        cMenu_LabelColour,
-                       item->Label
+                       item->Label, -1
                        );
                // Underline
                if(item->UnderlineW)
                {
                        WM_Render_FillRect(Window,
-                               ciMenu_LeftPadding + item->UnderlineX, y + ciMenu_FontHeight,
+                               ciMenu_LeftPadding + item->UnderlineX, y + 1 + ciMenu_FontHeight,
                                item->UnderlineW, 1,
                                cMenu_LabelColour
                                );
@@ -188,7 +188,7 @@ void Renderer_Menu_Redraw(tWindow *Window)
                                w, ciMenu_ItemHeight,
                                gMenu_Font,
                                cMenu_ShortcutColour,
-                               item->Shortcut
+                               item->Shortcut, -1
                                );
                }
                
@@ -275,33 +275,31 @@ int Renderer_Menu_int_AddItem(tWindow *Window, int Length, const tMenuMsg_AddIte
        }
        else
        {
-               char    tmp = item->Label[item->KeyOffset];
                // Get width of preceding substring
-               item->Label[item->KeyOffset] = '\0';
-               WM_Render_GetTextDims(NULL, item->Label, &item->UnderlineX, NULL);
+               WM_Render_GetTextDims(NULL, item->Label, item->KeyOffset, &item->UnderlineX, NULL);
                // Get the width of the underlined character
-               // TODO: Fix for high UTF-8 characters
-               item->Label[item->KeyOffset] = tmp;
-               tmp = item->Label[item->KeyOffset+1];
-               item->Label[item->KeyOffset+1] = '\0';
+               // NOTE: 1 makes only one character be parsed, even if it is >1 byte long
                WM_Render_GetTextDims(
-                       NULL, item->Label+item->KeyOffset,
+                       NULL, item->Label+item->KeyOffset, 1,
                        &item->UnderlineW, NULL
                        );
-               item->Label[item->KeyOffset+1] = tmp;
        }
        // - Labels
-       WM_Render_GetTextDims(NULL, item->Label, &item->LabelWidth, NULL);
+       WM_Render_GetTextDims(NULL, item->Label, -1, &item->LabelWidth, NULL);
        if(item->Shortcut)
-               WM_Render_GetTextDims(NULL, item->Shortcut, &item->ShortcutWidth, NULL);
+               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
@@ -313,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