hiding panel removes focus from any child

svn: r1003
This commit is contained in:
Matthew Flatt 2005-10-06 18:26:26 +00:00
parent ee1e6f6d0f
commit 4ccc351b3b
4 changed files with 31 additions and 1 deletions

View File

@ -196,6 +196,19 @@ void wxPanel::ChangeToGray(Bool gray)
}
}
void wxPanel::ReleaseAllFocus()
{
wxChildNode *cn;
wxChildList *cl;
cl = GetChildren();
for (cn = cl->First(); cn; cn = cn->Next()) {
wxWindow *w;
w = (wxWindow *)cn->Data();
w->ReleaseAllFocus();
}
ReleaseFocus();
}
//-----------------------------------------------------------------------------
// positioning of items
//-----------------------------------------------------------------------------

View File

@ -69,6 +69,7 @@ public:
// drawing
wxPanelDC* GetPanelDC(void) { return dc; }
virtual void ChangeToGray(Bool gray);
virtual void ReleaseAllFocus();
protected:
friend class wxButton; // allow access to default_item

View File

@ -753,8 +753,14 @@ void wxWindow::ChangeToGray(Bool gray)
if (XtIsSubclass(X->frame, xfwfEnforcerWidgetClass))
XtVaSetValues(X->frame, XtNdrawgray, (Boolean)gray, NULL);
if (gray)
ReleaseFocus();
}
void wxWindow::ReleaseFocus()
{
/* If disabling and this window has the focus, get rid of it: */
if (gray && (misc_flags & FOCUS_FLAG)) {
if (misc_flags & FOCUS_FLAG) {
wxWindow *p;
p = GetParent();
while (p) {
@ -767,6 +773,11 @@ void wxWindow::ChangeToGray(Bool gray)
}
}
void wxWindow::ReleaseAllFocus()
{
ReleaseFocus();
}
Bool wxWindow::IsGray(void)
{
return (misc_flags & DISABLED_FLAG) || internal_gray_disabled;
@ -926,6 +937,9 @@ Bool wxWindow::Show(Bool show)
if (!X->handle) // forbid, if no widget associated
return TRUE;
if (!show)
ReleaseAllFocus();
/* Get rid of or restore focus traversal */
if (XtIsSubclass(X->frame, xfwfCommonWidgetClass))
XtVaSetValues(X->frame, XtNtraversalOn, (Boolean)show, NULL);

View File

@ -159,6 +159,8 @@ public:
void MakeModal(int on);
void InternalEnable(Bool enable, Bool gray = FALSE);
virtual void ChangeToGray(Bool gray);
void ReleaseFocus();
virtual void ReleaseAllFocus();
Bool IsGray(void);
Bool IsShown(void);