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 IMPLEMENT_DYNAMIC_CLASS(wxOwnerDrawnComboBoxXmlHandler
, wxXmlResourceHandler
)
31 wxOwnerDrawnComboBoxXmlHandler::wxOwnerDrawnComboBoxXmlHandler()
32 :wxXmlResourceHandler()
35 XRC_ADD_STYLE(wxCB_SIMPLE
);
36 XRC_ADD_STYLE(wxCB_SORT
);
37 XRC_ADD_STYLE(wxCB_READONLY
);
38 XRC_ADD_STYLE(wxCB_DROPDOWN
);
39 XRC_ADD_STYLE(wxODCB_STD_CONTROL_PAINT
);
40 XRC_ADD_STYLE(wxODCB_DCLICK_CYCLES
);
41 XRC_ADD_STYLE(wxTE_PROCESS_ENTER
);
45 wxObject
*wxOwnerDrawnComboBoxXmlHandler::DoCreateResource()
47 if( m_class
== wxT("wxOwnerDrawnComboBox"))
50 long selection
= GetLong( wxT("selection"), -1 );
52 // need to build the list of strings from children
54 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
56 XRC_MAKE_INSTANCE(control
, wxOwnerDrawnComboBox
)
58 control
->Create(m_parentAsWindow
,
60 GetText(wxT("value")),
61 GetPosition(), GetSize(),
67 wxSize sizeBtn
=GetSize(wxT("buttonsize"));
69 if (sizeBtn
!= wxDefaultSize
)
70 control
->SetButtonPosition(sizeBtn
.GetWidth(), sizeBtn
.GetHeight());
73 control
->SetSelection(selection
);
77 strList
.Clear(); // dump the strings
84 // handle <item>Label</item>
87 wxString str
= GetNodeContent(m_node
);
88 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
89 str
= wxGetTranslation(str
, m_resource
->GetDomain());
96 bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode
*node
)
98 #if wxCHECK_VERSION(2,7,0)
100 return (IsOfClass(node
, wxT("wxOwnerDrawnComboBox")) ||
101 (m_insideBox
&& node
->GetName() == wxT("item")));
105 // Avoid GCC bug - this fails on certain GCC 3.3 and 3.4 builds for an unknown reason
106 // it is believed to be related to the fact IsOfClass is inline, and node->GetAttribute
107 // gets passed an invalid "this" pointer. On 2.7, the function is out of line, so the
108 // above should work fine. This code is left in here so this file can easily be used
109 // in a version backported to 2.6. All we are doing here is expanding the macro
111 bool fOurClass
= node
->GetAttribute(wxT("class"), wxEmptyString
) == wxT("wxOwnerDrawnComboBox");
113 (m_insideBox
&& node
->GetName() == wxT("item")));
117 #endif // wxUSE_XRC && wxUSE_ODCOMBOBOX