Skip to content

Commit

Permalink
Redraw fixes.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2276 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
michaelrsweet committed Jun 2, 2002
1 parent 9671c04 commit 839dfca
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGES
@@ -1,6 +1,9 @@
CHANGES IN FLTK 1.1.0rc3

- Documentation updates.
- Fixed some redraw() bugs, and now redraw portions of
the parent widget when the label appears outside the
widget.
- The boolean (char) value methods in Fl_Preferences
have been removed since some C++ compilers can't
handle char and int value methods with the same name.
Expand Down
33 changes: 30 additions & 3 deletions src/Fl.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl.cxx,v 1.24.2.41.2.33 2002/05/23 16:47:41 easysw Exp $"
// "$Id: Fl.cxx,v 1.24.2.41.2.34 2002/06/02 17:52:36 easysw Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -824,7 +824,34 @@ void Fl::paste(Fl_Widget &receiver) {

#include <FL/fl_draw.H>

void Fl_Widget::redraw() {damage(FL_DAMAGE_ALL);}
void Fl_Widget::redraw() {
if (box() == FL_NO_BOX) {
// Widgets with the FL_NO_BOX boxtype need a parent to
// redraw, since it is responsible for redrawing the
// background...
int X = x() > 0 ? x() - 1 : 0;
int Y = y() > 0 ? y() - 1 : 0;
window()->damage(FL_DAMAGE_ALL, X, Y, w() + 2, h() + 2);
}
else damage(FL_DAMAGE_ALL);

if (window() && align() && !(align() & FL_ALIGN_INSIDE)) {
// If the label is not inside the widget, compute the location of
// the label and redraw the window within that bounding box...
int W = 0, H = 0;
label_.measure(W, H);

if (align() & FL_ALIGN_BOTTOM) {
window()->damage(FL_DAMAGE_ALL, x(), y() + h(), w(), H);
} else if (align() & FL_ALIGN_TOP) {
window()->damage(FL_DAMAGE_ALL, x(), y() - H, w(), H);
} else if (align() & FL_ALIGN_LEFT) {
window()->damage(FL_DAMAGE_ALL, x() - W, y(), W, h());
} else if (align() & FL_ALIGN_RIGHT) {
window()->damage(FL_DAMAGE_ALL, x() + w(), y(), W, h());
}
}
}

void Fl_Widget::damage(uchar flags) {
if (type() < FL_WINDOW) {
Expand Down Expand Up @@ -901,5 +928,5 @@ void Fl_Window::flush() {
}

//
// End of "$Id: Fl.cxx,v 1.24.2.41.2.33 2002/05/23 16:47:41 easysw Exp $".
// End of "$Id: Fl.cxx,v 1.24.2.41.2.34 2002/06/02 17:52:36 easysw Exp $".
//
24 changes: 11 additions & 13 deletions src/Fl_Button.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.14 2002/05/17 11:31:09 easysw Exp $"
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.15 2002/06/02 17:52:36 easysw Exp $"
//
// Button widget for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -36,8 +36,13 @@ int Fl_Button::value(int v) {
v = v ? 1 : 0;
oldval = v;
clear_changed();
if (value_ != v) {value_ = v; redraw(); return 1;}
else return 0;
if (value_ != v) {
value_ = v;
redraw();
return 1;
} else {
return 0;
}
}

void Fl_Button::setonly() { // set this radio button on, turn others off
Expand All @@ -58,6 +63,7 @@ void Fl_Button::draw() {
draw_label();
if (Fl::focus() == this) draw_focus();
}

int Fl_Button::handle(int event) {
int newval;
switch (event) {
Expand Down Expand Up @@ -109,15 +115,7 @@ int Fl_Button::handle(int event) {
case FL_FOCUS :
case FL_UNFOCUS :
if (Fl::visible_focus()) {
if (event == FL_UNFOCUS && box() == FL_NO_BOX) {
// Buttons with the FL_NO_BOX boxtype need a parent to
// redraw, since it is responsible for redrawing the
// background...
int X = x() > 0 ? x() - 1 : 0;
int Y = y() > 0 ? y() - 1 : 0;
window()->damage(FL_DAMAGE_EXPOSE, X, Y, w() + 2, h() + 2);
}
else redraw();
redraw();
return 1;
} else return 0;
case FL_KEYBOARD :
Expand Down Expand Up @@ -147,5 +145,5 @@ Fl_Button::Fl_Button(int x,int y,int w,int h, const char *l)
}

//
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.14 2002/05/17 11:31:09 easysw Exp $".
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.15 2002/06/02 17:52:36 easysw Exp $".
//
19 changes: 5 additions & 14 deletions src/Fl_Widget.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.17 2002/05/24 14:19:19 easysw Exp $"
// "$Id: Fl_Widget.cxx,v 1.5.2.4.2.18 2002/06/02 17:52:36 easysw Exp $"
//
// Base widget class for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -176,20 +176,11 @@ Fl_Widget::draw_focus(Fl_Boxtype B, int X, int Y, int W, int H) const {
}


// redraw this, plus redraw opaque object if there is an outside label
static void redraw_label(Fl_Widget* w) {
w->redraw();
if (w->label() && (w->align()&15) && !(w->align() & FL_ALIGN_INSIDE)) {
for (Fl_Widget *p = w->parent(); p; p = p->parent())
if (p->box() || !p->parent()) {p->redraw(); break;}
}
}

void Fl_Widget::activate() {
if (!active()) {
clear_flag(INACTIVE);
if (active_r()) {
redraw_label(this);
redraw();
handle(FL_ACTIVATE);
if (inside(Fl::focus())) Fl::focus()->take_focus();
}
Expand All @@ -199,7 +190,7 @@ void Fl_Widget::activate() {
void Fl_Widget::deactivate() {
if (active_r()) {
set_flag(INACTIVE);
redraw_label(this);
redraw();
handle(FL_DEACTIVATE);
fl_throw_focus(this);
} else {
Expand All @@ -217,7 +208,7 @@ void Fl_Widget::show() {
if (!visible()) {
clear_flag(INVISIBLE);
if (visible_r()) {
redraw_label(this);
redraw();
handle(FL_SHOW);
if (inside(Fl::focus())) Fl::focus()->take_focus();
}
Expand Down Expand Up @@ -250,5 +241,5 @@ int Fl_Widget::contains(const Fl_Widget *o) const {
}

//
// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.17 2002/05/24 14:19:19 easysw Exp $".
// End of "$Id: Fl_Widget.cxx,v 1.5.2.4.2.18 2002/06/02 17:52:36 easysw Exp $".
//

0 comments on commit 839dfca

Please sign in to comment.