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