UI: Use wxID_ANY and wxNOT_FOUND instead of hardcoding -1 (#1581)
Some checks failed
Generate translation template / generate-pot (push) Failing after 1s
Build check / build (push) Has been cancelled

This commit is contained in:
oltolm 2025-05-30 01:39:02 +02:00 committed by GitHub
parent 02616bf6be
commit 152b790242
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 48 additions and 48 deletions

View file

@ -286,7 +286,7 @@ private:
}; };
MainWindow::MainWindow() MainWindow::MainWindow()
: wxFrame(nullptr, -1, GetInitialWindowTitle(), wxDefaultPosition, wxSize(1280, 720), wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN | wxRESIZE_BORDER) : wxFrame(nullptr, wxID_ANY, GetInitialWindowTitle(), wxDefaultPosition, wxSize(1280, 720), wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN | wxRESIZE_BORDER)
{ {
gui_initHandleContextFromWxWidgetsWindow(g_window_info.window_main, this); gui_initHandleContextFromWxWidgetsWindow(g_window_info.window_main, this);
g_mainFrame = this; g_mainFrame = this;
@ -1859,7 +1859,7 @@ public:
auto versionString = formatWxString(_("Cemu\nVersion {0}\nCompiled on {1}\nOriginal authors: {2}"), BUILD_VERSION_STRING, BUILD_DATE, "Exzap, Petergov"); auto versionString = formatWxString(_("Cemu\nVersion {0}\nCompiled on {1}\nOriginal authors: {2}"), BUILD_VERSION_STRING, BUILD_DATE, "Exzap, Petergov");
sizer->Add(new wxStaticText(parent, wxID_ANY, versionString), wxSizerFlags().Border(wxALL, 3).Border(wxTOP, 10)); sizer->Add(new wxStaticText(parent, wxID_ANY, versionString), wxSizerFlags().Border(wxALL, 3).Border(wxTOP, 10));
sizer->Add(new wxHyperlinkCtrl(parent, -1, "https://cemu.info", "https://cemu.info"), wxSizerFlags().Expand().Border(wxTOP | wxBOTTOM, 3)); sizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://cemu.info", "https://cemu.info"), wxSizerFlags().Expand().Border(wxTOP | wxBOTTOM, 3));
sizer->AddSpacer(3); sizer->AddSpacer(3);
sizer->Add(new wxStaticLine(parent), wxSizerFlags().Expand().Border(wxRIGHT, 4)); sizer->Add(new wxStaticLine(parent), wxSizerFlags().Expand().Border(wxRIGHT, 4));
@ -1879,95 +1879,95 @@ public:
// zLib // zLib
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "zLib ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "zLib ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.zlib.net", "https://www.zlib.net"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.zlib.net", "https://www.zlib.net"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// wxWidgets // wxWidgets
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "wxWidgets ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "wxWidgets ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.wxwidgets.org/", "https://www.wxwidgets.org/"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.wxwidgets.org/", "https://www.wxwidgets.org/"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// OpenSSL // OpenSSL
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "OpenSSL ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "OpenSSL ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.openssl.org/", "https://www.openssl.org/"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.openssl.org/", "https://www.openssl.org/"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// libcurl // libcurl
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "libcurl ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "libcurl ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://curl.haxx.se/libcurl/", "https://curl.haxx.se/libcurl/"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://curl.haxx.se/libcurl/", "https://curl.haxx.se/libcurl/"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// imgui // imgui
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "imgui ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "imgui ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://github.com/ocornut/imgui", "https://github.com/ocornut/imgui"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://github.com/ocornut/imgui", "https://github.com/ocornut/imgui"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// fontawesome // fontawesome
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "fontawesome ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "fontawesome ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://github.com/FortAwesome/Font-Awesome", "https://github.com/FortAwesome/Font-Awesome"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://github.com/FortAwesome/Font-Awesome", "https://github.com/FortAwesome/Font-Awesome"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// boost // boost
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "boost ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "boost ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.boost.org", "https://www.boost.org"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.boost.org", "https://www.boost.org"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// libusb // libusb
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "libusb ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "libusb ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://libusb.info", "https://libusb.info"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://libusb.info", "https://libusb.info"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// icons // icons
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "icons from "), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "icons from "), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://icons8.com", "https://icons8.com"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://icons8.com", "https://icons8.com"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// Lato font (are we still using it?) // Lato font (are we still using it?)
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "\"Lato\" font by tyPoland Lukasz Dziedzic (OFL, V1.1)"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "\"Lato\" font by tyPoland Lukasz Dziedzic (OFL, V1.1)"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// SDL // SDL
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "SDL ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "SDL ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://github.com/libsdl-org/SDL", "https://github.com/libsdl-org/SDL"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://github.com/libsdl-org/SDL", "https://github.com/libsdl-org/SDL"), 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
// IH264 // IH264
{ {
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
lineSizer->Add(new wxStaticText(parent, -1, "Modified ih264 from Android project ("), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, "Modified ih264 from Android project ("), 0);
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "Source", "https://cemu.info/oss/ih264d.zip"), 0); lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "Source", "https://cemu.info/oss/ih264d.zip"), 0);
lineSizer->Add(new wxStaticText(parent, -1, " "), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, " "), 0);
wxHyperlinkCtrl* noticeLink = new wxHyperlinkCtrl(parent, -1, "NOTICE", ""); wxHyperlinkCtrl* noticeLink = new wxHyperlinkCtrl(parent, wxID_ANY, "NOTICE", "");
noticeLink->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& event) noticeLink->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& event)
{ {
fs::path tempPath = fs::temp_directory_path(); fs::path tempPath = fs::temp_directory_path();
@ -2001,7 +2001,7 @@ public:
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _pathToUtf8(tempPath)))); wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _pathToUtf8(tempPath))));
}); });
lineSizer->Add(noticeLink, 0); lineSizer->Add(noticeLink, 0);
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0); lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
sizer->Add(lineSizer); sizer->Add(lineSizer);
} }
} }

View file

@ -393,7 +393,7 @@ void MemorySearcherTool::OnResultListClick(wxMouseEvent& event)
while (true) while (true)
{ {
selectedIndex = m_listResults->GetNextItem(selectedIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); selectedIndex = m_listResults->GetNextItem(selectedIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (selectedIndex == -1) if (selectedIndex == wxNOT_FOUND)
break; break;
long address = m_listResults->GetItemData(selectedIndex); long address = m_listResults->GetItemData(selectedIndex);
@ -684,7 +684,7 @@ void MemorySearcherTool::OnPopupClick(wxCommandEvent& event)
if (event.GetId() == LIST_ENTRY_REMOVE) if (event.GetId() == LIST_ENTRY_REMOVE)
{ {
const int row = m_listEntryTable->GetSelectedRow(); const int row = m_listEntryTable->GetSelectedRow();
if (row == -1) if (row == wxNOT_FOUND)
return; return;
m_listEntryTable->DeleteItem(row); m_listEntryTable->DeleteItem(row);
@ -700,7 +700,7 @@ void MemorySearcherTool::OnItemEdited(wxDataViewEvent& event)
else if (column == 3) else if (column == 3)
{ {
auto row = m_listEntryTable->GetSelectedRow(); auto row = m_listEntryTable->GetSelectedRow();
if (row == -1) if (row == wxNOT_FOUND)
return; return;
auto addressText = std::string(m_listEntryTable->GetTextValue(row, 1).mbc_str()); auto addressText = std::string(m_listEntryTable->GetTextValue(row, 1).mbc_str());

View file

@ -246,7 +246,7 @@ void BreakpointWindow::OnContextMenuClickSelected(wxCommandEvent& evt)
if (evt.GetId() == MENU_ID_DELETE_BP) if (evt.GetId() == MENU_ID_DELETE_BP)
{ {
long sel = m_breakpoints->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); long sel = m_breakpoints->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (sel != -1) if (sel != wxNOT_FOUND)
{ {
if (sel >= debuggerState.breakpoints.size()) if (sel >= debuggerState.breakpoints.size())
return; return;

View file

@ -126,7 +126,7 @@ void ModuleWindow::OnGameLoaded()
void ModuleWindow::OnLeftDClick(wxMouseEvent& event) void ModuleWindow::OnLeftDClick(wxMouseEvent& event)
{ {
long selected = m_modules->GetFirstSelected(); long selected = m_modules->GetFirstSelected();
if (selected == -1) if (selected == wxNOT_FOUND)
return; return;
const auto text = m_modules->GetItemText(selected, ColumnAddress); const auto text = m_modules->GetItemText(selected, ColumnAddress);
const auto address = std::stoul(text.ToStdString(), nullptr, 16); const auto address = std::stoul(text.ToStdString(), nullptr, 16);

View file

@ -107,7 +107,7 @@ wxString SymbolListCtrl::OnGetItemText(long item, long column) const
void SymbolListCtrl::OnLeftDClick(wxListEvent& event) void SymbolListCtrl::OnLeftDClick(wxListEvent& event)
{ {
long selected = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); long selected = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (selected == -1) if (selected == wxNOT_FOUND)
return; return;
const auto text = GetItemText(selected, ColumnAddress); const auto text = GetItemText(selected, ColumnAddress);
const auto address = std::stoul(text.ToStdString(), nullptr, 16); const auto address = std::stoul(text.ToStdString(), nullptr, 16);
@ -120,7 +120,7 @@ void SymbolListCtrl::OnLeftDClick(wxListEvent& event)
void SymbolListCtrl::OnRightClick(wxListEvent& event) void SymbolListCtrl::OnRightClick(wxListEvent& event)
{ {
long selected = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); long selected = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (selected == -1) if (selected == wxNOT_FOUND)
return; return;
auto text = GetItemText(selected, ColumnAddress); auto text = GetItemText(selected, ColumnAddress);
text = "0x" + text; text = "0x" + text;
@ -162,4 +162,4 @@ void SymbolListCtrl::ChangeListFilter(std::string filter)
SetItemCount(visible_entries); SetItemCount(visible_entries);
if (visible_entries > 0) if (visible_entries > 0)
RefreshItems(GetTopItem(), std::min<long>(visible_entries - 1, GetTopItem() + GetCountPerPage() + 1)); RefreshItems(GetTopItem(), std::min<long>(visible_entries - 1, GetTopItem() + GetCountPerPage() + 1));
} }

View file

@ -439,7 +439,7 @@ void DebugPPCThreadsWindow::OnThreadListRightClick(wxMouseEvent& event)
m_thread_list->SetItemState(itemIndex, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); m_thread_list->SetItemState(itemIndex, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
long sel = m_thread_list->GetNextItem(-1, wxLIST_NEXT_ALL, long sel = m_thread_list->GetNextItem(-1, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED); wxLIST_STATE_SELECTED);
if (sel != -1) if (sel != wxNOT_FOUND)
m_thread_list->SetItemState(sel, 0, wxLIST_STATE_SELECTED); m_thread_list->SetItemState(sel, 0, wxLIST_STATE_SELECTED);
m_thread_list->SetItemState(itemIndex, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); m_thread_list->SetItemState(itemIndex, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
// check if thread is still on the list of active threads // check if thread is still on the list of active threads

View file

@ -87,7 +87,7 @@ public:
wxCheckedListCtrl() wxCheckedListCtrl()
: wxListCtrl(), m_imageList(16, 16, TRUE) {} : wxListCtrl(), m_imageList(16, 16, TRUE) {}
wxCheckedListCtrl(wxWindow *parent, wxWindowID id = -1, wxCheckedListCtrl(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pt = wxDefaultPosition, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
long style = wxCLC_CHECK_WHEN_SELECTING, long style = wxCLC_CHECK_WHEN_SELECTING,
@ -96,7 +96,7 @@ public:
: wxListCtrl(), m_imageList(16, 16, TRUE) : wxListCtrl(), m_imageList(16, 16, TRUE)
{ Create(parent, id, pt, sz, style, validator, name); } { Create(parent, id, pt, sz, style, validator, name); }
bool Create(wxWindow *parent, wxWindowID id = -1, bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pt = wxDefaultPosition, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
long style = wxCLC_CHECK_WHEN_SELECTING, long style = wxCLC_CHECK_WHEN_SELECTING,