]>
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
)
32 wxObject
*wxCheckListXmlHandler::DoCreateResource()
34 if( m_Node
->GetName() == _T("checklist"))
36 // need to build the list of strings from children
38 CreateChildren( NULL
, TRUE
/* only this handler */,
39 GetParamNode(_T("content")));
40 wxString
*strings
= (wxString
*) NULL
;
41 if( strList
.GetCount() > 0 )
43 strings
= new wxString
[strList
.GetCount()];
44 int count
= strList
.GetCount();
45 for( int i
= 0; i
< count
; i
++ )
46 strings
[i
]=strList
[i
];
50 wxCheckListBox
*control
= new wxCheckListBox(m_ParentAsWindow
,
52 GetPosition(), GetSize(),
60 // step through children myself (again.)
61 wxXmlNode
*n
= GetParamNode(_T("content"));
62 if (n
) n
= n
->GetChildren();
66 if (n
->GetType() != wxXML_ELEMENT_NODE
||
67 n
->GetName() != _T("item" ))
68 { n
= n
->GetNext(); continue; }
70 // checking boolean is a bit ugly here (see GetBool() )
71 wxString v
= n
->GetPropVal(_T("checked"), wxEmptyString
);
73 if (v
&& v
== _T("1"))
74 control
->Check( i
, TRUE
);
84 strList
.Clear(); // dump the strings
91 // handle <item checked="boolean">Label</item>
94 strList
.Add( GetNodeContent(m_Node
) );
103 bool wxCheckListXmlHandler::CanHandle(wxXmlNode
*node
)
105 return( node
->GetName() == _T("checklist") ||
107 node
->GetName() == _T("item" ))