change:更改结构为较为合理结构。
This commit is contained in:
parent
93f39004dc
commit
c5139687ad
@ -22,9 +22,11 @@ find_package(wxWidgets REQUIRED COMPONENTS core base)
|
|||||||
include(${wxWidgets_USE_FILE})
|
include(${wxWidgets_USE_FILE})
|
||||||
|
|
||||||
add_executable(LinuxPack main.cpp
|
add_executable(LinuxPack main.cpp
|
||||||
MainEntry.h
|
MainPanel.h
|
||||||
MainEntry.cpp
|
MainPanel.cpp
|
||||||
MainWidget.cpp
|
MainFrame.cpp
|
||||||
MainWidget.h)
|
MainFrame.h
|
||||||
|
FunctionImp.cpp
|
||||||
|
FunctionImp.h)
|
||||||
target_link_libraries(LinuxPack PRIVATE ${wxWidgets_LIBRARIES})
|
target_link_libraries(LinuxPack PRIVATE ${wxWidgets_LIBRARIES})
|
||||||
set_target_properties(LinuxPack PROPERTIES WIN32_EXECUTABLE TRUE)
|
set_target_properties(LinuxPack PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||||
|
5
FunctionImp.cpp
Normal file
5
FunctionImp.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by taynpg on 24-8-6.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "FunctionImp.h"
|
8
FunctionImp.h
Normal file
8
FunctionImp.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//
|
||||||
|
// Created by taynpg on 24-8-6.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef FUNCTIONIMP_H
|
||||||
|
#define FUNCTIONIMP_H
|
||||||
|
|
||||||
|
#endif //FUNCTIONIMP_H
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
29
MainEntry.h
29
MainEntry.h
@ -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
|
|
15
MainFrame.cpp
Normal file
15
MainFrame.cpp
Normal file
@ -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);
|
||||||
|
}
|
21
MainFrame.h
Normal file
21
MainFrame.h
Normal file
@ -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
|
39
MainPanel.cpp
Normal file
39
MainPanel.cpp
Normal file
@ -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);
|
||||||
|
}
|
31
MainPanel.h
Normal file
31
MainPanel.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef MAIN_PANEL
|
||||||
|
#define MAIN_PANEL
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
|
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
|
@ -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_);
|
|
||||||
}
|
|
28
MainWidget.h
28
MainWidget.h
@ -1,28 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by sinxm on 24-8-5.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef MAINWIDGET_H
|
|
||||||
#define MAINWIDGET_H
|
|
||||||
|
|
||||||
#include <wx/wx.h>
|
|
||||||
|
|
||||||
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
|
|
13
main.cpp
13
main.cpp
@ -1,5 +1,16 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#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);
|
IMPLEMENT_APP(CLinuxPack);
|
||||||
DECLARE_APP(CLinuxPack);
|
DECLARE_APP(CLinuxPack);
|
Loading…
x
Reference in New Issue
Block a user