alder_lake_bios/Insyde/InsydeSetupPkg/Drivers/H2ODisplayEngineLocalMetroDxe/H2OPanels/H2OFormTitlePanel.c

228 lines
6.7 KiB
C

/** @file
UI Common Controls
;******************************************************************************
;* Copyright (c) 2012 - 2020, Insyde Software Corp. All Rights Reserved.
;*
;* You may not reproduce, distribute, publish, display, perform, modify, adapt,
;* transmit, broadcast, present, recite, release, license or otherwise exploit
;* any part of this publication in any form, by any means, without the prior
;* written permission of Insyde Software Corporation.
;*
;******************************************************************************
*/
#include "H2ODisplayEngineLocalMetro.h"
#include "H2OPanels.h"
#include "MetroUi.h"
STATIC H2O_FORM_TITLE_PANEL_CLASS *mH2OFormTitlePanelClass = NULL;
#define CURRENT_CLASS mH2OFormTitlePanelClass
#if FixedPcdGet32(PcdH2OLmdeMultiLayout) == 0
//CHAR16 *mFormTitlePanelChilds = L""
// L"<HorizontalLayout background-color='0xFF333333' height='-1'>"
// L"<HorizontalLayout width='-1' float='true' height='-1'>"
// L"<Texture background-image='@FormTitleBkg' background-image-style='stretch'/>"
// L"</HorizontalLayout>"
// L"<Control padding='13,0,15,30' width='37' height='37'>"
// L"<Texture name='TitleImage' background-image-style='stretch'/>"
// L"</Control>"
// L"<Label padding='15,0,15,8' width='1492' textcolor='0xFFFFFFFF' font-size='30' name='TitleName'/>"
// L"</HorizontalLayout>";
CHAR16 *mFormTitlePanelChilds = NULL;
#endif
STATIC
VOID
H2OFormTitlePanelUpdateVfcfOrder (
IN UI_CONTROL *Order
)
{
UINTN Index;
UI_CONTROL *Child;
CHAR16 Str[20];
EFI_IMAGE_INPUT *PageImage;
UINTN NameLen;
if (Order == NULL) {
return;
}
for (Index = 0; Index < Order->ItemCount; Index++) {
Child = Order->Items[Index];
if (Child->Name == NULL) {
continue;
}
NameLen = StrLen(Child->Name);
if (STR_MATCH(Child->Name, NameLen, L"formset-image")) {
PageImage = GetCurrentFormSetImage ();
if (PageImage != NULL) {
UnicodeSPrint (Str, sizeof (Str), L"0x%p", PageImage);
UiSetAttribute (Child, L"background-image", Str);
UiSetAttribute (Child, L"visibility", L"true");
} else {
UiSetAttribute (Child, L"visibility", L"false");
}
} else if (STR_MATCH(Child->Name, NameLen, L"formset-title")) {
UiSetAttribute (Child, L"text", (gFB->CurrentQ == NULL) ? L"" : GetCurrentFormSetTitle ());
} else if (STR_MATCH(Child->Name, NameLen, L"form-title")) {
//
// TODO: VFCF should support to dynamicaly hide form-title and str0.
//
if (IsRootPage ()) {
UiSetAttribute (Child, L"visibility", L"false");
} else {
UiSetAttribute (Child, L"visibility", L"true");
UiSetAttribute (Child, L"text", gFB->CurrentP->PageTitle);
}
} else if (PREFIX_STR_MATCH(Child->Name, NameLen, L"str")) {
if (IsRootPage ()) {
UiSetAttribute (Child, L"visibility", L"false");
} else {
UiSetAttribute (Child, L"visibility", L"true");
}
} else if (STR_MATCH(Child->Name, NameLen, L"container")) {
Child = CONTROL_CLASS(Child)->FindChildByName (Child, VFCF_PROPERTY_ORDER_CONTROL_NAME, UI_SEARCH_TYPE_ONLY_CHILD);
if (Child == NULL) {
continue;
}
H2OFormTitlePanelUpdateVfcfOrder (Child);
}
}
}
EFI_STATUS
RefreshFormTitleMenu (
H2O_FORM_TITLE_PANEL *This
)
{
EFI_IMAGE_INPUT *PageImage;
UI_CONTROL *Control;
UI_MANAGER *Manager;
CHAR16 *FormSetTitle;
CHAR16 *MenuTitle;
CHAR16 Str[20];
Control = (UI_CONTROL *) This;
Manager = Control->Manager;
PageImage = GetCurrentFormSetImage ();
Control = Manager->FindControlByName (Manager, L"TitleImage");
if (PageImage != NULL) {
UnicodeSPrint (Str, sizeof (Str), L"0x%p", PageImage);
UiSetAttribute (Control, L"background-image", Str);
UiSetAttribute (Control, L"visibility", L"true");
if (PcdGet32(PcdH2OLmdeMultiLayout) == 1) {
AdjustImageToMenuColor (Control);
}
} else {
UiSetAttribute (Control, L"visibility", L"false");
}
Control = Manager->FindControlByName (Manager, L"TitleName");
FormSetTitle = GetCurrentFormSetTitle ();
if (gFB->CurrentQ == NULL) {
UiSetAttribute (Control, L"text", L"");
} else {
if (!IsRootPage ()) {
MenuTitle = CatSPrint (NULL, L"%s > %s", FormSetTitle, gFB->CurrentP->PageTitle);
UiSetAttribute (Control, L"text", MenuTitle);
FreePool (MenuTitle);
} else {
UiSetAttribute (Control, L"text", FormSetTitle);
}
}
return EFI_SUCCESS;
}
LRESULT
EFIAPI
H2OFormTitlePanelProc (
HWND Hwnd,
UINT32 Msg,
WPARAM WParam,
LPARAM LParam
)
{
H2O_FORM_TITLE_PANEL *This;
UI_CONTROL *Control;
UI_CONTROL *Child;
This = (H2O_FORM_TITLE_PANEL *) GetWindowLongPtr (Hwnd, 0);
Control = (UI_CONTROL *)This;
if (This == NULL && Msg != WM_CREATE && Msg != WM_NCCALCSIZE) {
ASSERT (FALSE);
return 0;
}
switch (Msg) {
case WM_CREATE:
This = (H2O_FORM_TITLE_PANEL *) AllocateZeroPool (sizeof (H2O_FORM_TITLE_PANEL));
if (This != NULL) {
CONTROL_CLASS (This) = (UI_CONTROL_CLASS *) GetClassLongPtr (Hwnd, 0);
SetWindowLongPtr (Hwnd, 0, (INTN)This);
SendMessage (Hwnd, UI_NOTIFY_CREATE, WParam, LParam);
}
break;
case UI_NOTIFY_CREATE:
PARENT_CLASS_WNDPROC (CURRENT_CLASS, Hwnd, UI_NOTIFY_CREATE, WParam, LParam);
if (mFormTitlePanelChilds != NULL) {
XmlCreateControl (mFormTitlePanelChilds, Control);
}
break;
case FB_NOTIFY_REPAINT:
if (This != NULL) {
if (mFormTitlePanelChilds != NULL) {
RefreshFormTitleMenu (This);
} else {
Child = CONTROL_CLASS(Control)->FindChildByName (Control, VFCF_PROPERTY_ORDER_CONTROL_NAME, UI_SEARCH_TYPE_ONLY_CHILD);
if (Child != NULL) {
H2OFormTitlePanelUpdateVfcfOrder (Child);
}
}
}
break;
case WM_NCHITTEST:
return HTCLIENT;
default:
return PARENT_CLASS_WNDPROC (CURRENT_CLASS, Hwnd, Msg, WParam, LParam);
}
return 0;
}
H2O_FORM_TITLE_PANEL_CLASS *
EFIAPI
GetH2OFormTitlePanelClass (
VOID
)
{
if (CURRENT_CLASS != NULL) {
return CURRENT_CLASS;
}
InitUiClass ((UI_CONTROL_CLASS **)&CURRENT_CLASS, sizeof (*CURRENT_CLASS), L"H2OFormTitlePanel", (UI_CONTROL_CLASS *)GetControlClass());
if (CURRENT_CLASS == NULL) {
return NULL;
}
((UI_CONTROL_CLASS *)CURRENT_CLASS)->WndProc = H2OFormTitlePanelProc;
return CURRENT_CLASS;
}