]>
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"
26 IMPLEMENT_DYNAMIC_CLASS(wxListBoxXmlHandler
, wxXmlResourceHandler
)
28 wxListBoxXmlHandler::wxListBoxXmlHandler()
29 : wxXmlResourceHandler() , m_insideBox(FALSE
)
31 XRC_ADD_STYLE(wxLB_SINGLE
);
32 XRC_ADD_STYLE(wxLB_MULTIPLE
);
33 XRC_ADD_STYLE(wxLB_EXTENDED
);
34 XRC_ADD_STYLE(wxLB_HSCROLL
);
35 XRC_ADD_STYLE(wxLB_ALWAYS_SB
);
36 XRC_ADD_STYLE(wxLB_NEEDED_SB
);
37 XRC_ADD_STYLE(wxLB_SORT
);
41 wxObject
*wxListBoxXmlHandler::DoCreateResource()
43 if( m_class
== wxT("wxListBox"))
46 long selection
= GetLong(wxT("selection"), -1);
48 // need to build the list of strings from children
50 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
51 wxString
*strings
= (wxString
*) NULL
;
52 if (strList
.GetCount() > 0)
54 strings
= new wxString
[strList
.GetCount()];
55 int count
= strList
.GetCount();
56 for (int i
= 0; i
< count
; i
++)
57 strings
[i
]=strList
[i
];
60 XRC_MAKE_INSTANCE(control
, 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 wxString str
= GetNodeContent(m_node
);
89 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
90 str
= wxGetTranslation(str
);
97 bool wxListBoxXmlHandler::CanHandle(wxXmlNode
*node
)
99 return (IsOfClass(node
, wxT("wxListBox")) ||
100 (m_insideBox
&& node
->GetName() == wxT("item")));