diff --git a/rEFIt_UEFI/Platform/Nvram.cpp b/rEFIt_UEFI/Platform/Nvram.cpp index 82ffbe7ee..8e7857526 100644 --- a/rEFIt_UEFI/Platform/Nvram.cpp +++ b/rEFIt_UEFI/Platform/Nvram.cpp @@ -1142,7 +1142,7 @@ FindStartupDiskVolume ( // case insensitive cmp if (LoaderPath != NULL && StriCmp(gEfiBootLoaderPath, LoaderPath) == 0) { // that's the one - DBG (" - found entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title, Volume->VolName, LoaderPath); + DBG (" - found entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title.s(), Volume->VolName, LoaderPath); return Index; } } @@ -1165,7 +1165,7 @@ FindStartupDiskVolume ( // case insensitive cmp if (LoaderPath != NULL && StriCmp(gEfiBootLoaderPath, LoaderPath) == 0) { // that's the one - DBG (" - found entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title, Volume->VolName, LoaderPath); + DBG (" - found entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title.s(), Volume->VolName, LoaderPath); return Index; } } @@ -1188,7 +1188,7 @@ FindStartupDiskVolume ( Volume = MainMenu->Entries[Index].getLOADER_ENTRY()->Volume; } if (Volume != NULL && BootVolumeDevicePathEqual (gEfiBootVolume, Volume->DevicePath)) { - DBG (" - found entry %d. '%s', Volume '%s'\n", Index, MainMenu->Entries[Index].Title, Volume->VolName); + DBG (" - found entry %d. '%s', Volume '%s'\n", Index, MainMenu->Entries[Index].Title.s(), Volume->VolName); return Index; } } @@ -1205,7 +1205,7 @@ FindStartupDiskVolume ( Volume = MainMenu->Entries[Index].getLOADER_ENTRY()->Volume; } if (Volume != NULL && BootVolumeMediaDevicePathNodesEqual (gEfiBootVolume, Volume->DevicePath)) { - DBG (" - found entry %d. '%s', Volume '%s'\n", Index, MainMenu->Entries[Index].Title, Volume->VolName); + DBG (" - found entry %d. '%s', Volume '%s'\n", Index, MainMenu->Entries[Index].Title.s(), Volume->VolName); return Index; } } @@ -1251,7 +1251,7 @@ FindStartupDiskVolume ( //DBG (" OSType = %d\n", Volume->OSType); if (Volume->LegacyOS->Type == OSTYPE_WIN) { // that's the one - legacy win partition - DBG (" - found legacy entry %d. '%s', Volume '%s'\n", Index, LegacyEntry.Title, Volume->VolName); + DBG (" - found legacy entry %d. '%s', Volume '%s'\n", Index, LegacyEntry.Title.s(), Volume->VolName); return Index; } } @@ -1266,7 +1266,7 @@ FindStartupDiskVolume ( //DBG (" LoaderType = %d\n", LoaderEntry.LoaderType); if (LoaderEntry.LoaderType == OSTYPE_WINEFI) { // that's the one - win loader entry - DBG (" - found loader entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title, Volume->VolName, LoaderEntry.LoaderPath); + DBG (" - found loader entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title.s(), Volume->VolName, LoaderEntry.LoaderPath); return Index; } } @@ -1286,7 +1286,7 @@ FindStartupDiskVolume ( Volume = LegacyEntry.Volume; if (Volume != NULL && Volume->WholeDiskBlockIO == DiskVolume->BlockIO) { // that's the one - DBG (" - found legacy entry %d. '%s', Volume '%s'\n", Index, LegacyEntry.Title, Volume->VolName); + DBG (" - found legacy entry %d. '%s', Volume '%s'\n", Index, LegacyEntry.Title.s(), Volume->VolName); return Index; } @@ -1295,7 +1295,7 @@ FindStartupDiskVolume ( Volume = LoaderEntry.Volume; if (Volume != NULL && Volume->WholeDiskBlockIO == DiskVolume->BlockIO) { // that's the one - DBG (" - found loader entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title, Volume->VolName, LoaderEntry.LoaderPath); + DBG (" - found loader entry %d. '%s', Volume '%s', '%s'\n", Index, LoaderEntry.Title.s(), Volume->VolName, LoaderEntry.LoaderPath); return Index; } diff --git a/rEFIt_UEFI/cpp_foundation/XArray.h b/rEFIt_UEFI/cpp_foundation/XArray.h index 837d8449b..b64fbf72e 100755 --- a/rEFIt_UEFI/cpp_foundation/XArray.h +++ b/rEFIt_UEFI/cpp_foundation/XArray.h @@ -97,7 +97,7 @@ class XArray void RemoveAtIndex(int nIndex); void setEmpty(); - bool isEmpty() const { return size() == 0; } + bool isEmpty() const { return size() == 0; } xsize IdxOf(TYPE& e) const; bool ExistIn(TYPE& e) const { return IdxOf(e) != MAX_XSIZE; } diff --git a/rEFIt_UEFI/cpp_foundation/XStringW.cpp b/rEFIt_UEFI/cpp_foundation/XStringW.cpp index 244fa60fe..ebb171a53 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringW.cpp +++ b/rEFIt_UEFI/cpp_foundation/XStringW.cpp @@ -441,6 +441,10 @@ const XStringW &XStringW::operator =(const XStringW &aString) const XStringW &XStringW::operator =(const wchar_t *S) { //TRACE("Operator =const wchar_t *\n"); + if ( S == NULL ) { + DBG("operator =(const wchar_t *S) called with NULL\n"); + panic(); + } StrCpy(S); return *this; } diff --git a/rEFIt_UEFI/cpp_foundation/XStringW.h b/rEFIt_UEFI/cpp_foundation/XStringW.h index edc2452c7..5597a8906 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringW.h +++ b/rEFIt_UEFI/cpp_foundation/XStringW.h @@ -48,10 +48,13 @@ public: UINTN size() const { return m_len; } UINTN allocatedSize() const { return m_allocatedSize; } void SetLength(UINTN len); + const wchar_t* s() { return m_data; } /* IsNull ? */ - bool IsNull() const { return length() == 0 ; } - bool NotNull() const { return length() > 0 ; } + void setEmpty() { m_len = 0; } + bool isEmpty() const { return size() == 0; } +// bool IsNull() const { return size() == 0 ; } +// bool NotNull() const { return size() > 0 ; } /* Cast */ operator const wchar_t *() const { return data(); } diff --git a/rEFIt_UEFI/cpp_foundation/XStringWArray.h b/rEFIt_UEFI/cpp_foundation/XStringWArray.h index b1cc924b9..048280d1b 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringWArray.h +++ b/rEFIt_UEFI/cpp_foundation/XStringWArray.h @@ -37,7 +37,7 @@ class XStringWArray : public XStringWArraySuper // Add void AddStrings(const wchar_t *Val1, ...); - void AddNoNull(const XStringW &aString) { if ( aString.NotNull() ) AddCopy(aString); } + void AddNoNull(const XStringW &aString) { if ( !aString.isEmpty() ) AddCopy(aString); } void AddEvenNull(const XStringW &aString) { AddCopy(aString); } void Add(const XStringW &aString) { AddCopy(aString); } diff --git a/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp b/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp index 7836f38f3..cd38dc359 100755 --- a/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp +++ b/rEFIt_UEFI/cpp_unit_test/XStringW_test.cpp @@ -24,7 +24,7 @@ int XStringW_tests() if ( str != L"12" ) return 4; XStringW str2; - if ( str2.NotNull() ) return 10; + if ( !str2.isEmpty() ) return 10; str2.StrnCpy(str.data(), 2); if ( str2 != L"12" ) return 11; str2.StrnCat(L"345", 2); diff --git a/rEFIt_UEFI/entry_scan/legacy.cpp b/rEFIt_UEFI/entry_scan/legacy.cpp index d5d9c825d..79e744441 100644 --- a/rEFIt_UEFI/entry_scan/legacy.cpp +++ b/rEFIt_UEFI/entry_scan/legacy.cpp @@ -124,9 +124,9 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle, Entry->Title = EfiStrDuplicate(FullTitle); } else { if (GlobalConfig.BootCampStyle) { - Entry->Title = PoolPrint(L"%s", LoaderTitle); + Entry->Title.SPrintf("%ls", LoaderTitle); } else { - Entry->Title = PoolPrint(L"Boot %s from %s", LoaderTitle, VolDesc); + Entry->Title.SPrintf("Boot %ls from %ls", LoaderTitle, VolDesc); } } // DBG("Title=%s\n", Entry->Title); diff --git a/rEFIt_UEFI/entry_scan/loader.cpp b/rEFIt_UEFI/entry_scan/loader.cpp index 94d77ce80..f71295db3 100644 --- a/rEFIt_UEFI/entry_scan/loader.cpp +++ b/rEFIt_UEFI/entry_scan/loader.cpp @@ -644,38 +644,37 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath, break; } - Entry->Title = NULL; - + if (FullTitle) { - Entry->Title = EfiStrDuplicate(FullTitle); + Entry->Title = FullTitle; } - if ( Entry->Title == NULL && Volume->VolLabel != NULL ) { + if ( Entry->Title.isEmpty() && Volume->VolLabel != NULL ) { if ( Volume->VolLabel[0] == L'#' ) { - Entry->Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel+1); + Entry->Title.SPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel+1); }else{ - Entry->Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel); + Entry->Title.SPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel); } } - if ( Entry->Title == NULL && ((Entry->VolName == NULL) || (StrLen(Entry->VolName) == 0)) ) { + if ( Entry->Title.isEmpty() && ((Entry->VolName == NULL) || (StrLen(Entry->VolName) == 0)) ) { //DBG("encounter Entry->VolName ==%s and StrLen(Entry->VolName) ==%d\n",Entry->VolName, StrLen(Entry->VolName)); if (GlobalConfig.BootCampStyle) { - Entry->Title = PoolPrint(L"%s", ((LoaderTitle != NULL) ? LoaderTitle : Basename(Volume->DevicePathString))); + Entry->Title.SPrintf("%ls", ((LoaderTitle != NULL) ? LoaderTitle : Basename(Volume->DevicePathString))); } else { - Entry->Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), + Entry->Title.SPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Basename(Volume->DevicePathString)); } } - if ( Entry->Title == NULL ) { + if ( Entry->Title.isEmpty() ) { //DBG("encounter LoaderTitle ==%s and Entry->VolName ==%s\n", LoaderTitle, Entry->VolName); if (GlobalConfig.BootCampStyle) { if ((StriCmp(LoaderTitle, L"macOS") == 0) || (StriCmp(LoaderTitle, L"Recovery") == 0)) { - Entry->Title = PoolPrint(L"%s", Entry->VolName); + Entry->Title.SPrintf("%ls", Entry->VolName); } else { - Entry->Title = PoolPrint(L"%s", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath)); + Entry->Title.SPrintf("%ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath)); } } else { - Entry->Title = PoolPrint(L"Boot %s from %s", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), + Entry->Title.SPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Entry->VolName); } } @@ -683,7 +682,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath, // just an example that UI can show hibernated volume to the user // should be better to show it on entry image if (OSFLAG_ISSET(Entry->Flags, OSFLAG_HIBERNATED)) { - Entry->Title = PoolPrint(L"%s (hibernated)", Entry->Title); + Entry->Title.SPrintf("%ls (hibernated)", Entry->Title.s()); } Entry->ShortcutLetter = (Hotkey == 0) ? ShortcutLetter : Hotkey; @@ -754,7 +753,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) // create the submenu // SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN)); SubScreen = new REFIT_MENU_SCREEN; - SubScreen->Title = PoolPrint(L"Options for %s", Entry->Title, Entry->VolName); + SubScreen->Title = PoolPrint(L"Options for %s", Entry->Title.s(), Entry->VolName); SubScreen->TitleImage = Entry->Image; SubScreen->ID = Entry->LoaderType + 20; // DBG("get anime for os=%d\n", SubScreen->ID); @@ -885,10 +884,10 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) if (SubEntry) { FreePool(SubEntry->LoadOptions); if (Quiet) { - SubEntry->Title = PoolPrint(L"%s verbose", Entry->Title); + SubEntry->Title = PoolPrint(L"%s verbose", Entry->Title.s()); SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, L"quiet"); } else { - SubEntry->Title = PoolPrint(L"%s quiet", Entry->Title); + SubEntry->Title = PoolPrint(L"%s quiet", Entry->Title.s()); SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"quiet"); } } @@ -897,10 +896,10 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) if (SubEntry) { FreePool(SubEntry->LoadOptions); if (WithSplash) { - SubEntry->Title = PoolPrint(L"%s without splash", Entry->Title); + SubEntry->Title = PoolPrint(L"%s without splash", Entry->Title.s()); SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, L"splash"); } else { - SubEntry->Title = PoolPrint(L"%s with splash", Entry->Title); + SubEntry->Title = PoolPrint(L"%s with splash", Entry->Title.s()); SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"splash"); } } @@ -911,22 +910,22 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry) if (WithSplash) { if (Quiet) { TempOptions = RemoveLoadOption(Entry->LoadOptions, L"splash"); - SubEntry->Title = PoolPrint(L"%s verbose without splash", Entry->Title); + SubEntry->Title = PoolPrint(L"%s verbose without splash", Entry->Title.s()); SubEntry->LoadOptions = RemoveLoadOption(TempOptions, L"quiet"); FreePool(TempOptions); } else { TempOptions = RemoveLoadOption(Entry->LoadOptions, L"splash"); - SubEntry->Title = PoolPrint(L"%s quiet without splash", Entry->Title); + SubEntry->Title = PoolPrint(L"%s quiet without splash", Entry->Title.s()); SubEntry->LoadOptions = AddLoadOption(TempOptions, L"quiet"); FreePool(TempOptions); } } else if (Quiet) { TempOptions = RemoveLoadOption(Entry->LoadOptions, L"quiet"); - SubEntry->Title = PoolPrint(L"%s verbose with splash", Entry->Title); + SubEntry->Title = PoolPrint(L"%s verbose with splash", Entry->Title.s()); SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"splash"); FreePool(TempOptions); } else { - SubEntry->Title = PoolPrint(L"%s quiet with splash", Entry->Title); + SubEntry->Title = PoolPrint(L"%s quiet with splash", Entry->Title.s()); SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"quiet splash"); } } diff --git a/rEFIt_UEFI/entry_scan/securemenu.cpp b/rEFIt_UEFI/entry_scan/securemenu.cpp index f4f5e05be..74de98d7e 100644 --- a/rEFIt_UEFI/entry_scan/securemenu.cpp +++ b/rEFIt_UEFI/entry_scan/securemenu.cpp @@ -67,12 +67,12 @@ VOID AddSecureBootTool(VOID) // Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LOADER_ENTRY)); if (gSettings.SecureBoot) { Entry = new REFIT_MENU_ENTRY_SECURE_BOOT(); - Entry->Title = PoolPrint(L"Clover Secure Boot Configuration"); + Entry->Title.SPrintf("Clover Secure Boot Configuration"); // Entry->Tag = TAG_SECURE_BOOT_CONFIG; Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG); } else { Entry = new REFIT_MENU_ENTRY_SECURE_BOOT_CONFIG(); - Entry->Title = PoolPrint(L"Enable Clover Secure Boot"); + Entry->Title.SPrintf("Enable Clover Secure Boot"); // Entry->Tag = TAG_SECURE_BOOT; Entry->Image = BuiltinIcon(BUILTIN_ICON_FUNC_SECURE_BOOT); } @@ -442,7 +442,7 @@ BOOLEAN ConfigureSecureBoot(VOID) EFI_DEVICE_PATH *DevicePath = NULL; // Add the entry for secure boot policy SecureBootPolicyEntry.Title = PoolPrint(L"Secure boot policy: %s", SecureBootPolicyToStr(gSettings.SecureBootPolicy)); - if (SecureBootPolicyEntry.Title == NULL) { + if (SecureBootPolicyEntry.Title.isEmpty()) { break; } SecureBootPolicyMenu.Title = SecureBootPolicyEntry.Title; diff --git a/rEFIt_UEFI/entry_scan/tool.cpp b/rEFIt_UEFI/entry_scan/tool.cpp index 4672fe2df..12b3dde8e 100644 --- a/rEFIt_UEFI/entry_scan/tool.cpp +++ b/rEFIt_UEFI/entry_scan/tool.cpp @@ -92,7 +92,7 @@ STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTi if (FullTitle) { Entry->Title = EfiStrDuplicate(FullTitle); } else { - Entry->Title = PoolPrint(L"Start %s", LoaderTitle); + Entry->Title.SPrintf("Start %ls", LoaderTitle); } // Entry->Tag = TAG_TOOL; Entry->Row = 1; diff --git a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h index 41e01bd85..71d2084c9 100644 --- a/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h +++ b/rEFIt_UEFI/gui/REFIT_MENU_SCREEN.h @@ -91,7 +91,7 @@ public: : ID(0), Title(0), TitleImage(0), TimeoutSeconds(0), TimeoutText(0), Theme(0), AnimeRun(0), Once(0), LastDraw(0), CurrentFrame(0), - Frames(0), FrameTime(0), FilmPlace({0,0,0,0}), + Frames(0), FrameTime(0), Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle) {}; @@ -99,14 +99,14 @@ public: : ID(ID), Title(Title), TitleImage(0), TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0), Once(0), LastDraw(0), CurrentFrame(0), - Frames(0), FrameTime(0), FilmPlace({0,0,0,0}), + Frames(0), FrameTime(0), Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle) {}; REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* Title, CONST CHAR16* TimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2) : ID(ID), Title(Title), TitleImage(0), TimeoutSeconds(0), TimeoutText(TimeoutText), Theme(0), AnimeRun(0), Once(0), LastDraw(0), CurrentFrame(0), - Frames(0), FrameTime(0), FilmPlace({0,0,0,0}), + Frames(0), FrameTime(0), Film(0), mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle) { Entries.AddReference(entry1, false); diff --git a/rEFIt_UEFI/gui/menu_items/menu_items.h b/rEFIt_UEFI/gui/menu_items/menu_items.h index 5e2d3063a..1ad15fac5 100644 --- a/rEFIt_UEFI/gui/menu_items/menu_items.h +++ b/rEFIt_UEFI/gui/menu_items/menu_items.h @@ -96,7 +96,7 @@ class XPointer; class REFIT_ABSTRACT_MENU_ENTRY { public: - CONST CHAR16 *Title; + XStringW Title; UINTN Row; CHAR16 ShortcutDigit; CHAR16 ShortcutLetter; @@ -131,9 +131,15 @@ class REFIT_ABSTRACT_MENU_ENTRY virtual REFIT_MENU_ENTRY_ITEM_ABSTRACT* getREFIT_MENU_ITEM_IEM_ABSTRACT() { return nullptr; }; virtual REFIT_MENU_ITEM_BOOTNUM* getREFIT_MENU_ITEM_BOOTNUM() { return nullptr; }; - REFIT_ABSTRACT_MENU_ENTRY() : Title(NULL), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), Place({0,0,0,0}), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL) {}; - REFIT_ABSTRACT_MENU_ENTRY(CONST CHAR16 *Title_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), Place({0,0,0,0}), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL) {}; - REFIT_ABSTRACT_MENU_ENTRY(CONST CHAR16 *Title_, ACTION AtClick_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), Place({0,0,0,0}), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL) {}; + REFIT_ABSTRACT_MENU_ENTRY() : Title(""), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL) + {}; + REFIT_ABSTRACT_MENU_ENTRY(CONST CHAR16 *Title_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL) + {}; + REFIT_ABSTRACT_MENU_ENTRY(CONST CHAR16 *Title_, ACTION AtClick_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL) + {}; + REFIT_ABSTRACT_MENU_ENTRY(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) + : Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), Image(NULL), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL) + {}; REFIT_ABSTRACT_MENU_ENTRY(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, EG_IMAGE* Image_, EG_RECT Place_, ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_, @@ -169,59 +175,39 @@ class REFIT_ABSTRACT_MENU_ENTRY class REFIT_MENU_ITEM_RETURN : public REFIT_ABSTRACT_MENU_ENTRY { public: + REFIT_MENU_ITEM_RETURN() : REFIT_ABSTRACT_MENU_ENTRY() {}; REFIT_MENU_ITEM_RETURN(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) - : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, NULL, {0, 0, 0, 0}, AtClick_, ActionEnter, ActionNone, ActionNone, NULL) + : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_) {}; -// REFIT_MENU_ITEM_RETURN(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, -// EG_IMAGE* Image_, EG_RECT Place_, -// ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_, -// REFIT_MENU_SCREEN *SubScreen_) -// : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, Image_, Place_, AtClick_, AtDoubleClick_, AtRightClick_, AtMouseOver_, SubScreen_) -// {}; virtual REFIT_MENU_ITEM_RETURN* getREFIT_MENU_ITEM_RETURN() { return this; }; }; class REFIT_MENU_ITEM_SHUTDOWN : public REFIT_ABSTRACT_MENU_ENTRY { public: + REFIT_MENU_ITEM_SHUTDOWN() : REFIT_ABSTRACT_MENU_ENTRY() {}; REFIT_MENU_ITEM_SHUTDOWN(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) - : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, NULL, {0, 0, 0, 0}, AtClick_, ActionEnter, ActionNone, ActionNone, NULL) + : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_) {}; -// REFIT_MENU_ITEM_SHUTDOWN(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, -// EG_IMAGE* Image_, EG_RECT Place_, -// ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_, -// REFIT_MENU_SCREEN *SubScreen_) -// : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, Image_, Place_, AtClick_, AtDoubleClick_, AtRightClick_, AtMouseOver_, SubScreen_) -// {}; virtual REFIT_MENU_ITEM_SHUTDOWN* getREFIT_MENU_ITEM_SHUTDOWN() { return this; }; }; class REFIT_MENU_ITEM_RESET : public REFIT_ABSTRACT_MENU_ENTRY { public: + REFIT_MENU_ITEM_RESET() : REFIT_ABSTRACT_MENU_ENTRY() {}; REFIT_MENU_ITEM_RESET(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) - : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, NULL, {0, 0, 0, 0}, AtClick_, ActionEnter, ActionNone, ActionNone, NULL) + : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_) {}; -// REFIT_MENU_ITEM_RESET(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, -// EG_IMAGE* Image_, EG_RECT Place_, -// ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_, -// REFIT_MENU_SCREEN *SubScreen_) -// : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, Image_, Place_, AtClick_, AtDoubleClick_, AtRightClick_, AtMouseOver_, SubScreen_) -// {}; virtual REFIT_MENU_ITEM_RESET* getREFIT_MENU_ITEM_RESET() { return this; }; }; class REFIT_MENU_ITEM_ABOUT : public REFIT_ABSTRACT_MENU_ENTRY { public: + REFIT_MENU_ITEM_ABOUT() : REFIT_ABSTRACT_MENU_ENTRY() {}; REFIT_MENU_ITEM_ABOUT(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) - : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, NULL, {0, 0, 0, 0}, AtClick_, ActionEnter, ActionNone, ActionNone, NULL) + : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_) {}; -// REFIT_MENU_ITEM_ABOUT(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, -// EG_IMAGE* Image_, EG_RECT Place_, -// ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_, -// REFIT_MENU_SCREEN *SubScreen_) -// : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, Image_, Place_, AtClick_, AtDoubleClick_, AtRightClick_, AtMouseOver_, SubScreen_) -// {}; virtual REFIT_MENU_ITEM_ABOUT* getREFIT_MENU_ITEM_ABOUT() { return this; }; }; @@ -229,14 +215,8 @@ class REFIT_ABSTRACT_MENU_ENTRY public: REFIT_MENU_ITEM_OPTIONS() : REFIT_ABSTRACT_MENU_ENTRY() {}; REFIT_MENU_ITEM_OPTIONS(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_) - : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, NULL, {0, 0, 0, 0}, AtClick_, ActionEnter, ActionNone, ActionNone, NULL) + : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, AtClick_) {}; -// REFIT_MENU_ITEM_OPTIONS(CONST CHAR16 *Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, -// EG_IMAGE* Image_, EG_RECT Place_, -// ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_, -// REFIT_MENU_SCREEN *SubScreen_) -// : REFIT_ABSTRACT_MENU_ENTRY(Title_, Row_, ShortcutDigit_, ShortcutLetter_, Image_, Place_, AtClick_, AtDoubleClick_, AtRightClick_, AtMouseOver_, SubScreen_) -// {}; virtual REFIT_MENU_ITEM_OPTIONS* getREFIT_MENU_ITEM_OPTIONS() { return this; }; }; diff --git a/rEFIt_UEFI/libeg/XPointer.cpp b/rEFIt_UEFI/libeg/XPointer.cpp index f93f84c1b..ba363d1bb 100644 --- a/rEFIt_UEFI/libeg/XPointer.cpp +++ b/rEFIt_UEFI/libeg/XPointer.cpp @@ -104,10 +104,10 @@ EFI_STATUS XPointer::MouseBirth() VOID XPointer::Draw() { - + oldPlace = newPlace; +// CopyMem(&oldPlace, &newPlace, sizeof(EG_RECT)); //can we use oldPlace = newPlace; ? // take background image for later to restore background oldImage.GetArea(newPlace); - CopyMem(&oldPlace, &newPlace, sizeof(EG_RECT)); //can we use oldPlace = newPlace; ? PointerImage->Draw(newPlace.XPos, newPlace.YPos, 0.f); //zero means no scale } @@ -184,7 +184,7 @@ VOID XPointer::UpdatePointer() if (newPlace.YPos < 0) newPlace.YPos = 0; if (newPlace.YPos > UGAHeight - 1) newPlace.YPos = UGAHeight - 1; - if ( CompareMem(&oldPlace, &newPlace, sizeof(__typeof__(oldPlace))) != 0 ) { + if ( oldPlace != newPlace ) { Hide(); Draw(); } diff --git a/rEFIt_UEFI/libeg/libeg.h b/rEFIt_UEFI/libeg/libeg.h index 53f852342..37f38daba 100644 --- a/rEFIt_UEFI/libeg/libeg.h +++ b/rEFIt_UEFI/libeg/libeg.h @@ -174,12 +174,19 @@ typedef struct { BOOLEAN HasAlpha; //moved here to avoid alignment issue } EG_IMAGE; -typedef struct { +class EG_RECT { +public: INTN XPos; INTN YPos; INTN Width; INTN Height; -} EG_RECT; + + EG_RECT() : XPos(0), YPos(0), Width(0), Height(0) {}; + EG_RECT(const EG_RECT& other) { XPos = other.XPos; YPos = other.YPos; Width = other.Width; Height = other.Height; } + const EG_RECT& operator = (const EG_RECT& other) { XPos = other.XPos; YPos = other.YPos; Width = other.Width; Height = other.Height; return *this; } + bool operator == (const EG_RECT& other) { return XPos == other.XPos && YPos == other.YPos && Width == other.Width && Height == other.Height; } + bool operator != (const EG_RECT& other) { return !(*this == other); } +}; #define TEXT_YMARGIN (2) diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 5a8c1658d..0b71ff0e8 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -1074,7 +1074,7 @@ static VOID StartTool(IN REFIT_MENU_ENTRY_LOADER_TOOL *Entry) DBG("Start Tool: %s\n", Entry->LoaderPath); egClearScreen(&DarkBackgroundPixel); // assumes "Start