From 511f3432b442a1fa1ba402617dd1f92dee736745 Mon Sep 17 00:00:00 2001
From: zcy <290198252@qq.com>
Date: Thu, 13 Jan 2022 01:37:24 +0800
Subject: [PATCH] no message
---
examples/basic/main.cpp | 4 +-
examples/controls/controls.vcxproj | 11 ++++-
examples/controls/controls_form.cpp | 1 -
examples/controls/main.cpp | 5 +--
examples/layouts/layouts.vcxproj | 2 +-
examples/proto_debuger/base_form.cpp | 45 +++++++++----------
examples/proto_debuger/proto_debuger.vcxproj | 2 +-
.../proto_debuger.vcxproj.filters | 6 +--
examples/proto_debuger/tcp_server_form.cpp | 7 ++-
.../proto_debuger/tcp_server_libevent.cpp | 21 ++++++++-
examples/proto_debuger/tcp_server_libevent.h | 3 ++
11 files changed, 68 insertions(+), 39 deletions(-)
diff --git a/examples/basic/main.cpp b/examples/basic/main.cpp
index added98b..41d67d00 100644
--- a/examples/basic/main.cpp
+++ b/examples/basic/main.cpp
@@ -15,8 +15,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
- AllocConsole();
- freopen("CONOUT$", "w", stdout);
+ //AllocConsole();
+ //freopen("CONOUT$", "w", stdout);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
diff --git a/examples/controls/controls.vcxproj b/examples/controls/controls.vcxproj
index 1d239846..bf10e990 100644
--- a/examples/controls/controls.vcxproj
+++ b/examples/controls/controls.vcxproj
@@ -42,7 +42,7 @@
Application
true
- v120_xp
+ v142
Unicode
@@ -203,6 +203,15 @@
{0149ba6e-3c0a-426d-aa0a-0b9ec7742f19}
+
+ {2bffa1ee-039d-479e-9bcc-2d12f8aedd16}
+
+
+ {878f5bf0-652a-4fdb-992b-bb7f26d62f0d}
+
+
+ {e35589c6-9509-4116-996f-1d045c2dacae}
+
diff --git a/examples/controls/controls_form.cpp b/examples/controls/controls_form.cpp
index d5d15c9e..f030922c 100644
--- a/examples/controls/controls_form.cpp
+++ b/examples/controls/controls_form.cpp
@@ -1,5 +1,4 @@
#include "stdafx.h"
-#include "controls_form.h"
#include "Utils\DpiManager.h"
#include
diff --git a/examples/controls/main.cpp b/examples/controls/main.cpp
index b3d283c8..55babf07 100644
--- a/examples/controls/main.cpp
+++ b/examples/controls/main.cpp
@@ -4,7 +4,6 @@
#include "stdafx.h"
#include "main.h"
#include "controls_form.h"
-#include "Utils\DpiManager.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
@@ -12,8 +11,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
- AllocConsole();
- freopen("CONOUT$", "w", stdout);
+ //AllocConsole();
+ //freopen("CONOUT$", "w", stdout);
auto dpiManager = ui::DpiManager::GetInstance();
dpiManager->SetAdaptDPI(); // 设置适配自动dpi
diff --git a/examples/layouts/layouts.vcxproj b/examples/layouts/layouts.vcxproj
index a2c201f1..9e0a2ecf 100644
--- a/examples/layouts/layouts.vcxproj
+++ b/examples/layouts/layouts.vcxproj
@@ -42,7 +42,7 @@
Application
true
- v120_xp
+ v142
Unicode
diff --git a/examples/proto_debuger/base_form.cpp b/examples/proto_debuger/base_form.cpp
index c566270f..ae86a683 100644
--- a/examples/proto_debuger/base_form.cpp
+++ b/examples/proto_debuger/base_form.cpp
@@ -130,8 +130,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
auto key = info->ip + L":" + std::to_wstring(info->port);
node->SetText(key);
node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 20, 0, 0, 0 });
+ std::cout << "node heigjt" << node->GetHeight();
mMonitor->GetRootNode()->GetChildNode(2)->AddChildNode(node);
gTcpServerCnt++;
@@ -189,8 +188,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
ui::TreeNode* node = new ui::TreeNode;
node->SetText(p->name);
node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 20, 0, 0, 0 });
+
mMonitor->GetRootNode()->GetChildNode(0)->AddChildNode(node);
if (mUartForm.find(p->name) == mUartForm.end()) {
@@ -255,48 +253,45 @@ void BasicForm::InitWindow(){
});
}
mMonitor = dynamic_cast(FindControl(L"tree"));
+ mMonitor->SetClass(L"list");
+ mMonitor->SetIndent(5);
if (nullptr != mMonitor) {
ui::TreeNode* node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"uart"));
- node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 10, 0, 0, 0 });
- mMonitor->GetRootNode()->AddChildNode(node);
+ node->SetClass(L"list_topitem");
+ node->SetFixedHeight(30);
+ mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"tcp client"));
- node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 10, 0, 0, 0 });
+ node->SetClass(L"list_topitem");
+ node->SetFixedHeight(30);
mMonitor->GetRootNode()->AddChildNode(node);
-
-
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"tcp server"));
- node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 10, 0, 0, 0 });
+ node->SetClass(L"list_topitem");
+ node->SetFixedHeight(30);
+
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"udp client"));
- node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 10, 0, 0, 0 });
+ node->SetClass(L"list_topitem");
+ node->SetFixedHeight(30);
+
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"udp server"));
- node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 10, 0, 0, 0 });
+ node->SetClass(L"list_topitem");
+ node->SetFixedHeight(30);
+
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"udp group"));
- node->SetClass(L"listitem");
- node->SetFixedHeight(20);
- node->SetMargin({ 10, 0, 0, 0 });
+ node->SetClass(L"list_topitem");
+
mMonitor->GetRootNode()->AddChildNode(node);
}
diff --git a/examples/proto_debuger/proto_debuger.vcxproj b/examples/proto_debuger/proto_debuger.vcxproj
index 25fc7f21..bb0b4245 100644
--- a/examples/proto_debuger/proto_debuger.vcxproj
+++ b/examples/proto_debuger/proto_debuger.vcxproj
@@ -192,9 +192,9 @@
-
+
diff --git a/examples/proto_debuger/proto_debuger.vcxproj.filters b/examples/proto_debuger/proto_debuger.vcxproj.filters
index 93631579..77e601cd 100644
--- a/examples/proto_debuger/proto_debuger.vcxproj.filters
+++ b/examples/proto_debuger/proto_debuger.vcxproj.filters
@@ -88,9 +88,6 @@
-
- 资源文件
-
资源文件
@@ -106,6 +103,9 @@
资源文件
+
+ 资源文件
+
diff --git a/examples/proto_debuger/tcp_server_form.cpp b/examples/proto_debuger/tcp_server_form.cpp
index 1e12cb65..b49534cf 100644
--- a/examples/proto_debuger/tcp_server_form.cpp
+++ b/examples/proto_debuger/tcp_server_form.cpp
@@ -84,8 +84,13 @@ void TcpServerFrom::OnNewConnAccept(ConnectionLibevent* p)
element->SetTextPadding({ 6,0,6,0 });
element->SetText(std::to_wstring(p->SocketFd()));
mClients[p->SocketFd()] = p;
-
m_combo_1->Add(element);
+ p->SetRecvHandler(
+ [this](char* p, uint32_t len) {
+ std::cout << "SetRecvHandler " << p;
+ }
+ );
+
return;
}
diff --git a/examples/proto_debuger/tcp_server_libevent.cpp b/examples/proto_debuger/tcp_server_libevent.cpp
index 52ad9e6b..4759feb8 100644
--- a/examples/proto_debuger/tcp_server_libevent.cpp
+++ b/examples/proto_debuger/tcp_server_libevent.cpp
@@ -8,6 +8,11 @@ extern "C" {
#include "event2/thread.h"
};
+void defaultConnRead(char* p, uint32_t len) {
+ std::cout << p;
+ return;
+}
+
class ServerCallbacks {
public:
@@ -19,7 +24,8 @@ ConnectionLibevent::ConnectionLibevent(TcpServerLibevent* p, struct bufferevent*
m_parent_server(nullptr),
m_event(nullptr),
m_fd(-1),
- m_addr(nullptr)
+ m_addr(nullptr),
+ m_recv_handle(defaultConnRead)
{
m_parent_server = p;
m_event = ev;
@@ -50,8 +56,13 @@ void defaultConnClose(ConnectionLibevent*p) {
}
+
+
int ConnectionLibevent::OnRecv(char* p, uint32_t len) {
std::cout << "OnRecv " << p << std::endl;
+ if (m_recv_handle != nullptr) {
+ (m_recv_handle)(p, len);
+ }
m_bytes_recv += len;
return 0;
}
@@ -82,6 +93,12 @@ int ConnectionLibevent::Close() {
}
return 0;
}
+int ConnectionLibevent::SetRecvHandler(OnRecvHandle p) {
+ if (nullptr == p)
+ return -1;
+ this->m_recv_handle = p;
+ return 0;
+}
int ConnectionLibevent::SetServer(TcpServerLibevent* p) {
if (nullptr != p) {
@@ -271,6 +288,8 @@ int TcpServerLibevent::SetConnectionLeaveHandle(OnDisconnect p) {
return 0;
}
+
+
/**
* @description:
* @param {int} ports
diff --git a/examples/proto_debuger/tcp_server_libevent.h b/examples/proto_debuger/tcp_server_libevent.h
index d072f94c..4c5c68fd 100644
--- a/examples/proto_debuger/tcp_server_libevent.h
+++ b/examples/proto_debuger/tcp_server_libevent.h
@@ -35,11 +35,13 @@ public:
uint32_t fd,
struct sockaddr_in* p1);
+ typedef std::function OnRecvHandle;
virtual int OnRecv(char* p, uint32_t len); // data ready callback
virtual int OnClose(); // close callback
virtual int OnWrite(); // write data done callback
int WriteData(const char* p, uint16_t len);
int SetServer(TcpServerLibevent*);
+ int SetRecvHandler(OnRecvHandle);
TcpServerLibevent* Server();
string IpAddress();
uint32_t SocketFd();
@@ -51,6 +53,7 @@ private:
struct bufferevent* m_event;
struct sockaddr_in* m_addr;
uint32_t m_fd;
+ OnRecvHandle m_recv_handle;
};
// 管理服务端