1. Code clean up: add IN/OUT modifier for parameters.

2. UI enchancement: if there is no editable item in a Form, the F9/F10 will not be displayed in the footer.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9363 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xdu2 2009-10-26 03:05:16 +00:00
parent f4a2af1f4d
commit 8b0fc5c1e1
11 changed files with 125 additions and 76 deletions

View File

@ -512,7 +512,7 @@ InitializeUnicodeCollationProtocol (
**/ **/
VOID VOID
IfrStrToUpper ( IfrStrToUpper (
CHAR16 *String IN CHAR16 *String
) )
{ {
while (*String != 0) { while (*String != 0) {

View File

@ -141,7 +141,7 @@ UpdateCheckBoxStringToken (
**/ **/
BOOLEAN BOOLEAN
IsNextOpCodeGuidedVarEqName ( IsNextOpCodeGuidedVarEqName (
UINT8 *OpCodeData IN UINT8 *OpCodeData
) )
{ {
// //

View File

@ -31,11 +31,11 @@ UI_MENU_SELECTION *gCurrentSelection;
**/ **/
VOID VOID
ClearLines ( ClearLines (
UINTN LeftColumn, IN UINTN LeftColumn,
UINTN RightColumn, IN UINTN RightColumn,
UINTN TopRow, IN UINTN TopRow,
UINTN BottomRow, IN UINTN BottomRow,
UINTN TextAttribute IN UINTN TextAttribute
) )
{ {
CHAR16 *Buffer; CHAR16 *Buffer;
@ -80,8 +80,8 @@ ClearLines (
**/ **/
VOID VOID
NewStrCat ( NewStrCat (
CHAR16 *Destination, IN OUT CHAR16 *Destination,
CHAR16 *Source IN CHAR16 *Source
) )
{ {
UINTN Length; UINTN Length;
@ -117,7 +117,7 @@ NewStrCat (
**/ **/
UINTN UINTN
GetStringWidth ( GetStringWidth (
CHAR16 *String IN CHAR16 *String
) )
{ {
UINTN Index; UINTN Index;
@ -460,6 +460,7 @@ DisplayForm (
FORM_BROWSER_STATEMENT *Statement; FORM_BROWSER_STATEMENT *Statement;
UINT16 NumberOfLines; UINT16 NumberOfLines;
EFI_STATUS Status; EFI_STATUS Status;
UI_MENU_OPTION *MenuOption;
Handle = Selection->Handle; Handle = Selection->Handle;
MenuItemCount = 0; MenuItemCount = 0;
@ -494,6 +495,7 @@ DisplayForm (
return Status; return Status;
} }
Selection->FormEditable = FALSE;
Link = GetFirstNode (&Selection->Form->StatementListHead); Link = GetFirstNode (&Selection->Form->StatementListHead);
while (!IsNull (&Selection->Form->StatementListHead, Link)) { while (!IsNull (&Selection->Form->StatementListHead, Link)) {
Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link); Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
@ -530,8 +532,15 @@ DisplayForm (
// We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do
// it in UiFreeMenu. // it in UiFreeMenu.
// //
UiAddMenuOption (StringPtr, Selection->Handle, Statement, NumberOfLines, MenuItemCount); MenuOption = UiAddMenuOption (StringPtr, Selection->Handle, Statement, NumberOfLines, MenuItemCount);
MenuItemCount++; MenuItemCount++;
if (MenuOption->IsQuestion && !MenuOption->ReadOnly) {
//
// At least one item is not readonly, this Form is considered as editable
//
Selection->FormEditable = TRUE;
}
} }
Link = GetNextNode (&Selection->Form->StatementListHead, Link); Link = GetNextNode (&Selection->Form->StatementListHead, Link);
@ -553,7 +562,6 @@ InitializeBrowserStrings (
VOID VOID
) )
{ {
gFunctionOneString = GetToken (STRING_TOKEN (FUNCTION_ONE_STRING), gHiiHandle);
gFunctionNineString = GetToken (STRING_TOKEN (FUNCTION_NINE_STRING), gHiiHandle); gFunctionNineString = GetToken (STRING_TOKEN (FUNCTION_NINE_STRING), gHiiHandle);
gFunctionTenString = GetToken (STRING_TOKEN (FUNCTION_TEN_STRING), gHiiHandle); gFunctionTenString = GetToken (STRING_TOKEN (FUNCTION_TEN_STRING), gHiiHandle);
gEnterString = GetToken (STRING_TOKEN (ENTER_STRING), gHiiHandle); gEnterString = GetToken (STRING_TOKEN (ENTER_STRING), gHiiHandle);
@ -596,7 +604,6 @@ FreeBrowserStrings (
VOID VOID
) )
{ {
FreePool (gFunctionOneString);
FreePool (gFunctionNineString); FreePool (gFunctionNineString);
FreePool (gFunctionTenString); FreePool (gFunctionTenString);
FreePool (gEnterString); FreePool (gEnterString);
@ -632,12 +639,14 @@ FreeBrowserStrings (
/** /**
Update key's help imformation. Update key's help imformation.
@param Selection Tell setup browser the information about the Selection
@param MenuOption The Menu option @param MenuOption The Menu option
@param Selected Whether or not a tag be selected @param Selected Whether or not a tag be selected
**/ **/
VOID VOID
UpdateKeyHelp ( UpdateKeyHelp (
IN UI_MENU_SELECTION *Selection,
IN UI_MENU_OPTION *MenuOption, IN UI_MENU_OPTION *MenuOption,
IN BOOLEAN Selected IN BOOLEAN Selected
) )
@ -676,9 +685,10 @@ UpdateKeyHelp (
if (!Selected) { if (!Selected) {
if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gFunctionOneString); if (Selection->FormEditable) {
PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString); PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString);
PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString); PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString);
}
PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
} }
@ -732,9 +742,10 @@ UpdateKeyHelp (
ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND); ClearLines (LeftColumnOfHelp, RightColumnOfHelp, TopRowOfHelp, BottomRowOfHelp, KEYHELP_TEXT | KEYHELP_BACKGROUND);
if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gFunctionOneString); if (Selection->FormEditable) {
PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString); PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString);
PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString); PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString);
}
PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
} }
@ -752,9 +763,10 @@ UpdateKeyHelp (
if (!Selected) { if (!Selected) {
if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) { if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
PrintStringAt (StartColumnOfHelp, TopRowOfHelp, gFunctionOneString); if (Selection->FormEditable) {
PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString); PrintStringAt (SecCol, TopRowOfHelp, gFunctionNineString);
PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString); PrintStringAt (ThdCol, TopRowOfHelp, gFunctionTenString);
}
PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString); PrintStringAt (ThdCol, BottomRowOfHelp, gEscapeString);
} }

View File

@ -44,7 +44,6 @@ BOOLEAN gDownArrow;
// //
// Browser Global Strings // Browser Global Strings
// //
CHAR16 *gFunctionOneString;
CHAR16 *gFunctionNineString; CHAR16 *gFunctionNineString;
CHAR16 *gFunctionTenString; CHAR16 *gFunctionTenString;
CHAR16 *gEnterString; CHAR16 *gEnterString;
@ -2500,10 +2499,6 @@ InitializeFormSet (
// //
// Function key prompt can not be displayed if the function key has been disabled. // Function key prompt can not be displayed if the function key has been disabled.
// //
if ((gFunctionKeySetting & FUNCTION_ONE) != FUNCTION_ONE) {
gFunctionOneString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
}
if ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE) { if ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE) {
gFunctionNineString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle); gFunctionNineString = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
} }

View File

@ -71,9 +71,8 @@ extern UINT8 SetupBrowserStrings[];
// Definition for function key setting // Definition for function key setting
// //
#define NONE_FUNCTION_KEY_SETTING 0 #define NONE_FUNCTION_KEY_SETTING 0
#define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_ONE | FUNCTION_NINE | FUNCTION_TEN) #define DEFAULT_FUNCTION_KEY_SETTING (FUNCTION_NINE | FUNCTION_TEN)
#define FUNCTION_ONE (1 << 0)
#define FUNCTION_NINE (1 << 2) #define FUNCTION_NINE (1 << 2)
#define FUNCTION_TEN (1 << 3) #define FUNCTION_TEN (1 << 3)
@ -466,7 +465,6 @@ extern FORM_BROWSER_FORMSET *gOldFormSet;
// //
// Browser Global Strings // Browser Global Strings
// //
extern CHAR16 *gFunctionOneString;
extern CHAR16 *gFunctionNineString; extern CHAR16 *gFunctionNineString;
extern CHAR16 *gFunctionTenString; extern CHAR16 *gFunctionTenString;
extern CHAR16 *gEnterString; extern CHAR16 *gEnterString;

View File

@ -558,8 +558,10 @@ UiWaitForSingleEvent (
@param NumberOfLines Display lines for this Menu Option. @param NumberOfLines Display lines for this Menu Option.
@param MenuItemCount The index for this Option in the Menu. @param MenuItemCount The index for this Option in the Menu.
@retval Pointer Pointer to the added Menu Option.
**/ **/
VOID UI_MENU_OPTION *
UiAddMenuOption ( UiAddMenuOption (
IN CHAR16 *String, IN CHAR16 *String,
IN EFI_HII_HANDLE Handle, IN EFI_HII_HANDLE Handle,
@ -573,6 +575,7 @@ UiAddMenuOption (
UINTN Count; UINTN Count;
Count = 1; Count = 1;
MenuOption = NULL;
if (Statement->Operand == EFI_IFR_DATE_OP || Statement->Operand == EFI_IFR_TIME_OP) { if (Statement->Operand == EFI_IFR_DATE_OP || Statement->Operand == EFI_IFR_TIME_OP) {
// //
@ -617,6 +620,26 @@ UiAddMenuOption (
MenuOption->GrayOut = Statement->GrayOutExpression->Result.Value.b; MenuOption->GrayOut = Statement->GrayOutExpression->Result.Value.b;
} }
switch (Statement->Operand) {
case EFI_IFR_ORDERED_LIST_OP:
case EFI_IFR_ONE_OF_OP:
case EFI_IFR_NUMERIC_OP:
case EFI_IFR_TIME_OP:
case EFI_IFR_DATE_OP:
case EFI_IFR_CHECKBOX_OP:
case EFI_IFR_PASSWORD_OP:
case EFI_IFR_STRING_OP:
//
// User could change the value of these items
//
MenuOption->IsQuestion = TRUE;
break;
default:
MenuOption->IsQuestion = FALSE;
break;
}
if ((Statement->ValueExpression != NULL) || if ((Statement->ValueExpression != NULL) ||
((Statement->QuestionFlags & EFI_IFR_FLAG_READ_ONLY) != 0)) { ((Statement->QuestionFlags & EFI_IFR_FLAG_READ_ONLY) != 0)) {
MenuOption->ReadOnly = TRUE; MenuOption->ReadOnly = TRUE;
@ -624,6 +647,8 @@ UiAddMenuOption (
InsertTailList (&Menu, &MenuOption->Link); InsertTailList (&Menu, &MenuOption->Link);
} }
return MenuOption;
} }
@ -2245,7 +2270,7 @@ UiDisplayMenu (
} }
} }
UpdateKeyHelp (MenuOption, FALSE); UpdateKeyHelp (Selection, MenuOption, FALSE);
// //
// Clear reverse attribute // Clear reverse attribute
@ -2384,8 +2409,7 @@ UiDisplayMenu (
break; break;
case CHAR_NULL: case CHAR_NULL:
if (((Key.ScanCode == SCAN_F1) && ((gFunctionKeySetting & FUNCTION_ONE) != FUNCTION_ONE)) || if (((Key.ScanCode == SCAN_F9) && ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE)) ||
((Key.ScanCode == SCAN_F9) && ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE)) ||
((Key.ScanCode == SCAN_F10) && ((gFunctionKeySetting & FUNCTION_TEN) != FUNCTION_TEN)) ((Key.ScanCode == SCAN_F10) && ((gFunctionKeySetting & FUNCTION_TEN) != FUNCTION_TEN))
) { ) {
// //
@ -2589,13 +2613,13 @@ UiDisplayMenu (
// //
// Editable Questions: oneof, ordered list, checkbox, numeric, string, password // Editable Questions: oneof, ordered list, checkbox, numeric, string, password
// //
UpdateKeyHelp (MenuOption, TRUE); UpdateKeyHelp (Selection, MenuOption, TRUE);
Status = ProcessOptions (Selection, MenuOption, TRUE, &OptionString); Status = ProcessOptions (Selection, MenuOption, TRUE, &OptionString);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Repaint = TRUE; Repaint = TRUE;
NewLine = TRUE; NewLine = TRUE;
UpdateKeyHelp (MenuOption, FALSE); UpdateKeyHelp (Selection, MenuOption, FALSE);
} else { } else {
Selection->Action = UI_ACTION_REFRESH_FORM; Selection->Action = UI_ACTION_REFRESH_FORM;
} }
@ -3078,6 +3102,12 @@ UiDisplayMenu (
case CfUiDefault: case CfUiDefault:
ControlFlag = CfCheckSelection; ControlFlag = CfCheckSelection;
if (!Selection->FormEditable) {
//
// This Form is not editable, ignore the F9 (reset to default)
//
break;
}
Status = ExtractFormDefault (Selection->FormSet, Selection->Form, DefaultId); Status = ExtractFormDefault (Selection->FormSet, Selection->Form, DefaultId);

View File

@ -108,6 +108,11 @@ typedef struct {
FORM_BROWSER_FORMSET *FormSet; FORM_BROWSER_FORMSET *FormSet;
FORM_BROWSER_FORM *Form; FORM_BROWSER_FORM *Form;
FORM_BROWSER_STATEMENT *Statement; FORM_BROWSER_STATEMENT *Statement;
//
// Whether the Form is editable
//
BOOLEAN FormEditable;
} UI_MENU_SELECTION; } UI_MENU_SELECTION;
#define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm') #define UI_MENU_OPTION_SIGNATURE SIGNATURE_32 ('u', 'i', 'm', 'm')
@ -140,6 +145,11 @@ typedef struct {
BOOLEAN GrayOut; BOOLEAN GrayOut;
BOOLEAN ReadOnly; BOOLEAN ReadOnly;
//
// Whether user could change value of this item
//
BOOLEAN IsQuestion;
} UI_MENU_OPTION; } UI_MENU_OPTION;
#define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE) #define MENU_OPTION_FROM_LINK(a) CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
@ -280,8 +290,10 @@ UiFreeRefreshList (
@param NumberOfLines Display lines for this Menu Option. @param NumberOfLines Display lines for this Menu Option.
@param MenuItemCount The index for this Option in the Menu. @param MenuItemCount The index for this Option in the Menu.
@retval Pointer Pointer to the added Menu Option.
**/ **/
VOID UI_MENU_OPTION *
UiAddMenuOption ( UiAddMenuOption (
IN CHAR16 *String, IN CHAR16 *String,
IN EFI_HII_HANDLE Handle, IN EFI_HII_HANDLE Handle,
@ -589,12 +601,14 @@ ProcessHelpString (
/** /**
Update key's help imformation. Update key's help imformation.
@param Selection Tell setup browser the information about the Selection
@param MenuOption The Menu option @param MenuOption The Menu option
@param Selected Whether or not a tag be selected @param Selected Whether or not a tag be selected
**/ **/
VOID VOID
UpdateKeyHelp ( UpdateKeyHelp (
IN UI_MENU_SELECTION *Selection,
IN UI_MENU_OPTION *MenuOption, IN UI_MENU_OPTION *MenuOption,
IN BOOLEAN Selected IN BOOLEAN Selected
); );
@ -611,11 +625,11 @@ UpdateKeyHelp (
**/ **/
VOID VOID
ClearLines ( ClearLines (
UINTN LeftColumn, IN UINTN LeftColumn,
UINTN RightColumn, IN UINTN RightColumn,
UINTN TopRow, IN UINTN TopRow,
UINTN BottomRow, IN UINTN BottomRow,
UINTN TextAttribute IN UINTN TextAttribute
); );
/** /**
@ -634,7 +648,7 @@ ClearLines (
**/ **/
UINTN UINTN
GetStringWidth ( GetStringWidth (
CHAR16 *String IN CHAR16 *String
); );
/** /**
@ -683,8 +697,8 @@ GetWidth (
**/ **/
VOID VOID
NewStrCat ( NewStrCat (
CHAR16 *Destination, IN OUT CHAR16 *Destination,
CHAR16 *Source IN CHAR16 *Source
); );
/** /**