]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
Clean the garbage space for the statements nest in subtitle menu.
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.c
index d265a25ec921100d642ee8dbd4c6ac1213f635fa..9f6c963153cb3b1c30471597e9eb391e913d536d 100644 (file)
@@ -259,7 +259,7 @@ GetPrompt (
 /**\r
   Get the supported width for a particular op-code\r
 \r
-  @param  Statement              The curent statement.\r
+  @param  MenuOption             The menu option.\r
   @param  AdjustWidth            The width which is saved for the space.\r
 \r
   @return Returns the number of CHAR16 characters that is support.\r
@@ -267,13 +267,17 @@ GetPrompt (
 **/\r
 UINT16\r
 GetWidth (\r
-  IN FORM_DISPLAY_ENGINE_STATEMENT        *Statement,\r
-  OUT UINT16                              *AdjustWidth\r
+  IN  UI_MENU_OPTION     *MenuOption,\r
+  OUT UINT16             *AdjustWidth\r
   )\r
 {\r
-  CHAR16       *String;\r
-  UINTN        Size;\r
-  EFI_IFR_TEXT *TestOp;\r
+  CHAR16                        *String;\r
+  UINTN                         Size;\r
+  EFI_IFR_TEXT                  *TestOp;\r
+  UINT16                        ReturnWidth;\r
+  FORM_DISPLAY_ENGINE_STATEMENT *Statement;\r
+\r
+  Statement = MenuOption->ThisTag;\r
 \r
   //\r
   // For modal form, clean the entire row.\r
@@ -319,13 +323,23 @@ GetWidth (
     //\r
     // Keep consistent with current behavior.\r
     //\r
-    return (UINT16) (gPromptBlockWidth + gOptionBlockWidth - 2);\r
+    ReturnWidth = (UINT16) (gPromptBlockWidth + gOptionBlockWidth - 2);\r
+  } else {\r
+    if (AdjustWidth != NULL) {\r
+      *AdjustWidth = 1;\r
+    }\r
+\r
+    ReturnWidth =  (UINT16) (gPromptBlockWidth - 1);\r
   }\r
 \r
-  if (AdjustWidth != NULL) {\r
-    *AdjustWidth = 1;\r
+  //\r
+  // For nest in statement, should the subtitle indent.\r
+  //\r
+  if (MenuOption->NestInStatement) {\r
+    ReturnWidth -= SUBTITLE_INDENT;\r
   }\r
-  return (UINT16) (gPromptBlockWidth - 1);\r
+\r
+  return ReturnWidth;\r
 }\r
 \r
 /**\r
@@ -539,24 +553,7 @@ UiAddMenuOption (
   String = GetToken (PromptId, gFormData->HiiHandle);\r
   ASSERT (String != NULL);\r
 \r
-  Width  = GetWidth (Statement, NULL);\r
-  for (; GetLineByWidth (String, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) {\r
-    //\r
-    // If there is more string to process print on the next row and increment the Skip value\r
-    //\r
-    if (StrLen (&String[ArrayEntry]) != 0) {\r
-      NumberOfLines++;\r
-    }\r
-    FreePool (OutputString);\r
-  }\r
-\r
   if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {\r
-    //\r
-    // Add three MenuOptions for Date/Time\r
-    // Data format :      [01/02/2004]      [11:22:33]\r
-    // Line number :        0  0    1         0  0  1\r
-    //\r
-    NumberOfLines = 0;\r
     Count = 3;\r
   }\r
 \r
@@ -571,14 +568,6 @@ UiAddMenuOption (
     MenuOption->NestInStatement = NestIn;\r
     MenuOption->EntryNumber = *MenuItemCount;\r
 \r
-    if (Index == 2) {\r
-      //\r
-      // Override LineNumber for the MenuOption in Date/Time sequence\r
-      //\r
-      MenuOption->Skip = 1;\r
-    } else {\r
-      MenuOption->Skip = NumberOfLines;\r
-    }\r
     MenuOption->Sequence = Index;\r
 \r
     if ((Statement->Attribute & HII_DISPLAY_GRAYOUT) != 0) {\r
@@ -633,6 +622,37 @@ UiAddMenuOption (
       }\r
     }\r
 \r
+    if (Index == 0 && \r
+      (Statement->OpCode->OpCode != EFI_IFR_DATE_OP) && \r
+      (Statement->OpCode->OpCode != EFI_IFR_TIME_OP)) {\r
+      Width  = GetWidth (MenuOption, NULL);\r
+      for (; GetLineByWidth (String, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) {\r
+        //\r
+        // If there is more string to process print on the next row and increment the Skip value\r
+        //\r
+        if (StrLen (&String[ArrayEntry]) != 0) {\r
+          NumberOfLines++;\r
+        }\r
+        FreePool (OutputString);\r
+      }\r
+    } else {\r
+      //\r
+      // Add three MenuOptions for Date/Time\r
+      // Data format :      [01/02/2004]      [11:22:33]\r
+      // Line number :        0  0    1         0  0  1\r
+      //    \r
+      NumberOfLines = 0;\r
+    }\r
+\r
+    if (Index == 2) {\r
+      //\r
+      // Override LineNumber for the MenuOption in Date/Time sequence\r
+      //\r
+      MenuOption->Skip = 1;\r
+    } else {\r
+      MenuOption->Skip = NumberOfLines;\r
+    }\r
+\r
     InsertTailList (&gMenuOption, &MenuOption->Link);\r
   }\r
 \r
@@ -1765,7 +1785,7 @@ DisplayOneMenu (
   //\r
   // 2. Paint the description.\r
   //\r
-  PromptWidth   = GetWidth (Statement, &AdjustValue);\r
+  PromptWidth   = GetWidth (MenuOption, &AdjustValue);\r
   Row           = MenuOption->Row;\r
   GlyphWidth    = 1;\r
   PromptLineNum = 0;\r
@@ -2077,7 +2097,7 @@ UiDisplayMenu (
 \r
           if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {\r
             Status = DisplayOneMenu (MenuOption, \r
-                            LEFT_SKIPPED_COLUMNS,\r
+                            MenuOption->Col - gStatementDimensions.LeftColumn,\r
                             gStatementDimensions.LeftColumn + gModalSkipColumn, \r
                             Link == TopOfScreen ? SkipValue : 0, \r
                             BottomRow,\r
@@ -2085,7 +2105,7 @@ UiDisplayMenu (
                             );\r
           } else {\r
             Status = DisplayOneMenu (MenuOption, \r
-                            LEFT_SKIPPED_COLUMNS,\r
+                            MenuOption->Col - gStatementDimensions.LeftColumn,\r
                             gStatementDimensions.LeftColumn, \r
                             Link == TopOfScreen ? SkipValue : 0, \r
                             BottomRow,\r
@@ -2194,7 +2214,7 @@ UiDisplayMenu (
               ProcessStringForDateTime(MenuOption, OptionString, FALSE);\r
             }\r
 \r
-            Width               = (UINT16) gOptionBlockWidth;\r
+            Width               = (UINT16) gOptionBlockWidth - 1;\r
             OriginalRow         = MenuOption->Row;\r
             GlyphWidth          = 1;\r
 \r
@@ -2229,7 +2249,7 @@ UiDisplayMenu (
               }\r
 \r
               OriginalRow = MenuOption->Row;\r
-              Width       = GetWidth (MenuOption->ThisTag, NULL);\r
+              Width       = GetWidth (MenuOption, NULL);\r
               GlyphWidth  = 1;\r
 \r
               for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {\r
@@ -2280,7 +2300,7 @@ UiDisplayMenu (
           if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {\r
             ProcessStringForDateTime(MenuOption, OptionString, FALSE);\r
           }\r
-          Width               = (UINT16) gOptionBlockWidth;\r
+          Width               = (UINT16) gOptionBlockWidth - 1;\r
 \r
           OriginalRow         = MenuOption->Row;\r
           GlyphWidth          = 1;\r
@@ -2311,7 +2331,7 @@ UiDisplayMenu (
           if (NewLine) {\r
             OriginalRow = MenuOption->Row;\r
 \r
-            Width       = GetWidth (Statement, NULL);\r
+            Width       = GetWidth (MenuOption, NULL);\r
             GlyphWidth          = 1;\r
 \r
             for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {\r
@@ -2874,6 +2894,11 @@ UiDisplayMenu (
         MenuOption = MENU_OPTION_FROM_LINK (SavedListEntry);\r
         UpdateStatusBar (INPUT_ERROR, FALSE);\r
       } else {\r
+        if (NewPos->ForwardLink == &gMenuOption) {\r
+          NewLine   = FALSE;\r
+          Repaint   = FALSE;\r
+          break;\r
+        }\r
         //\r
         // Scroll up to the last page.\r
         //\r
@@ -2882,6 +2907,7 @@ UiDisplayMenu (
         MenuOption      = MENU_OPTION_FROM_LINK (SavedListEntry);\r
         ScreenOperation = UiPageUp;\r
         ControlFlag     = CfScreenOperation;\r
+        SkipValue       = 0;\r
       }\r
       break;\r
 \r
@@ -2938,23 +2964,32 @@ UiDisplayMenu (
       }\r
       \r
       if ((Link->BackLink == &gMenuOption) && (Index >= TopRow)) {\r
-        SkipValue = 0;\r
         if (TopOfScreen == &gMenuOption) {\r
           TopOfScreen = gMenuOption.ForwardLink;\r
           NewPos      = gMenuOption.BackLink;\r
           MoveToNextStatement (TRUE, &NewPos, BottomRow - TopRow);\r
-          Repaint = FALSE;\r
+          if (Index < PreviousMenuOption->Skip) {\r
+            Repaint = TRUE;\r
+            SkipValue = PreviousMenuOption->Skip - (Index - TopRow);\r
+          } else {\r
+            Repaint = FALSE;\r
+            SkipValue = 0;\r
+          }\r
         } else if (TopOfScreen != Link) {\r
           TopOfScreen = Link;\r
           NewPos      = Link;\r
           MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow);\r
+          SkipValue = 0;\r
         } else {\r
           //\r
           // Finally we know that NewPos is the last MenuOption can be focused.\r
           //\r
-          Repaint = FALSE;\r
+          if (SkipValue == 0) {\r
+            Repaint = FALSE;\r
+          }\r
           NewPos  = Link;\r
           MoveToNextStatement (FALSE, &NewPos, BottomRow - TopRow);\r
+          SkipValue = 0;\r
         }\r
       } else {\r
         if (Index > TopRow) {\r
@@ -3002,6 +3037,13 @@ UiDisplayMenu (
 \r
       ASSERT (NewPos != NULL);\r
       if (NewPos->ForwardLink == &gMenuOption) {\r
+        MenuOption = MENU_OPTION_FROM_LINK (NewPos);\r
+        if (SkipValue + BottomRow - TopRow + 1 < MenuOption->Skip) {\r
+          SkipValue += BottomRow - TopRow + 1;\r
+          NewLine = TRUE;\r
+          Repaint = TRUE;\r
+          break;\r
+        }\r
         NewLine = FALSE;\r
         Repaint = FALSE;\r
         break;\r
@@ -3080,6 +3122,12 @@ UiDisplayMenu (
       AdjustDateAndTimePosition (FALSE, &NewPos);\r
 \r
       if (NewPos->ForwardLink != &gMenuOption) {\r
+        if (NewPos == TopOfScreen) {\r
+          Temp2 = SkipValue;\r
+        } else {\r
+          Temp2 = 0;\r
+        }\r
+\r
         MenuOption      = MENU_OPTION_FROM_LINK (NewPos);\r
         NewLine         = TRUE;\r
         NewPos          = NewPos->ForwardLink;\r
@@ -3088,11 +3136,11 @@ UiDisplayMenu (
         //\r
         // Current menu not at the bottom of the form.\r
         //\r
-        if (BottomRow >= MenuOption->Row + MenuOption->Skip) {\r
+        if (BottomRow >= MenuOption->Row + MenuOption->Skip - Temp2) {\r
           //\r
           // Find the next selectable menu.\r
           //\r
-          Difference = MoveToNextStatement (FALSE, &NewPos, BottomRow - MenuOption->Row - MenuOption->Skip);\r
+          Difference = MoveToNextStatement (FALSE, &NewPos, BottomRow - MenuOption->Row - MenuOption->Skip + Temp2);\r
           //\r
           // We hit the end of MenuOption that can be focused\r
           // so we simply scroll to the first page.\r
@@ -3124,10 +3172,10 @@ UiDisplayMenu (
         if (NextMenuOption->Row == 0) {\r
           UpdateOptionSkipLines (NextMenuOption);\r
         }\r
-        DistanceValue  = Difference + NextMenuOption->Skip;\r
+        DistanceValue  = Difference + NextMenuOption->Skip - Temp2;\r
 \r
         Temp = MenuOption->Row + MenuOption->Skip + DistanceValue - 1;\r
-        if ((MenuOption->Row + MenuOption->Skip == BottomRow + 1) &&\r
+        if ((MenuOption->Row + MenuOption->Skip - Temp2 == BottomRow + 1) &&\r
             (NextMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_DATE_OP ||\r
              NextMenuOption->ThisTag->OpCode->OpCode == EFI_IFR_TIME_OP)\r
             ) {\r
@@ -3225,7 +3273,7 @@ UiDisplayMenu (
         //\r
         // Scroll to the first page.\r
         //\r
-        if (TopOfScreen != gMenuOption.ForwardLink) {\r
+        if (TopOfScreen != gMenuOption.ForwardLink || SkipValue != 0) {\r
           TopOfScreen = gMenuOption.ForwardLink;\r
           Repaint     = TRUE;\r
           MenuOption  = NULL;\r