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