-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathListCtrl.cpp
More file actions
78 lines (66 loc) · 2.73 KB
/
ListCtrl.cpp
File metadata and controls
78 lines (66 loc) · 2.73 KB
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
#include "Ai16.xpm"
#include "Ai48.xpm"
#include "Avi16.xpm"
#include "Avi48.xpm"
#include "Bmp16.xpm"
#include "Bmp48.xpm"
#include <wx/app.h>
#include <wx/choice.h>
#include <wx/frame.h>
#include <wx/imaglist.h>
#include <wx/listctrl.h>
#include <wx/panel.h>
namespace ListCtrlExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "ListCtrl example"} {
SetClientSize(350, 260);
imageListLarge.Add(wxBitmap {aiIcon48});
imageListLarge.Add(wxBitmap {aviIcon48});
imageListLarge.Add(wxBitmap {bmpIcon48});
listCtrl->SetImageList(&imageListLarge, wxIMAGE_LIST_NORMAL);
imageListSmall.Add(wxBitmap {aiIcon16});
imageListSmall.Add(wxBitmap {aviIcon16});
imageListSmall.Add(wxBitmap {bmpIcon16});
listCtrl->SetImageList(&imageListSmall, wxIMAGE_LIST_SMALL);
listCtrl->AppendColumn("Name", wxLIST_FORMAT_LEFT, 80);
listCtrl->AppendColumn("Type", wxLIST_FORMAT_LEFT, 50);
listCtrl->AppendColumn("Size", wxLIST_FORMAT_LEFT, 50);
listCtrl->AppendColumn("Comment", wxLIST_FORMAT_LEFT, 140);
listCtrl->InsertItem(0, "First");
listCtrl->SetItem(0, 1, "Movie");
listCtrl->SetItem(0, 2, "5359");
listCtrl->SetItem(0, 3, "This is the first item");
listCtrl->SetItemImage(0, 1);
listCtrl->InsertItem(1, "Second");
listCtrl->SetItem(1, 1, "Picture");
listCtrl->SetItem(1, 2, "1256");
listCtrl->SetItem(1, 3, "This is the second item");
listCtrl->SetItemImage(1, 0);
listCtrl->InsertItem(2, "Third");
listCtrl->SetItem(2, 1, "Picture");
listCtrl->SetItem(2, 2, "4284");
listCtrl->SetItem(2, 3, "This is the third item");
listCtrl->SetItemImage(2, 2);
listCtrl->wxWindow::Update();
choice1->Append("LargeIcon", reinterpret_cast<void*>(wxLC_ICON));
choice1->Append("Detail", reinterpret_cast<void*>(wxLC_REPORT));
choice1->Append("SmallIcon", reinterpret_cast<void*>(wxLC_SMALL_ICON));
choice1->Append("List", reinterpret_cast<void*>(wxLC_LIST));
choice1->SetSelection(1);
choice1->Bind(wxEVT_CHOICE, [&](wxCommandEvent& event) {
listCtrl->SetSingleStyle(reinterpret_cast<long long>(choice1->GetClientData(choice1->GetSelection())));
});
}
private:
wxPanel* panel = new wxPanel {this};
wxListCtrl* listCtrl = new wxListCtrl {panel, wxID_ANY, {10, 10}, {330, 200}, wxLC_REPORT|wxSIMPLE_BORDER};
wxChoice* choice1 = new wxChoice {panel, wxID_ANY, {10, 220}};
wxImageList imageListLarge {48, 48};
wxImageList imageListSmall {16, 16};
};
class Application : public wxApp {
auto OnInit() -> bool override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(ListCtrlExample::Application);