Skip to content

Commit

Permalink
Focus fixes from Bill.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/trunk@159 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Dec 15, 1998
1 parent 4f9aa69 commit 136a364
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions src/Fl_Widget.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget.cxx,v 1.3 1998/10/21 14:20:26 mike Exp $"
// "$Id: Fl_Widget.cxx,v 1.4 1998/12/15 15:35:19 mike Exp $"
//
// Base widget class for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -132,19 +132,25 @@ static void redraw_label(Fl_Widget* w) {
}

void Fl_Widget::activate() {
if (active()) return;
clear_flag(INACTIVE);
handle(FL_ACTIVATE);
if (inside(Fl::focus())) Fl::focus()->take_focus();
redraw_label(this);
if (!active()) {
clear_flag(INACTIVE);
if (active_r()) {
redraw_label(this);
handle(FL_ACTIVATE);
if (inside(Fl::focus())) Fl::focus()->take_focus();
}
}
}

void Fl_Widget::deactivate() {
if (!active()) return;
set_flag(INACTIVE);
handle(FL_DEACTIVATE);
fl_throw_focus(this);
redraw_label(this);
if (active_r()) {
set_flag(INACTIVE);
redraw_label(this);
handle(FL_DEACTIVATE);
fl_throw_focus(this);
} else {
set_flag(INACTIVE);
}
}

int Fl_Widget::active_r() const {
Expand All @@ -154,20 +160,26 @@ int Fl_Widget::active_r() const {
}

void Fl_Widget::show() {
if (visible()) return;
clear_flag(INVISIBLE);
handle(FL_SHOW);
if (inside(Fl::focus())) Fl::focus()->take_focus();
redraw_label(this);
if (!visible()) {
clear_flag(INVISIBLE);
if (visible_r()) {
redraw_label(this);
handle(FL_SHOW);
if (inside(Fl::focus())) Fl::focus()->take_focus();
}
}
}

void Fl_Widget::hide() {
if (!visible()) return;
set_flag(INVISIBLE);
handle(FL_HIDE);
fl_throw_focus(this);
for (Fl_Widget *p = parent(); p; p = p->parent())
if (p->box() || !p->parent()) {p->redraw(); break;}
if (visible_r()) {
set_flag(INVISIBLE);
for (Fl_Widget *p = parent(); p; p = p->parent())
if (p->box() || !p->parent()) {p->redraw(); break;}
handle(FL_HIDE);
fl_throw_focus(this);
} else {
set_flag(INVISIBLE);
}
}

int Fl_Widget::visible_r() const {
Expand All @@ -184,5 +196,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const {
}

//
// End of "$Id: Fl_Widget.cxx,v 1.3 1998/10/21 14:20:26 mike Exp $".
// End of "$Id: Fl_Widget.cxx,v 1.4 1998/12/15 15:35:19 mike Exp $".
//

0 comments on commit 136a364

Please sign in to comment.