]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c
The input StringInfo should be kept for HiiStringIdToImage() function.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / InputHandler.c
index 2905006856ac62573e589ecbe49c070a7234ff1c..360a6d75ecff552d852d05298d4f1558488aa121 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Implementation for handling user input from the User Interfaces.\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -270,6 +270,12 @@ GetNumericInput (
   Minimum       = Question->Minimum;\r
   Maximum       = Question->Maximum;\r
 \r
+  //\r
+  // Only two case, user can enter to this function: Enter and +/- case.\r
+  // In Enter case, gDirection = 0; in +/- case, gDirection = SCAN_LEFT/SCAN_WRIGHT\r
+  //\r
+  ManualInput        = (BOOLEAN)(gDirection == 0 ? TRUE : FALSE);\r
+\r
   if ((Question->Operand == EFI_IFR_DATE_OP) || (Question->Operand == EFI_IFR_TIME_OP)) {\r
     DateOrTime = TRUE;\r
   } else {\r
@@ -344,12 +350,6 @@ GetNumericInput (
     }\r
   }\r
 \r
-  if (Step == 0) {\r
-    ManualInput = TRUE;\r
-  } else {\r
-    ManualInput = FALSE;\r
-  }\r
-\r
   if ((Question->Operand == EFI_IFR_NUMERIC_OP) &&\r
       ((Question->Flags & EFI_IFR_DISPLAY) == EFI_IFR_DISPLAY_UINT_HEX)) {\r
     HexInput = TRUE;\r
@@ -357,41 +357,96 @@ GetNumericInput (
     HexInput = FALSE;\r
   }\r
 \r
+  //\r
+  // Enter from "Enter" input, clear the old word showing.\r
+  //\r
   if (ManualInput) {\r
-    if (HexInput) {\r
-      InputWidth = Question->StorageWidth * 2;\r
-    } else {\r
-      switch (Question->StorageWidth) {\r
-      case 1:\r
-        InputWidth = 3;\r
-        break;\r
+    if (Question->Operand == EFI_IFR_NUMERIC_OP) {\r
+      if (HexInput) {\r
+        InputWidth = Question->StorageWidth * 2;\r
+      } else {\r
+        switch (Question->StorageWidth) {\r
+        case 1:\r
+          InputWidth = 3;\r
+          break;\r
 \r
-      case 2:\r
-        InputWidth = 5;\r
-        break;\r
+        case 2:\r
+          InputWidth = 5;\r
+          break;\r
 \r
-      case 4:\r
-        InputWidth = 10;\r
-        break;\r
+        case 4:\r
+          InputWidth = 10;\r
+          break;\r
 \r
-      case 8:\r
-        InputWidth = 20;\r
-        break;\r
+        case 8:\r
+          InputWidth = 20;\r
+          break;\r
 \r
-      default:\r
-        InputWidth = 0;\r
-        break;\r
+        default:\r
+          InputWidth = 0;\r
+          break;\r
+        }\r
+      }\r
+\r
+      InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+      SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+      ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);\r
+      InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+      InputText[InputWidth + 2] = L'\0';\r
+\r
+      PrintAt (Column, Row, InputText);\r
+      Column++;\r
+    }\r
+\r
+    if (Question->Operand == EFI_IFR_DATE_OP) {\r
+      if (MenuOption->Sequence == 2) {\r
+        InputWidth = 4;\r
+      } else {\r
+        InputWidth = 2;\r
+      }\r
+\r
+      if (MenuOption->Sequence == 0) {\r
+        InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+        SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+      } else {\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+      }\r
+\r
+      if (MenuOption->Sequence == 2) {\r
+        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+      } else {\r
+        InputText[InputWidth + 1] = DATE_SEPARATOR;\r
+      }\r
+      InputText[InputWidth + 2] = L'\0';\r
+\r
+      PrintAt (Column, Row, InputText);\r
+      if (MenuOption->Sequence == 0) {\r
+        Column++;\r
       }\r
     }\r
 \r
-    InputText[0] = LEFT_NUMERIC_DELIMITER;\r
-    SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
-    ASSERT (InputWidth + 2 < MAX_NUMERIC_INPUT_WIDTH);\r
-    InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
-    InputText[InputWidth + 2] = L'\0';\r
+    if (Question->Operand == EFI_IFR_TIME_OP) {\r
+      InputWidth = 2;\r
+\r
+      if (MenuOption->Sequence == 0) {\r
+        InputText[0] = LEFT_NUMERIC_DELIMITER;\r
+        SetUnicodeMem (InputText + 1, InputWidth, L' ');\r
+      } else {\r
+        SetUnicodeMem (InputText, InputWidth, L' ');\r
+      }\r
+\r
+      if (MenuOption->Sequence == 2) {\r
+        InputText[InputWidth + 1] = RIGHT_NUMERIC_DELIMITER;\r
+      } else {\r
+        InputText[InputWidth + 1] = TIME_SEPARATOR;\r
+      }\r
+      InputText[InputWidth + 2] = L'\0';\r
 \r
-    PrintAt (Column, Row, InputText);\r
-    Column++;\r
+      PrintAt (Column, Row, InputText);\r
+      if (MenuOption->Sequence == 0) {\r
+        Column++;\r
+      }\r
+    }\r
   }\r
 \r
   //\r
@@ -425,7 +480,7 @@ TheKey2:
       switch (Key.ScanCode) {\r
       case SCAN_LEFT:\r
       case SCAN_RIGHT:\r
-        if (DateOrTime) {\r
+        if (DateOrTime && !ManualInput) {\r
           //\r
           // By setting this value, we will return back to the caller.\r
           // We need to do this since an auto-refresh will destroy the adjustment\r
@@ -435,7 +490,7 @@ TheKey2:
           gDirection = SCAN_DOWN;\r
         }\r
 \r
-        if (!ManualInput) {\r
+        if ((Step != 0) && !ManualInput) {\r
           if (Key.ScanCode == SCAN_LEFT) {\r
             if (EditValue > Step) {\r
               EditValue = EditValue - Step;\r
@@ -485,11 +540,11 @@ TheKey2:
             PrintFormattedNumber (Question, FormattedNumber, 21 * sizeof (CHAR16));\r
           }\r
 \r
-          gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r
+          gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND);\r
           for (Loop = 0; Loop < EraseLen; Loop++) {\r
             PrintAt (MenuOption->OptCol + Loop, MenuOption->Row, L" ");\r
           }\r
-          gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT_HIGHLIGHT | FIELD_BACKGROUND_HIGHLIGHT);\r
+          gST->ConOut->SetAttribute (gST->ConOut, PcdGet8 (PcdBrowserFieldTextHighlightColor) | PcdGet8 (PcdBrowserFieldBackgroundHighlightColor));\r
 \r
           if (MenuOption->Sequence == 0) {\r
             PrintCharAt (MenuOption->OptCol, Row, LEFT_NUMERIC_DELIMITER);\r