]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_choic.cpp
wxGTK1 : wx/private/eventloopsourcesmanager.h was missing in evtloop.cpp
[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
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
b36e08d0 17#if wxUSE_XRC && wxUSE_CHOICE
a1e4ec87 18
78d14f80 19#include "wx/xrc/xh_choic.h"
88a7a4e1
WS
20
21#ifndef WX_PRECOMP
22 #include "wx/intl.h"
b36e08d0 23 #include "wx/choice.h"
88a7a4e1
WS
24#endif
25
df27f1dc
VZ
26#include "wx/xml/xml.h"
27
854e189f
VS
28IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler)
29
f80ea77b
WS
30wxChoiceXmlHandler::wxChoiceXmlHandler()
31: wxXmlResourceHandler() , m_insideBox(false)
78d14f80 32{
544fee32 33 XRC_ADD_STYLE(wxCB_SORT);
78d14f80
VS
34 AddWindowStyles();
35}
36
37wxObject *wxChoiceXmlHandler::DoCreateResource()
f80ea77b 38{
78d14f80
VS
39 if( m_class == wxT("wxChoice"))
40 {
41 // find the selection
544fee32 42 long selection = GetLong(wxT("selection"), -1);
78d14f80
VS
43
44 // need to build the list of strings from children
f80ea77b 45 m_insideBox = true;
544fee32 46 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
78d14f80 47
544fee32 48 XRC_MAKE_INSTANCE(control, wxChoice)
f2588180
VS
49
50 control->Create(m_parentAsWindow,
51 GetID(),
52 GetPosition(), GetSize(),
187d8152 53 strList,
f2588180
VS
54 GetStyle(),
55 wxDefaultValidator,
56 GetName());
78d14f80 57
544fee32
VS
58 if (selection != -1)
59 control->SetSelection(selection);
78d14f80
VS
60
61 SetupWindow(control);
62
f80ea77b 63 strList.Clear(); // dump the strings
78d14f80
VS
64
65 return control;
66 }
67 else
68 {
69 // on the inside now.
70 // handle <item>Label</item>
f80ea77b 71
78d14f80 72 // add to the list
74c107ba
VS
73 wxString str = GetNodeContent(m_node);
74 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
d4a724d4 75 str = wxGetTranslation(str, m_resource->GetDomain());
74c107ba 76 strList.Add(str);
78d14f80
VS
77
78 return NULL;
79 }
78d14f80
VS
80}
81
78d14f80
VS
82bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node)
83{
84 return (IsOfClass(node, wxT("wxChoice")) ||
544fee32 85 (m_insideBox && node->GetName() == wxT("item")));
78d14f80 86}
a1e4ec87 87
b36e08d0 88#endif // wxUSE_XRC && wxUSE_CHOICE