]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_choic.cpp
Hacks for wine.
[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
854e189f
VS
27IMPLEMENT_DYNAMIC_CLASS(wxChoiceXmlHandler, wxXmlResourceHandler)
28
f80ea77b
WS
29wxChoiceXmlHandler::wxChoiceXmlHandler()
30: wxXmlResourceHandler() , m_insideBox(false)
78d14f80 31{
544fee32 32 XRC_ADD_STYLE(wxCB_SORT);
78d14f80
VS
33 AddWindowStyles();
34}
35
36wxObject *wxChoiceXmlHandler::DoCreateResource()
f80ea77b 37{
78d14f80
VS
38 if( m_class == wxT("wxChoice"))
39 {
40 // find the selection
544fee32 41 long selection = GetLong(wxT("selection"), -1);
78d14f80
VS
42
43 // need to build the list of strings from children
f80ea77b 44 m_insideBox = true;
544fee32 45 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
78d14f80 46 wxString *strings = (wxString *) NULL;
544fee32 47 if (strList.GetCount() > 0)
78d14f80
VS
48 {
49 strings = new wxString[strList.GetCount()];
50 int count = strList.GetCount();
544fee32 51 for (int i = 0; i < count; i++)
78d14f80
VS
52 strings[i]=strList[i];
53 }
54
544fee32 55 XRC_MAKE_INSTANCE(control, wxChoice)
f2588180
VS
56
57 control->Create(m_parentAsWindow,
58 GetID(),
59 GetPosition(), GetSize(),
60 strList.GetCount(),
61 strings,
62 GetStyle(),
63 wxDefaultValidator,
64 GetName());
78d14f80 65
544fee32
VS
66 if (selection != -1)
67 control->SetSelection(selection);
78d14f80
VS
68
69 SetupWindow(control);
70
544fee32
VS
71 if (strings != NULL)
72 delete[] strings;
f80ea77b 73 strList.Clear(); // dump the strings
78d14f80
VS
74
75 return control;
76 }
77 else
78 {
79 // on the inside now.
80 // handle <item>Label</item>
f80ea77b 81
78d14f80 82 // add to the list
74c107ba
VS
83 wxString str = GetNodeContent(m_node);
84 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
d4a724d4 85 str = wxGetTranslation(str, m_resource->GetDomain());
74c107ba 86 strList.Add(str);
78d14f80
VS
87
88 return NULL;
89 }
78d14f80
VS
90}
91
78d14f80
VS
92bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node)
93{
94 return (IsOfClass(node, wxT("wxChoice")) ||
544fee32 95 (m_insideBox && node->GetName() == wxT("item")));
78d14f80 96}
a1e4ec87 97
b36e08d0 98#endif // wxUSE_XRC && wxUSE_CHOICE