| | |
| | | //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() |
| | |
| | | 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) |
| | |
| | | int type = array[i][1].GetInt(); |
| | | queueList.push_back(TradeQueue({ to_string(num),type })); |
| | | } |
| | | } |
| | | } |
| | | cout << code << endl; |
| | | |
| | | if (context != nullptr && context->listControl != nullptr) |
| | | { |
| | | context->listControl->setTradeQueue(queueList); |
| | | context->latest_request_result = result; |
| | | } |
| | | } |
| | | else { |
| | | cout << "code!=0" << endl; |
| | | } |
| | | } |
| | | cout << code << endl; |
| | | |
| | | } |
| | | } |
| | | catch (string st) { |
| | | cout << "出错"<< endl; |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | 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++; |
| | | Sleep(100); |
| | | } |
| | | |
| | | } |
| | | |