#include "TradeQueueListControl.h"
|
#include "common.h"
|
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)
|
: wxControl(parent, id, pos, size, wxBORDER_NONE) {
|
Bind(wxEVT_PAINT, &TradeQueueListControl::OnPaint, this);
|
}
|
|
void TradeQueueListControl::OnPaint(wxPaintEvent& event) {
|
cout <<"OnPaint"<< endl;
|
try {
|
wxPaintDC dc(this);
|
dc.SetBackground(wxBrush(GetBackgroundColour()));
|
dc.Clear();
|
|
dc.SetPen(*wxBLACK_PEN);
|
dc.SetBrush(*wxLIGHT_GREY_BRUSH);
|
dc.DrawRectangle(GetClientRect());
|
|
wxSize queueSize(50*DPI/100, 22*DPI/100);
|
|
// »æÖƱ³¾°ÑÕÉ«
|
wxRect queueRect = 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);
|
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;
|
|
wxFont font = dc.GetFont();
|
//font.SetNumericWeight(wxFONTWEIGHT_BOLD);
|
font.SetPointSize(10);
|
dc.SetFont(font);
|
|
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;
|
default:
|
color = *wxRED;
|
break;
|
}
|
// wxColor(66,32,33)
|
WidgetsRenderUtil::drawBtn(&dc, (*e).num, rect, color, *wxBLACK);
|
if (e != queueList.end()) {
|
++e;
|
}
|
}
|
}
|
dc.SetTextForeground(*wxBLACK);
|
|
// ¸üнçÃæ
|
Update();
|
}
|
catch (...) {
|
|
}
|
}
|
|
void TradeQueueListControl::setTradeQueue(std::list<TradeQueue> queueList) {
|
cout << "setTradeQueue" << endl;
|
if (this != nullptr) {
|
this->queueList = queueList;
|
Refresh();
|
}
|
}
|