1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/xrc/xh_odcombo.cpp
3 // Purpose: XRC resource for wxRadioBox
4 // Author: Alex Bligh - Based on src/xrc/xh_combo.cpp
7 // Copyright: (c) 2006 Alex Bligh
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #if wxUSE_XRC && wxUSE_ODCOMBOBOX
20 #include "wx/xrc/xh_odcombo.h"
24 #include "wx/textctrl.h"
27 #include "wx/odcombo.h"
29 #include "wx/xml/xml.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxOwnerDrawnComboBoxXmlHandler
, wxXmlResourceHandler
)
33 wxOwnerDrawnComboBoxXmlHandler::wxOwnerDrawnComboBoxXmlHandler()
34 :wxXmlResourceHandler()
37 XRC_ADD_STYLE(wxCB_SIMPLE
);
38 XRC_ADD_STYLE(wxCB_SORT
);
39 XRC_ADD_STYLE(wxCB_READONLY
);
40 XRC_ADD_STYLE(wxCB_DROPDOWN
);
41 XRC_ADD_STYLE(wxODCB_STD_CONTROL_PAINT
);
42 XRC_ADD_STYLE(wxODCB_DCLICK_CYCLES
);
43 XRC_ADD_STYLE(wxTE_PROCESS_ENTER
);
47 wxObject
*wxOwnerDrawnComboBoxXmlHandler::DoCreateResource()
49 if( m_class
== wxT("wxOwnerDrawnComboBox"))
52 long selection
= GetLong( wxT("selection"), -1 );
54 // need to build the list of strings from children
56 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
58 XRC_MAKE_INSTANCE(control
, wxOwnerDrawnComboBox
)
60 control
->Create(m_parentAsWindow
,
62 GetText(wxT("value")),
63 GetPosition(), GetSize(),
69 wxSize sizeBtn
=GetSize(wxT("buttonsize"));
71 if (sizeBtn
!= wxDefaultSize
)
72 control
->SetButtonPosition(sizeBtn
.GetWidth(), sizeBtn
.GetHeight());
75 control
->SetSelection(selection
);
79 strList
.Clear(); // dump the strings
86 // handle <item>Label</item>
89 wxString str
= GetNodeContent(m_node
);
90 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
91 str
= wxGetTranslation(str
, m_resource
->GetDomain());
98 bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode
*node
)
100 #if wxCHECK_VERSION(2,7,0)
102 return (IsOfClass(node
, wxT("wxOwnerDrawnComboBox")) ||
103 (m_insideBox
&& node
->GetName() == wxT("item")));
107 // Avoid GCC bug - this fails on certain GCC 3.3 and 3.4 builds for an unknown reason
108 // it is believed to be related to the fact IsOfClass is inline, and node->GetAttribute
109 // gets passed an invalid "this" pointer. On 2.7, the function is out of line, so the
110 // above should work fine. This code is left in here so this file can easily be used
111 // in a version backported to 2.6. All we are doing here is expanding the macro
113 bool fOurClass
= node
->GetAttribute(wxT("class"), wxEmptyString
) == wxT("wxOwnerDrawnComboBox");
115 (m_insideBox
&& node
->GetName() == wxT("item")));
119 #endif // wxUSE_XRC && wxUSE_ODCOMBOBOX