]>
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")
48 #if WXWIN_COMPATIBILITY_2_4
49 || m_class
== wxT("wxCheckList")
53 #if WXWIN_COMPATIBILITY_2_4
54 if (m_class
== wxT("wxCheckList"))
55 wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
57 // need to build the list of strings from children
59 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
61 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
63 control
->Create(m_parentAsWindow
,
65 GetPosition(), GetSize(),
71 // step through children myself (again.)
72 wxXmlNode
*n
= GetParamNode(wxT("content"));
78 if (n
->GetType() != wxXML_ELEMENT_NODE
||
79 n
->GetName() != wxT("item"))
80 { n
= n
->GetNext(); continue; }
82 // checking boolean is a bit ugly here (see GetBool() )
83 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
85 if (v
&& v
== wxT("1"))
86 control
->Check( i
, true );
94 strList
.Clear(); // dump the strings
100 // on the inside now.
101 // handle <item checked="boolean">Label</item>
104 wxString str
= GetNodeContent(m_node
);
105 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
106 str
= wxGetTranslation(str
, m_resource
->GetDomain());
112 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
114 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
115 #if WXWIN_COMPATIBILITY_2_4
116 IsOfClass(node
, wxT("wxCheckList")) ||
118 (m_insideBox
&& node
->GetName() == wxT("item")));
121 #endif // wxUSE_XRC && wxUSE_CHECKLISTBOX