00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include <wx/wx.h>
00012
00013 #include "xh_odcombo.h"
00014
00015 #if wxXTRA_XH_ODCOMBO
00016 #include "odcombo.h"
00017
00018 IMPLEMENT_DYNAMIC_CLASS(wxOwnerDrawnComboBoxXmlHandler, wxXmlResourceHandler)
00019
00020 wxOwnerDrawnComboBoxXmlHandler::wxOwnerDrawnComboBoxXmlHandler()
00021 :wxXmlResourceHandler()
00022 ,m_insideBox(false)
00023 {
00024 XRC_ADD_STYLE(wxCB_SIMPLE);
00025 XRC_ADD_STYLE(wxCB_SORT);
00026 XRC_ADD_STYLE(wxCB_READONLY);
00027 XRC_ADD_STYLE(wxCB_DROPDOWN);
00028 XRC_ADD_STYLE(wxODCB_STD_CONTROL_PAINT);
00029 XRC_ADD_STYLE(wxODCB_DCLICK_CYCLES);
00030 XRC_ADD_STYLE(wxTE_PROCESS_ENTER);
00031 AddWindowStyles();
00032 }
00033
00034 wxObject *wxOwnerDrawnComboBoxXmlHandler::DoCreateResource()
00035 {
00036 if( m_class == wxT("wxOwnerDrawnComboBox"))
00037 {
00038
00039 long selection = GetLong( wxT("selection"), -1 );
00040
00041
00042 m_insideBox = true;
00043 CreateChildrenPrivately(NULL, GetParamNode(wxT("content")));
00044 wxString *strings = (wxString *) NULL;
00045 if (strList.GetCount() > 0)
00046 {
00047 strings = new wxString[strList.GetCount()];
00048 int count = strList.GetCount();
00049 for (int i = 0; i < count; i++)
00050 strings[i]=strList[i];
00051 }
00052
00053 XRC_MAKE_INSTANCE(control, wxOwnerDrawnComboBox)
00054
00055 control->Create(m_parentAsWindow,
00056 GetID(),
00057 GetText(wxT("value")),
00058 GetPosition(), GetSize(),
00059 strList.GetCount(),
00060 strings,
00061 GetStyle(),
00062 wxDefaultValidator,
00063 GetName());
00064
00065 wxSize ButtonSize=GetSize(wxT("buttonsize"));
00066
00067 if (ButtonSize != wxDefaultSize)
00068 control->SetButtonPosition(ButtonSize.GetWidth(), ButtonSize.GetHeight());
00069
00070 if (selection != -1)
00071 control->SetSelection(selection);
00072
00073 SetupWindow(control);
00074
00075 if (strings != NULL)
00076 delete[] strings;
00077 strList.Clear();
00078
00079 return control;
00080 }
00081 else
00082 {
00083
00084
00085
00086
00087 wxString str = GetNodeContent(m_node);
00088 if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
00089 str = wxGetTranslation(str);
00090 strList.Add(str);
00091
00092 return NULL;
00093 }
00094 }
00095
00096 bool wxOwnerDrawnComboBoxXmlHandler::CanHandle(wxXmlNode *node)
00097 {
00098 #if wxABI_VERSION >= 20700
00099
00100 return (IsOfClass(node, wxT("wxOwnerDrawnComboBox")) ||
00101 (m_insideBox && node->GetName() == wxT("item")));
00102
00103 #else
00104
00105
00106
00107
00108
00109
00110
00111 bool fOurClass = node->GetPropVal(wxT("class"), wxEmptyString) == wxT("wxOwnerDrawnComboBox");
00112 return (fOurClass ||
00113 (m_insideBox && node->GetName() == wxT("item")));
00114 #endif
00115 }
00116
00117 #endif // wxUSE_XRC && wxUSE_ODCOMBOBOX