Debian Codegraph @

wxcrafter/controls/list_ctrl_wrapper.cpp

raw
1 #include "list_ctrl_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "wxgui_defs.h"
4 #include <wx/listctrl.h>
5
6 ListCtrlWrapper::ListCtrlWrapper()
7 : wxcWidget(ID_WXLISTCTRL)
8 {
9 SetPropertyString(_("Common Settings"), "wxListCtrl");
10
11 PREPEND_STYLE(wxLC_LIST, false);
12 PREPEND_STYLE(wxLC_REPORT, true);
13 PREPEND_STYLE(wxLC_VIRTUAL, false);
14 PREPEND_STYLE(wxLC_ICON, false);
15 PREPEND_STYLE(wxLC_SMALL_ICON, false);
16 PREPEND_STYLE(wxLC_ALIGN_TOP, false);
17 PREPEND_STYLE(wxLC_ALIGN_LEFT, false);
18 PREPEND_STYLE(wxLC_EDIT_LABELS, false);
19 PREPEND_STYLE(wxLC_NO_HEADER, false);
20 PREPEND_STYLE(wxLC_SINGLE_SEL, false);
21 PREPEND_STYLE(wxLC_SORT_ASCENDING, false);
22 PREPEND_STYLE(wxLC_SORT_DESCENDING, false);
23 PREPEND_STYLE(wxLC_HRULES, false);
24 PREPEND_STYLE(wxLC_VRULES, false);
25
26 RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_SELECTED"), wxT("wxListEvent"), _("The item has been selected"));
27 RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_DESELECTED"), wxT("wxListEvent"), _("The item has been deselected"));
28 RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK"), wxT("wxListEvent"),
29 _("The right mouse button has been clicked on an item"));
30 RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK"), wxT("wxListEvent"),
31 _("The middle mouse button has been clicked on an item"));
32 RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_ACTIVATED"), wxT("wxListEvent"),
33 _("The item has been activated (ENTER or double click)"));
34 RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_FOCUSED"), wxT("wxListEvent"),
35 _("The currently focused item has changed"));
36 RegisterEvent(wxT("wxEVT_COMMAND_LIST_KEY_DOWN"), wxT("wxListEvent"), _("A key has been pressed"));
37
38 RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_CLICK"), wxT("wxListEvent"),
39 _("A column (m_col) has been left-clicked"));
40 RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_RIGHT_CLICK"), wxT("wxListEvent"),
41 _("A column (m_col) has been right-clicked"));
42 RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_BEGIN_DRAG"), wxT("wxListEvent"),
43 _("The user started resizing a column - can be vetoed"));
44 RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_DRAGGING"), wxT("wxListEvent"),
45 _("The divider between columns is being dragged"));
46 RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_END_DRAG"), wxT("wxListEvent"),
47 _("A column has been resized by the user"));
48
49 RegisterEvent(wxT("wxEVT_COMMAND_LIST_BEGIN_DRAG"), wxT("wxListEvent"),
50 _("Begin dragging with the left mouse button"));
51 RegisterEvent(wxT("wxEVT_COMMAND_LIST_BEGIN_RDRAG"), wxT("wxListEvent"),
52 _("Begin dragging with the right mouse button."));
53 RegisterEvent(wxT("wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT"), wxT("wxListEvent"),
54 _("Begin editing a label. This can be prevented by calling Veto()"));
55 RegisterEvent(wxT("wxEVT_COMMAND_LIST_END_LABEL_EDIT"), wxT("wxListEvent"),
56 _("Finish editing a label. This can be prevented by calling Veto()"));
57 RegisterEvent(wxT("wxEVT_COMMAND_LIST_DELETE_ITEM"), wxT("wxListEvent"), _("Delete an item"));
58 RegisterEvent(wxT("wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS"), wxT("wxListEvent"), _("Delete all items"));
59 RegisterEvent(wxT("wxEVT_COMMAND_LIST_INSERT_ITEM"), wxT("wxListEvent"), _("An item has been inserted"));
60
61 m_namePattern = wxT("m_listCtrl");
62 SetName(GenerateName());
63 }
64
65 ListCtrlWrapper::~ListCtrlWrapper() {}
66
67 wxcWidget* ListCtrlWrapper::Clone() const { return new ListCtrlWrapper(); }
68
69 wxString ListCtrlWrapper::CppCtorCode() const
70 {
71 // wxListCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size =
72 // wxDefaultSize,
73 // long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name =
74 // wxListCtrlNameStr)
75 wxString code;
76 code << GetName() << wxT(" = new ") << GetRealClassName() << "(" << GetWindowParent() << wxT(", ") << WindowID()
77 << wxT(", ") << wxT("wxDefaultPosition, ") << SizeAsString() << wxT(", ") << StyleFlags(wxT("0"))
78 << wxT(");\n");
79 code << CPPCommonAttributes();
80 return code;
81 }
82
83 void ListCtrlWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/listctrl.h>")); }
84
85 wxString ListCtrlWrapper::GetWxClassName() const { return wxT("wxListCtrl"); }
86
87 void ListCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const
88 {
89 text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes();
90
91 // add columns
92 ChildrenXRC(text, type);
93
94 text << XRCSuffix();
95 }