]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xrc/xh_combo.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC resource for wxRadioBox
4 // Author: Bob Mitchell
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_combo.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xrc/xh_combo.h"
23 #include "wx/combobox.h"
28 wxComboBoxXmlHandler::wxComboBoxXmlHandler()
29 : wxXmlResourceHandler() , m_insideBox(FALSE
)
31 XRC_ADD_STYLE(wxCB_SIMPLE
);
32 XRC_ADD_STYLE(wxCB_SORT
);
33 XRC_ADD_STYLE(wxCB_READONLY
);
34 XRC_ADD_STYLE(wxCB_DROPDOWN
);
38 wxObject
*wxComboBoxXmlHandler::DoCreateResource()
40 if( m_class
== wxT("wxComboBox"))
43 long selection
= GetLong( wxT("selection"), -1 );
45 // need to build the list of strings from children
47 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
48 wxString
*strings
= (wxString
*) NULL
;
49 if (strList
.GetCount() > 0)
51 strings
= new wxString
[strList
.GetCount()];
52 int count
= strList
.GetCount();
53 for (int i
= 0; i
< count
; i
++)
54 strings
[i
]=strList
[i
];
57 XRC_MAKE_INSTANCE(control
, wxComboBox
)
59 control
->Create(m_parentAsWindow
,
61 GetText(wxT("value")),
62 GetPosition(), GetSize(),
70 control
->SetSelection(selection
);
76 strList
.Clear(); // dump the strings
83 // handle <item>Label</item>
86 wxString str
= GetNodeContent(m_node
);
87 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
88 str
= wxGetTranslation(str
);
95 bool wxComboBoxXmlHandler::CanHandle(wxXmlNode
*node
)
97 return (IsOfClass(node
, wxT("wxComboBox")) ||
98 (m_insideBox
&& node
->GetName() == wxT("item")));