1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_editlbox.cpp
3 // Purpose: implementation of wxEditableListBox XRC handler
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
25 #if wxUSE_XRC && wxUSE_EDITABLELISTBOX
31 #include "wx/editlbox.h"
32 #include "wx/xrc/xh_editlbox.h"
34 #include "wx/xml/xml.h"
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
43 const char * const EDITLBOX_CLASS_NAME
= "wxEditableListBox";
44 const char * const EDITLBOX_ITEM_NAME
= "item";
46 } // anonymous namespace
48 // ============================================================================
50 // ============================================================================
52 IMPLEMENT_DYNAMIC_CLASS(wxEditableListBoxXmlHandler
, wxXmlResourceHandler
)
54 wxEditableListBoxXmlHandler::wxEditableListBoxXmlHandler()
58 XRC_ADD_STYLE(wxEL_ALLOW_NEW
);
59 XRC_ADD_STYLE(wxEL_ALLOW_EDIT
);
60 XRC_ADD_STYLE(wxEL_ALLOW_DELETE
);
61 XRC_ADD_STYLE(wxEL_NO_REORDER
);
66 wxObject
*wxEditableListBoxXmlHandler::DoCreateResource()
68 if ( m_class
== EDITLBOX_CLASS_NAME
)
70 // create the control itself
71 XRC_MAKE_INSTANCE(control
, wxEditableListBox
)
86 // if any items are given, add them to the control
87 wxXmlNode
* const contents
= GetParamNode("content");
91 CreateChildrenPrivately(NULL
, contents
);
94 control
->SetStrings(m_items
);
100 else if ( m_insideBox
&& m_node
->GetName() == EDITLBOX_ITEM_NAME
)
102 wxString str
= GetNodeContent(m_node
);
103 if ( m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
104 str
= wxGetTranslation(str
, m_resource
->GetDomain());
105 m_items
.push_back(str
);
111 ReportError("Unexpected node inside wxEditableListBox");
116 bool wxEditableListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
118 return IsOfClass(node
, EDITLBOX_CLASS_NAME
) ||
119 (m_insideBox
&& node
->GetName() == EDITLBOX_ITEM_NAME
);
123 #endif // wxUSE_XRC && wxUSE_EDITABLELISTBOX