]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_bmpcbox.cpp
The check column needs more space
[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 {
47 wxLogError(_("XRC syntex error: ownerdrawnitem only allowed within "
48 " a bitmapcombobox!"));
49 return NULL;
50 }
95a46303 51
733b7d1e
VS
52 m_combobox->Append(GetText(wxT("text")),
53 GetBitmap(wxT("bitmap")));
95a46303
RR
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
103bool 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