| 1 |
#include "myxh_treelist.h" |
| 2 |
#include "designer_panel.h" |
| 3 |
#include "wxgui_helpers.h" |
| 4 |
#include "wxguicraft_main_view.h" |
| 5 |
#include <wx/imaglist.h> |
| 6 |
#include <wx/treelist.h> |
| 7 |
|
| 8 |
MyTreeListCtrl::MyTreeListCtrl() |
| 9 |
: wxXmlResourceHandler() |
| 10 |
{ |
| 11 |
XRC_ADD_STYLE(wxTL_SINGLE); |
| 12 |
XRC_ADD_STYLE(wxTL_MULTIPLE); |
| 13 |
XRC_ADD_STYLE(wxTL_CHECKBOX); |
| 14 |
XRC_ADD_STYLE(wxTL_3STATE); |
| 15 |
XRC_ADD_STYLE(wxTL_USER_3STATE); |
| 16 |
XRC_ADD_STYLE(wxTL_DEFAULT_STYLE); |
| 17 |
AddWindowStyles(); |
| 18 |
} |
| 19 |
|
| 20 |
bool MyTreeListCtrl::CanHandle(wxXmlNode* node) |
| 21 |
{ |
| 22 |
return IsOfClass(node, "wxTreeListCtrl") || IsOfClass(node, "wxTreeListCtrlCol"); |
| 23 |
} |
| 24 |
|
| 25 |
wxObject* MyTreeListCtrl::DoCreateResource() |
| 26 |
{ |
| 27 |
if(m_class == "wxTreeListCtrlCol") { |
| 28 |
HandleListCol(); |
| 29 |
|
| 30 |
} else { |
| 31 |
wxASSERT_MSG(m_class == "wxTreeListCtrl", wxT("can't handle unknown node")); |
| 32 |
|
| 33 |
return HandleListCtrl(); |
| 34 |
} |
| 35 |
return m_parentAsWindow; |
| 36 |
} |
| 37 |
|
| 38 |
void MyTreeListCtrl::HandleListCol() |
| 39 |
{ |
| 40 |
// Add column to the wxDataViewListCtrl |
| 41 |
wxTreeListCtrl* const list = wxDynamicCast(m_parentAsWindow, wxTreeListCtrl); |
| 42 |
wxCHECK_RET(list, wxT("must have wxTreeListCtrl parent")); |
| 43 |
|
| 44 |
// Column properties |
| 45 |
int colwidth = GetLong("width", wxCOL_WIDTH_DEFAULT); |
| 46 |
wxString label = GetText("label"); |
| 47 |
wxString salign = GetText("align", false); |
| 48 |
wxString col_flags = GetText("flags", false); |
| 49 |
|
| 50 |
wxAlignment al = (wxAlignment)wxCrafter::ToAligment(salign); |
| 51 |
int flags = wxCrafter::ColumnFlagsFromString(col_flags); |
| 52 |
list->AppendColumn(label, colwidth, al, flags); |
| 53 |
} |
| 54 |
|
| 55 |
wxTreeListCtrl* MyTreeListCtrl::HandleListCtrl() |
| 56 |
{ |
| 57 |
XRC_MAKE_INSTANCE(list, wxTreeListCtrl) |
| 58 |
|
| 59 |
list->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(), GetName()); |
| 60 |
CreateChildrenPrivately(list); |
| 61 |
SetupWindow(list); |
| 62 |
|
| 63 |
// This is a one ugly hack: connect our newly created list control |
| 64 |
// to the designer panel |
| 65 |
// list->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(DesignerPanel::OnTreeListCtrlFocus), NULL, |
| 66 |
// GUICraftMainPanel::m_MainPanel->GetDesignerPanel()); |
| 67 |
return list; |
| 68 |
} |