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);