From cf12e52e101ac17a4c73539cb14a6e70edc77142 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 3 Apr 2025 16:49:08 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E4=B8=80=E4=B8=AA=E6=9C=80?= =?UTF-8?q?=E5=88=9D=E7=9A=84=E7=AE=80=E5=8D=95=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/design/basepanel.cxx | 42 +++++++++++++++++++++++++++++++--------- gui/design/basepanel.h | 12 +++++++++++- gui/main.cxx | 1 + gui/mainframe.cxx | 22 ++++++++++++--------- gui/mainframe.h | 2 ++ gui/mainpanel.h | 4 ++-- 6 files changed, 62 insertions(+), 21 deletions(-) diff --git a/gui/design/basepanel.cxx b/gui/design/basepanel.cxx index a546423..198782d 100644 --- a/gui/design/basepanel.cxx +++ b/gui/design/basepanel.cxx @@ -4,23 +4,47 @@ CBasePanel::CBasePanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, cons : wxPanel(parent, wxID_ANY, pos, size, style, name) { Init(); + ManLayout(); } void CBasePanel::Init() { - auto* topSizer = new wxBoxSizer(wxVERTICAL); + edIp_ = new wxTextCtrl(this, wxID_ANY, _("")); + edPort_ = new wxTextCtrl(this, wxID_ANY, _("")); + btnConnect_ = new wxButton(this, wxID_ANY, _("Connect")); + btnDisconnect_ = new wxButton(this, wxID_ANY, _("DisConnect")); + dirctrl_ = new wxGenericDirCtrl(this); + rbtLocal_ = new wxRadioButton(this, wxID_ANY, _("Local")); + rbtRemote_ = new wxRadioButton(this, wxID_ANY, _("Remote")); + lbState_ = new wxStaticText(this, wxID_ANY, _("State")); +} +void CBasePanel::ManLayout() +{ + auto* topSizer = new wxBoxSizer(wxVERTICAL); auto* szL1 = new wxBoxSizer(wxHORIZONTAL); auto* lbIp = new wxStaticText(this, wxID_ANY, _("ServerIP:")); - edIp_ = new wxTextCtrl(this, wxID_ANY, _("")); auto* lbPort = new wxStaticText(this, wxID_ANY, _("Port:")); - edPort_ = new wxTextCtrl(this, wxID_ANY, _("Port")); - szL1->Add(lbIp, 0, wxALL, 5); - szL1->Add(edIp_, 0, wxALL, 5); - szL1->Add(lbPort, 0, wxALL, 5); - szL1->Add(edPort_, 0, wxALL, 5); + szL1->Add(lbIp, 0, wxALL | wxCENTER, g_BaseBorder); + szL1->Add(edIp_, 0, wxALL | wxEXPAND, g_BaseBorder); + szL1->Add(lbPort, 0, wxALL | wxCENTER, g_BaseBorder); + szL1->Add(edPort_, 0, wxALL | wxEXPAND, g_BaseBorder); + szL1->Add(btnConnect_, 0, wxALL | wxEXPAND, g_BaseBorder); + szL1->Add(btnDisconnect_, 0, wxALL | wxEXPAND, g_BaseBorder); - topSizer->Add(szL1, 0, wxEXPAND | wxALL, 5); + auto* szL2 = new wxBoxSizer(wxHORIZONTAL); + auto* lbCurMode = new wxStaticText(this, wxID_ANY, _("CurrentOperMode:")); + szL2->Add(lbCurMode, 0, wxALL | wxEXPAND, g_BaseBorder); + szL2->Add(rbtLocal_, 0, wxALL | wxEXPAND, g_BaseBorder); + szL2->Add(rbtRemote_, 0, wxALL | wxEXPAND, g_BaseBorder); + szL2->Add(lbState_, 0, wxALL | wxEXPAND, g_BaseBorder); + + auto* szL3 = new wxBoxSizer(wxHORIZONTAL); + szL3->Add(dirctrl_, 1, wxALL | wxEXPAND, g_BaseBorder); + + topSizer->Add(szL1, 0, wxEXPAND | wxALL, g_BaseBorder); + topSizer->Add(szL2, 0, wxEXPAND | wxALL, g_BaseBorder); + topSizer->Add(szL3, 1, wxEXPAND | wxALL, g_BaseBorder); this->SetSizer(topSizer); -} +} \ No newline at end of file diff --git a/gui/design/basepanel.h b/gui/design/basepanel.h index b07c01e..435747e 100644 --- a/gui/design/basepanel.h +++ b/gui/design/basepanel.h @@ -2,6 +2,9 @@ #define BASEMAIN_H #include +#include + +constexpr int g_BaseBorder = 3; class CBasePanel : public wxPanel { @@ -10,10 +13,17 @@ public: private: void Init(); + void ManLayout(); -protected: +public: wxTextCtrl* edIp_{}; wxTextCtrl* edPort_{}; + wxButton* btnConnect_{}; + wxButton* btnDisconnect_{}; + wxGenericDirCtrl* dirctrl_{}; + wxRadioButton* rbtLocal_{}; + wxRadioButton* rbtRemote_{}; + wxStaticText* lbState_{}; }; #endif // BASEMAIN_H \ No newline at end of file diff --git a/gui/main.cxx b/gui/main.cxx index 9b4b1a8..9e25465 100644 --- a/gui/main.cxx +++ b/gui/main.cxx @@ -15,6 +15,7 @@ DECLARE_APP(CMainForm); bool CMainForm::OnInit() { + SetProcessDPIAware(); // 这里也是自动释放的,不需要智能指针或者手动释放。 frmae_ = new CMainFrame(_("GTransm")); frmae_->Show(true); diff --git a/gui/mainframe.cxx b/gui/mainframe.cxx index cd255e2..a93943d 100644 --- a/gui/mainframe.cxx +++ b/gui/mainframe.cxx @@ -4,22 +4,26 @@ CMainFrame::CMainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title { InitFrame(); ManLayout(); + SetMinSize(wxSize(1280, 700)); } void CMainFrame::InitFrame() { - if (panela_ == nullptr) { - panela_ = new CMainPanel(this); - } - if (panelb_ == nullptr) { - panelb_ = new CMainPanel(this); - } + panela_ = new CMainPanel(this); + panelb_ = new CMainPanel(this); + listbox_ = new wxCheckListBox(this, wxID_ANY); + toolbar_ = new wxToolBar(this, wxID_ANY); } void CMainFrame::ManLayout() { - auto* szTop = new wxBoxSizer(wxHORIZONTAL); - szTop->Add(panela_, 1, wxEXPAND); - szTop->Add(panelb_, 1, wxEXPAND); + auto* szTop = new wxBoxSizer(wxVERTICAL); + auto* szL1 = new wxBoxSizer(wxHORIZONTAL); + szL1->Add(panela_, 1, wxALL | wxEXPAND, g_Border); + szL1->Add(panelb_, 1, wxALL | wxEXPAND, g_Border); + + szTop->Add(toolbar_, 0, wxALL, g_Border); + szTop->Add(szL1, 3, wxALL | wxEXPAND, g_Border); + szTop->Add(listbox_, 1, wxALL | wxEXPAND, g_Border); SetSizer(szTop); } diff --git a/gui/mainframe.h b/gui/mainframe.h index 3c6ce18..04b60de 100644 --- a/gui/mainframe.h +++ b/gui/mainframe.h @@ -16,6 +16,8 @@ public: private: CMainPanel* panela_{}; CMainPanel* panelb_{}; + wxCheckListBox* listbox_{}; + wxToolBar* toolbar_{}; }; #endif \ No newline at end of file diff --git a/gui/mainpanel.h b/gui/mainpanel.h index 1dbb37b..1e4920b 100644 --- a/gui/mainpanel.h +++ b/gui/mainpanel.h @@ -5,13 +5,13 @@ constexpr int g_Width = 300; constexpr int g_Heigh = 450; -constexpr int g_Border = 3; +constexpr int g_Border = 1; class CMainPanel : public CBasePanel { public: 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); + const wxSize& size = wxSize(g_Width, g_Heigh), long style = wxBORDER_RAISED, const wxString& name = wxEmptyString); }; #endif // MAINPANEL_H \ No newline at end of file