#include "TradeQueueListControl.h" #include "common.h" #include using namespace std; //wxDEFINE_EVENT(wxEVT_UPDATE_UI, wxCommandEvent); // //BEGIN_EVENT_TABLE(TradeQueueListControl, wxControl) // EVT_COMMAND(wxID_ANY, wxEVT_UPDATE_UI, TradeQueueListControl::OnUpdateUI) //END_EVENT_TABLE() TradeQueueListControl::TradeQueueListControl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, wxSize queueItemSize) : wxControl(parent, id, pos, size, wxBORDER_NONE), suitHeight(false),queueItemSize(queueItemSize){ Bind(wxEVT_PAINT, &TradeQueueListControl::OnPaint, this); } void TradeQueueListControl::OnPaint(wxPaintEvent& event) { cout <<"OnPaint"<< endl; try { wxBufferedPaintDC dc(this); PrepareDC(dc); dc.SetBackground(wxBrush(*wxBLACK)); dc.Clear(); wxSize queueSize(queueItemSize.GetWidth() *DPI/100, queueItemSize.GetHeight() *DPI/100); // »æÖƱ³¾°ÑÕÉ« wxRect queueRect = wxRect(wxPoint(0, 0), GetSize());//wxRect(GetPosition(), GetSize()); dc.SetPen(*wxBLACK); dc.SetBrush(*wxBLACK); dc.DrawRectangle(queueRect); int width = GetSize().GetWidth(); int padding = 3*DPI/100; int countPerLine = (width+padding) / (queueSize.x+padding); if (countPerLine == 0) { countPerLine = 1; } int lineCount = queueList.size() % countPerLine == 0 ? queueList.size() / countPerLine : queueList.size() / countPerLine + 1; std::list::iterator e = queueList.begin(); int startx = padding; int starty = padding; wxFont font = dc.GetFont(); //font.SetNumericWeight(wxFONTWEIGHT_BOLD); font.SetPointSize(10); dc.SetFont(font); int height = startx; for (int r = 0; r < lineCount; r++) { int top = r * queueSize.GetHeight() + padding*r; for (int c = 0; c < countPerLine; c++) { if (r * countPerLine + c >= queueList.size()) { break; } int left = c * queueSize.GetWidth() + c* padding; wxRect rect = wxRect(left + startx, top + starty, queueSize.x, queueSize.y); wxColour color; switch ((*e).type) { case 0: color = *wxRED; break; case 1: color = *wxWHITE; break; case 2: color = wxColor(209, 135, 252); break; case 3: color = wxColor(225, 225, 225); break; default: color = *wxRED; break; } // wxColor(66,32,33) WidgetsRenderUtil::drawBtn(&dc, (*e).num, rect, color, *wxBLACK,wxALIGN_RIGHT); if (e != queueList.end()) { ++e; } height = rect.y + rect.GetHeight() + padding; } } this->contentHeight = height; if (suitHeight) { //GetSize().SetHeight(height); } dc.SetTextForeground(*wxBLACK); // ¸üнçÃæ Update(); } catch (...) { } } void TradeQueueListControl::setTradeQueue(std::list queueList) { cout << "setTradeQueue" << endl; if (this != nullptr) { this->queueList = queueList; Refresh(); } } int TradeQueueListControl::getContentHeight() { return this->contentHeight; } int TradeQueueListControl::getDataCount() { return this->queueList.size(); }