From 4c8f80dde837a05942546758f213db14378b1f6c Mon Sep 17 00:00:00 2001 From: taynpg Date: Tue, 6 Aug 2024 10:30:05 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E7=9B=AE=E5=BD=95=E5=87=BD=E6=95=B0=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainPanel.cpp | 17 ++++++++++++++--- MainPanel.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/MainPanel.cpp b/MainPanel.cpp index f5283d1..97ea91f 100644 --- a/MainPanel.cpp +++ b/MainPanel.cpp @@ -29,16 +29,17 @@ void CMainPanel::InitPanel() sizer_select_->Add(btn_select_, 0, wxALL | wxALIGN_LEFT, g_Border); // 将水平 sizer 添加到带标题的 sizer 中, wxALIGN_CENTER_VERTICAL 仅水平可用 - base_box_sizer_->Add(label_select_, 0, wxALL, g_Border); + base_box_sizer_->Add(label_select_, 0, wxALL | wxEXPAND, g_Border); base_box_sizer_->Add(sizer_select_, 0, wxALL | wxEXPAND, g_Border); sizer_output_ = new wxBoxSizer(wxHORIZONTAL); btn_output_ = new wxButton(this, wxID_ANY, wxT("选择目录")); + btn_output_->Bind(wxEVT_BUTTON, &CMainPanel::selectDir, this); text_output_ctrl_ = new wxTextCtrl(this, wxID_ANY); label_output_ = new wxStaticText(this, wxID_ANY, wxT("输出目录:")); - base_box_sizer_->Add(label_output_, 0, wxALL, g_Border); + base_box_sizer_->Add(label_output_, 0, wxALL| wxEXPAND, g_Border); - sizer_output_->Add(text_output_ctrl_, 1, wxALL, g_Border); + sizer_output_->Add(text_output_ctrl_, 1, wxALL | wxEXPAND, g_Border); sizer_output_->Add(btn_output_, 0, wxALL, g_Border); base_box_sizer_->Add(sizer_output_, 0, wxALL | wxEXPAND, g_Border); @@ -75,6 +76,16 @@ void CMainPanel::InitPanel() SetSizer(top_sizer_); } +void CMainPanel::selectDir(wxCommandEvent& event) +{ + wxDirDialog dirDialog(this, wxT("Select Directory"), wxEmptyString, wxDD_DIR_MUST_EXIST); + + if (dirDialog.ShowModal() == wxID_CANCEL) return; // 用户取消选择 + + wxString selectedDir = dirDialog.GetPath(); + text_output_ctrl_->SetValue(selectedDir); +} + void CMainPanel::genResult(wxCommandEvent& event) { wxArrayString arrayStrings; diff --git a/MainPanel.h b/MainPanel.h index 55faaf8..516937b 100644 --- a/MainPanel.h +++ b/MainPanel.h @@ -44,6 +44,7 @@ public: private: void selectBinaryFile(wxCommandEvent& event); + void selectDir(wxCommandEvent& event); void addEnv(wxCommandEvent& event); void delEnv(wxCommandEvent& event); void genResult(wxCommandEvent& event);