]>
git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_combo.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_combo.cpp
3 // Purpose: XRC resource for wxComboBox
4 // Author: Bob Mitchell
6 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_XRC && wxUSE_COMBOBOX
19 #include "wx/xrc/xh_combo.h"
23 #include "wx/combobox.h"
24 #include "wx/textctrl.h" // for wxTE_PROCESS_ENTER
27 #include "wx/xml/xml.h"
29 IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler
, wxXmlResourceHandler
)
31 wxComboBoxXmlHandler::wxComboBoxXmlHandler()
32 :wxXmlResourceHandler()
35 XRC_ADD_STYLE(wxCB_SIMPLE
);
36 XRC_ADD_STYLE(wxCB_SORT
);
37 XRC_ADD_STYLE(wxCB_READONLY
);
38 XRC_ADD_STYLE(wxCB_DROPDOWN
);
39 XRC_ADD_STYLE(wxTE_PROCESS_ENTER
);
43 wxObject
*wxComboBoxXmlHandler::DoCreateResource()
45 if( m_class
== wxT("wxComboBox"))
48 long selection
= GetLong( wxT("selection"), -1 );
50 // need to build the list of strings from children
52 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
54 XRC_MAKE_INSTANCE(control
, wxComboBox
)
56 control
->Create(m_parentAsWindow
,
58 GetText(wxT("value")),
59 GetPosition(), GetSize(),
66 control
->SetSelection(selection
);
70 strList
.Clear(); // dump the strings
77 // handle <item>Label</item>
80 wxString str
= GetNodeContent(m_node
);
81 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
82 str
= wxGetTranslation(str
, m_resource
->GetDomain());
89 bool wxComboBoxXmlHandler::CanHandle(wxXmlNode
*node
)
91 return (IsOfClass(node
, wxT("wxComboBox")) ||
92 (m_insideBox
&& node
->GetName() == wxT("item")));
95 #endif // wxUSE_XRC && wxUSE_COMBOBOX