From 797ac914551f7a23013752c3f7a0180515067034 Mon Sep 17 00:00:00 2001 From: taynpg Date: Fri, 9 May 2025 23:49:27 +0800 Subject: [PATCH] =?UTF-8?q?layout=EF=BC=9A=E5=A4=A7=E8=87=B4=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E5=B8=83=E5=B1=80=E5=AE=8C=E6=88=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UserInterface/ControlManager.cxx | 2 ++ UserInterface/ControlManager.h | 4 ++++ UserInterface/InterfaceDefine.hpp | 2 +- UserInterface/LogControl.cxx | 20 ++++++++++++++++++++ UserInterface/LogControl.h | 13 ++++++++++++- UserInterface/OnLineControl.cxx | 25 +++++++++++++++++++++++++ UserInterface/OnLineControl.h | 12 +++++++++++- UserInterface/RemoteControl.cxx | 23 ++++++++++++++++++++++- UserInterface/RemoteControl.h | 5 +++++ UserInterface/TaskControl.cxx | 6 ++++++ UserInterface/UserInterface.cxx | 16 +++++++++++----- Util/Util.cxx | 2 +- 12 files changed, 120 insertions(+), 10 deletions(-) diff --git a/UserInterface/ControlManager.cxx b/UserInterface/ControlManager.cxx index 875f2db..a77545e 100644 --- a/UserInterface/ControlManager.cxx +++ b/UserInterface/ControlManager.cxx @@ -11,4 +11,6 @@ void ControlManager::Init() local_ = new LocalControl(parent_); remote_ = new RemoteControl(parent_); task_ = new TaskControl(parent_); + log_ = new LogControl(parent_); + online_ = new OnlineControl(parent_); } \ No newline at end of file diff --git a/UserInterface/ControlManager.h b/UserInterface/ControlManager.h index ac2cdf3..77e2ef3 100644 --- a/UserInterface/ControlManager.h +++ b/UserInterface/ControlManager.h @@ -5,6 +5,8 @@ #include "LocalControl.h" #include "RemoteControl.h" #include "TaskControl.h" +#include "LogControl.h" +#include "OnLineControl.h" #include class ControlManager @@ -24,6 +26,8 @@ public: LocalControl* local_; RemoteControl* remote_; TaskControl* task_; + LogControl* log_; + OnlineControl* online_; }; #endif // CONTROL_MANAGER_H \ No newline at end of file diff --git a/UserInterface/InterfaceDefine.hpp b/UserInterface/InterfaceDefine.hpp index d18ef67..59f4b5f 100644 --- a/UserInterface/InterfaceDefine.hpp +++ b/UserInterface/InterfaceDefine.hpp @@ -3,6 +3,6 @@ #include -#define gBorder (5) +#define gBorder (2) #endif // INTERFACEDEFINE_HPP \ No newline at end of file diff --git a/UserInterface/LogControl.cxx b/UserInterface/LogControl.cxx index 7132c9b..9c4c4fe 100644 --- a/UserInterface/LogControl.cxx +++ b/UserInterface/LogControl.cxx @@ -1,9 +1,29 @@ #include "LogControl.h" +#include LogControl::LogControl(wxWindow* parent) : wxPanel(parent) { + Init(); +} + +void LogControl::Init() +{ + listBox_ = new wxListBox(this, wxID_ANY); + auto* topSizer = new wxBoxSizer(wxVERTICAL); + topSizer->Add(listBox_, 1, wxEXPAND); + SetSizer(topSizer); + Layout(); } LogControl::~LogControl() { } + +void LogControl::AddLog(const wxString& log) +{ + std::lock_guard lock(mutex_); + auto now = wxDateTime::UNow(); + auto strTime = now.Format("%H:%M:%S.%l"); + listBox_->Append(strTime + wxT(" ") + log); + listBox_->SetSelection(listBox_->GetCount() - 1); +} diff --git a/UserInterface/LogControl.h b/UserInterface/LogControl.h index 726c3fd..8a89bac 100644 --- a/UserInterface/LogControl.h +++ b/UserInterface/LogControl.h @@ -1,13 +1,24 @@ #ifndef LOGCONTROL_H #define LOGCONTROL_H -#include +#include "InterfaceDefine.hpp" +#include class LogControl : public wxPanel { public: LogControl(wxWindow* parent); ~LogControl() override; + +private: + void Init(); + +public: + void AddLog(const wxString& log); + +public: + wxListBox* listBox_; + std::mutex mutex_; }; #endif // LOGCONTROL_H \ No newline at end of file diff --git a/UserInterface/OnLineControl.cxx b/UserInterface/OnLineControl.cxx index b5520b6..0a0c08c 100644 --- a/UserInterface/OnLineControl.cxx +++ b/UserInterface/OnLineControl.cxx @@ -2,8 +2,33 @@ OnlineControl::OnlineControl(wxWindow* parent) : wxPanel(parent) { + Init(); } OnlineControl::~OnlineControl() { } + +void OnlineControl::Init() +{ + lbCurState_ = new wxStaticText(this, wxID_ANY, _("Current State => ")); + elbCurState_ = new wxStaticText(this, wxID_ANY, _("Disconnected")); + elbCurState_->SetForegroundColour(*wxBLUE); + onLineList_ = new wxListBox(this, wxID_ANY); + + lbCurPoint_ = new wxStaticText(this, wxID_ANY, _("Commnunicate Point => ")); + elbCurPoint_ = new wxStaticText(this, wxID_ANY, _("None")); + elbCurPoint_->SetForegroundColour(*wxBLUE); + + auto* leveSizerA = new wxBoxSizer(wxHORIZONTAL); + leveSizerA->Add(lbCurState_, 0, wxEXPAND | wxALL, gBorder + 1); + leveSizerA->Add(elbCurState_, 0, wxEXPAND | wxALL, gBorder + 1); + + auto* topSizer = new wxBoxSizer(wxVERTICAL); + topSizer->Add(leveSizerA, 0, wxEXPAND | wxALL, gBorder + 1); + topSizer->Add(lbCurPoint_, 0, wxEXPAND | wxALL, gBorder + 1); + topSizer->Add(elbCurPoint_, 0, wxEXPAND | wxALL, gBorder + 1); + topSizer->Add(onLineList_, 1, wxEXPAND | wxALL, gBorder + 1); + SetSizer(topSizer); + Layout(); +} diff --git a/UserInterface/OnLineControl.h b/UserInterface/OnLineControl.h index b807917..7008a7e 100644 --- a/UserInterface/OnLineControl.h +++ b/UserInterface/OnLineControl.h @@ -1,13 +1,23 @@ #ifndef ONLINECONTROL_H #define ONLINECONTROL_H -#include +#include "InterfaceDefine.hpp" class OnlineControl : public wxPanel { public: OnlineControl(wxWindow* parent); ~OnlineControl() override; + +private: + void Init(); + +public: + wxStaticText* lbCurState_; + wxStaticText* elbCurState_; + wxStaticText* lbCurPoint_; + wxStaticText* elbCurPoint_; + wxListBox* onLineList_; }; #endif // ONLINECONTROL_H \ No newline at end of file diff --git a/UserInterface/RemoteControl.cxx b/UserInterface/RemoteControl.cxx index a3f8bc3..d9406e5 100644 --- a/UserInterface/RemoteControl.cxx +++ b/UserInterface/RemoteControl.cxx @@ -14,7 +14,28 @@ void RemoteControl::Init() { grid_ = new wxGrid(this, wxID_ANY); auto* topSizer = new wxBoxSizer(wxVERTICAL); - topSizer->Add(grid_, 1, wxEXPAND); + + auto* dirSizer = new wxBoxSizer(wxHORIZONTAL); + textCtrl_ = new wxTextCtrl(this, wxID_ANY); + dirSizer->Add(textCtrl_, 1, wxALL | wxEXPAND, gBorder); + + btnHome_ = new wxButton(this, wxID_ANY, _("Home")); + dirSizer->Add(btnHome_, 0, wxALL | wxCENTER, gBorder); + + btnGet_ = new wxButton(this, wxID_ANY, _("Get")); + dirSizer->Add(btnGet_, 0, wxALL | wxCENTER, gBorder); + + btnUpLevel_ = new wxButton(this, wxID_ANY, _("UpLevel")); + dirSizer->Add(btnUpLevel_, 0, wxALL | wxCENTER, gBorder); + + btnRefresh_ = new wxButton(this, wxID_ANY, _("Refresh")); + dirSizer->Add(btnRefresh_, 0, wxALL | wxCENTER, gBorder); + + auto* bottomSizer = new wxBoxSizer(wxHORIZONTAL); + bottomSizer->Add(grid_, 1, wxEXPAND); + + topSizer->Add(dirSizer, 0, wxALL | wxEXPAND); + topSizer->Add(bottomSizer, 1, wxEXPAND | wxCENTER); SetSizer(topSizer); Layout(); } diff --git a/UserInterface/RemoteControl.h b/UserInterface/RemoteControl.h index 17542b1..d7bbd29 100644 --- a/UserInterface/RemoteControl.h +++ b/UserInterface/RemoteControl.h @@ -16,6 +16,11 @@ private: public: wxGrid* grid_; + wxTextCtrl* textCtrl_; + wxButton* btnHome_; + wxButton* btnGet_; + wxButton* btnUpLevel_; + wxButton* btnRefresh_; }; #endif // REMOTECONTROL_H \ No newline at end of file diff --git a/UserInterface/TaskControl.cxx b/UserInterface/TaskControl.cxx index a515e4c..e0d3381 100644 --- a/UserInterface/TaskControl.cxx +++ b/UserInterface/TaskControl.cxx @@ -27,4 +27,10 @@ void TaskControl::SetGrid() grid_->SetColLabelValue(2, _("LocalType")); grid_->SetColLabelValue(3, _("RemtoePurpose")); grid_->SetColLabelValue(4, _("RemtoeType")); + + grid_->SetColSize(0, 100); + grid_->SetColSize(1, 200); + grid_->SetColSize(2, 100); + grid_->SetColSize(3, 200); + grid_->SetColSize(4, 100); } \ No newline at end of file diff --git a/UserInterface/UserInterface.cxx b/UserInterface/UserInterface.cxx index 15897ff..bfbafaa 100644 --- a/UserInterface/UserInterface.cxx +++ b/UserInterface/UserInterface.cxx @@ -12,6 +12,8 @@ UserInterface::UserInterface(const wxString& title) : wxFrame(nullptr, wxID_ANY, InitUI(); InitData(); TryRestoreLayout(); + + controlMgr_->log_->AddLog(wxT("Welcome to RelayFile.")); } UserInterface::~UserInterface() @@ -25,11 +27,15 @@ void UserInterface::InitUI() controlMgr_ = std::make_shared(this); mgr_.AddPane(controlMgr_->header_, wxAuiPaneInfo().Name("header").Caption(_("header")).CloseButton(false).Floatable(false).MinSize(-1, 40)); - mgr_.AddPane(controlMgr_->local_, wxAuiPaneInfo().Name("local").Caption(_("local")).CloseButton(false).BestSize(300, 400)); - mgr_.AddPane(controlMgr_->remote_, wxAuiPaneInfo().Name("remote").Caption(_("remote")).CloseButton(false).BestSize(300, 400)); + mgr_.AddPane(controlMgr_->log_, wxAuiPaneInfo().Name("log").Caption(_("log")).CloseButton(false).BestSize(300, 400)); + mgr_.AddPane(controlMgr_->local_, + wxAuiPaneInfo().Name("local").Caption(_("local")).CloseButton(false).BestSize(300, 400).Bottom()); + mgr_.AddPane(controlMgr_->remote_, + wxAuiPaneInfo().Name("remote").Caption(_("remote")).CloseButton(false).BestSize(300, 400).Bottom()); mgr_.AddPane(controlMgr_->task_, wxAuiPaneInfo().Name("task").Caption(_("task")).CloseButton(false).BestSize(300, 400).CenterPane()); - + mgr_.AddPane(controlMgr_->online_, + wxAuiPaneInfo().Name("online").Caption(_("online")).CloseButton(false).BestSize(300, 400).Right()); // update mgr_.Update(); } @@ -38,7 +44,7 @@ void UserInterface::InitMenu() { menuBar_ = new wxMenuBar(); wxMenu* auimenu = new wxMenu(); - auimenu->Append(ID_SaveLayout, "&SaveLayou\tCtrl-S", _("Save Layout")); + auimenu->Append(ID_SaveLayout, "&SaveLayout\tCtrl-S", _("Save Layout")); menuBar_->Append(auimenu, "&Aui"); SetMenuBar(menuBar_); @@ -49,7 +55,7 @@ void UserInterface::InitData() { auto configDir = wxUtil::GetConfigDir(); wxUtil::CreateConfigDir(configDir, wxT("RelayFile"), configDir_); - configPath_ = configDir + wxT("/RelayFile.ini"); + configPath_ = configDir_ + wxT("/RelayFile.ini"); } void UserInterface::TryRestoreLayout() diff --git a/Util/Util.cxx b/Util/Util.cxx index 8c7ac3a..a7a2745 100644 --- a/Util/Util.cxx +++ b/Util/Util.cxx @@ -62,9 +62,9 @@ bool wxUtil::CreateConfigDir(const wxString& dir, const wxString& name, wxString { fs::path path(dir.ToStdString()); path.append(name.ToStdString()); + fullPath = wxString::FromUTF8(path.string()); if (fs::exists(path)) { return true; } - fullPath = wxString::FromUTF8(path.string()); return fs::create_directories(path); }