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