]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_bmpcbox.cpp
gcc signed/unsigned comparison warning fix
[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 #endif
25
26 #include "wx/bmpcbox.h"
27
28 IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBoxXmlHandler, wxXmlResourceHandler)
29
30 wxBitmapComboBoxXmlHandler::wxBitmapComboBoxXmlHandler()
31 :wxXmlResourceHandler()
32 ,m_combobox(NULL)
33 ,m_isInside(false)
34 {
35 XRC_ADD_STYLE(wxCB_SORT);
36 XRC_ADD_STYLE(wxCB_READONLY);
37 AddWindowStyles();
38 }
39
40 wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource()
41 {
42 if (m_class == wxT("ownerdrawnitem"))
43 {
44 wxCHECK_MSG(m_combobox, NULL, wxT("Incorrect syntax of XRC resource: ownerdrawnitem not within a bitmapcombobox!"));
45
46 m_combobox->Append(GetText(wxT("text")), GetBitmap(wxT("bitmap"), wxART_MISSING_IMAGE));
47
48 return m_combobox;
49 }
50 else /*if( m_class == wxT("wxBitmapComboBox"))*/
51 {
52 // find the selection
53 long selection = GetLong( wxT("selection"), -1 );
54
55 XRC_MAKE_INSTANCE(control, wxBitmapComboBox)
56
57 control->Create(m_parentAsWindow,
58 GetID(),
59 GetText(wxT("value")),
60 GetPosition(), GetSize(),
61 0,
62 NULL,
63 GetStyle(),
64 wxDefaultValidator,
65 GetName());
66
67 m_isInside = true;
68 m_combobox = control;
69
70 wxXmlNode *children_node = GetParamNode(wxT("object"));
71
72 wxXmlNode *n = children_node;
73
74 while (n)
75 {
76 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
77 (n->GetName() == wxT("object")))
78 {
79 CreateResFromNode(n, control, NULL);
80 }
81 n = n->GetNext();
82 }
83
84 m_isInside = false;
85 m_combobox = NULL;
86
87 if (selection != -1)
88 control->SetSelection(selection);
89
90 SetupWindow(control);
91
92 return control;
93 }
94 }
95
96 bool wxBitmapComboBoxXmlHandler::CanHandle(wxXmlNode *node)
97 {
98 return ((!m_isInside && IsOfClass(node, wxT("wxBitmapComboBox"))) ||
99 (m_isInside && IsOfClass(node, wxT("ownerdrawnitem"))));
100 }
101
102 #endif // wxUSE_XRC && wxUSE_BITMAPCOMBOBOX