+{
+ if ( m_class == LISTITEM_CLASS_NAME )
+ {
+ HandleListItem();
+ }
+ else if ( m_class == LISTCOL_CLASS_NAME )
+ {
+ HandleListCol();
+ }
+ else
+ {
+ wxASSERT_MSG( m_class == LISTCTRL_CLASS_NAME,
+ "can't handle unknown node" );
+
+ return HandleListCtrl();
+ }
+
+ return m_parentAsWindow;
+}
+
+bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node)
+{
+ return IsOfClass(node, LISTCTRL_CLASS_NAME) ||
+ IsOfClass(node, LISTITEM_CLASS_NAME) ||
+ IsOfClass(node, LISTCOL_CLASS_NAME);
+}
+
+void wxListCtrlXmlHandler::HandleCommonItemAttrs(wxListItem& item)
+{
+ if (HasParam(wxT("align")))
+ item.SetAlign((wxListColumnFormat)GetStyle(wxT("align")));
+ if (HasParam(wxT("text")))
+ item.SetText(GetText(wxT("text")));
+}
+
+void wxListCtrlXmlHandler::HandleListCol()
+{
+ wxListCtrl * const list = wxDynamicCast(m_parentAsWindow, wxListCtrl);
+ wxCHECK_RET( list, "must have wxListCtrl parent" );
+
+ if ( !list->HasFlag(wxLC_REPORT) )
+ {
+ ReportError("Only report mode list controls can have columns.");
+ return;
+ }
+
+ wxListItem item;
+
+ HandleCommonItemAttrs(item);
+ if (HasParam(wxT("width")))
+ item.SetWidth((int)GetLong(wxT("width")));
+ if (HasParam(wxT("image")))
+ item.SetImage((int)GetLong(wxT("image")));
+
+ list->InsertColumn(list->GetColumnCount(), item);
+}
+
+void wxListCtrlXmlHandler::HandleListItem()
+{
+ wxListCtrl * const list = wxDynamicCast(m_parentAsWindow, wxListCtrl);
+ wxCHECK_RET( list, "must have wxListCtrl parent" );
+
+ wxListItem item;
+
+ HandleCommonItemAttrs(item);
+
+ if (HasParam(wxT("bg")))
+ item.SetBackgroundColour(GetColour(wxT("bg")));
+ if (HasParam(wxT("col")))
+ item.SetColumn((int)GetLong(wxT("col")));
+ if (HasParam(wxT("data")))
+ item.SetData(GetLong(wxT("data")));
+ if (HasParam(wxT("font")))
+ item.SetFont(GetFont(wxT("font"), list));
+ if (HasParam(wxT("state")))
+ item.SetState(GetStyle(wxT("state")));
+ if (HasParam(wxT("textcolour")))
+ item.SetTextColour(GetColour(wxT("textcolour")));
+ if (HasParam(wxT("textcolor")))
+ item.SetTextColour(GetColour(wxT("textcolor")));
+
+ // the list control icon style, may be 0
+ int image;
+ if ( list->HasFlag(wxLC_ICON) )
+ image = GetImageIndex(list, wxIMAGE_LIST_NORMAL);
+ else if ( list->HasFlag(wxLC_SMALL_ICON) || list->HasFlag(wxLC_REPORT) || list->HasFlag(wxLC_LIST) )
+ image = GetImageIndex(list, wxIMAGE_LIST_SMALL);
+ else
+ image = wxNOT_FOUND;
+
+ if ( image != wxNOT_FOUND )
+ item.SetImage(image);
+
+ // append the list item to the control
+ item.SetId(list->GetItemCount());
+
+ list->InsertItem(item);
+}
+
+wxListCtrl *wxListCtrlXmlHandler::HandleListCtrl()
+{
+ XRC_MAKE_INSTANCE(list, wxListCtrl)
+
+ list->Create(m_parentAsWindow,
+ GetID(),
+ GetPosition(), GetSize(),
+ GetStyle(),
+ wxDefaultValidator,
+ GetName());
+
+ // we can optionally have normal and/or small image lists
+ wxImageList *imagelist;
+ imagelist = GetImageList(wxT("imagelist"));
+ if ( imagelist )
+ list->AssignImageList(imagelist, wxIMAGE_LIST_NORMAL);
+ imagelist = GetImageList(wxT("imagelist-small"));
+ if ( imagelist )
+ list->AssignImageList(imagelist, wxIMAGE_LIST_SMALL);
+
+ CreateChildrenPrivately(list);