Skip to content

Commit 152b790

Browse files
authored
UI: Use wxID_ANY and wxNOT_FOUND instead of hardcoding -1 (#1581)
1 parent 02616bf commit 152b790

File tree

7 files changed

+48
-48
lines changed

7 files changed

+48
-48
lines changed

src/gui/MainWindow.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class wxAmiiboDropTarget : public wxFileDropTarget
286286
};
287287

288288
MainWindow::MainWindow()
289-
: wxFrame(nullptr, -1, GetInitialWindowTitle(), wxDefaultPosition, wxSize(1280, 720), wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN | wxRESIZE_BORDER)
289+
: wxFrame(nullptr, wxID_ANY, GetInitialWindowTitle(), wxDefaultPosition, wxSize(1280, 720), wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN | wxRESIZE_BORDER)
290290
{
291291
gui_initHandleContextFromWxWidgetsWindow(g_window_info.window_main, this);
292292
g_mainFrame = this;
@@ -1859,7 +1859,7 @@ class CemuAboutDialog : public wxDialog
18591859
auto versionString = formatWxString(_("Cemu\nVersion {0}\nCompiled on {1}\nOriginal authors: {2}"), BUILD_VERSION_STRING, BUILD_DATE, "Exzap, Petergov");
18601860

18611861
sizer->Add(new wxStaticText(parent, wxID_ANY, versionString), wxSizerFlags().Border(wxALL, 3).Border(wxTOP, 10));
1862-
sizer->Add(new wxHyperlinkCtrl(parent, -1, "https://cemu.info", "https://cemu.info"), wxSizerFlags().Expand().Border(wxTOP | wxBOTTOM, 3));
1862+
sizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://cemu.info", "https://cemu.info"), wxSizerFlags().Expand().Border(wxTOP | wxBOTTOM, 3));
18631863

18641864
sizer->AddSpacer(3);
18651865
sizer->Add(new wxStaticLine(parent), wxSizerFlags().Expand().Border(wxRIGHT, 4));
@@ -1879,95 +1879,95 @@ class CemuAboutDialog : public wxDialog
18791879
// zLib
18801880
{
18811881
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1882-
lineSizer->Add(new wxStaticText(parent, -1, "zLib ("), 0);
1883-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.zlib.net", "https://www.zlib.net"), 0);
1884-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1882+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "zLib ("), 0);
1883+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.zlib.net", "https://www.zlib.net"), 0);
1884+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
18851885
sizer->Add(lineSizer);
18861886
}
18871887
// wxWidgets
18881888
{
18891889
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1890-
lineSizer->Add(new wxStaticText(parent, -1, "wxWidgets ("), 0);
1891-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.wxwidgets.org/", "https://www.wxwidgets.org/"), 0);
1892-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1890+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "wxWidgets ("), 0);
1891+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.wxwidgets.org/", "https://www.wxwidgets.org/"), 0);
1892+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
18931893
sizer->Add(lineSizer);
18941894
}
18951895
// OpenSSL
18961896
{
18971897
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1898-
lineSizer->Add(new wxStaticText(parent, -1, "OpenSSL ("), 0);
1899-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.openssl.org/", "https://www.openssl.org/"), 0);
1900-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1898+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "OpenSSL ("), 0);
1899+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.openssl.org/", "https://www.openssl.org/"), 0);
1900+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
19011901
sizer->Add(lineSizer);
19021902
}
19031903
// libcurl
19041904
{
19051905
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1906-
lineSizer->Add(new wxStaticText(parent, -1, "libcurl ("), 0);
1907-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://curl.haxx.se/libcurl/", "https://curl.haxx.se/libcurl/"), 0);
1908-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1906+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "libcurl ("), 0);
1907+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://curl.haxx.se/libcurl/", "https://curl.haxx.se/libcurl/"), 0);
1908+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
19091909
sizer->Add(lineSizer);
19101910
}
19111911
// imgui
19121912
{
19131913
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1914-
lineSizer->Add(new wxStaticText(parent, -1, "imgui ("), 0);
1915-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://github.com/ocornut/imgui", "https://github.com/ocornut/imgui"), 0);
1916-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1914+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "imgui ("), 0);
1915+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://github.com/ocornut/imgui", "https://github.com/ocornut/imgui"), 0);
1916+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
19171917
sizer->Add(lineSizer);
19181918
}
19191919
// fontawesome
19201920
{
19211921
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1922-
lineSizer->Add(new wxStaticText(parent, -1, "fontawesome ("), 0);
1923-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://github.com/FortAwesome/Font-Awesome", "https://github.com/FortAwesome/Font-Awesome"), 0);
1924-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1922+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "fontawesome ("), 0);
1923+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://github.com/FortAwesome/Font-Awesome", "https://github.com/FortAwesome/Font-Awesome"), 0);
1924+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
19251925
sizer->Add(lineSizer);
19261926
}
19271927
// boost
19281928
{
19291929
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1930-
lineSizer->Add(new wxStaticText(parent, -1, "boost ("), 0);
1931-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://www.boost.org", "https://www.boost.org"), 0);
1932-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1930+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "boost ("), 0);
1931+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://www.boost.org", "https://www.boost.org"), 0);
1932+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
19331933
sizer->Add(lineSizer);
19341934
}
19351935
// libusb
19361936
{
19371937
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1938-
lineSizer->Add(new wxStaticText(parent, -1, "libusb ("), 0);
1939-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://libusb.info", "https://libusb.info"), 0);
1940-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1938+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "libusb ("), 0);
1939+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://libusb.info", "https://libusb.info"), 0);
1940+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
19411941
sizer->Add(lineSizer);
19421942
}
19431943
// icons
19441944
{
19451945
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1946-
lineSizer->Add(new wxStaticText(parent, -1, "icons from "), 0);
1947-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://icons8.com", "https://icons8.com"), 0);
1946+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "icons from "), 0);
1947+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://icons8.com", "https://icons8.com"), 0);
19481948
sizer->Add(lineSizer);
19491949
}
19501950
// Lato font (are we still using it?)
19511951
{
19521952
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1953-
lineSizer->Add(new wxStaticText(parent, -1, "\"Lato\" font by tyPoland Lukasz Dziedzic (OFL, V1.1)"), 0);
1953+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "\"Lato\" font by tyPoland Lukasz Dziedzic (OFL, V1.1)"), 0);
19541954
sizer->Add(lineSizer);
19551955
}
19561956
// SDL
19571957
{
19581958
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1959-
lineSizer->Add(new wxStaticText(parent, -1, "SDL ("), 0);
1960-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "https://github.com/libsdl-org/SDL", "https://github.com/libsdl-org/SDL"), 0);
1961-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
1959+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "SDL ("), 0);
1960+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "https://github.com/libsdl-org/SDL", "https://github.com/libsdl-org/SDL"), 0);
1961+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
19621962
sizer->Add(lineSizer);
19631963
}
19641964
// IH264
19651965
{
19661966
wxSizer* lineSizer = new wxBoxSizer(wxHORIZONTAL);
1967-
lineSizer->Add(new wxStaticText(parent, -1, "Modified ih264 from Android project ("), 0);
1968-
lineSizer->Add(new wxHyperlinkCtrl(parent, -1, "Source", "https://cemu.info/oss/ih264d.zip"), 0);
1969-
lineSizer->Add(new wxStaticText(parent, -1, " "), 0);
1970-
wxHyperlinkCtrl* noticeLink = new wxHyperlinkCtrl(parent, -1, "NOTICE", "");
1967+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, "Modified ih264 from Android project ("), 0);
1968+
lineSizer->Add(new wxHyperlinkCtrl(parent, wxID_ANY, "Source", "https://cemu.info/oss/ih264d.zip"), 0);
1969+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, " "), 0);
1970+
wxHyperlinkCtrl* noticeLink = new wxHyperlinkCtrl(parent, wxID_ANY, "NOTICE", "");
19711971
noticeLink->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& event)
19721972
{
19731973
fs::path tempPath = fs::temp_directory_path();
@@ -2001,7 +2001,7 @@ class CemuAboutDialog : public wxDialog
20012001
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", _pathToUtf8(tempPath))));
20022002
});
20032003
lineSizer->Add(noticeLink, 0);
2004-
lineSizer->Add(new wxStaticText(parent, -1, ")"), 0);
2004+
lineSizer->Add(new wxStaticText(parent, wxID_ANY, ")"), 0);
20052005
sizer->Add(lineSizer);
20062006
}
20072007
}

src/gui/MemorySearcherTool.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void MemorySearcherTool::OnResultListClick(wxMouseEvent& event)
393393
while (true)
394394
{
395395
selectedIndex = m_listResults->GetNextItem(selectedIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
396-
if (selectedIndex == -1)
396+
if (selectedIndex == wxNOT_FOUND)
397397
break;
398398

399399
long address = m_listResults->GetItemData(selectedIndex);
@@ -684,7 +684,7 @@ void MemorySearcherTool::OnPopupClick(wxCommandEvent& event)
684684
if (event.GetId() == LIST_ENTRY_REMOVE)
685685
{
686686
const int row = m_listEntryTable->GetSelectedRow();
687-
if (row == -1)
687+
if (row == wxNOT_FOUND)
688688
return;
689689

690690
m_listEntryTable->DeleteItem(row);
@@ -700,7 +700,7 @@ void MemorySearcherTool::OnItemEdited(wxDataViewEvent& event)
700700
else if (column == 3)
701701
{
702702
auto row = m_listEntryTable->GetSelectedRow();
703-
if (row == -1)
703+
if (row == wxNOT_FOUND)
704704
return;
705705

706706
auto addressText = std::string(m_listEntryTable->GetTextValue(row, 1).mbc_str());

src/gui/debugger/BreakpointWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void BreakpointWindow::OnContextMenuClickSelected(wxCommandEvent& evt)
246246
if (evt.GetId() == MENU_ID_DELETE_BP)
247247
{
248248
long sel = m_breakpoints->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
249-
if (sel != -1)
249+
if (sel != wxNOT_FOUND)
250250
{
251251
if (sel >= debuggerState.breakpoints.size())
252252
return;

src/gui/debugger/ModuleWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void ModuleWindow::OnGameLoaded()
126126
void ModuleWindow::OnLeftDClick(wxMouseEvent& event)
127127
{
128128
long selected = m_modules->GetFirstSelected();
129-
if (selected == -1)
129+
if (selected == wxNOT_FOUND)
130130
return;
131131
const auto text = m_modules->GetItemText(selected, ColumnAddress);
132132
const auto address = std::stoul(text.ToStdString(), nullptr, 16);

src/gui/debugger/SymbolCtrl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ wxString SymbolListCtrl::OnGetItemText(long item, long column) const
107107
void SymbolListCtrl::OnLeftDClick(wxListEvent& event)
108108
{
109109
long selected = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
110-
if (selected == -1)
110+
if (selected == wxNOT_FOUND)
111111
return;
112112
const auto text = GetItemText(selected, ColumnAddress);
113113
const auto address = std::stoul(text.ToStdString(), nullptr, 16);
@@ -120,7 +120,7 @@ void SymbolListCtrl::OnLeftDClick(wxListEvent& event)
120120
void SymbolListCtrl::OnRightClick(wxListEvent& event)
121121
{
122122
long selected = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
123-
if (selected == -1)
123+
if (selected == wxNOT_FOUND)
124124
return;
125125
auto text = GetItemText(selected, ColumnAddress);
126126
text = "0x" + text;
@@ -162,4 +162,4 @@ void SymbolListCtrl::ChangeListFilter(std::string filter)
162162
SetItemCount(visible_entries);
163163
if (visible_entries > 0)
164164
RefreshItems(GetTopItem(), std::min<long>(visible_entries - 1, GetTopItem() + GetCountPerPage() + 1));
165-
}
165+
}

src/gui/windows/PPCThreadsViewer/DebugPPCThreadsWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ void DebugPPCThreadsWindow::OnThreadListRightClick(wxMouseEvent& event)
439439
m_thread_list->SetItemState(itemIndex, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
440440
long sel = m_thread_list->GetNextItem(-1, wxLIST_NEXT_ALL,
441441
wxLIST_STATE_SELECTED);
442-
if (sel != -1)
442+
if (sel != wxNOT_FOUND)
443443
m_thread_list->SetItemState(sel, 0, wxLIST_STATE_SELECTED);
444444
m_thread_list->SetItemState(itemIndex, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
445445
// check if thread is still on the list of active threads

src/gui/wxcomponents/checkedlistctrl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class wxCheckedListCtrl : public wxListCtrl
8787
wxCheckedListCtrl()
8888
: wxListCtrl(), m_imageList(16, 16, TRUE) {}
8989

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

99-
bool Create(wxWindow *parent, wxWindowID id = -1,
99+
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
100100
const wxPoint& pt = wxDefaultPosition,
101101
const wxSize& sz = wxDefaultSize,
102102
long style = wxCLC_CHECK_WHEN_SELECTING,

0 commit comments

Comments
 (0)