1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        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 IMPLEMENT_DYNAMIC_CLASS(wxSimpleHtmlListBoxXmlHandler
, wxXmlResourceHandler
) 
  27 wxSimpleHtmlListBoxXmlHandler::wxSimpleHtmlListBoxXmlHandler() 
  28 : wxXmlResourceHandler(), m_insideBox(false) 
  30     XRC_ADD_STYLE(wxHLB_DEFAULT_STYLE
); 
  31     XRC_ADD_STYLE(wxHLB_MULTIPLE
); 
  35 wxObject 
*wxSimpleHtmlListBoxXmlHandler::DoCreateResource() 
  37     if ( m_class 
== wxT("wxSimpleHtmlListBox")) 
  40         long selection 
= GetLong(wxT("selection"), -1); 
  42         // need to build the list of strings from children 
  44         CreateChildrenPrivately(NULL
, GetParamNode(wxT("content"))); 
  47         XRC_MAKE_INSTANCE(control
, wxSimpleHtmlListBox
) 
  49         control
->Create(m_parentAsWindow
, 
  51                         GetPosition(), GetSize(), 
  53                         GetStyle(_T("style"), wxHLB_DEFAULT_STYLE
), 
  58             control
->SetSelection(selection
); 
  61         strList
.Clear();    // dump the strings 
  68         // handle <item>Label</item> 
  71         wxString str 
= GetNodeContent(m_node
); 
  72         if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
) 
  73             str 
= wxGetTranslation(str
, m_resource
->GetDomain()); 
  80 bool wxSimpleHtmlListBoxXmlHandler::CanHandle(wxXmlNode 
*node
) 
  82     return (IsOfClass(node
, wxT("wxSimpleHtmlListBox")) || 
  83            (m_insideBox 
&& node
->GetName() == wxT("item"))); 
  86 #endif // wxUSE_XRC && wxUSE_HTML