]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_listb.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_listb.cpp
3 // Purpose: XRC resource for wxListBox
4 // Author: Bob Mitchell & Vaclav Slavik
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_LISTBOX
19 #include "wx/xrc/xh_listb.h"
23 #include "wx/listbox.h"
26 #include "wx/xml/xml.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler
, wxXmlResourceHandler
)
30 wxListBoxXmlHandler::wxListBoxXmlHandler()
31 : wxXmlResourceHandler(),
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
);
44 wxObject
*wxListBoxXmlHandler::DoCreateResource()
46 if ( m_class
== wxT("wxListBox"))
49 long selection
= GetLong(wxT("selection"), -1);
51 // need to build the list of strings from children
53 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
56 XRC_MAKE_INSTANCE(control
, wxListBox
)
58 control
->Create(m_parentAsWindow
,
60 GetPosition(), GetSize(),
67 control
->SetSelection(selection
);
70 strList
.Clear(); // dump the strings
77 // handle <item>Label</item>
80 wxString str
= GetNodeContent(m_node
);
81 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
82 str
= wxGetTranslation(str
, m_resource
->GetDomain());
89 bool wxListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
91 return (IsOfClass(node
, wxT("wxListBox")) ||
92 (m_insideBox
&& node
->GetName() == wxT("item")));
95 #endif // wxUSE_XRC && wxUSE_LISTBOX