]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_editlbox.cpp
Fix compilation with MinGW -std=c++11 option.
[wxWidgets.git] / src / xrc / xh_editlbox.cpp
CommitLineData
adcda299
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/xrc/xh_editlbox.cpp
3// Purpose: implementation of wxEditableListBox XRC handler
4// Author: Vadim Zeitlin
5// Created: 2009-06-04
6// RCS-ID: $Id$
7// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// for compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_XRC && wxUSE_EDITABLELISTBOX
27
28#ifndef WX_PRECOMP
29 #include "wx/intl.h"
30#endif // WX_PRECOMP
31
32#include "wx/editlbox.h"
33#include "wx/xrc/xh_editlbox.h"
34
df27f1dc
VZ
35#include "wx/xml/xml.h"
36
adcda299
VZ
37// ----------------------------------------------------------------------------
38// constants
39// ----------------------------------------------------------------------------
40
41namespace
42{
43
44const char * const EDITLBOX_CLASS_NAME = "wxEditableListBox";
45const char * const EDITLBOX_ITEM_NAME = "item";
46
47} // anonymous namespace
48
49// ============================================================================
50// implementation
51// ============================================================================
52
53IMPLEMENT_DYNAMIC_CLASS(wxEditableListBoxXmlHandler, wxXmlResourceHandler)
54
55wxEditableListBoxXmlHandler::wxEditableListBoxXmlHandler()
56{
57 m_insideBox = false;
58
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);
63
64 AddWindowStyles();
65}
66
67wxObject *wxEditableListBoxXmlHandler::DoCreateResource()
68{
69 if ( m_class == EDITLBOX_CLASS_NAME )
70 {
71 // create the control itself
72 XRC_MAKE_INSTANCE(control, wxEditableListBox)
73
74 control->Create
75 (
76 m_parentAsWindow,
77 GetID(),
78 GetText("label"),
79 GetPosition(),
80 GetSize(),
81 GetStyle(),
82 GetName()
83 );
84
85 SetupWindow(control);
86
87 // if any items are given, add them to the control
88 wxXmlNode * const contents = GetParamNode("content");
89 if ( contents )
90 {
91 m_insideBox = true;
92 CreateChildrenPrivately(NULL, contents);
93 m_insideBox = false;
94
95 control->SetStrings(m_items);
96 m_items.clear();
97 }
98
99 return control;
100 }
101 else if ( m_insideBox && m_node->GetName() == EDITLBOX_ITEM_NAME )
102 {
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);
107
108 return NULL;
109 }
110 else
111 {
112 ReportError("Unexpected node inside wxEditableListBox");
113 return NULL;
114 }
115}
116
117bool wxEditableListBoxXmlHandler::CanHandle(wxXmlNode *node)
118{
119 return IsOfClass(node, EDITLBOX_CLASS_NAME) ||
120 (m_insideBox && node->GetName() == EDITLBOX_ITEM_NAME);
121}
122
123
124#endif // wxUSE_XRC && wxUSE_EDITABLELISTBOX