]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_bmpcbox.cpp
Really fix the problem with caret in wxGrid text editor under MSW.
[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
df27f1dc
VZ
29#include "wx/xml/xml.h"
30
95a46303
RR
31IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBoxXmlHandler, wxXmlResourceHandler)
32
33wxBitmapComboBoxXmlHandler::wxBitmapComboBoxXmlHandler()
34 :wxXmlResourceHandler()
35 ,m_combobox(NULL)
36 ,m_isInside(false)
37{
38 XRC_ADD_STYLE(wxCB_SORT);
39 XRC_ADD_STYLE(wxCB_READONLY);
40 AddWindowStyles();
41}
42
43wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource()
44{
45 if (m_class == wxT("ownerdrawnitem"))
46 {
07acc3cc
VZ
47 if ( !m_combobox )
48 {
819559b2 49 ReportError("ownerdrawnitem only allowed within a wxBitmapComboBox");
07acc3cc
VZ
50 return NULL;
51 }
95a46303 52
733b7d1e
VS
53 m_combobox->Append(GetText(wxT("text")),
54 GetBitmap(wxT("bitmap")));
95a46303
RR
55
56 return m_combobox;
57 }
58 else /*if( m_class == wxT("wxBitmapComboBox"))*/
59 {
60 // find the selection
61 long selection = GetLong( wxT("selection"), -1 );
62
63 XRC_MAKE_INSTANCE(control, wxBitmapComboBox)
64
65 control->Create(m_parentAsWindow,
66 GetID(),
67 GetText(wxT("value")),
68 GetPosition(), GetSize(),
69 0,
70 NULL,
71 GetStyle(),
72 wxDefaultValidator,
73 GetName());
74
75 m_isInside = true;
76 m_combobox = control;
77
78 wxXmlNode *children_node = GetParamNode(wxT("object"));
79
80 wxXmlNode *n = children_node;
81
82 while (n)
83 {
84 if ((n->GetType() == wxXML_ELEMENT_NODE) &&
85 (n->GetName() == wxT("object")))
86 {
87 CreateResFromNode(n, control, NULL);
88 }
89 n = n->GetNext();
90 }
91
92 m_isInside = false;
93 m_combobox = NULL;
94
95 if (selection != -1)
96 control->SetSelection(selection);
97
98 SetupWindow(control);
99
100 return control;
101 }
102}
103
104bool wxBitmapComboBoxXmlHandler::CanHandle(wxXmlNode *node)
105{
106 return ((!m_isInside && IsOfClass(node, wxT("wxBitmapComboBox"))) ||
107 (m_isInside && IsOfClass(node, wxT("ownerdrawnitem"))));
108}
109
110#endif // wxUSE_XRC && wxUSE_BITMAPCOMBOBOX