layout:大致基本的布局完成。
This commit is contained in:
parent
c5fe1e349f
commit
797ac91455
@ -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_);
|
||||
}
|
@ -5,6 +5,8 @@
|
||||
#include "LocalControl.h"
|
||||
#include "RemoteControl.h"
|
||||
#include "TaskControl.h"
|
||||
#include "LogControl.h"
|
||||
#include "OnLineControl.h"
|
||||
#include <memory>
|
||||
|
||||
class ControlManager
|
||||
@ -24,6 +26,8 @@ public:
|
||||
LocalControl* local_;
|
||||
RemoteControl* remote_;
|
||||
TaskControl* task_;
|
||||
LogControl* log_;
|
||||
OnlineControl* online_;
|
||||
};
|
||||
|
||||
#endif // CONTROL_MANAGER_H
|
@ -3,6 +3,6 @@
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#define gBorder (5)
|
||||
#define gBorder (2)
|
||||
|
||||
#endif // INTERFACEDEFINE_HPP
|
@ -1,9 +1,29 @@
|
||||
#include "LogControl.h"
|
||||
#include <wx/datetime.h>
|
||||
|
||||
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<std::mutex> lock(mutex_);
|
||||
auto now = wxDateTime::UNow();
|
||||
auto strTime = now.Format("%H:%M:%S.%l");
|
||||
listBox_->Append(strTime + wxT(" ") + log);
|
||||
listBox_->SetSelection(listBox_->GetCount() - 1);
|
||||
}
|
||||
|
@ -1,13 +1,24 @@
|
||||
#ifndef LOGCONTROL_H
|
||||
#define LOGCONTROL_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include "InterfaceDefine.hpp"
|
||||
#include <mutex>
|
||||
|
||||
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
|
@ -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();
|
||||
}
|
||||
|
@ -1,13 +1,23 @@
|
||||
#ifndef ONLINECONTROL_H
|
||||
#define ONLINECONTROL_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#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
|
@ -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();
|
||||
}
|
||||
|
@ -16,6 +16,11 @@ private:
|
||||
|
||||
public:
|
||||
wxGrid* grid_;
|
||||
wxTextCtrl* textCtrl_;
|
||||
wxButton* btnHome_;
|
||||
wxButton* btnGet_;
|
||||
wxButton* btnUpLevel_;
|
||||
wxButton* btnRefresh_;
|
||||
};
|
||||
|
||||
#endif // REMOTECONTROL_H
|
@ -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);
|
||||
}
|
@ -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<ControlManager>(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()
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user