Micro-refactor

This commit is contained in:
SoftFever
2026-08-19 14:08:19 +08:00
parent 7c55b07736
commit 1e87d56482
10 changed files with 181 additions and 335 deletions
+3 -21
View File
@@ -156,14 +156,13 @@ void ButtonsListCtrl::SetSelection(int sel)
Refresh();
}
bool ButtonsListCtrl::InsertPage(size_t n, const wxString &text, bool bSelect /* = false*/, const std::string &bmp_name /* = ""*/, int imageId /* = wxBookCtrlBase::NO_IMAGE */)
bool ButtonsListCtrl::InsertPage(size_t n, const wxString &text, bool bSelect /* = false*/, const std::string &bmp_name /* = ""*/, const wxBitmap &bmp /* = wxNullBitmap */)
{
Button * btn = new Button(this, text.empty() ? text : " " + text, bmp_name, wxNO_BORDER);
btn->SetCornerRadius(0);
if (bmp_name.empty() && m_imageList != nullptr && imageId != wxBookCtrlBase::NO_IMAGE && imageId >= 0 &&
imageId < m_imageList->GetImageCount())
btn->SetIcon(m_imageList->GetBitmap(imageId));
if (bmp_name.empty() && bmp.IsOk())
btn->SetIcon(bmp);
int em = em_unit(this);
//BBS set size for button
@@ -232,23 +231,6 @@ bool ButtonsListCtrl::SetPageImage(size_t n, const std::string& bmp_name) const
return true;
}
bool ButtonsListCtrl::SetPageImage(size_t n, int imageId)
{
if (n >= m_pageButtons.size())
return false;
if (imageId == wxBookCtrlBase::NO_IMAGE) {
m_pageButtons[n]->SetIcon(wxBitmap());
return true;
}
if (m_imageList == nullptr || imageId < 0 || imageId >= m_imageList->GetImageCount())
return false;
m_pageButtons[n]->SetIcon(m_imageList->GetBitmap(imageId));
return true;
}
void ButtonsListCtrl::SetPageText(size_t n, const wxString& strText)
{
Button* btn = m_pageButtons[n];