]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xrc/xh_listb.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XRC resource for wxListBox
4 // Author: Bob Mitchell & Vaclav Slavik
7 // Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "xh_listb.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/xrc/xh_listb.h"
23 #include "wx/listbox.h"
25 wxListBoxXmlHandler::wxListBoxXmlHandler()
26 : wxXmlResourceHandler() , m_insideBox(FALSE
)
28 XRC_ADD_STYLE(wxLB_SINGLE
);
29 XRC_ADD_STYLE(wxLB_MULTIPLE
);
30 XRC_ADD_STYLE(wxLB_EXTENDED
);
31 XRC_ADD_STYLE(wxLB_HSCROLL
);
32 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
33 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
34 XRC_ADD_STYLE(wxLB_SORT
);
38 wxObject
*wxListBoxXmlHandler::DoCreateResource()
40 if( m_class
== wxT("wxListBox"))
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
, wxListBox
)
59 control
->Create(m_parentAsWindow
,
61 GetPosition(), GetSize(),
69 control
->SetSelection(selection
);
75 strList
.Clear(); // dump the strings
82 // handle <item>Label</item>
85 strList
.Add(GetNodeContent(m_node
));
91 bool wxListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
93 return (IsOfClass(node
, wxT("wxListBox")) ||
94 (m_insideBox
&& node
->GetName() == wxT("item")));