]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix display engine driver paint some menu error.
authorEric Dong <eric.dong@intel.com>
Tue, 8 Oct 2013 06:25:36 +0000 (06:25 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 8 Oct 2013 06:25:36 +0000 (06:25 +0000)
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14747 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c

index c9852891aac2540ae67cfce585549bbdf61c672d..0cda8a86d4163417f34b80a2841ebcf97edc6a16 100644 (file)
@@ -1577,6 +1577,58 @@ DisplayMenuString (
   PrintStringAtWithWidth (Col + Length, Row, L"", Width - Length);\r
 }\r
 \r
+/**\r
+  Check whether this menu can has option string.\r
+\r
+  @param  MenuOption               The menu opton which this attribut used to.\r
+\r
+  @retval TRUE                     This menu option can have option string.\r
+  @retval FALSE                    This menu option can't have option string.\r
+\r
+**/\r
+BOOLEAN \r
+HasOptionString (\r
+  IN UI_MENU_OPTION                  *MenuOption\r
+  )\r
+{\r
+  FORM_DISPLAY_ENGINE_STATEMENT   *Statement;\r
+  CHAR16                          *String;\r
+  UINTN                           Size;\r
+  EFI_IFR_TEXT                    *TestOp;\r
+\r
+  Size = 0;\r
+  Statement = MenuOption->ThisTag;\r
+\r
+  //\r
+  // See if the second text parameter is really NULL\r
+  //\r
+  if (Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) {\r
+    TestOp = (EFI_IFR_TEXT *) Statement->OpCode;\r
+    if (TestOp->TextTwo != 0) {\r
+      String = GetToken (TestOp->TextTwo, gFormData->HiiHandle);\r
+      Size   = StrLen (String);\r
+      FreePool (String);\r
+    }\r
+  }\r
+\r
+  if ((Statement->OpCode->OpCode == EFI_IFR_SUBTITLE_OP) ||\r
+    (Statement->OpCode->OpCode == EFI_IFR_REF_OP) ||\r
+    (Statement->OpCode->OpCode == EFI_IFR_PASSWORD_OP) ||\r
+    (Statement->OpCode->OpCode == EFI_IFR_ACTION_OP) ||\r
+    (Statement->OpCode->OpCode == EFI_IFR_RESET_BUTTON_OP) ||\r
+    //\r
+    // Allow a wide display if text op-code and no secondary text op-code\r
+    //\r
+    ((Statement->OpCode->OpCode == EFI_IFR_TEXT_OP) && (Size == 0))\r
+    ) {\r
+\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
+\r
 /**\r
   Print string for this menu option.\r
 \r
@@ -1607,7 +1659,6 @@ DisplayOneMenu (
   CHAR16                          *StringPtr;\r
   CHAR16                          *OptionString;\r
   CHAR16                          *OutputString;\r
-  UINTN                           OriginalRow;\r
   UINT16                          GlyphWidth;\r
   UINTN                           Temp;\r
   UINTN                           Temp2;\r
@@ -1616,15 +1667,18 @@ DisplayOneMenu (
   UINTN                           Row;\r
   UINTN                           Col;\r
   UINTN                           PromptLineNum;\r
+  UINTN                           OptionLineNum;\r
   CHAR16                          AdjustValue;\r
+  UINTN                           MaxRow;\r
 \r
   Statement = MenuOption->ThisTag;\r
-  Col       = MenuOption->Col;\r
-  Row       = MenuOption->Row;\r
   Temp      = SkipLine;\r
   Temp2     = SkipLine;\r
   Temp3     = SkipLine;\r
-  AdjustValue = 0;\r
+  AdjustValue   = 0;\r
+  PromptLineNum = 0;\r
+  OptionLineNum = 0;\r
+  MaxRow        = 0;\r
 \r
   //\r
   // Set default color.\r
@@ -1648,8 +1702,9 @@ DisplayOneMenu (
     }\r
   \r
     Width       = (UINT16) gOptionBlockWidth - 1;\r
-    OriginalRow = Row;\r
+    Row         = MenuOption->Row;\r
     GlyphWidth  = 1;\r
+    OptionLineNum = 0;\r
   \r
     for (Index = 0; GetLineByWidth (OptionString, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) {\r
       if (((Temp2 == 0)) && (Row <= BottomRow)) {\r
@@ -1674,6 +1729,7 @@ DisplayOneMenu (
         } else {\r
           DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, Width + 1, Highlight);\r
         }\r
+        OptionLineNum++;\r
       }\r
       \r
       //\r
@@ -1689,7 +1745,7 @@ DisplayOneMenu (
           //\r
           // If the difference in rows is greater than or equal to the skip value, increase the skip value\r
           //\r
-          if ((Row - OriginalRow) >= MenuOption->Skip) {\r
+          if ((Row - MenuOption->Row) >= MenuOption->Skip) {\r
             MenuOption->Skip++;\r
           }\r
         }\r
@@ -1701,50 +1757,22 @@ DisplayOneMenu (
       }\r
     }\r
   \r
-    Row   = OriginalRow;\r
     Highlight = FALSE;\r
 \r
     FreePool (OptionString);\r
   }\r
-  Temp2 = 0;\r
-\r
 \r
   //\r
-  // 2. Pre calculate the skip value.\r
-  //\r
-  if ((Statement->OpCode->OpCode  == EFI_IFR_TEXT_OP) && (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo != 0)) {\r
-    StringPtr   = GetToken (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo, gFormData->HiiHandle);\r
-  \r
-    Width       = (UINT16) gOptionBlockWidth - 1;\r
-    OriginalRow = Row;\r
-    GlyphWidth    = 1;\r
-    for (Index = 0; GetLineByWidth (StringPtr, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { \r
-      if (StrLen (&StringPtr[Index]) != 0) {\r
-        Row++;\r
-        if ((Row - OriginalRow) >= MenuOption->Skip) {\r
-          MenuOption->Skip++;\r
-        }\r
-      }\r
-      FreePool (OutputString);\r
-    }\r
-  \r
-    Row = OriginalRow;\r
-    FreePool (StringPtr);\r
-  }\r
-\r
-\r
-  //\r
-  // 3. Paint the description.\r
+  // 2. Paint the description.\r
   //\r
   PromptWidth   = GetWidth (Statement, &AdjustValue);\r
-  OriginalRow   = Row;\r
+  Row           = MenuOption->Row;\r
   GlyphWidth    = 1;\r
   PromptLineNum = 0;\r
 \r
   if (MenuOption->Description == NULL || MenuOption->Description[0] == '\0') {\r
-    while (Temp++ < MenuOption->Skip) {\r
-      PrintStringAtWithWidth (BeginCol, Row++, L"", PromptWidth + AdjustValue + SkipWidth);\r
-    } \r
+    PrintStringAtWithWidth (BeginCol, Row, L"", PromptWidth + AdjustValue + SkipWidth);\r
+    PromptLineNum++;\r
   } else {\r
     for (Index = 0; GetLineByWidth (MenuOption->Description, PromptWidth, &GlyphWidth, &Index, &OutputString) != 0x0000;) {      \r
       if ((Temp == 0) && (Row <= BottomRow)) { \r
@@ -1782,34 +1810,24 @@ DisplayOneMenu (
     }\r
 \r
     Highlight = FALSE;\r
-\r
-    //\r
-    // Clean the empty prompt line.\r
-    // These line is used by option string but not prompt, so clean them here.\r
-    //\r
-    Row = OriginalRow + PromptLineNum;\r
-    while (PromptLineNum + SkipLine < MenuOption->Skip && Row <= BottomRow) {\r
-      PrintStringAtWithWidth (BeginCol, Row, L"", PromptWidth + AdjustValue + SkipWidth);\r
-      PromptLineNum ++;\r
-      Row ++;\r
-    }\r
   }\r
-  Row = OriginalRow;\r
 \r
 \r
   //\r
-  // 4. If this is a text op with secondary text information\r
+  // 3. If this is a text op with secondary text information\r
   //\r
   if ((Statement->OpCode->OpCode  == EFI_IFR_TEXT_OP) && (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo != 0)) {\r
     StringPtr   = GetToken (((EFI_IFR_TEXT*)Statement->OpCode)->TextTwo, gFormData->HiiHandle);\r
   \r
     Width       = (UINT16) gOptionBlockWidth - 1;\r
-    OriginalRow = Row;\r
+    Row         = MenuOption->Row;\r
     GlyphWidth  = 1;\r
+    OptionLineNum = 0;\r
 \r
     for (Index = 0; GetLineByWidth (StringPtr, Width, &GlyphWidth, &Index, &OutputString) != 0x0000;) { \r
       if ((Temp3 == 0) && (Row <= BottomRow)) {\r
         DisplayMenuString (MenuOption, MenuOption->OptCol, Row, OutputString, Width + 1, Highlight);\r
+        OptionLineNum++;\r
       }\r
       //\r
       // If there is more string to process print on the next row and increment the Skip value\r
@@ -1825,11 +1843,25 @@ DisplayOneMenu (
         Temp3--;\r
       }\r
     }\r
-  \r
-    Row = OriginalRow;\r
+\r
     FreePool (StringPtr);\r
   }\r
 \r
+  //\r
+  // 4.Line number for Option string and prompt string are not equal.\r
+  //  Clean the column whose line number is less.\r
+  //\r
+  if (HasOptionString(MenuOption) && (OptionLineNum != PromptLineNum)) {\r
+    Col    =  OptionLineNum < PromptLineNum ? MenuOption->OptCol : BeginCol;\r
+    Row    = (OptionLineNum < PromptLineNum ? OptionLineNum : PromptLineNum) + MenuOption->Row;\r
+    Width  = (UINT16) (OptionLineNum < PromptLineNum ? gOptionBlockWidth : PromptWidth + AdjustValue + SkipWidth);\r
+    MaxRow = (OptionLineNum < PromptLineNum ? PromptLineNum : OptionLineNum) + MenuOption->Row - 1;\r
+    \r
+    while (Row <= MaxRow) {\r
+      DisplayMenuString (MenuOption, Col, Row++, L"", Width, FALSE);\r
+    }\r
+  }\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r