]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_combo.cpp
Hopefully fixed misplaced printout in libgnomeprint.
[wxWidgets.git] / src / xrc / xh_combo.cpp
CommitLineData
78d14f80 1/////////////////////////////////////////////////////////////////////////////
88a7a4e1 2// Name: src/xrc/xh_combo.cpp
5f6475c1 3// Purpose: XRC resource for wxComboBox
78d14f80
VS
4// Author: Bob Mitchell
5// Created: 2000/03/21
6// RCS-ID: $Id$
7// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
f80ea77b 10
78d14f80
VS
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
621be1ec 18#if wxUSE_XRC && wxUSE_COMBOBOX
a1e4ec87 19
78d14f80 20#include "wx/xrc/xh_combo.h"
88a7a4e1
WS
21
22#ifndef WX_PRECOMP
23 #include "wx/intl.h"
a5bbd1cc 24 #include "wx/combobox.h"
88a7a4e1
WS
25#endif
26
854e189f
VS
27IMPLEMENT_DYNAMIC_CLASS(wxComboBoxXmlHandler, wxXmlResourceHandler)
28
f80ea77b 29wxComboBoxXmlHandler::wxComboBoxXmlHandler()
a5bbd1cc
WS
30 :wxXmlResourceHandler()
31 ,m_insideBox(false)
78d14f80 32{
544fee32
VS
33 XRC_ADD_STYLE(wxCB_SIMPLE);
34 XRC_ADD_STYLE(wxCB_SORT);
35 XRC_ADD_STYLE(wxCB_READONLY);
36 XRC_ADD_STYLE(wxCB_DROPDOWN);
78d14f80
VS
37 AddWindowStyles();
38}
39
40wxObject *wxComboBoxXmlHandler::DoCreateResource()
f80ea77b 41{
78d14f80
VS
42 if( m_class == wxT("wxComboBox"))
43 {
44 // find the selection
45 long selection = GetLong( wxT("selection"), -1 );
46
47 // need to build the list of strings from children
f80ea77b 48 m_insideBox = true;
544fee32 49 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
78d14f80 50
544fee32 51 XRC_MAKE_INSTANCE(control, wxComboBox)
78d14f80 52
544fee32 53 control->Create(m_parentAsWindow,
f2588180
VS
54 GetID(),
55 GetText(wxT("value")),
56 GetPosition(), GetSize(),
187d8152 57 strList,
f2588180
VS
58 GetStyle(),
59 wxDefaultValidator,
60 GetName());
78d14f80 61
544fee32
VS
62 if (selection != -1)
63 control->SetSelection(selection);
78d14f80
VS
64
65 SetupWindow(control);
66
f80ea77b 67 strList.Clear(); // dump the strings
78d14f80
VS
68
69 return control;
70 }
71 else
72 {
73 // on the inside now.
74 // handle <item>Label</item>
75
76 // add to the list
74c107ba
VS
77 wxString str = GetNodeContent(m_node);
78 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
d4a724d4 79 str = wxGetTranslation(str, m_resource->GetDomain());
74c107ba 80 strList.Add(str);
78d14f80
VS
81
82 return NULL;
83 }
78d14f80
VS
84}
85
78d14f80
VS
86bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node)
87{
88 return (IsOfClass(node, wxT("wxComboBox")) ||
544fee32 89 (m_insideBox && node->GetName() == wxT("item")));
78d14f80
VS
90}
91
621be1ec 92#endif // wxUSE_XRC && wxUSE_COMBOBOX