]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_combo.cpp
Reflect changes in stc.cpp in stc.cpp.in from which it's generated.
[wxWidgets.git] / src / xrc / xh_combo.cpp
CommitLineData
78d14f80 1/////////////////////////////////////////////////////////////////////////////
88a7a4e1 2// Name: src/xrc/xh_combo.cpp
5f6475c1 3// Purpose: XRC resource for wxComboBox
78d14f80
VS
4// Author: Bob Mitchell
5// Created: 2000/03/21
78d14f80
VS
6// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
f80ea77b 9
78d14f80
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
621be1ec 17#if wxUSE_XRC && wxUSE_COMBOBOX
a1e4ec87 18
78d14f80 19#include "wx/xrc/xh_combo.h"
88a7a4e1
WS
20
21#ifndef WX_PRECOMP
22 #include "wx/intl.h"
a5bbd1cc 23 #include "wx/combobox.h"
7920be66 24 #include "wx/textctrl.h" // for wxTE_PROCESS_ENTER
88a7a4e1
WS
25#endif
26
df27f1dc
VZ
27#include "wx/xml/xml.h"
28
854e189f
VS
29IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler)
30
f80ea77b 31wxComboBoxXmlHandler::wxComboBoxXmlHandler()
a5bbd1cc
WS
32 :wxXmlResourceHandler()
33 ,m_insideBox(false)
78d14f80 34{
544fee32
VS
35 XRC_ADD_STYLE(wxCB_SIMPLE);
36 XRC_ADD_STYLE(wxCB_SORT);
37 XRC_ADD_STYLE(wxCB_READONLY);
38 XRC_ADD_STYLE(wxCB_DROPDOWN);
1d196b01 39 XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
78d14f80
VS
40 AddWindowStyles();
41}
42
43wxObject *wxComboBoxXmlHandler::DoCreateResource()
f80ea77b 44{
78d14f80
VS
45 if( m_class == wxT("wxComboBox"))
46 {
47 // find the selection
48 long selection = GetLong( wxT("selection"), -1 );
49
50 // need to build the list of strings from children
f80ea77b 51 m_insideBox = true;
544fee32 52 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
78d14f80 53
544fee32 54 XRC_MAKE_INSTANCE(control, wxComboBox)
78d14f80 55
544fee32 56 control->Create(m_parentAsWindow,
f2588180
VS
57 GetID(),
58 GetText(wxT("value")),
59 GetPosition(), GetSize(),
187d8152 60 strList,
f2588180
VS
61 GetStyle(),
62 wxDefaultValidator,
63 GetName());
78d14f80 64
544fee32
VS
65 if (selection != -1)
66 control->SetSelection(selection);
78d14f80
VS
67
68 SetupWindow(control);
69
f80ea77b 70 strList.Clear(); // dump the strings
78d14f80
VS
71
72 return control;
73 }
74 else
75 {
76 // on the inside now.
77 // handle <item>Label</item>
78
79 // add to the list
74c107ba
VS
80 wxString str = GetNodeContent(m_node);
81 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
d4a724d4 82 str = wxGetTranslation(str, m_resource->GetDomain());
74c107ba 83 strList.Add(str);
78d14f80
VS
84
85 return NULL;
86 }
78d14f80
VS
87}
88
78d14f80
VS
89bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node)
90{
91 return (IsOfClass(node, wxT("wxComboBox")) ||
544fee32 92 (m_insideBox && node->GetName() == wxT("item")));
78d14f80
VS
93}
94
621be1ec 95#endif // wxUSE_XRC && wxUSE_COMBOBOX