Debian Codegraph @

wxcrafter/controls/property_grid_manager_wrapper.cpp

raw
1 #include "property_grid_manager_wrapper.h"
2
3 #include "allocator_mgr.h"
4
5 PropertyGridManagerWrapper::PropertyGridManagerWrapper()
6 : wxcWidget(ID_WXPROPERTYGRIDMANAGER)
7 {
8 SetPropertyString(_("Common Settings"), "wxPropertyGridManager");
9 PREPEND_STYLE_FALSE(wxPG_AUTO_SORT);
10 PREPEND_STYLE_FALSE(wxPG_HIDE_CATEGORIES);
11 PREPEND_STYLE_FALSE(wxPG_ALPHABETIC_MODE);
12 PREPEND_STYLE_TRUE(wxPG_BOLD_MODIFIED);
13 PREPEND_STYLE_TRUE(wxPG_SPLITTER_AUTO_CENTER);
14 PREPEND_STYLE_FALSE(wxPG_TOOLTIPS);
15 PREPEND_STYLE_FALSE(wxPG_HIDE_MARGIN);
16 PREPEND_STYLE_FALSE(wxPG_STATIC_SPLITTER);
17 PREPEND_STYLE_FALSE(wxPG_STATIC_LAYOUT);
18 PREPEND_STYLE_FALSE(wxPG_LIMITED_EDITING);
19 PREPEND_STYLE_FALSE(wxPG_TOOLBAR);
20 PREPEND_STYLE_TRUE(wxPG_DESCRIPTION);
21 PREPEND_STYLE_FALSE(wxPG_NO_INTERNAL_BORDER);
22
23 RegisterEvent(
24 "wxEVT_PG_SELECTED", "wxPropertyGridEvent",
25 _("Respond to wxEVT_PG_SELECTED event, generated when a property selection has been changed, either by user "
26 "action or by indirect program function.\nFor instance, collapsing a parent property programmatically causes "
27 "any selected child property to become unselected, and may therefore cause this event to be generated."));
28 RegisterEvent("wxEVT_PG_CHANGED", "wxPropertyGridEvent",
29 _("Respond to wxEVT_PG_CHANGED event, generated when property value has been changed by the user"));
30 RegisterEvent("wxEVT_PG_CHANGING", "wxPropertyGridEvent",
31 _("Respond to wxEVT_PG_CHANGING event, generated when property value is about to be changed by user. "
32 "Use wxPropertyGridEvent::GetValue() to take a peek at the pending value, and "
33 "wxPropertyGridEvent::Veto() to prevent change from taking place, if necessary"));
34 RegisterEvent("wxEVT_PG_HIGHLIGHTED", "wxPropertyGridEvent",
35 _("Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse moves over a property. Event's "
36 "property is NULL if hovered area does not belong to any property."));
37 RegisterEvent(
38 "wxEVT_PG_RIGHT_CLICK", "wxPropertyGridEvent",
39 _("Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is clicked on with right mouse button."));
40 RegisterEvent("wxEVT_PG_DOUBLE_CLICK", "wxPropertyGridEvent",
41 _("Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when "
42 "property is double-clicked on with left mouse button."));
43 RegisterEvent("wxEVT_PG_ITEM_COLLAPSED", "wxPropertyGridEvent",
44 _("Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses a property or category."));
45 RegisterEvent("wxEVT_PG_ITEM_EXPANDED", "wxPropertyGridEvent",
46 _("Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands a property or category."));
47 RegisterEvent("wxEVT_PG_LABEL_EDIT_BEGIN", "wxPropertyGridEvent",
48 _("Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when user is about to begin editing a "
49 "property label. You can veto this event to prevent the action."));
50 RegisterEvent("wxEVT_PG_LABEL_EDIT_ENDING", "wxPropertyGridEvent",
51 _("Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when user is about to end editing of a "
52 "property label. You can veto this event to prevent the action."));
53 RegisterEvent(
54 "wxEVT_PG_COL_BEGIN_DRAG", "wxPropertyGridEvent",
55 _("Respond to wxEVT_PG_COL_BEGIN_DRAG event, generated when user starts resizing a column - can be vetoed."));
56 RegisterEvent("wxEVT_PG_COL_DRAGGING", "wxPropertyGridEvent",
57 _("Respond to wxEVT_PG_COL_DRAGGING, event, generated when a column resize by user is in progress. "
58 "This event is also generated when user double-clicks the splitter in order to recenter it."));
59 RegisterEvent("wxEVT_PG_COL_END_DRAG", "wxPropertyGridEvent",
60 _("Respond to wxEVT_PG_COL_END_DRAG event, generated after column resize by user has finished."));
61 RegisterEvent("wxEVT_COMMAND_BUTTON_CLICKED", "wxCommandEvent",
62 _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the custom editor button is clicked."));
63
64 AddInteger(PROP_SASH_POS, _("Sets x coordinate of the splitter"), -1);
65 AddBool(PROP_SPLITTER_LEFT,
66 _("Moves splitter as left as possible, while still allowing all labels to be shown in full"), false);
67
68 m_namePattern = "m_pgMgr";
69 SetName(GenerateName());
70 }
71
72 PropertyGridManagerWrapper::~PropertyGridManagerWrapper() {}
73
74 wxcWidget* PropertyGridManagerWrapper::Clone() const { return new PropertyGridManagerWrapper(); }
75
76 wxString PropertyGridManagerWrapper::CppCtorCode() const
77 {
78 wxString cppCode;
79
80 cppCode << "wxArrayString " << GetName() << "Arr;\n";
81 cppCode << "wxUnusedVar(" << GetName() << "Arr"
82 << ");\n";
83
84 cppCode << "wxArrayInt " << GetName() << "IntArr;\n";
85 cppCode << "wxUnusedVar(" << GetName() << "IntArr"
86 << ");\n";
87
88 cppCode << CPPStandardWxCtor(StyleFlags("wxPGMAN_DEFAULT_STYLE"));
89 return cppCode;
90 }
91
92 void PropertyGridManagerWrapper::GetIncludeFile(wxArrayString& headers) const
93 {
94 headers.Add("#include <wx/propgrid/manager.h>");
95 }
96
97 wxString PropertyGridManagerWrapper::GetWxClassName() const { return "wxPropertyGridManager"; }
98
99 void PropertyGridManagerWrapper::ToXRC(wxString& text, XRC_TYPE type) const
100 {
101 if(type == XRC_LIVE) {
102 text << XRCUnknown();
103
104 } else {
105 text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes();
106 text << "<splitterpos>" << PropertyInt(PROP_SASH_POS) << "</splitterpos>";
107 text << "<splitterleft>" << PropertyBool(PROP_SPLITTER_LEFT) << "</splitterleft>";
108 ChildrenXRC(text, type);
109 text << XRCSuffix();
110 }
111 }
112
113 wxString PropertyGridManagerWrapper::DoGenerateCppCtorCode_End() const
114 {
115 wxString cppCode;
116
117 if(IsPropertyChecked(PROP_SPLITTER_LEFT)) {
118 cppCode << GetName() << "->GetGrid()->SetSplitterLeft(true);\n";
119 }
120
121 int splitterPos = PropertyInt(PROP_SASH_POS);
122 if(splitterPos != wxNOT_FOUND) {
123 cppCode << GetName() << "->GetGrid()->SetSplitterPosition(" << splitterPos << ", 0);\n";
124 }
125 return cppCode;
126 }