admin
2024-05-17 03654f19baa454b990c052c43e2393a1c53c2c81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#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();
    }
}