]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DriverSample: Add sample case for popup protocol
authorDandan Bi <dandan.bi@intel.com>
Tue, 22 Aug 2017 07:06:21 +0000 (15:06 +0800)
committerEric Dong <eric.dong@intel.com>
Wed, 23 Aug 2017 02:37:14 +0000 (10:37 +0800)
Add one sample case about how to use HiiPopup protocol to draw message box.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni

index f103b9ca21485e47d39fa8e8b793f048a8c2002c..bbd9713eea75afa3ca69131e8223bbc62e3797c8 100644 (file)
@@ -1100,6 +1100,9 @@ DriverCallback (
   CHAR16                          *TmpStr;\r
   UINTN                           Index;\r
   UINT64                          BufferValue;\r
+  EFI_HII_POPUP_SELECTION         UserSelection;\r
+\r
+  UserSelection = 0xFF;\r
 \r
   if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))||\r
     (ActionRequest == NULL)) {\r
@@ -1619,6 +1622,22 @@ DriverCallback (
         }\r
         break;\r
 \r
+      case 0x1330:\r
+        Status = mPrivateData->HiiPopup->CreatePopup (\r
+          mPrivateData->HiiPopup,\r
+          EfiHiiPopupStyleInfo,\r
+          EfiHiiPopupTypeYesNo,\r
+          mPrivateData->HiiHandle[0],\r
+          STRING_TOKEN (STR_POPUP_STRING),\r
+          &UserSelection\r
+          );\r
+        if (!EFI_ERROR (Status)) {\r
+          if (UserSelection == EfiHiiPopupSelectionYes) {\r
+            *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
+          }\r
+        }\r
+        break;\r
+\r
       default:\r
       break;\r
     }\r
@@ -1678,6 +1697,7 @@ DriverSampleInit (
   EFI_FORM_BROWSER2_PROTOCOL      *FormBrowser2;\r
   EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
   EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler;\r
+  EFI_HII_POPUP_PROTOCOL              *PopupHandler;\r
   CHAR16                          *NewString;\r
   UINTN                           BufferSize;\r
   DRIVER_SAMPLE_CONFIGURATION     *Configuration;\r
@@ -1763,6 +1783,15 @@ DriverSampleInit (
   }\r
   mPrivateData->HiiKeywordHandler = HiiKeywordHandler;\r
 \r
+  //\r
+  // Locate HiiPopup protocol\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiHiiPopupProtocolGuid, NULL, (VOID **) &PopupHandler);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  mPrivateData->HiiPopup = PopupHandler;\r
+\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &DriverHandle[0],\r
                   &gEfiDevicePathProtocolGuid,\r
index 6c97239cf37c2881ec72d55a43e67578becb0340..507cff6ec9fc477d093d132dfa4676a39184c1f0 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2017, 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
@@ -33,6 +33,7 @@ Revision History
 #include <Protocol/HiiString.h>\r
 #include <Protocol/FormBrowserEx.h>\r
 #include <Protocol/HiiConfigKeyword.h>\r
+#include <Protocol/HiiPopup.h>\r
 \r
 #include <Guid/MdeModuleHii.h>\r
 #include <Library/DebugLib.h>\r
@@ -98,6 +99,7 @@ typedef struct {
   EFI_HII_STRING_PROTOCOL          *HiiString;\r
   EFI_HII_CONFIG_ROUTING_PROTOCOL  *HiiConfigRouting;\r
   EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler;\r
+  EFI_HII_POPUP_PROTOCOL              *HiiPopup;\r
 \r
   EFI_FORM_BROWSER2_PROTOCOL       *FormBrowser2;\r
 \r
index 4233e635bc39f8433099cd3e6f1327036b759162..bfd74845181b8c067a78b7755a2fcb0daf907185 100644 (file)
@@ -4,7 +4,7 @@
 # This driver shows how HII protocol, VFR and UNI files are used to create a HII \r
 # driver which can be dipslayed and configured by a UEFI HII Form Browser.\r
 #\r
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -93,6 +93,7 @@
   gEfiSimpleTextInputExProtocolGuid             ## SOMETIMES_CONSUMES\r
   gEdkiiFormBrowserExProtocolGuid               ## CONSUMES\r
   gEfiConfigKeywordHandlerProtocolGuid          ## CONSUMES\r
+  gEfiHiiPopupProtocolGuid                      ## CONSUMES\r
 \r
 [Depex]\r
   gEfiSimpleTextOutProtocolGuid AND gEfiHiiDatabaseProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid\r
index 4bdaf765bc2667016665a1b76e2e20db58d8a4f9..d547ec809b89c80b36f541ca02bdaa8f814277f3 100644 (file)
@@ -2,7 +2,7 @@
 //\r
 //    Sample Setup formset.\r
 //\r
-//  Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
+//  Copyright (c) 2004 - 2017, 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
@@ -476,7 +476,13 @@ formset
             maximum = 255,\r
             default = 18,\r
     endnumeric;\r
-    \r
+\r
+    text\r
+      help  = STRING_TOKEN(STR_POPUP_TEST_HELP),\r
+      text  = STRING_TOKEN(STR_POPUP_TEST_PROMPT),\r
+      flags = INTERACTIVE,\r
+      key   = 0x1330;\r
+\r
     goto 2,\r
       prompt = STRING_TOKEN(STR_GOTO_FORM2), //SecondSetupPage  // this too has no end-op and basically it's a jump to a form ONLY\r
       help   = STRING_TOKEN(STR_GOTO_HELP);\r
index 8d24a476f32886edb13c0552ea0d78202094a926..6a268d12369c9d7fbd932a804cc56d6b1100b851 100644 (file)
@@ -1,6 +1,6 @@
 // *++\r
        //\r
-// Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2007 - 2017, 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
                                                      #language fr-FR "Submitted callback test"\r
 #string STR_SUBMITTED_CALLBACK_TEST_HELP             #language en-US "Change the value and press F10 to submmit will pop up a dialogue to show SUBMITTED Callback has been triggered"\r
                                                      #language fr-FR "Change the value and press F10 to submmit will pop up a dialogue to show SUBMITTED Callback has been triggered"\r
+#string STR_POPUP_TEST_PROMPT                        #language en-US "Select it to invoke Hii Popup Protocol"\r
+                                                     #language fr-FR "Select it to invoke Hii Popup Protocol"\r
+#string STR_POPUP_TEST_HELP                          #language en-US "Select this question will pop up a message box, then user can decide whether exit curret form or not"\r
+                                                     #language fr-FR "Select this question will pop up a message box, then user can decide whether exit curret form or not"\r
+#string STR_POPUP_STRING                             #language en-US "Are you sure to exit current form?"\r
+                                                     #language fr-FR "Are you sure to exit current form?"\r
 // Boot Order\r
 #string STR_BOOT_TITLE                 #language en-US "Boot"\r
 #string STR_BOOT_OPTIONS               #language en-US "Boot Order"\r