]>
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
6 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_CHECKLISTBOX
19 #include "wx/xrc/xh_chckl.h"
24 #include "wx/checklst.h"
27 #include "wx/xml/xml.h"
29 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
31 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
32 : wxXmlResourceHandler(), m_insideBox(false)
35 XRC_ADD_STYLE(wxLB_SINGLE
);
36 XRC_ADD_STYLE(wxLB_MULTIPLE
);
37 XRC_ADD_STYLE(wxLB_EXTENDED
);
38 XRC_ADD_STYLE(wxLB_HSCROLL
);
39 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
40 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
41 XRC_ADD_STYLE(wxLB_SORT
);
46 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
48 if (m_class
== wxT("wxCheckListBox"))
50 // need to build the list of strings from children
52 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
54 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
56 control
->Create(m_parentAsWindow
,
58 GetPosition(), GetSize(),
64 // step through children myself (again.)
65 wxXmlNode
*n
= GetParamNode(wxT("content"));
71 if (n
->GetType() != wxXML_ELEMENT_NODE
||
72 n
->GetName() != wxT("item"))
73 { n
= n
->GetNext(); continue; }
75 // checking boolean is a bit ugly here (see GetBool() )
76 wxString v
= n
->GetAttribute(wxT("checked"), wxEmptyString
);
79 control
->Check( i
, true );
87 strList
.Clear(); // dump the strings
94 // handle <item checked="boolean">Label</item>
97 wxString str
= GetNodeContent(m_node
);
98 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
99 str
= wxGetTranslation(str
, m_resource
->GetDomain());
105 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
107 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
108 (m_insideBox
&& node
->GetName() == wxT("item")));
111 #endif // wxUSE_XRC && wxUSE_CHECKLISTBOX