From 3ef188e6075649f4c72e3e7588d8966e1071f2ff Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 05 七月 2024 15:50:40 +0800 Subject: [PATCH] update .gitignore --- DelegateQueue/TradeQueueFrame.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 103 insertions(+), 7 deletions(-) diff --git a/DelegateQueue/TradeQueueFrame.cpp b/DelegateQueue/TradeQueueFrame.cpp index a005e9f..0b3c650 100644 --- a/DelegateQueue/TradeQueueFrame.cpp +++ b/DelegateQueue/TradeQueueFrame.cpp @@ -10,14 +10,31 @@ //SetTransparent(225); this->killed = false; Bind(wxEVT_CLOSE_WINDOW, &TradeQueueFrame::OnClose, this); - listControl = new TradeQueueListControl(this, wxID_ANY); + Bind(wxEVT_SIZE, &TradeQueueFrame::OnSize, this); + + scrolledWindow = new wxScrolledWindow(this, wxID_ANY); + listControl = new TradeQueueListControl(scrolledWindow, wxID_ANY, wxDefaultPosition,wxSize(-1, size.GetHeight()-35)); + dealBigMoneyListControl = new TradeQueueListControl(scrolledWindow, wxID_ANY, wxDefaultPosition, wxSize(-1, size.GetHeight() - 35), wxSize(75,22)); wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); + + sizer->Add(dealBigMoneyListControl, 0, wxEXPAND | wxBottom, 10); sizer->Add(listControl, 1, wxEXPAND); - SetSizer(sizer); + //SetSizer(sizer); SetBackgroundColour(*wxBLACK); + scrolledWindow->SetScrollbars(1, dealBigMoneyListControl->GetSize().GetHeight(), 0, 2); + scrolledWindow->SetSizer(sizer); + scrolledWindow->SetScrollRate(0, dealBigMoneyListControl->GetSize().GetHeight()); + scrolledWindow->Scroll(0, 1); + + wxBoxSizer* rootSizer = new wxBoxSizer(wxVERTICAL); + rootSizer->Add(scrolledWindow, 1, wxEXPAND); + SetSizer(rootSizer); requestThread = new std::thread(requestTradeQueue, code, this); requestThread->detach(); + + std::thread* t1 = new std::thread(requestDealBigList, code, this); + t1->detach(); } TradeQueueFrame::~TradeQueueFrame() @@ -37,6 +54,31 @@ MyConfigUtil::setTradeQueueWindowPos(GetPosition(), GetSize()); // 正常关闭 event.Skip(); +} + +void TradeQueueFrame::OnSize(wxSizeEvent& event) +{ + event.Skip(); + wxSize size = GetClientSize(); + cout <<"窗口大小:"<< size.GetWidth()<<"-"<<size.GetHeight()<< endl; + listControl->SetSize(size); + dealBigMoneyListControl->SetSize(size); + //resetScrollInfo(); +} + +void TradeQueueFrame::resetScrollInfo() +{ + int height = dealBigMoneyListControl->getContentHeight(); + int pos = scrolledWindow->GetScrollPos(wxVERTICAL); + scrolledWindow->AdjustScrollbars(); + scrolledWindow->SetScrollbars(1, dealBigMoneyListControl->GetSize().GetHeight(), 0, 1); + scrolledWindow->SetScrollRate(0, dealBigMoneyListControl->GetSize().GetHeight()); + //scrolledWindow->Layout(); + scrolledWindow->Scroll(0, pos); + + cout << "成交队列的高度:" << listControl->GetClientRect().GetHeight() << endl; + cout << "scrollwindow的高度:" << scrolledWindow->GetSize().GetHeight() << endl; + Refresh(); } void TradeQueueFrame::requestTradeQueue(wxString code, TradeQueueFrame* context) @@ -73,18 +115,72 @@ int type = array[i][1].GetInt(); queueList.push_back(TradeQueue({ to_string(num),type })); } + + if (context != nullptr && context->listControl != nullptr) + { + context->listControl->setTradeQueue(queueList); + context->latest_request_result = result; + } + } + else { + cout << "code!=0" << endl; } } cout << code << endl; - if (context != nullptr && context->listControl != nullptr) - { - context->listControl->setTradeQueue(queueList); - context->latest_request_result = result; + + } + } + catch (string st) { + cout << "出错"<< endl; + + } + } + count++; + Sleep(100); + } + +} + +void TradeQueueFrame::requestDealBigList(wxString code, TradeQueueFrame* context) +{ + + int count = 0; + while (TRUE) { + + if (context->killed) { + break; + } + + if (count % 30 == 0) { + count = 1; + try { + list<TradeQueue> moneyList; + string result = MyNetworkApi::get_deal_big_money_list(code.ToStdString()); + if (context->killed) { + break; + } + auto doc = JsonUtil::parseUTF16(result); + if (doc.IsObject()) { + if (doc[L"code"].GetInt() == 0) { + auto array = doc[L"data"].GetArray(); + for (int i = 0; i < array.Size(); i++) { + wxString money = array[i].GetString(); + int type = 3; + moneyList.push_back(TradeQueue({ money,type })); + } + if (context != nullptr && context->listControl != nullptr) + { + bool lengthChange = moneyList.size() != context->dealBigMoneyListControl->getDataCount(); + context->dealBigMoneyListControl->setTradeQueue(moneyList); + if (lengthChange) + { + context->resetScrollInfo(); + } + } } } } catch (string st) { - } } count++; -- Gitblit v1.8.0