]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xml/xh_chckl.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML resource for wxCheckList
4 // Author: Bob Mitchell
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_chckl.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xml/xh_chckl.h"
23 #include "wx/checklst.h"
25 wxCheckListXmlHandler::wxCheckListXmlHandler()
26 : wxXmlResourceHandler(), m_InsideBox(FALSE
)
31 wxObject
*wxCheckListXmlHandler::DoCreateResource()
33 if( m_Node
->GetName() == _T("checklist"))
35 // need to build the list of strings from children
37 CreateChildren( NULL
, TRUE
/* only this handler */,
38 GetParamNode(_T("content")));
39 wxString
*strings
= (wxString
*) NULL
;
40 if( strList
.GetCount() > 0 )
42 strings
= new wxString
[strList
.GetCount()];
43 int count
= strList
.GetCount();
44 for( int i
= 0; i
< count
; i
++ )
45 strings
[i
]=strList
[i
];
49 wxCheckListBox
*control
= new wxCheckListBox(m_ParentAsWindow
,
51 GetPosition(), GetSize(),
59 // step through children myself (again.)
60 wxXmlNode
*n
= GetParamNode(_T("content"));
61 if (n
) n
= n
->GetChildren();
65 if (n
->GetType() != wxXML_ELEMENT_NODE
||
66 n
->GetName() != _T("item" ))
67 { n
= n
->GetNext(); continue; }
69 // checking boolean is a bit ugly here (see GetBool() )
70 wxString v
= n
->GetPropVal(_T("checked"), wxEmptyString
);
72 if (v
&& v
== _T("1"))
73 control
->Check( i
, TRUE
);
83 strList
.Clear(); // dump the strings
90 // handle <item checked="boolean">Label</item>
93 strList
.Add( GetNodeContent(m_Node
) );
102 bool wxCheckListXmlHandler::CanHandle(wxXmlNode
*node
)
104 return( node
->GetName() == _T("checklist") ||
106 node
->GetName() == _T("item" ))