]>
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 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
30 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
31 : wxXmlResourceHandler(), m_insideBox(false)
34 XRC_ADD_STYLE(wxLB_SINGLE
);
35 XRC_ADD_STYLE(wxLB_MULTIPLE
);
36 XRC_ADD_STYLE(wxLB_EXTENDED
);
37 XRC_ADD_STYLE(wxLB_HSCROLL
);
38 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
39 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
40 XRC_ADD_STYLE(wxLB_SORT
);
45 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
47 if (m_class
== wxT("wxCheckListBox"))
49 // need to build the list of strings from children
51 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
53 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
55 control
->Create(m_parentAsWindow
,
57 GetPosition(), GetSize(),
63 // step through children myself (again.)
64 wxXmlNode
*n
= GetParamNode(wxT("content"));
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 );
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
, m_resource
->GetDomain());
104 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
106 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
107 (m_insideBox
&& node
->GetName() == wxT("item")));
110 #endif // wxUSE_XRC && wxUSE_CHECKLISTBOX