]>
Commit | Line | Data |
---|---|---|
78d14f80 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: xh_combo.cpp | |
b5d6954b | 3 | // Purpose: XRC resource for wxRadioBox |
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 | ||
621be1ec | 18 | #if wxUSE_XRC && wxUSE_COMBOBOX |
a1e4ec87 | 19 | |
78d14f80 VS |
20 | #include "wx/xrc/xh_combo.h" |
21 | #include "wx/combobox.h" | |
02df3799 | 22 | #include "wx/intl.h" |
78d14f80 | 23 | |
854e189f VS |
24 | IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler) |
25 | ||
f80ea77b WS |
26 | wxComboBoxXmlHandler::wxComboBoxXmlHandler() |
27 | : wxXmlResourceHandler() , m_insideBox(false) | |
78d14f80 | 28 | { |
544fee32 VS |
29 | XRC_ADD_STYLE(wxCB_SIMPLE); |
30 | XRC_ADD_STYLE(wxCB_SORT); | |
31 | XRC_ADD_STYLE(wxCB_READONLY); | |
32 | XRC_ADD_STYLE(wxCB_DROPDOWN); | |
78d14f80 VS |
33 | AddWindowStyles(); |
34 | } | |
35 | ||
36 | wxObject *wxComboBoxXmlHandler::DoCreateResource() | |
f80ea77b | 37 | { |
78d14f80 VS |
38 | if( m_class == wxT("wxComboBox")) |
39 | { | |
40 | // find the selection | |
41 | long selection = GetLong( wxT("selection"), -1 ); | |
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, wxComboBox) |
78d14f80 | 56 | |
544fee32 | 57 | control->Create(m_parentAsWindow, |
f2588180 VS |
58 | GetID(), |
59 | GetText(wxT("value")), | |
60 | GetPosition(), GetSize(), | |
61 | strList.GetCount(), | |
62 | strings, | |
63 | GetStyle(), | |
64 | wxDefaultValidator, | |
65 | GetName()); | |
78d14f80 | 66 | |
544fee32 VS |
67 | if (selection != -1) |
68 | control->SetSelection(selection); | |
78d14f80 VS |
69 | |
70 | SetupWindow(control); | |
71 | ||
544fee32 VS |
72 | if (strings != NULL) |
73 | delete[] strings; | |
f80ea77b | 74 | strList.Clear(); // dump the strings |
78d14f80 VS |
75 | |
76 | return control; | |
77 | } | |
78 | else | |
79 | { | |
80 | // on the inside now. | |
81 | // handle <item>Label</item> | |
82 | ||
83 | // add to the list | |
74c107ba VS |
84 | wxString str = GetNodeContent(m_node); |
85 | if (m_resource->GetFlags() & wxXRC_USE_LOCALE) | |
86 | str = wxGetTranslation(str); | |
87 | strList.Add(str); | |
78d14f80 VS |
88 | |
89 | return NULL; | |
90 | } | |
78d14f80 VS |
91 | } |
92 | ||
78d14f80 VS |
93 | bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node) |
94 | { | |
95 | return (IsOfClass(node, wxT("wxComboBox")) || | |
544fee32 | 96 | (m_insideBox && node->GetName() == wxT("item"))); |
78d14f80 VS |
97 | } |
98 | ||
621be1ec | 99 | #endif // wxUSE_XRC && wxUSE_COMBOBOX |