基本框架
This commit is contained in:
parent
948deb1408
commit
93f39004dc
@ -3,10 +3,15 @@ project(LinuxPack)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
set(CMAKE_PREFIX_PATH "/home/taynpg/mlib/wxwidget")
|
set(CMAKE_PREFIX_PATH
|
||||||
|
"/home/taynpg/mlib/wxwidget"
|
||||||
|
"D:/Code/wxWidgets-install"
|
||||||
|
)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE "Release")
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
add_compile_options(/source-charset:utf-8)
|
add_compile_options(/source-charset:utf-8)
|
||||||
add_compile_options(/EHsc)
|
add_compile_options(/EHsc)
|
||||||
@ -17,7 +22,9 @@ 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
|
||||||
MainUi.h
|
MainEntry.h
|
||||||
MainUi.cpp)
|
MainEntry.cpp
|
||||||
|
MainWidget.cpp
|
||||||
|
MainWidget.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)
|
||||||
|
35
MainEntry.cpp
Normal file
35
MainEntry.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#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
Normal file
29
MainEntry.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#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
|
30
MainUi.cpp
30
MainUi.cpp
@ -1,30 +0,0 @@
|
|||||||
#include "MainUi.h"
|
|
||||||
|
|
||||||
bool CLinuxPack::OnInit()
|
|
||||||
{
|
|
||||||
auto* frame = new CMainFrame(wxT("Linux二进制打包工具"));
|
|
||||||
frame->Show(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMainFrame::OnQuit(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
CMainFrame::CMainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title)
|
|
||||||
{
|
|
||||||
auto* button = new wxButton(this, wxID_OK, wxT("OK"), wxPoint(100, 100));
|
|
||||||
|
|
||||||
wxSize screenSize = wxGetDisplaySize();
|
|
||||||
wxSize initSize(screenSize.GetWidth() / 2, screenSize.GetHeight() / 2);
|
|
||||||
|
|
||||||
SetSize(initSize);
|
|
||||||
|
|
||||||
// 计算窗口的位置,使其居中
|
|
||||||
int x = (screenSize.GetWidth() - initSize.GetWidth()) / 2;
|
|
||||||
int y = (screenSize.GetHeight() - initSize.GetHeight()) / 2;
|
|
||||||
|
|
||||||
// 设置窗口的位置
|
|
||||||
SetPosition(wxPoint(x, y));
|
|
||||||
}
|
|
20
MainUi.h
20
MainUi.h
@ -1,20 +0,0 @@
|
|||||||
#ifndef MAIN_UI
|
|
||||||
#define MAIN_UI
|
|
||||||
|
|
||||||
#include <wx/wx.h>
|
|
||||||
#define USE_DYNAMIC_CONNECT
|
|
||||||
|
|
||||||
class CLinuxPack : public wxApp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool OnInit() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CMainFrame : public wxFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit CMainFrame(const wxString& title);
|
|
||||||
void OnQuit(wxCommandEvent& event);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
25
MainWidget.cpp
Normal file
25
MainWidget.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// 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
Normal file
28
MainWidget.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// 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
|
Loading…
x
Reference in New Issue
Block a user