|
1 #include <wx/wx.h> |
|
2 |
|
3 #include "PageList.hpp" |
|
4 |
|
5 BEGIN_EVENT_TABLE(PageList, wxListCtrl) |
|
6 EVT_CONTEXT_MENU(PageList::on_context_menu) |
|
7 END_EVENT_TABLE() |
|
8 |
|
9 |
|
10 PageList::PageList(wxWindow *parent) |
|
11 :wxListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, |
|
12 wxLC_REPORT) |
|
13 { |
|
14 InsertColumn(0, _("File")); |
|
15 InsertColumn(1, _("Crop area")); |
|
16 InsertColumn(2, _("Binarizer")); |
|
17 InsertColumn(3, _("Packing")); |
|
18 } |
|
19 |
|
20 void |
|
21 PageList::add_files(const wxArrayString &filenames) |
|
22 { |
|
23 for(unsigned int i=0; i < filenames.GetCount(); ++i) |
|
24 { |
|
25 wxListItem item; |
|
26 item.SetText(filenames[i]); |
|
27 item.SetColumn(0); |
|
28 long pos = InsertItem(item); |
|
29 /* Test */ |
|
30 SetItem(pos, 1, wxT("test")); |
|
31 } |
|
32 SetColumnWidth(0, wxLIST_AUTOSIZE); |
|
33 } |
|
34 |
|
35 void |
|
36 PageList::on_context_menu(wxContextMenuEvent &event) |
|
37 { |
|
38 wxString title; |
|
39 |
|
40 /* Try to guess what we should apply actions to. */ |
|
41 if (GetSelectedItemCount() == 0) |
|
42 { |
|
43 return; |
|
44 } |
|
45 else if (GetSelectedItemCount() == 1) |
|
46 { |
|
47 title = GetItemText(GetNextItem(-1, wxLIST_NEXT_ALL, |
|
48 wxLIST_STATE_SELECTED)); |
|
49 } |
|
50 else |
|
51 { |
|
52 title = _("Selection"); |
|
53 } |
|
54 wxMenu *menu = new wxMenu(title); |
|
55 |
|
56 menu->Append(wxID_CLOSE, wxT("Hello")); |
|
57 |
|
58 PopupMenu(menu); |
|
59 } |