1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_editlbox.cpp
3 // Purpose: implementation of wxEditableListBox XRC handler
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #if wxUSE_XRC && wxUSE_EDITABLELISTBOX
32 #include "wx/editlbox.h"
33 #include "wx/xrc/xh_editlbox.h"
35 #include "wx/xml/xml.h"
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
44 const char * const EDITLBOX_CLASS_NAME
= "wxEditableListBox";
45 const char * const EDITLBOX_ITEM_NAME
= "item";
47 } // anonymous namespace
49 // ============================================================================
51 // ============================================================================
53 IMPLEMENT_DYNAMIC_CLASS(wxEditableListBoxXmlHandler
, wxXmlResourceHandler
)
55 wxEditableListBoxXmlHandler::wxEditableListBoxXmlHandler()
59 XRC_ADD_STYLE(wxEL_ALLOW_NEW
);
60 XRC_ADD_STYLE(wxEL_ALLOW_EDIT
);
61 XRC_ADD_STYLE(wxEL_ALLOW_DELETE
);
62 XRC_ADD_STYLE(wxEL_NO_REORDER
);
67 wxObject
*wxEditableListBoxXmlHandler::DoCreateResource()
69 if ( m_class
== EDITLBOX_CLASS_NAME
)
71 // create the control itself
72 XRC_MAKE_INSTANCE(control
, wxEditableListBox
)
87 // if any items are given, add them to the control
88 wxXmlNode
* const contents
= GetParamNode("content");
92 CreateChildrenPrivately(NULL
, contents
);
95 control
->SetStrings(m_items
);
101 else if ( m_insideBox
&& m_node
->GetName() == EDITLBOX_ITEM_NAME
)
103 wxString str
= GetNodeContent(m_node
);
104 if ( m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
105 str
= wxGetTranslation(str
, m_resource
->GetDomain());
106 m_items
.push_back(str
);
112 ReportError("Unexpected node inside wxEditableListBox");
117 bool wxEditableListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
119 return IsOfClass(node
, EDITLBOX_CLASS_NAME
) ||
120 (m_insideBox
&& node
->GetName() == EDITLBOX_ITEM_NAME
);
124 #endif // wxUSE_XRC && wxUSE_EDITABLELISTBOX