xh_gridcombo.cpp

Go to the documentation of this file.
00001 
00002 // For compilers that support precompilation, includes "wx.h".
00003 #include "wx/wxprec.h"
00004 
00005 #ifdef __BORLANDC__
00006     #pragma hdrstop
00007 #endif
00008 
00009 #if wxUSE_XRC
00010 
00011 #include "xh_gridcombo.h"
00012 
00013 #include "gridcombo.h"
00014 
00015 IMPLEMENT_DYNAMIC_CLASS(wxGridComboXmlHandler, wxXmlResourceHandler)
00016 
00017 wxGridComboXmlHandler::wxGridComboXmlHandler()
00018                         :wxXmlResourceHandler()
00019 {
00020     XRC_ADD_STYLE(wxCB_SIMPLE);
00021     XRC_ADD_STYLE(wxCB_READONLY);
00022     XRC_ADD_STYLE(wxCB_DROPDOWN);
00023 
00024     AddWindowStyles();
00025 }
00026 
00027 /******************************************************************************
00028 Function  : *wxGridComboXmlHandler::DoCreateResource
00029 Author    : Mikhail Tatarnikov
00030 Purpose   : Creates new wxGridCombo and initializes it with values from the
00031             resources.
00032 Returns   : wxObject* - the brand new initialized object.
00033 Exceptions: None
00034 Parameters: None
00035 Notes     : 
00036 ******************************************************************************/
00037 wxObject* wxGridComboXmlHandler::DoCreateResource()
00038 {
00039     XRC_MAKE_INSTANCE(pControl, wxGridCombo)
00040 
00041     // Grid like stuff
00042     if(HasParam(wxT("columns")))
00043     {
00044         pControl->SetColumns(GetLong(wxT("columns")));
00045     }
00046 
00047     if(HasParam(wxT("itemsize")))
00048     {
00049         wxSize sizItemSize = GetSize(wxT("itemsize"));
00050         pControl->SetItemSize(sizItemSize);
00051     }
00052 
00053     pControl->Create(m_parentAsWindow,
00054                     GetID(),
00055                     GetPosition(), GetSize(),
00056                     GetStyle(),
00057                     GetName());
00058 
00059 
00060     // ComboCtrl like stuff
00061     wxSize ButtonSize=GetSize(wxT("buttonsize"));
00062     if (ButtonSize != wxDefaultSize)
00063         pControl->SetButtonPosition(ButtonSize.GetWidth(), ButtonSize.GetHeight());
00064 
00065     SetupWindow(pControl);
00066 
00067     return pControl;
00068 }
00069 
00070 /******************************************************************************
00071 Function  : wxGridComboXmlHandler::CanHandle
00072 Author    : Mikhail Tatarnikov
00073 Purpose   : Checks if an XML node corresponds to our wxGridCombo control.
00074 Returns   : bool - true if wxGridCombo can be created from the node, false otherwise.
00075 Exceptions: 
00076 Parameters: [in] wxXmlNode* node - resource XML node to test.
00077 Notes     : 
00078 ******************************************************************************/
00079 bool wxGridComboXmlHandler::CanHandle(wxXmlNode* node)
00080 {
00081 #if wxCHECK_VERSION(2,7,0)
00082 
00083     return (IsOfClass(node, wxT("wxGridCombo")));
00084 
00085 #else
00086 
00087 //  Avoid GCC bug - this fails on certain GCC 3.3 and 3.4 builds for an unknown reason
00088 //  it is believed to be related to the fact IsOfClass is inline, and node->GetPropVal
00089 //  gets passed an invalid "this" pointer. On 2.7, the function is out of line, so the
00090 //  above should work fine. This code is left in here so this file can easily be used
00091 //  in a version backported to 2.6. All we are doing here is expanding the macro
00092 
00093     bool bOurClass = node->GetPropVal(wxT("class"), wxEmptyString) == wxT("wxGridCombo");
00094     return bOurClass;
00095 #endif
00096 }
00097 
00098 #endif // wxUSE_XRC

Generated on Sat Nov 10 03:49:02 2007 for Camelot by  doxygen 1.4.4