]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_bmpcbox.cpp
Workaround for #15404: wxRichTextCtrl: caret does not disappear when focus is lost...
[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
95a46303
RR
6// Copyright: (c) 2006 Jaakko Salli
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
17#if wxUSE_XRC && wxUSE_BITMAPCOMBOBOX
18
19#include "wx/xrc/xh_bmpcbox.h"
20
21#ifndef WX_PRECOMP
22 #include "wx/intl.h"
b935c45d 23 #include "wx/log.h"
95a46303
RR
24#endif
25
26#include "wx/bmpcbox.h"
27
df27f1dc
VZ
28#include "wx/xml/xml.h"
29
95a46303
RR
30IMPLEMENT_DYNAMIC_CLASS(wxBitmapComboBoxXmlHandler, wxXmlResourceHandler)
31
32wxBitmapComboBoxXmlHandler::wxBitmapComboBoxXmlHandler()
33 :wxXmlResourceHandler()
34 ,m_combobox(NULL)
35 ,m_isInside(false)
36{
37 XRC_ADD_STYLE(wxCB_SORT);
38 XRC_ADD_STYLE(wxCB_READONLY);
39 AddWindowStyles();
40}
41
42wxObject *wxBitmapComboBoxXmlHandler::DoCreateResource()
43{
44 if (m_class == wxT("ownerdrawnitem"))
45 {
07acc3cc
VZ
46 if ( !m_combobox )
47 {
819559b2 48 ReportError("ownerdrawnitem only allowed within a wxBitmapComboBox");
07acc3cc
VZ
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