]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_chckl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_chckl.cpp
3 // Purpose: XRC resource for wxCheckListBox
4 // Author: Bob Mitchell
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_CHECKLISTBOX
20 #include "wx/xrc/xh_chckl.h"
25 #include "wx/checklst.h"
28 #include "wx/xml/xml.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
32 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
33 : wxXmlResourceHandler(), m_insideBox(false)
36 XRC_ADD_STYLE(wxLB_SINGLE
);
37 XRC_ADD_STYLE(wxLB_MULTIPLE
);
38 XRC_ADD_STYLE(wxLB_EXTENDED
);
39 XRC_ADD_STYLE(wxLB_HSCROLL
);
40 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
41 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
42 XRC_ADD_STYLE(wxLB_SORT
);
47 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
49 if (m_class
== wxT("wxCheckListBox"))
51 // need to build the list of strings from children
53 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
55 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
57 control
->Create(m_parentAsWindow
,
59 GetPosition(), GetSize(),
65 // step through children myself (again.)
66 wxXmlNode
*n
= GetParamNode(wxT("content"));
72 if (n
->GetType() != wxXML_ELEMENT_NODE
||
73 n
->GetName() != wxT("item"))
74 { n
= n
->GetNext(); continue; }
76 // checking boolean is a bit ugly here (see GetBool() )
77 wxString v
= n
->GetAttribute(wxT("checked"), wxEmptyString
);
80 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
, m_resource
->GetDomain());
106 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
108 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
109 (m_insideBox
&& node
->GetName() == wxT("item")));
112 #endif // wxUSE_XRC && wxUSE_CHECKLISTBOX