]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xrc/xh_chckl.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC 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/xrc/xh_chckl.h"
23 #include "wx/checklst.h"
26 wxCheckListXmlHandler::wxCheckListXmlHandler()
27 : wxXmlResourceHandler(), m_insideBox(FALSE
)
33 wxObject
*wxCheckListXmlHandler::DoCreateResource()
35 if (m_class
== wxT("wxCheckList"))
37 // need to build the list of strings from children
39 CreateChildrenPrivately(NULL
, GetParamNode(wxT("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
];
49 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
51 control
->Create(m_parentAsWindow
,
53 GetPosition(), GetSize(),
60 // step through children myself (again.)
61 wxXmlNode
*n
= GetParamNode(wxT("content"));
62 if (n
) n
= n
->GetChildren();
66 if (n
->GetType() != wxXML_ELEMENT_NODE
||
67 n
->GetName() != wxT("item"))
68 { n
= n
->GetNext(); continue; }
70 // checking boolean is a bit ugly here (see GetBool() )
71 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
73 if (v
&& v
== wxT("1"))
74 control
->Check( i
, TRUE
);
84 strList
.Clear(); // dump the strings
91 // handle <item checked="boolean">Label</item>
94 wxString str
= GetNodeContent(m_node
);
95 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
96 str
= wxGetTranslation(str
);
102 bool wxCheckListXmlHandler::CanHandle(wxXmlNode
*node
)
104 return (IsOfClass(node
, wxT("wxCheckList")) ||
105 (m_insideBox
&& node
->GetName() == wxT("item")));