]>
git.saurik.com Git - wxWidgets.git/blob - 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 #if wxUSE_OWNER_DRAWN || !defined(__WXMSW__)
24 #include "wx/xrc/xh_chckl.h"
25 #include "wx/checklst.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxCheckListXmlHandler
, wxXmlResourceHandler
)
30 wxCheckListXmlHandler::wxCheckListXmlHandler()
31 : wxXmlResourceHandler(), m_insideBox(FALSE
)
37 wxObject
*wxCheckListXmlHandler::DoCreateResource()
39 if (m_class
== wxT("wxCheckList"))
41 // need to build the list of strings from children
43 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
44 wxString
*strings
= (wxString
*) NULL
;
45 if (strList
.GetCount() > 0)
47 strings
= new wxString
[strList
.GetCount()];
48 int count
= strList
.GetCount();
49 for(int i
= 0; i
< count
; i
++)
50 strings
[i
] = strList
[i
];
53 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
55 control
->Create(m_parentAsWindow
,
57 GetPosition(), GetSize(),
64 // step through children myself (again.)
65 wxXmlNode
*n
= GetParamNode(wxT("content"));
66 if (n
) n
= n
->GetChildren();
70 if (n
->GetType() != wxXML_ELEMENT_NODE
||
71 n
->GetName() != wxT("item"))
72 { n
= n
->GetNext(); continue; }
74 // checking boolean is a bit ugly here (see GetBool() )
75 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
77 if (v
&& v
== wxT("1"))
78 control
->Check( i
, TRUE
);
88 strList
.Clear(); // dump the strings
95 // handle <item checked="boolean">Label</item>
98 wxString str
= GetNodeContent(m_node
);
99 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
100 str
= wxGetTranslation(str
);
106 bool wxCheckListXmlHandler::CanHandle(wxXmlNode
*node
)
108 return (IsOfClass(node
, wxT("wxCheckList")) ||
109 (m_insideBox
&& node
->GetName() == wxT("item")));