1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_simplehtmllbox.cpp
3 // Purpose: XML resource handler for wxSimpleHtmlListBox
4 // Author: Francesco Montorsi
7 // Copyright: (c) 2006 Francesco Montorsi
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_HTML
20 #include "wx/xrc/xh_htmllbox.h"
22 #include "wx/htmllbox.h"
23 #include "wx/filesys.h"
25 #include "wx/xml/xml.h"
27 IMPLEMENT_DYNAMIC_CLASS(wxSimpleHtmlListBoxXmlHandler
, wxXmlResourceHandler
)
29 wxSimpleHtmlListBoxXmlHandler::wxSimpleHtmlListBoxXmlHandler()
30 : wxXmlResourceHandler(), m_insideBox(false)
32 XRC_ADD_STYLE(wxHLB_DEFAULT_STYLE
);
33 XRC_ADD_STYLE(wxHLB_MULTIPLE
);
37 wxObject
*wxSimpleHtmlListBoxXmlHandler::DoCreateResource()
39 if ( m_class
== wxT("wxSimpleHtmlListBox"))
42 long selection
= GetLong(wxT("selection"), -1);
44 // need to build the list of strings from children
46 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
49 XRC_MAKE_INSTANCE(control
, wxSimpleHtmlListBox
)
51 control
->Create(m_parentAsWindow
,
53 GetPosition(), GetSize(),
55 GetStyle(wxT("style"), wxHLB_DEFAULT_STYLE
),
60 control
->SetSelection(selection
);
63 strList
.Clear(); // dump the strings
70 // handle <item>Label</item>
73 wxString str
= GetNodeContent(m_node
);
74 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
75 str
= wxGetTranslation(str
, m_resource
->GetDomain());
82 bool wxSimpleHtmlListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
84 return (IsOfClass(node
, wxT("wxSimpleHtmlListBox")) ||
85 (m_insideBox
&& node
->GetName() == wxT("item")));
88 #endif // wxUSE_XRC && wxUSE_HTML