From 038dc600b82567dab3f3ad630029e2364f1e4118 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 17 Apr 2025 21:03:35 +0800 Subject: [PATCH] =?UTF-8?q?pacnt=EF=BC=9A=E7=AD=9B=E9=80=89=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=8C=B9=E9=85=8D=E6=9E=B6=E5=AD=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 18 +++++++- ParamMatchCnt/CMakeLists.txt | 2 + ParamMatchCnt/main.cxx | 3 ++ ParamMatchCnt/mainframe.cxx | 84 +++++++++++++++++++++++++++++++++++- ParamMatchCnt/mainframe.h | 13 +++++- ParamMatchCnt/mainfunc.cxx | 5 +++ ParamMatchCnt/mainfunc.h | 10 +++++ version.h.in | 2 - 8 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 ParamMatchCnt/mainfunc.cxx create mode 100644 ParamMatchCnt/mainfunc.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 15905a3..426798b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,4 +12,20 @@ message(STATUS "Compiler CXX ID: ${CMAKE_CXX_COMPILER_ID}") set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/) -add_subdirectory(ParamMatchCnt) \ No newline at end of file +add_subdirectory(ParamMatchCnt) + +execute_process( + COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +configure_file(version.h.in version.h) +message(STATUS "build dir:${PROJECT_BINARY_DIR}") +include_directories(${PROJECT_BINARY_DIR}) \ No newline at end of file diff --git a/ParamMatchCnt/CMakeLists.txt b/ParamMatchCnt/CMakeLists.txt index 300d97f..d567b7b 100644 --- a/ParamMatchCnt/CMakeLists.txt +++ b/ParamMatchCnt/CMakeLists.txt @@ -17,6 +17,8 @@ set(PSOURCES mainframe.h mainframe.cxx main.cxx +mainfunc.h +mainfunc.cxx ) find_package(wxWidgets CONFIG REQUIRED) diff --git a/ParamMatchCnt/main.cxx b/ParamMatchCnt/main.cxx index 82d4206..1093349 100644 --- a/ParamMatchCnt/main.cxx +++ b/ParamMatchCnt/main.cxx @@ -6,6 +6,9 @@ public: virtual bool OnInit() { MainFrame* frame = new MainFrame(wxT("ParamMatchCnt")); + if (!frame->Init()) { + return false; + } frame->Show(true); return true; } diff --git a/ParamMatchCnt/mainframe.cxx b/ParamMatchCnt/mainframe.cxx index 825982f..d0cdcc3 100644 --- a/ParamMatchCnt/mainframe.cxx +++ b/ParamMatchCnt/mainframe.cxx @@ -1,7 +1,11 @@ #include "mainframe.h" +#include + +constexpr int g_Border = 2; MainFrame::MainFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600)) { + match_func_ = std::make_shared(); } MainFrame::~MainFrame() @@ -10,5 +14,81 @@ MainFrame::~MainFrame() bool MainFrame::Init() { - return false; -} \ No newline at end of file + auto* panel = new wxPanel(this, wxID_ANY); + auto* mainSizer = new wxBoxSizer(wxVERTICAL); + + auto* sizerA = new wxBoxSizer(wxHORIZONTAL); + auto* staticTextA = new wxStaticText(panel, wxID_ANY, wxT("工程目录:")); + proj_root_ = new wxTextCtrl(panel, wxID_ANY, wxT("")); + auto* buttonA = new wxButton(panel, wxID_ANY, wxT("...")); + + buttonA->Bind(wxEVT_BUTTON, &MainFrame::OnSelectDir, this, buttonA->GetId()); + + sizerA->Add(staticTextA, 0, wxALL | wxALIGN_CENTER_VERTICAL, g_Border); + sizerA->Add(proj_root_, 1, wxALL, g_Border); + sizerA->Add(buttonA, 0, wxALL, g_Border); + + auto* sizerHelp = new wxBoxSizer(wxHORIZONTAL); + auto* sizerB = new wxBoxSizer(wxHORIZONTAL); + auto* helpText = new wxStaticText(panel, wxID_ANY, wxT("简要说明:筛选框多个内容以|分隔。")); + sizerHelp->Add(helpText, 1, wxALL, g_Border); + + auto* staticTextB = new wxStaticText(panel, wxID_ANY, wxT("筛选后缀:")); + auto* staticTextC = new wxStaticText(panel, wxID_ANY, wxT("筛选函数:")); + auto* combox = new wxChoice(panel, wxID_ANY); + combox->Append(wxT("printf")); + combox->Append(wxT("format")); + combox->SetSelection(0); + + auto* textCtrlC = new wxTextCtrl(panel, wxID_ANY, wxT("cxx|cpp|h|hpp|cc|c")); + + sizerB->Add(staticTextB, 0, wxALL | wxALIGN_CENTER_VERTICAL, g_Border); + sizerB->Add(textCtrlC, 1, wxALL | wxEXPAND, g_Border); + sizerB->Add(staticTextC, 0, wxALL | wxALIGN_CENTER_VERTICAL, g_Border); + sizerB->Add(combox, 0, wxALL, g_Border); + + auto* sizerC = new wxBoxSizer(wxHORIZONTAL); + // 表格控件 + auto* tableCtrl = new wxGrid(panel, wxID_ANY); + tableCtrl->CreateGrid(1, 2); + tableCtrl->SetColLabelValue(0, wxT("文件名")); + tableCtrl->SetColLabelValue(1, wxT("行号")); + sizerC->Add(tableCtrl, 1, wxALL, g_Border); + + auto* sizerD = new wxBoxSizer(wxHORIZONTAL); + auto* btnStart = new wxButton(panel, wxID_ANY, wxT("开始")); + auto* btnRecheck = new wxButton(panel, wxID_ANY, wxT("重查")); + auto* btnSimpleIntro = new wxButton(panel, wxID_ANY, wxT("工具简介")); + auto* btnExit = new wxButton(panel, wxID_ANY, wxT("退出")); + sizerD->Add(btnStart, 0, wxALL, g_Border); + sizerD->Add(btnRecheck, 0, wxALL, g_Border); + sizerD->Add(btnSimpleIntro, 0, wxALL, g_Border); + sizerD->Add(btnExit, 0, wxALL, g_Border); + + mainSizer->Add(sizerA, 0, wxEXPAND | wxALL, g_Border); + mainSizer->Add(sizerHelp, 0, wxEXPAND | wxALL, g_Border); + mainSizer->Add(sizerB, 0, wxEXPAND | wxALL, g_Border); + mainSizer->Add(sizerC, 1, wxEXPAND | wxALL, g_Border); + mainSizer->Add(sizerD, 0, wxEXPAND | wxALL, g_Border); + + panel->SetSizer(mainSizer); + + return true; +} + +void MainFrame::OnSelectDir(wxCommandEvent& event) +{ + wxDirDialog dialog(this, wxT("选择工程根目录")); + if (dialog.ShowModal() == wxID_OK) { + proj_root_->SetValue(dialog.GetPath()); + } +} + +void MainFrame::Start(wxCommandEvent& event) +{ + auto dir = proj_root_->GetValue(); + if (dir.Trim().IsEmpty()) { + wxMessageBox(wxT("请选择工程根目录!"), wxT("提示"), wxOK | wxICON_INFORMATION); + return; + } +} diff --git a/ParamMatchCnt/mainframe.h b/ParamMatchCnt/mainframe.h index e111bd2..2677679 100644 --- a/ParamMatchCnt/mainframe.h +++ b/ParamMatchCnt/mainframe.h @@ -1,6 +1,8 @@ #ifndef MAINFRAME_H #define MAINFRAME_H +#include "mainfunc.h" +#include #include class MainFrame : public wxFrame @@ -13,7 +15,16 @@ public: bool Init(); private: - + wxTextCtrl* proj_root_; + +private: + // 选择目录 + void OnSelectDir(wxCommandEvent& event); + + void Start(wxCommandEvent& event); + +private: + std::shared_ptr match_func_; }; #endif // MAINFRAME_H \ No newline at end of file diff --git a/ParamMatchCnt/mainfunc.cxx b/ParamMatchCnt/mainfunc.cxx new file mode 100644 index 0000000..34b0fe8 --- /dev/null +++ b/ParamMatchCnt/mainfunc.cxx @@ -0,0 +1,5 @@ +#include "mainfunc.h" + +MatchFunc::MatchFunc() +{ +} \ No newline at end of file diff --git a/ParamMatchCnt/mainfunc.h b/ParamMatchCnt/mainfunc.h new file mode 100644 index 0000000..f8a97d5 --- /dev/null +++ b/ParamMatchCnt/mainfunc.h @@ -0,0 +1,10 @@ +#ifndef MAINFUNC_CXX +#define MAINFUNC_CXX + +class MatchFunc +{ +public: + MatchFunc(); +}; + +#endif // MAINFUNC_CXX diff --git a/version.h.in b/version.h.in index d06491c..4050203 100644 --- a/version.h.in +++ b/version.h.in @@ -3,7 +3,5 @@ #define VERSION_GIT_COMMIT "@VERSION_GIT_HASH@" #define VERSION_GIT_BRANCH "@VERSION_GIT_BRANCH@" -#define VERSION_NUM "@PROJECT_VERSION@" -#define VERSION_URL "@PROJECT_URL@" #endif