From 86b6df50596e81e3a67e3c7bf028bb35fb10749b Mon Sep 17 00:00:00 2001 From: Cilda Date: Sun, 6 Oct 2024 16:19:27 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6?= =?UTF-8?q?=E3=83=88=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 選択肢の効果の余白が初期と設定変更後でずれる問題を修正 --- UmaUmaChecker/src/UI/MainFrame.cpp | 4 ++-- UmaUmaChecker/src/UI/MainFrame.h | 4 ++-- UmaUmaChecker/src/UI/wxUmaTextCtrl.cpp | 24 ++++++++++++------------ UmaUmaChecker/src/UI/wxUmaTextCtrl.h | 3 +++ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/UmaUmaChecker/src/UI/MainFrame.cpp b/UmaUmaChecker/src/UI/MainFrame.cpp index 7fe6452..2ed8078 100644 --- a/UmaUmaChecker/src/UI/MainFrame.cpp +++ b/UmaUmaChecker/src/UI/MainFrame.cpp @@ -141,6 +141,7 @@ MainFrame::MainFrame(wxWindow* parent, const wxPoint& pos, const wxSize& size, l m_statusBar->PushStatusText(wxT("CPU: 100.0%"), 0); m_statusBar->PushStatusText(wxT("MEM: 0.0 MB"), 1); m_statusBar->PushStatusText(_("umamusume: Not detected"), 2); + if (!config->IsShowStatusBar) m_statusBar->Hide(); this->SetStatusBar(m_statusBar); m_comboPopup = new wxComboBoxPopup(this); @@ -179,8 +180,7 @@ MainFrame::MainFrame(wxWindow* parent, const wxPoint& pos, const wxSize& size, l this->Move(config->WindowX, config->WindowY); } - if (!config->IsShowStatusBar) m_statusBar->Hide(); - else timer.Start(1000); + if (config->IsShowStatusBar) timer.Start(1000); Init(); } diff --git a/UmaUmaChecker/src/UI/MainFrame.h b/UmaUmaChecker/src/UI/MainFrame.h index 26e4a56..a1676a4 100644 --- a/UmaUmaChecker/src/UI/MainFrame.h +++ b/UmaUmaChecker/src/UI/MainFrame.h @@ -47,8 +47,8 @@ class MainFrame : public ThemedWindowWrapper void AddToSystemMenu(); void OnClose(wxCloseEvent& event); - void OnSize(wxSizeEvent& event); - void OnSizing(wxSizeEvent& event); + //void OnSize(wxSizeEvent& event); + //void OnSizing(wxSizeEvent& event); void OnClickStart(wxCommandEvent& event); void OnClickScreenShot(wxCommandEvent& event); void OnRightClickScreenShot(wxMouseEvent& event); diff --git a/UmaUmaChecker/src/UI/wxUmaTextCtrl.cpp b/UmaUmaChecker/src/UI/wxUmaTextCtrl.cpp index 901f450..181faa7 100644 --- a/UmaUmaChecker/src/UI/wxUmaTextCtrl.cpp +++ b/UmaUmaChecker/src/UI/wxUmaTextCtrl.cpp @@ -7,16 +7,13 @@ wxUmaTextCtrl::wxUmaTextCtrl(wxWindow* parent, int line): wxTextCtrl(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_RICH2 | wxTE_MULTILINE | wxTE_NO_VSCROLL | wxTE_DONTWRAP) { - Line = line; - DWORD dwOptions = SendMessage(this->GetHWND(), EM_GETLANGOPTIONS, 0, 0); dwOptions &= ~IMF_AUTOFONT; dwOptions |= IMF_UIFONTS; SendMessage(this->GetHWND(), EM_SETLANGOPTIONS, 0, (LPARAM)dwOptions); SendMessage(this->GetHWND(), EM_SHOWSCROLLBAR, SB_HORZ, FALSE); - SetHeightByLine(Line); - SetValue("+1\n2\n3\n4\n5\n6"); + SetHeightByLine(line); this->Refresh(); } @@ -128,17 +125,20 @@ bool wxUmaTextCtrl::SetFont(const wxFont& font) void wxUmaTextCtrl::SetHeightByLine(int line) { + if (Line == line) return; + Line = line; - wxClientDC dc(this); - wxTextAttr attr = this->GetDefaultStyle(); - wxFontMetrics metrics = dc.GetFontMetrics(); + wxSize size = wxSize(-1, GetHeightByLine(Line)); - wxSize size = wxSize(-1, metrics.height * line); - //this->SetMinClientSize(size); - - this->SetClientSize(size); - this->SetMaxClientSize(size); + this->SetMinClientSize(size); + + this->InvalidateBestSize(); +} + +wxSize wxUmaTextCtrl::DoGetBestClientSize() const +{ + return wxSize(-1, GetHeightByLine(Line)); } int wxUmaTextCtrl::GetHeightByLine(int line) const diff --git a/UmaUmaChecker/src/UI/wxUmaTextCtrl.h b/UmaUmaChecker/src/UI/wxUmaTextCtrl.h index 3d30048..6fffc3f 100644 --- a/UmaUmaChecker/src/UI/wxUmaTextCtrl.h +++ b/UmaUmaChecker/src/UI/wxUmaTextCtrl.h @@ -14,6 +14,9 @@ class wxUmaTextCtrl : public wxTextCtrl virtual bool SetFont(const wxFont& font); void SetHeightByLine(int line); +protected: + wxSize DoGetBestClientSize() const override; + private: int GetHeightByLine(int line) const;