#include "wx/platinfo.h"
#include "wx/private/window.h"
-#ifdef __WXMSW__
+#ifdef __WINDOWS__
#include "wx/msw/wrapwin.h"
#endif
}
// ----------------------------------------------------------------------------
-// reparenting the window
+// Dealing with parents and children.
// ----------------------------------------------------------------------------
+bool wxWindowBase::IsDescendant(wxWindowBase* win) const
+{
+ // Iterate until we find this window in the parent chain or exhaust it.
+ while ( win )
+ {
+ wxWindow* const parent = win->GetParent();
+ if ( parent == this )
+ return true;
+
+ // Stop iterating on reaching the top level window boundary.
+ if ( parent->IsTopLevel() )
+ break;
+
+ win = parent;
+ }
+
+ return false;
+}
+
void wxWindowBase::AddChild(wxWindowBase *child)
{
wxCHECK_RET( child, wxT("can't add a NULL child") );
return m_foregroundColour;
}
+bool wxWindowBase::SetBackgroundStyle(wxBackgroundStyle style)
+{
+ // The checks below shouldn't be triggered if we're not really changing the
+ // style.
+ if ( style == m_backgroundStyle )
+ return true;
+
+ // Transparent background style can be only set before creation because of
+ // wxGTK limitation.
+ wxCHECK_MSG( (style != wxBG_STYLE_TRANSPARENT) || !GetHandle(),
+ false,
+ "wxBG_STYLE_TRANSPARENT style can only be set before "
+ "Create()-ing the window." );
+
+ // And once it is set, wxBG_STYLE_TRANSPARENT can't be unset.
+ wxCHECK_MSG( (m_backgroundStyle != wxBG_STYLE_TRANSPARENT) ||
+ (style == wxBG_STYLE_TRANSPARENT),
+ false,
+ "wxBG_STYLE_TRANSPARENT can't be unset once it was set." );
+
+ m_backgroundStyle = style;
+
+ return true;
+}
+
+bool wxWindowBase::IsTransparentBackgroundSupported(wxString *reason) const
+{
+ if ( reason )
+ *reason = _("This platform does not support background transparency.");
+
+ return false;
+}
+
bool wxWindowBase::SetBackgroundColour( const wxColour &colour )
{
if ( colour == m_backgroundColour )
// dialog oriented functions
// ----------------------------------------------------------------------------
+#if WXWIN_COMPATIBILITY_2_8
void wxWindowBase::MakeModal(bool modal)
{
// Disable all other windows
}
}
}
+#endif // WXWIN_COMPATIBILITY_2_8
bool wxWindowBase::Validate()
{
}
}
+bool wxWindowBase::CopyToolTip(wxToolTip *tip)
+{
+ SetToolTip(tip ? new wxToolTip(tip->GetTip()) : NULL);
+
+ return tip != NULL;
+}
+
#endif // wxUSE_TOOLTIPS
// ----------------------------------------------------------------------------
void wxWindowBase::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) const
{
- // don't do it for the dialogs/frames - they float independently of their
- // parent
- if ( !IsTopLevel() )
+ wxWindow *parent = GetParent();
+ if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent )
{
- wxWindow *parent = GetParent();
- if ( !(sizeFlags & wxSIZE_NO_ADJUSTMENTS) && parent )
- {
- wxPoint pt(parent->GetClientAreaOrigin());
- x += pt.x;
- y += pt.y;
- }
+ wxPoint pt(parent->GetClientAreaOrigin());
+ x += pt.x;
+ y += pt.y;
}
}
bool wxWindowBase::HasFocus() const
{
- wxWindowBase *win = DoFindFocus();
- return win == this ||
- win == wxConstCast(this, wxWindowBase)->GetMainWindowOfCompositeControl();
+ wxWindowBase* const win = DoFindFocus();
+ return win &&
+ (this == win || this == win->GetMainWindowOfCompositeControl());
}
// ----------------------------------------------------------------------------