Redraw fixes.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2276 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-06-02 17:52:36 +00:00
parent 9671c04290
commit 839dfca778
4 changed files with 49 additions and 30 deletions

View File

@ -1,6 +1,9 @@
CHANGES IN FLTK 1.1.0rc3 CHANGES IN FLTK 1.1.0rc3
- Documentation updates. - 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 - The boolean (char) value methods in Fl_Preferences
have been removed since some C++ compilers can't have been removed since some C++ compilers can't
handle char and int value methods with the same name. handle char and int value methods with the same name.

View File

@ -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). // Main event handling code for the Fast Light Tool Kit (FLTK).
// //
@ -824,7 +824,34 @@ void Fl::paste(Fl_Widget &receiver) {
#include <FL/fl_draw.H> #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) { void Fl_Widget::damage(uchar flags) {
if (type() < FL_WINDOW) { if (type() < FL_WINDOW) {
@ -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 $".
// //

View File

@ -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). // Button widget for the Fast Light Tool Kit (FLTK).
// //
@ -36,8 +36,13 @@ int Fl_Button::value(int v) {
v = v ? 1 : 0; v = v ? 1 : 0;
oldval = v; oldval = v;
clear_changed(); clear_changed();
if (value_ != v) {value_ = v; redraw(); return 1;} if (value_ != v) {
else return 0; value_ = v;
redraw();
return 1;
} else {
return 0;
}
} }
void Fl_Button::setonly() { // set this radio button on, turn others off void Fl_Button::setonly() { // set this radio button on, turn others off
@ -58,6 +63,7 @@ void Fl_Button::draw() {
draw_label(); draw_label();
if (Fl::focus() == this) draw_focus(); if (Fl::focus() == this) draw_focus();
} }
int Fl_Button::handle(int event) { int Fl_Button::handle(int event) {
int newval; int newval;
switch (event) { switch (event) {
@ -109,15 +115,7 @@ int Fl_Button::handle(int event) {
case FL_FOCUS : case FL_FOCUS :
case FL_UNFOCUS : case FL_UNFOCUS :
if (Fl::visible_focus()) { if (Fl::visible_focus()) {
if (event == FL_UNFOCUS && box() == FL_NO_BOX) { redraw();
// 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();
return 1; return 1;
} else return 0; } else return 0;
case FL_KEYBOARD : case FL_KEYBOARD :
@ -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 $".
// //

View File

@ -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). // Base widget class for the Fast Light Tool Kit (FLTK).
// //
@ -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() { void Fl_Widget::activate() {
if (!active()) { if (!active()) {
clear_flag(INACTIVE); clear_flag(INACTIVE);
if (active_r()) { if (active_r()) {
redraw_label(this); redraw();
handle(FL_ACTIVATE); handle(FL_ACTIVATE);
if (inside(Fl::focus())) Fl::focus()->take_focus(); if (inside(Fl::focus())) Fl::focus()->take_focus();
} }
@ -199,7 +190,7 @@ void Fl_Widget::activate() {
void Fl_Widget::deactivate() { void Fl_Widget::deactivate() {
if (active_r()) { if (active_r()) {
set_flag(INACTIVE); set_flag(INACTIVE);
redraw_label(this); redraw();
handle(FL_DEACTIVATE); handle(FL_DEACTIVATE);
fl_throw_focus(this); fl_throw_focus(this);
} else { } else {
@ -217,7 +208,7 @@ void Fl_Widget::show() {
if (!visible()) { if (!visible()) {
clear_flag(INVISIBLE); clear_flag(INVISIBLE);
if (visible_r()) { if (visible_r()) {
redraw_label(this); redraw();
handle(FL_SHOW); handle(FL_SHOW);
if (inside(Fl::focus())) Fl::focus()->take_focus(); if (inside(Fl::focus())) Fl::focus()->take_focus();
} }
@ -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 $".
// //