]> git.saurik.com Git - wxWidgets.git/blob - src/xrc/xh_bmpcbox.cpp
wxWizard XRC handler should call SetupWindow() to handle standard window properties
[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")),
47 GetBitmap(wxT("bitmap")));
48
49 return m_combobox;
50 }
51 else /*if( m_class == wxT("wxBitmapComboBox"))*/
52 {
53 // find the selection
54 long selection = GetLong( wxT("selection"), -1 );
55
56 XRC_MAKE_INSTANCE(control, wxBitmapComboBox)
57
58 control->Create(m_parentAsWindow,
59 GetID(),
60 GetText(wxT("value")),
61 GetPosition(), GetSize(),
62 0,
63 NULL,
64 GetStyle(),
65 wxDefaultValidator,
66 GetName());
67
68 m_isInside = true;
69 m_combobox = control;
70
71 wxXmlNode *children_node = GetParamNode(wxT("object"));
72
73 wxXmlNode *n = children_node;
74
75 while (n)
76 {
77 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
78 (n->GetName() == wxT("object")))
79 {
80 CreateResFromNode(n, control, NULL);
81 }
82 n = n->GetNext();
83 }
84
85 m_isInside = false;
86 m_combobox = NULL;
87
88 if (selection != -1)
89 control->SetSelection(selection);
90
91 SetupWindow(control);
92
93 return control;
94 }
95 }
96
97 bool wxBitmapComboBoxXmlHandler::CanHandle(wxXmlNode *node)
98 {
99 return ((!m_isInside && IsOfClass(node, wxT("wxBitmapComboBox"))) ||
100 (m_isInside && IsOfClass(node, wxT("ownerdrawnitem"))));
101 }
102
103 #endif // wxUSE_XRC && wxUSE_BITMAPCOMBOBOX