// Purpose: wxCompositeWindow<> declaration
// Author: Vadim Zeitlin
// Created: 2011-01-02
-// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
+// RCS-ID: $Id$
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#include "wx/window.h"
+class WXDLLIMPEXP_FWD_CORE wxToolTip;
+
// NB: This is an experimental and, as for now, undocumented class used only by
// wxWidgets itself internally. Don't use it in your code until its API is
// officially stabilized unless you are ready to change it with the next
// wxWidgets release.
+// FIXME-VC6: This compiler can't compile DoSetForAllParts() template function,
+// it can't determine whether the deduced type should be "T" or "const T&". And
+// without this function wxCompositeWindow is pretty useless so simply disable
+// this code for it, this does mean that setting colours/fonts/... for
+// composite controls won't work in the library compiled with it but so far
+// this only affects the generic wxDatePickerCtrl which is not used by default
+// under MSW anyhow so it doesn't seem to be worth it to spend time and uglify
+// the code to fix it.
+#ifndef __VISUALC6__
+
// ----------------------------------------------------------------------------
// wxCompositeWindow is a helper for implementing composite windows: to define
// a class using subwindows, simply inherit from it specialized with the real
if ( !BaseWindowClass::SetForegroundColour(colour) )
return false;
- DoSetForAllParts(&wxWindow::SetForegroundColour, colour);
+ SetForAllParts(&wxWindowBase::SetForegroundColour, colour);
return true;
}
if ( !BaseWindowClass::SetBackgroundColour(colour) )
return false;
- DoSetForAllParts(&wxWindow::SetBackgroundColour, colour);
+ SetForAllParts(&wxWindowBase::SetBackgroundColour, colour);
return true;
}
if ( !BaseWindowClass::SetFont(font) )
return false;
- DoSetForAllParts(&wxWindow::SetFont, font);
+ SetForAllParts(&wxWindowBase::SetFont, font);
return true;
}
if ( !BaseWindowClass::SetCursor(cursor) )
return false;
- DoSetForAllParts(&wxWindow::SetCursor, cursor);
+ SetForAllParts(&wxWindowBase::SetCursor, cursor);
return true;
}
+#if wxUSE_TOOLTIPS
+ virtual void DoSetToolTip(wxToolTip *tip)
+ {
+ BaseWindowClass::DoSetToolTip(tip);
+
+ SetForAllParts(&wxWindowBase::CopyToolTip, tip);
+ }
+#endif // wxUSE_TOOLTIPS
+
private:
// Must be implemented by the derived class to return all children to which
// the public methods we override should forward to.
virtual wxWindowList GetCompositeWindowParts() const = 0;
template <class T>
- void DoSetForAllParts(bool (wxWindow::*func)(const T&), const T& arg)
+ void SetForAllParts(bool (wxWindowBase::*func)(const T&), const T& arg)
+ {
+ DoSetForAllParts<const T&>(func, arg);
+ }
+
+ template <class T>
+ void SetForAllParts(bool (wxWindowBase::*func)(T*), T* arg)
+ {
+ DoSetForAllParts<T*>(func, arg);
+ }
+
+ template <class T>
+ void DoSetForAllParts(bool (wxWindowBase::*func)(T), T arg)
{
// Simply call the setters for all parts of this composite window.
const wxWindowList parts = GetCompositeWindowParts();
{
wxWindow * const child = *i;
- (child->*func)(arg);
+ // Allow NULL elements in the list, this makes the code of derived
+ // composite controls which may have optionally shown children
+ // simpler and it doesn't cost us much here.
+ if ( child )
+ (child->*func)(arg);
}
}
wxDECLARE_NO_COPY_TEMPLATE_CLASS(wxCompositeWindow, W);
};
+#else // __VISUALC6__
+
+template <class W>
+class wxCompositeWindow : public W
+{
+};
+
+#endif // !__VISUALC6__/__VISUALC6__
+
#endif // _WX_COMPOSITEWIN_H_