]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/xrc/xh_listb.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: XML 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 ADD_STYLE(wxLB_SINGLE
);
29 ADD_STYLE(wxLB_MULTIPLE
);
30 ADD_STYLE(wxLB_EXTENDED
);
31 ADD_STYLE(wxLB_HSCROLL
);
32 ADD_STYLE(wxLB_ALWAYS_SB
);
33 ADD_STYLE(wxLB_NEEDED_SB
);
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
];
58 wxListBox
*control
= new wxListBox(m_parentAsWindow
,
60 GetPosition(), GetSize(),
69 control
->SetSelection( selection
);
75 strList
.Clear(); // dump the strings
82 // handle <item>Label</item>
85 strList
.Add( GetNodeContent(m_node
) );
94 bool wxListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
96 return (IsOfClass(node
, wxT("wxListBox")) ||
97 (m_insideBox
&& node
->GetName() == wxT("item"))