| 1 |
#include "tree_list_ctrl_column_wrapper.h" |
| 2 |
|
| 3 |
#include "allocator_mgr.h" |
| 4 |
#include "choice_property.h" |
| 5 |
#include "col_header_flags_property.h" |
| 6 |
#include "wxgui_helpers.h" |
| 7 |
|
| 8 |
#include <wx/headercol.h> |
| 9 |
|
| 10 |
TreeListCtrlColumnWrapper::TreeListCtrlColumnWrapper() |
| 11 |
: wxcWidget(ID_WXTREELISTCTRLCOL) |
| 12 |
{ |
| 13 |
m_styles.Clear(); |
| 14 |
m_sizerFlags.Clear(); |
| 15 |
m_properties.DeleteValues(); |
| 16 |
|
| 17 |
wxArrayString alignment; |
| 18 |
alignment.Add("wxALIGN_LEFT"); |
| 19 |
alignment.Add("wxALIGN_RIGHT"); |
| 20 |
alignment.Add("wxALIGN_CENTER"); |
| 21 |
|
| 22 |
// FIXME: add alignment + column flags here |
| 23 |
AddProperty(new CategoryProperty(_("wxTreeListCtrl Column"))); |
| 24 |
AddProperty(new StringProperty(PROP_NAME, _("My Column"), _("Column caption"))); |
| 25 |
AddProperty(new ChoiceProperty(PROP_DV_LISTCTRL_COL_ALIGN, alignment, 0, |
| 26 |
_("Alignment of both the column header and its items"))); |
| 27 |
AddProperty(new StringProperty( |
| 28 |
PROP_WIDTH, "-2", |
| 29 |
_("The width of the column in pixels or the special wxCOL_WIDTH_AUTOSIZE(-2) value indicating that the column " |
| 30 |
"should adjust to its contents. Notice that the first column is special and will be always resized to fill " |
| 31 |
"all the space not taken by the other columns, i.e. the width specified here is ignored for it"))); |
| 32 |
AddProperty(new ColHeaderFlagsProperty( |
| 33 |
PROP_COL_FLAGS, wxCOL_DEFAULT_FLAGS, |
| 34 |
_("Column flags, currently can include wxCOL_RESIZABLE to allow the user to resize the column and " |
| 35 |
"wxCOL_SORTABLE to allow the user to resort the control contents by clicking on this column"))); |
| 36 |
} |
| 37 |
|
| 38 |
TreeListCtrlColumnWrapper::~TreeListCtrlColumnWrapper() {} |
| 39 |
|
| 40 |
wxcWidget* TreeListCtrlColumnWrapper::Clone() const { return new TreeListCtrlColumnWrapper(); } |
| 41 |
|
| 42 |
wxString TreeListCtrlColumnWrapper::CppCtorCode() const |
| 43 |
{ |
| 44 |
wxString cppCode; |
| 45 |
wxString alignstring = PropertyString(PROP_DV_LISTCTRL_COL_ALIGN); |
| 46 |
|
| 47 |
cppCode << GetWindowParent() << "->AppendColumn(" << wxCrafter::UNDERSCORE(GetName()) << ", " // Label |
| 48 |
<< PropertyInt(PROP_WIDTH, -1) << ", " // Width |
| 49 |
<< alignstring << ", " // Alignment |
| 50 |
<< PropertyString(PROP_COL_FLAGS, "0") << ");"; // Flags |
| 51 |
return cppCode; |
| 52 |
} |
| 53 |
|
| 54 |
void TreeListCtrlColumnWrapper::GetIncludeFile(wxArrayString& headers) const { wxUnusedVar(headers); } |
| 55 |
|
| 56 |
wxString TreeListCtrlColumnWrapper::GetWxClassName() const { return ""; } |
| 57 |
|
| 58 |
void TreeListCtrlColumnWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 59 |
{ |
| 60 |
if(type == XRC_LIVE) { |
| 61 |
text << XRCUnknown(); |
| 62 |
|
| 63 |
} else { |
| 64 |
text << "<object class=\"wxTreeListCtrlCol\">" |
| 65 |
<< "<label>" << wxCrafter::CDATA(GetName()) << "</label>" |
| 66 |
<< "<width>" << PropertyInt(PROP_WIDTH, -1) << "</width>" |
| 67 |
<< "<align>" |
| 68 |
<< "wxALIGN_LEFT" |
| 69 |
<< "</align>" |
| 70 |
<< "<flags>" << PropertyString(PROP_COL_FLAGS, "0") << "</flags>" |
| 71 |
<< "</object>"; |
| 72 |
} |
| 73 |
} |