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"
26 #include "wx/odcombo.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxOwnerDrawnComboBoxXmlHandler
, wxXmlResourceHandler
)
30 wxOwnerDrawnComboBoxXmlHandler::wxOwnerDrawnComboBoxXmlHandler()
31 :wxXmlResourceHandler()
34 XRC_ADD_STYLE(wxCB_SIMPLE
);
35 XRC_ADD_STYLE(wxCB_SORT
);
36 XRC_ADD_STYLE(wxCB_READONLY
);
37 XRC_ADD_STYLE(wxCB_DROPDOWN
);
38 XRC_ADD_STYLE(wxODCB_STD_CONTROL_PAINT
);
39 XRC_ADD_STYLE(wxODCB_DCLICK_CYCLES
);
43 wxObject
*wxOwnerDrawnComboBoxXmlHandler::DoCreateResource()
45 if( m_class
== wxT("wxOwnerDrawnComboBox"))
48 long selection
= GetLong( wxT("selection"), -1 );
50 // need to build the list of strings from children
52 CreateChildrenPrivately(NULL
, GetParamNode(wxT("content")));
53 wxString
*strings
= (wxString
*) NULL
;
54 if (strList
.GetCount() > 0)
56 strings
= new wxString
[strList
.GetCount()];
57 int count
= strList
.GetCount();
58 for (int i
= 0; i
< count
; i
++)
59 strings
[i
]=strList
[i
];
62 XRC_MAKE_INSTANCE(control
, wxOwnerDrawnComboBox
)
64 control
->Create(m_parentAsWindow
,
66 GetText(wxT("value")),
67 GetPosition(), GetSize(),
74 wxSize ButtonSize
=GetSize(wxT("buttonsize"));
76 if (ButtonSize
!= wxDefaultSize
)
77 control
->SetButtonPosition(ButtonSize
.GetWidth(), ButtonSize
.GetHeight());
80 control
->SetSelection(selection
);
86 strList
.Clear(); // dump the strings
93 // handle <item>Label</item>
96 wxString str
= GetNodeContent(m_node
);
97 if (m_resource
->GetFlags() & wxXRC_USE_LOCALE
)
98 str
= wxGetTranslation(str
);
105 bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode
*node
)
107 // Avoid GCC bug - this fails on certain GCC 3.x builds for an unknown reason
108 // return (IsOfClass(node, wxT("wxOwnerDrawnComboBox")) ||
109 // (m_insideBox && node->GetName() == wxT("item")));
111 bool fOurClass
= node
->GetPropVal(wxT("class"), wxEmptyString
) == wxT("wxOwnerDrawnComboBox");
113 (m_insideBox
&& node
->GetName() == wxT("item")));
117 #endif // wxUSE_XRC && wxUSE_ODCOMBOBOX