]>
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"
29 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
31 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
32 : wxXmlResourceHandler(), m_insideBox(FALSE
)
38 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
40 if (m_class
== wxT("wxCheckListBox")
41 #if WXWIN_COMPATIBILITY_2_4
42 || m_class
== wxT("wxCheckList")
46 #if WXWIN_COMPATIBILITY_2_4
47 if (m_class
== wxT("wxCheckList"))
48 wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
50 // need to build the list of strings from children
52 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
53 wxString
*strings
= (wxString
*) NULL
;
54 if (strList
.GetCount() > 0)
56 strings
= new wxString
[strList
.GetCount()];
57 int count
= strList
.GetCount();
58 for(int i
= 0; i
< count
; i
++)
59 strings
[i
] = strList
[i
];
62 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
64 control
->Create(m_parentAsWindow
,
66 GetPosition(), GetSize(),
73 // step through children myself (again.)
74 wxXmlNode
*n
= GetParamNode(wxT("content"));
75 if (n
) n
= n
->GetChildren();
79 if (n
->GetType() != wxXML_ELEMENT_NODE
||
80 n
->GetName() != wxT("item"))
81 { n
= n
->GetNext(); continue; }
83 // checking boolean is a bit ugly here (see GetBool() )
84 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
86 if (v
&& v
== wxT("1"))
87 control
->Check( i
, TRUE
);
97 strList
.Clear(); // dump the strings
103 // on the inside now.
104 // handle <item checked="boolean">Label</item>
107 wxString str
= GetNodeContent(m_node
);
108 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
109 str
= wxGetTranslation(str
);
115 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
117 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
118 #if WXWIN_COMPATIBILITY_2_4
119 IsOfClass(node
, wxT("wxCheckList")) ||
121 (m_insideBox
&& node
->GetName() == wxT("item")));