]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_bmpcbox.cpp
Update OpenVMS compile support
[wxWidgets.git] / src / xrc / xh_bmpcbox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_bmpcbox.cpp
3 // Purpose: XRC resource for wxBitmapComboBox
4 // Author: Jaakko Salli
5 // Created: Sep-10-2006
6 // Copyright: (c) 2006 Jaakko Salli
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #if wxUSE_XRC && wxUSE_BITMAPCOMBOBOX
18
19 #include "wx/xrc/xh_bmpcbox.h"
20
21 #ifndef WX_PRECOMP
22 #include "wx/intl.h"
23 #include "wx/log.h"
24 #endif
25
26 #include "wx/bmpcbox.h"
27
28 #include "wx/xml/xml.h"
29
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBoxXmlHandler, wxXmlResourceHandler)
31
32 wxBitmapComboBoxXmlHandler::wxBitmapComboBoxXmlHandler()
33 :wxXmlResourceHandler()
34 ,m_combobox(NULL)
35 ,m_isInside(false)
36 {
37 XRC_ADD_STYLE(wxCB_SORT);
38 XRC_ADD_STYLE(wxCB_READONLY);
39 AddWindowStyles();
40 }
41
42 wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource()
43 {
44 if (m_class == wxT("ownerdrawnitem"))
45 {
46 if ( !m_combobox )
47 {
48 ReportError("ownerdrawnitem only allowed within a wxBitmapComboBox");
49 return NULL;
50 }
51
52 m_combobox->Append(GetText(wxT("text")),
53 GetBitmap(wxT("bitmap")));
54
55 return m_combobox;
56 }
57 else /*if( m_class == wxT("wxBitmapComboBox"))*/
58 {
59 // find the selection
60 long selection = GetLong( wxT("selection"), -1 );
61
62 XRC_MAKE_INSTANCE(control, wxBitmapComboBox)
63
64 control->Create(m_parentAsWindow,
65 GetID(),
66 GetText(wxT("value")),
67 GetPosition(), GetSize(),
68 0,
69 NULL,
70 GetStyle(),
71 wxDefaultValidator,
72 GetName());
73
74 m_isInside = true;
75 m_combobox = control;
76
77 wxXmlNode *children_node = GetParamNode(wxT("object"));
78
79 wxXmlNode *n = children_node;
80
81 while (n)
82 {
83 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
84 (n->GetName() == wxT("object")))
85 {
86 CreateResFromNode(n, control, NULL);
87 }
88 n = n->GetNext();
89 }
90
91 m_isInside = false;
92 m_combobox = NULL;
93
94 if (selection != -1)
95 control->SetSelection(selection);
96
97 SetupWindow(control);
98
99 return control;
100 }
101 }
102
103 bool wxBitmapComboBoxXmlHandler::CanHandle(wxXmlNode *node)
104 {
105 return ((!m_isInside && IsOfClass(node, wxT("wxBitmapComboBox"))) ||
106 (m_isInside && IsOfClass(node, wxT("ownerdrawnitem"))));
107 }
108
109 #endif // wxUSE_XRC && wxUSE_BITMAPCOMBOBOX