]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_bmpcbox.cpp
Always link with expat in monolithic build.
[wxWidgets.git] / src / xrc / xh_bmpcbox.cpp
CommitLineData
95a46303
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/xrc/xh_bmpcbox.cpp
3// Purpose: XRC resource for wxBitmapComboBox
4// Author: Jaakko Salli
5// Created: Sep-10-2006
1c4e8f38 6// RCS-ID: $Id$
95a46303
RR
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"
b935c45d 24 #include "wx/log.h"
95a46303
RR
25#endif
26
27#include "wx/bmpcbox.h"
28
29IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBoxXmlHandler, wxXmlResourceHandler)
30
31wxBitmapComboBoxXmlHandler::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
41wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource()
42{
43 if (m_class == wxT("ownerdrawnitem"))
44 {
07acc3cc
VZ
45 if ( !m_combobox )
46 {
819559b2 47 ReportError("ownerdrawnitem only allowed within a wxBitmapComboBox");
07acc3cc
VZ
48 return NULL;
49 }
95a46303 50
733b7d1e
VS
51 m_combobox->Append(GetText(wxT("text")),
52 GetBitmap(wxT("bitmap")));
95a46303
RR
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
102bool 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