base:最基础的可以跑起来的版本。

This commit is contained in:
taynpg 2024-08-05 17:31:26 +08:00
parent ae358408e0
commit 948deb1408
4 changed files with 56 additions and 6 deletions

View File

@ -16,6 +16,8 @@ endif()
find_package(wxWidgets REQUIRED COMPONENTS core base)
include(${wxWidgets_USE_FILE})
add_executable(LinuxPack main.cpp)
add_executable(LinuxPack main.cpp
MainUi.h
MainUi.cpp)
target_link_libraries(LinuxPack PRIVATE ${wxWidgets_LIBRARIES})
set_target_properties(LinuxPack PROPERTIES WIN32_EXECUTABLE TRUE)

30
MainUi.cpp Normal file
View File

@ -0,0 +1,30 @@
#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 Normal file
View File

@ -0,0 +1,20 @@
#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

View File

@ -1,7 +1,5 @@
#include <iostream>
#include "MainUi.h"
int main()
{
std::cout << "Hello, World!" << std::endl;
return 0;
}
IMPLEMENT_APP(CLinuxPack);
DECLARE_APP(CLinuxPack);