]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_listb.cpp
Applied patch [ 709618 ] fixes drawing position in wxPrinterDC::DoBlit()
[wxWidgets.git] / src / xrc / xh_listb.cpp
CommitLineData
78d14f80
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: xh_listb.cpp
b5d6954b 3// Purpose: XRC resource for wxListBox
78d14f80
VS
4// Author: Bob Mitchell & Vaclav Slavik
5// Created: 2000/07/29
6// RCS-ID: $Id$
7// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifdef __GNUG__
12#pragma implementation "xh_listb.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
22#include "wx/xrc/xh_listb.h"
23#include "wx/listbox.h"
02df3799 24#include "wx/intl.h"
78d14f80
VS
25
26wxListBoxXmlHandler::wxListBoxXmlHandler()
27: wxXmlResourceHandler() , m_insideBox(FALSE)
28{
544fee32
VS
29 XRC_ADD_STYLE(wxLB_SINGLE);
30 XRC_ADD_STYLE(wxLB_MULTIPLE);
31 XRC_ADD_STYLE(wxLB_EXTENDED);
32 XRC_ADD_STYLE(wxLB_HSCROLL);
33 XRC_ADD_STYLE(wxLB_ALWAYS_SB);
34 XRC_ADD_STYLE(wxLB_NEEDED_SB);
35 XRC_ADD_STYLE(wxLB_SORT);
78d14f80
VS
36 AddWindowStyles();
37}
38
39wxObject *wxListBoxXmlHandler::DoCreateResource()
40{
41 if( m_class == wxT("wxListBox"))
42 {
43 // find the selection
544fee32 44 long selection = GetLong(wxT("selection"), -1);
78d14f80
VS
45
46 // need to build the list of strings from children
47 m_insideBox = TRUE;
544fee32 48 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
78d14f80 49 wxString *strings = (wxString *) NULL;
544fee32 50 if (strList.GetCount() > 0)
78d14f80
VS
51 {
52 strings = new wxString[strList.GetCount()];
53 int count = strList.GetCount();
544fee32 54 for (int i = 0; i < count; i++)
78d14f80
VS
55 strings[i]=strList[i];
56 }
57
544fee32 58 XRC_MAKE_INSTANCE(control, wxListBox)
f2588180
VS
59
60 control->Create(m_parentAsWindow,
61 GetID(),
62 GetPosition(), GetSize(),
63 strList.GetCount(),
64 strings,
65 GetStyle(),
66 wxDefaultValidator,
67 GetName());
78d14f80 68
544fee32
VS
69 if (selection != -1)
70 control->SetSelection(selection);
78d14f80
VS
71
72 SetupWindow(control);
73
544fee32
VS
74 if (strings != NULL)
75 delete[] strings;
78d14f80
VS
76 strList.Clear(); // dump the strings
77
78 return control;
79 }
80 else
81 {
82 // on the inside now.
83 // handle <item>Label</item>
84
85 // add to the list
74c107ba
VS
86 wxString str = GetNodeContent(m_node);
87 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
88 str = wxGetTranslation(str);
89 strList.Add(str);
78d14f80
VS
90
91 return NULL;
92 }
78d14f80
VS
93}
94
78d14f80
VS
95bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node)
96{
97 return (IsOfClass(node, wxT("wxListBox")) ||
544fee32 98 (m_insideBox && node->GetName() == wxT("item")));
78d14f80 99}