diff --git a/CMakeLists.txt b/CMakeLists.txt index 6794679..9d5a427 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,11 @@ find_package(wxWidgets REQUIRED COMPONENTS core base) include(${wxWidgets_USE_FILE}) add_executable(LinuxPack main.cpp - MainEntry.h - MainEntry.cpp - MainWidget.cpp - MainWidget.h) + MainPanel.h + MainPanel.cpp + MainFrame.cpp + MainFrame.h + FunctionImp.cpp + FunctionImp.h) target_link_libraries(LinuxPack PRIVATE ${wxWidgets_LIBRARIES}) set_target_properties(LinuxPack PROPERTIES WIN32_EXECUTABLE TRUE) diff --git a/FunctionImp.cpp b/FunctionImp.cpp new file mode 100644 index 0000000..6acf678 --- /dev/null +++ b/FunctionImp.cpp @@ -0,0 +1,5 @@ +// +// Created by taynpg on 24-8-6. +// + +#include "FunctionImp.h" diff --git a/FunctionImp.h b/FunctionImp.h new file mode 100644 index 0000000..42d004a --- /dev/null +++ b/FunctionImp.h @@ -0,0 +1,8 @@ +// +// Created by taynpg on 24-8-6. +// + +#ifndef FUNCTIONIMP_H +#define FUNCTIONIMP_H + +#endif //FUNCTIONIMP_H diff --git a/MainEntry.cpp b/MainEntry.cpp deleted file mode 100644 index b0b865a..0000000 --- a/MainEntry.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "MainEntry.h" - -bool CLinuxPack::OnInit() -{ - auto* frame = new CMainFrame(wxT("Linux二进制打包")); - frame->Show(true); - return true; -} - -CMainEntry::CMainEntry(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) - : CMainWidget(parent, id, pos, size, style, name) -{ - -} - - CMainFrame::CMainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title) -{ - entry_ = new CMainEntry(this, wxID_ANY); -} - -void CMainFrame::selectBinaryFile(wxCommandEvent& event) -{ - // btnSelectBinary->Bind(wxEVT_BUTTON, &CMainFrame::selectBinaryFile, this); - wxFileDialog openFileDialog( - this, _("Open file"), "", "", - "Text files (*.txt)|*.txt|PDF files (*.pdf)|*.pdf|All files (*.*)|*.*", - wxFD_OPEN | wxFD_FILE_MUST_EXIST); - - if (openFileDialog.ShowModal() == wxID_CANCEL) - return; - - wxString filePath = openFileDialog.GetPath(); - //text_ctrl_->SetValue(filePath); -} - diff --git a/MainEntry.h b/MainEntry.h deleted file mode 100644 index aade995..0000000 --- a/MainEntry.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef MAIN_ENTRY -#define MAIN_ENTRY - -#include "MainWidget.h" - -class CLinuxPack : public wxApp -{ -public: - bool OnInit() override; -}; - -class CMainEntry : public CMainWidget -{ -public: - explicit CMainEntry(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(649, 422), - long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString); - -}; - -class CMainFrame : public wxFrame -{ -private: - CMainEntry* entry_{}; -public: - explicit CMainFrame(const wxString& title); - void selectBinaryFile(wxCommandEvent& event); -}; - -#endif \ No newline at end of file diff --git a/MainFrame.cpp b/MainFrame.cpp new file mode 100644 index 0000000..5b09dc7 --- /dev/null +++ b/MainFrame.cpp @@ -0,0 +1,15 @@ +// +// Created by sinxm on 24-8-5. +// + +#include "MainFrame.h" + +CMainFrame::CMainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title) +{ + InitFrame(); +} + +void CMainFrame::InitFrame() +{ + panel_ = new CMainPanel(this); +} \ No newline at end of file diff --git a/MainFrame.h b/MainFrame.h new file mode 100644 index 0000000..4f0e40a --- /dev/null +++ b/MainFrame.h @@ -0,0 +1,21 @@ +// +// Created by sinxm on 24-8-5. +// + +#ifndef MAINWIDGET_H +#define MAINWIDGET_H + +#include "MainPanel.h" + +class CMainFrame : public wxFrame +{ +private: + CMainPanel* panel_{}; +public: + explicit CMainFrame(const wxString& title); + +public: + void InitFrame(); +}; + +#endif // MAINWIDGET_H diff --git a/MainPanel.cpp b/MainPanel.cpp new file mode 100644 index 0000000..b7a5f9d --- /dev/null +++ b/MainPanel.cpp @@ -0,0 +1,39 @@ +#include "MainPanel.h" + +CMainPanel::CMainPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) + : wxPanel(parent, id, pos, size, style, name) +{ + InitPanel(); +} + +void CMainPanel::InitPanel() +{ + ui_box_sizer_ = new wxStaticBoxSizer(wxVERTICAL, this, wxT("一、基本信息")); + + sizer_select_ = new wxBoxSizer(wxHORIZONTAL); + label_select_ = new wxStaticText(ui_box_sizer_->GetStaticBox(), wxID_ANY, wxT("要打包的二进制文件")); + text_select_ctrl_ = new wxTextCtrl(ui_box_sizer_->GetStaticBox(), wxID_ANY); + text_select_ctrl_->SetMinSize(wxSize(300, -1)); + btn_select_ = new wxButton(ui_box_sizer_->GetStaticBox(), wxID_ANY, wxT("选择")); + btn_select_->Bind(wxEVT_BUTTON, &CMainPanel::selectBinaryFile, this); + sizer_select_->Add(label_select_, 0, wxALL | wxALIGN_CENTER_VERTICAL, 3); + sizer_select_->Add(text_select_ctrl_, 1, wxALL, 3); + sizer_select_->Add(btn_select_, 0, wxALL | wxALIGN_LEFT, 3); + + ui_box_sizer_->Add(sizer_select_, 0, wxALL | wxEXPAND, 3); + SetSizer(ui_box_sizer_); +} + +void CMainPanel::selectBinaryFile(wxCommandEvent& event) +{ + wxFileDialog openFileDialog( + this, _("Open file"), "", "", + "Text files (*.txt)|*.txt|PDF files (*.pdf)|*.pdf|All files (*.*)|*.*", + wxFD_OPEN | wxFD_FILE_MUST_EXIST); + + if (openFileDialog.ShowModal() == wxID_CANCEL) + return; + + wxString filePath = openFileDialog.GetPath(); + text_select_ctrl_->SetValue(filePath); +} diff --git a/MainPanel.h b/MainPanel.h new file mode 100644 index 0000000..daa2c71 --- /dev/null +++ b/MainPanel.h @@ -0,0 +1,31 @@ +#ifndef MAIN_PANEL +#define MAIN_PANEL + +#include + +constexpr int g_Width = 700; +constexpr int g_Heigh = 450; + +class CMainPanel : public wxPanel +{ +protected: + wxStaticBox* ui_basic_box_{}; + wxStaticBox* ui_second_box_{}; + wxStaticBoxSizer* ui_box_sizer_{}; + wxStaticText* label_select_{}; + wxBoxSizer* sizer_select_{}; + wxTextCtrl* text_select_ctrl_{}; + wxButton* btn_select_{}; + +public: + explicit CMainPanel(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxSize(g_Width, g_Heigh), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString); + +public: + void InitPanel(); + +private: + void selectBinaryFile(wxCommandEvent& event); +}; + +#endif \ No newline at end of file diff --git a/MainWidget.cpp b/MainWidget.cpp deleted file mode 100644 index 18da8a7..0000000 --- a/MainWidget.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by sinxm on 24-8-5. -// - -#include "MainWidget.h" - -CMainWidget::CMainWidget(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) - : wxPanel(parent, id, pos, size, style, name) -{ - InitUi(); -} - -void CMainWidget::InitUi() -{ - ui_basic_box_ = new wxStaticBox(this, wxID_ANY, _("基本信息")); - ui_box_sizer_ = new wxStaticBoxSizer(ui_basic_box_, wxVERTICAL); - label_select_ = new wxStaticText(ui_box_sizer_->GetStaticBox(), wxID_ANY, _("要打包的二进制文件"), wxDefaultPosition, wxDefaultSize, 0); - sizer_select_ = new wxBoxSizer(wxHORIZONTAL); - text_select_ctrl_ = new wxTextCtrl(ui_box_sizer_->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); - sizer_select_->Add(text_select_ctrl_, 0, wxALL, 5); - btn_select_ = new wxButton(ui_box_sizer_->GetStaticBox(), wxID_ANY, _("选择"), wxDefaultPosition, wxDefaultSize, 0); - sizer_select_->Add(btn_select_, 0, wxALL, 5); - ui_box_sizer_->Add(sizer_select_, 1, wxEXPAND, 5); - SetSizer(ui_box_sizer_); -} \ No newline at end of file diff --git a/MainWidget.h b/MainWidget.h deleted file mode 100644 index d8e1eba..0000000 --- a/MainWidget.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// Created by sinxm on 24-8-5. -// - -#ifndef MAINWIDGET_H -#define MAINWIDGET_H - -#include - -class CMainWidget : public wxPanel -{ -protected: - wxStaticBox* ui_basic_box_{}; - wxStaticBoxSizer* ui_box_sizer_{}; - wxStaticText* label_select_{}; - wxBoxSizer* sizer_select_{}; - wxTextCtrl* text_select_ctrl_{}; - wxButton* btn_select_{}; - -public: - explicit CMainWidget(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(649, 422), - long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString); - -public: - void InitUi(); -}; - -#endif // MAINWIDGET_H diff --git a/main.cpp b/main.cpp index 897b673..9101de1 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,16 @@ #include -#include "MainEntry.h" +#include "MainFrame.h" + +class CLinuxPack : public wxApp +{ +public: + bool OnInit() override + { + auto* frame = new CMainFrame(wxT("Linux二进制打包")); + frame->Show(true); + return true; + } +}; IMPLEMENT_APP(CLinuxPack); DECLARE_APP(CLinuxPack); \ No newline at end of file