]>
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 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
20 #if wxUSE_CHECKLISTBOX
22 #include "wx/xrc/xh_chckl.h"
23 #include "wx/checklst.h"
27 IMPLEMENT_DYNAMIC_CLASS(wxCheckListBoxXmlHandler
, wxXmlResourceHandler
)
29 wxCheckListBoxXmlHandler::wxCheckListBoxXmlHandler()
30 : wxXmlResourceHandler(), m_insideBox(false)
33 XRC_ADD_STYLE(wxLB_SINGLE
);
34 XRC_ADD_STYLE(wxLB_MULTIPLE
);
35 XRC_ADD_STYLE(wxLB_EXTENDED
);
36 XRC_ADD_STYLE(wxLB_HSCROLL
);
37 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
38 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
39 XRC_ADD_STYLE(wxLB_SORT
);
44 wxObject
*wxCheckListBoxXmlHandler::DoCreateResource()
46 if (m_class
== wxT("wxCheckListBox")
47 #if WXWIN_COMPATIBILITY_2_4
48 || m_class
== wxT("wxCheckList")
52 #if WXWIN_COMPATIBILITY_2_4
53 if (m_class
== wxT("wxCheckList"))
54 wxLogDebug(wxT("'wxCheckList' name is deprecated, use 'wxCheckListBox' instead."));
56 // need to build the list of strings from children
58 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
59 wxString
*strings
= (wxString
*) NULL
;
60 if (strList
.GetCount() > 0)
62 strings
= new wxString
[strList
.GetCount()];
63 int count
= strList
.GetCount();
64 for(int i
= 0; i
< count
; i
++)
65 strings
[i
] = strList
[i
];
68 XRC_MAKE_INSTANCE(control
, wxCheckListBox
)
70 control
->Create(m_parentAsWindow
,
72 GetPosition(), GetSize(),
79 // step through children myself (again.)
80 wxXmlNode
*n
= GetParamNode(wxT("content"));
81 if (n
) n
= n
->GetChildren();
85 if (n
->GetType() != wxXML_ELEMENT_NODE
||
86 n
->GetName() != wxT("item"))
87 { n
= n
->GetNext(); continue; }
89 // checking boolean is a bit ugly here (see GetBool() )
90 wxString v
= n
->GetPropVal(wxT("checked"), wxEmptyString
);
92 if (v
&& v
== wxT("1"))
93 control
->Check( i
, true );
103 strList
.Clear(); // dump the strings
109 // on the inside now.
110 // handle <item checked="boolean">Label</item>
113 wxString str
= GetNodeContent(m_node
);
114 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
115 str
= wxGetTranslation(str
);
121 bool wxCheckListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
123 return (IsOfClass(node
, wxT("wxCheckListBox")) ||
124 #if WXWIN_COMPATIBILITY_2_4
125 IsOfClass(node
, wxT("wxCheckList")) ||
127 (m_insideBox
&& node
->GetName() == wxT("item")));
130 #endif // wxUSE_CHECKLISTBOX