Added machinery to Enable/Disable windows. When a window is disabled, it

disables all of its children.  Every window maintains a bool indicating
whether it should be enabled (i.e. Enable() was called on it directly).
When a window is reenabled, it reenables children, but only if they are
actually supposed to be enabled. Override CocoaSetEnabled() in subclasses
to actually enable/disable a Cocoa control.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23014 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott
2003-08-19 14:45:54 +00:00
parent 5751dd32c7
commit adb4816c3e
2 changed files with 38 additions and 0 deletions

View File

@@ -202,6 +202,7 @@ void wxWindowCocoa::Init()
m_cocoaScroller = NULL;
m_isBeingDeleted = FALSE;
m_isInPaint = FALSE;
m_shouldBeEnabled = true;
}
// Constructor
@@ -416,6 +417,34 @@ void wxWindow::CocoaReplaceView(WX_NSView oldView, WX_NSView newView)
[[oldView superview] replaceSubview:oldView with:newView];
}
bool wxWindow::EnableSelfAndChildren(bool enable)
{
// If the state isn't changing, don't do anything
if(!wxWindowBase::Enable(enable && m_shouldBeEnabled))
return false;
// Set the state of the Cocoa window
CocoaSetEnabled(m_isEnabled);
// Disable all children or (if enabling) return them to their proper state
for(wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
node; node = node->GetNext())
{
node->GetData()->EnableSelfAndChildren(enable);
}
return true;
}
bool wxWindow::Enable(bool enable)
{
// Keep track of what the window SHOULD be doing
m_shouldBeEnabled = enable;
// If the parent is disabled for any reason, then this window will be too.
if(!IsTopLevel() && GetParent())
{
enable = enable && GetParent()->IsEnabled();
}
return EnableSelfAndChildren(enable);
}
bool wxWindow::Show(bool show)
{
wxAutoNSAutoreleasePool pool;