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