]>
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 wxCheckListXmlHandler::wxCheckListXmlHandler()
29 : wxXmlResourceHandler(), m_insideBox(FALSE
)
35 wxObject
*wxCheckListXmlHandler::DoCreateResource()
37 if (m_class
== wxT("wxCheckList"))
39 // need to build the list of strings from children
41 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
42 wxString
*strings
= (wxString
*) NULL
;
43 if (strList
.GetCount() > 0)
45 strings
= new wxString
[strList
.GetCount()];
46 int count
= strList
.GetCount();
47 for(int i
= 0; i
< count
; i
++)
48 strings
[i
] = strList
[i
];
51 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
53 control
->Create(m_parentAsWindow
,
55 GetPosition(), GetSize(),
62 // step through children myself (again.)
63 wxXmlNode
*n
= GetParamNode(wxT("content"));
64 if (n
) n
= n
->GetChildren();
68 if (n
->GetType() != wxXML_ELEMENT_NODE
||
69 n
->GetName() != wxT("item"))
70 { n
= n
->GetNext(); continue; }
72 // checking boolean is a bit ugly here (see GetBool() )
73 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
75 if (v
&& v
== wxT("1"))
76 control
->Check( i
, TRUE
);
86 strList
.Clear(); // dump the strings
93 // handle <item checked="boolean">Label</item>
96 wxString str
= GetNodeContent(m_node
);
97 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
98 str
= wxGetTranslation(str
);
104 bool wxCheckListXmlHandler::CanHandle(wxXmlNode
*node
)
106 return (IsOfClass(node
, wxT("wxCheckList")) ||
107 (m_insideBox
&& node
->GetName() == wxT("item")));