add:一个最初的简单结构。

This commit is contained in:
taynpg 2025-04-03 16:49:08 +08:00
parent 2daea403b4
commit cf12e52e10
6 changed files with 62 additions and 21 deletions

View File

@ -4,23 +4,47 @@ CBasePanel::CBasePanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, cons
: wxPanel(parent, wxID_ANY, pos, size, style, name) : wxPanel(parent, wxID_ANY, pos, size, style, name)
{ {
Init(); Init();
ManLayout();
} }
void CBasePanel::Init() 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* szL1 = new wxBoxSizer(wxHORIZONTAL);
auto* lbIp = new wxStaticText(this, wxID_ANY, _("ServerIP:")); auto* lbIp = new wxStaticText(this, wxID_ANY, _("ServerIP:"));
edIp_ = new wxTextCtrl(this, wxID_ANY, _(""));
auto* lbPort = new wxStaticText(this, wxID_ANY, _("Port:")); auto* lbPort = new wxStaticText(this, wxID_ANY, _("Port:"));
edPort_ = new wxTextCtrl(this, wxID_ANY, _("Port")); szL1->Add(lbIp, 0, wxALL | wxCENTER, g_BaseBorder);
szL1->Add(lbIp, 0, wxALL, 5); szL1->Add(edIp_, 0, wxALL | wxEXPAND, g_BaseBorder);
szL1->Add(edIp_, 0, wxALL, 5); szL1->Add(lbPort, 0, wxALL | wxCENTER, g_BaseBorder);
szL1->Add(lbPort, 0, wxALL, 5); szL1->Add(edPort_, 0, wxALL | wxEXPAND, g_BaseBorder);
szL1->Add(edPort_, 0, wxALL, 5); 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); this->SetSizer(topSizer);
} }

View File

@ -2,6 +2,9 @@
#define BASEMAIN_H #define BASEMAIN_H
#include <wx/wx.h> #include <wx/wx.h>
#include <wx/dirctrl.h>
constexpr int g_BaseBorder = 3;
class CBasePanel : public wxPanel class CBasePanel : public wxPanel
{ {
@ -10,10 +13,17 @@ public:
private: private:
void Init(); void Init();
void ManLayout();
protected: public:
wxTextCtrl* edIp_{}; wxTextCtrl* edIp_{};
wxTextCtrl* edPort_{}; wxTextCtrl* edPort_{};
wxButton* btnConnect_{};
wxButton* btnDisconnect_{};
wxGenericDirCtrl* dirctrl_{};
wxRadioButton* rbtLocal_{};
wxRadioButton* rbtRemote_{};
wxStaticText* lbState_{};
}; };
#endif // BASEMAIN_H #endif // BASEMAIN_H

View File

@ -15,6 +15,7 @@ DECLARE_APP(CMainForm);
bool CMainForm::OnInit() bool CMainForm::OnInit()
{ {
SetProcessDPIAware();
// 这里也是自动释放的,不需要智能指针或者手动释放。 // 这里也是自动释放的,不需要智能指针或者手动释放。
frmae_ = new CMainFrame(_("GTransm")); frmae_ = new CMainFrame(_("GTransm"));
frmae_->Show(true); frmae_->Show(true);

View File

@ -4,22 +4,26 @@ CMainFrame::CMainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title
{ {
InitFrame(); InitFrame();
ManLayout(); ManLayout();
SetMinSize(wxSize(1280, 700));
} }
void CMainFrame::InitFrame() void CMainFrame::InitFrame()
{ {
if (panela_ == nullptr) { panela_ = new CMainPanel(this);
panela_ = new CMainPanel(this); panelb_ = new CMainPanel(this);
} listbox_ = new wxCheckListBox(this, wxID_ANY);
if (panelb_ == nullptr) { toolbar_ = new wxToolBar(this, wxID_ANY);
panelb_ = new CMainPanel(this);
}
} }
void CMainFrame::ManLayout() void CMainFrame::ManLayout()
{ {
auto* szTop = new wxBoxSizer(wxHORIZONTAL); auto* szTop = new wxBoxSizer(wxVERTICAL);
szTop->Add(panela_, 1, wxEXPAND); auto* szL1 = new wxBoxSizer(wxHORIZONTAL);
szTop->Add(panelb_, 1, wxEXPAND); 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); SetSizer(szTop);
} }

View File

@ -16,6 +16,8 @@ public:
private: private:
CMainPanel* panela_{}; CMainPanel* panela_{};
CMainPanel* panelb_{}; CMainPanel* panelb_{};
wxCheckListBox* listbox_{};
wxToolBar* toolbar_{};
}; };
#endif #endif

View File

@ -5,13 +5,13 @@
constexpr int g_Width = 300; constexpr int g_Width = 300;
constexpr int g_Heigh = 450; constexpr int g_Heigh = 450;
constexpr int g_Border = 3; constexpr int g_Border = 1;
class CMainPanel : public CBasePanel class CMainPanel : public CBasePanel
{ {
public: public:
CMainPanel(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, 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 #endif // MAINPANEL_H