| | |
| | | #include "TradeQueueListControl.h" |
| | | #include "common.h" |
| | | #include <wx\dcbuffer.h> |
| | | using namespace std; |
| | | |
| | | //wxDEFINE_EVENT(wxEVT_UPDATE_UI, wxCommandEvent); |
| | |
| | | |
| | | |
| | | TradeQueueListControl::TradeQueueListControl(wxWindow* parent, wxWindowID id, |
| | | const wxPoint& pos, const wxSize& size) |
| | | : wxControl(parent, id, pos, size, wxBORDER_NONE) { |
| | | 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 { |
| | | wxPaintDC dc(this); |
| | | dc.SetBackground(wxBrush(GetBackgroundColour())); |
| | | wxBufferedPaintDC dc(this); |
| | | PrepareDC(dc); |
| | | |
| | | dc.SetBackground(wxBrush(*wxBLACK)); |
| | | dc.Clear(); |
| | | |
| | | dc.SetPen(*wxBLACK_PEN); |
| | | dc.SetBrush(*wxLIGHT_GREY_BRUSH); |
| | | dc.DrawRectangle(GetClientRect()); |
| | | |
| | | wxSize queueSize(50*DPI/100, 22*DPI/100); |
| | | wxSize queueSize(queueItemSize.GetWidth() *DPI/100, queueItemSize.GetHeight() *DPI/100); |
| | | |
| | | // 绘制背景颜色 |
| | | wxRect queueRect = wxRect(GetPosition(), GetSize()); |
| | | wxRect queueRect = wxRect(wxPoint(0, 0), GetSize());//wxRect(GetPosition(), GetSize()); |
| | | dc.SetPen(*wxBLACK); |
| | | dc.SetBrush(*wxBLACK); |
| | | dc.DrawRectangle(queueRect); |
| | |
| | | |
| | | 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<TradeQueue>::iterator e = queueList.begin(); |
| | | |
| | | |
| | | int startx = GetPosition().x + padding; |
| | | int starty = GetPosition().y + padding; |
| | | 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++) { |
| | | |
| | |
| | | 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); |
| | | 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); |
| | | |
| | |
| | | Refresh(); |
| | | } |
| | | } |
| | | |
| | | int TradeQueueListControl::getContentHeight() |
| | | { |
| | | return this->contentHeight; |
| | | } |
| | | |
| | | int TradeQueueListControl::getDataCount() |
| | | { |
| | | return this->queueList.size(); |
| | | } |