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 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
42 const char * const EDITLBOX_CLASS_NAME
= "wxEditableListBox";
43 const char * const EDITLBOX_ITEM_NAME
= "item";
45 } // anonymous namespace
47 // ============================================================================
49 // ============================================================================
51 IMPLEMENT_DYNAMIC_CLASS(wxEditableListBoxXmlHandler
, wxXmlResourceHandler
)
53 wxEditableListBoxXmlHandler::wxEditableListBoxXmlHandler()
57 XRC_ADD_STYLE(wxEL_ALLOW_NEW
);
58 XRC_ADD_STYLE(wxEL_ALLOW_EDIT
);
59 XRC_ADD_STYLE(wxEL_ALLOW_DELETE
);
60 XRC_ADD_STYLE(wxEL_NO_REORDER
);
65 wxObject
*wxEditableListBoxXmlHandler::DoCreateResource()
67 if ( m_class
== EDITLBOX_CLASS_NAME
)
69 // create the control itself
70 XRC_MAKE_INSTANCE(control
, wxEditableListBox
)
85 // if any items are given, add them to the control
86 wxXmlNode
* const contents
= GetParamNode("content");
90 CreateChildrenPrivately(NULL
, contents
);
93 control
->SetStrings(m_items
);
99 else if ( m_insideBox
&& m_node
->GetName() == EDITLBOX_ITEM_NAME
)
101 wxString str
= GetNodeContent(m_node
);
102 if ( m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
103 str
= wxGetTranslation(str
, m_resource
->GetDomain());
104 m_items
.push_back(str
);
110 ReportError("Unexpected node inside wxEditableListBox");
115 bool wxEditableListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
117 return IsOfClass(node
, EDITLBOX_CLASS_NAME
) ||
118 (m_insideBox
&& node
->GetName() == EDITLBOX_ITEM_NAME
);
122 #endif // wxUSE_XRC && wxUSE_EDITABLELISTBOX