]>
git.saurik.com Git - wxWidgets.git/blob - 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 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
];
57 wxListBox
*control
= wxStaticCast(m_instance
, wxListBox
);
60 control
= new wxListBox
;
62 control
->Create(m_parentAsWindow
,
64 GetPosition(), GetSize(),
72 control
->SetSelection( selection
);
78 strList
.Clear(); // dump the strings
85 // handle <item>Label</item>
88 strList
.Add( GetNodeContent(m_node
) );
97 bool wxListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
99 return (IsOfClass(node
, wxT("wxListBox")) ||
100 (m_insideBox
&& node
->GetName() == wxT("item"))