diff --git a/CHANGES b/CHANGES index 6d125e87a..902789410 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ CHANGES IN FLTK 1.3.0 + - Fixed label alignment (STR #2436) - Added interface to set color chooser mode (STR #2407) - Fixed compile errors when HAVE_LIBJPEG was not defined (STR #2382) diff --git a/src/Fl.cxx b/src/Fl.cxx index c2e0c3eaf..ec5750617 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1414,6 +1414,7 @@ void Fl_Widget::redraw_label() { W += 5; // Add a little to the size of the label to cover overflow H += 5; + // FIXME: this does not take all outside label positions into account! if (align() & FL_ALIGN_BOTTOM) { window()->damage(FL_DAMAGE_EXPOSE, x(), y() + h(), w(), H); } else if (align() & FL_ALIGN_TOP) { diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index a84cd2d7e..c25e7fffc 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -789,38 +789,44 @@ void Fl_Group::draw_outside_label(const Fl_Widget& widget) const { int Y = widget.y(); int W = widget.w(); int H = widget.h(); + int wx, wy; + if (const_cast(this)->as_window()) { + wx = wy = 0; + } else { + wx = x(); wy = y(); + } if ( (a & 0x0f) == FL_ALIGN_LEFT_TOP ) { a = (a &~0x0f ) | FL_ALIGN_TOP_RIGHT; - X = x(); + X = wx; W = widget.x()-X-3; } else if ( (a & 0x0f) == FL_ALIGN_LEFT_BOTTOM ) { a = (a &~0x0f ) | FL_ALIGN_BOTTOM_RIGHT; - X = x(); + X = wx; W = widget.x()-X-3; } else if ( (a & 0x0f) == FL_ALIGN_RIGHT_TOP ) { a = (a &~0x0f ) | FL_ALIGN_TOP_LEFT; X = X+W+3; - W = x()+this->w()-X; + W = wx+this->w()-X; } else if ( (a & 0x0f) == FL_ALIGN_RIGHT_BOTTOM ) { a = (a &~0x0f ) | FL_ALIGN_BOTTOM_LEFT; X = X+W+3; - W = x()+this->w()-X; + W = wx+this->w()-X; } else if (a & FL_ALIGN_TOP) { a ^= (FL_ALIGN_BOTTOM|FL_ALIGN_TOP); - Y = y(); + Y = wy; H = widget.y()-Y; } else if (a & FL_ALIGN_BOTTOM) { a ^= (FL_ALIGN_BOTTOM|FL_ALIGN_TOP); Y = Y+H; - H = y()+h()-Y; + H = wy+h()-Y; } else if (a & FL_ALIGN_LEFT) { a ^= (FL_ALIGN_LEFT|FL_ALIGN_RIGHT); - X = x(); + X = wx; W = widget.x()-X-3; } else if (a & FL_ALIGN_RIGHT) { a ^= (FL_ALIGN_LEFT|FL_ALIGN_RIGHT); X = X+W+3; - W = x()+this->w()-X; + W = wx+this->w()-X; } widget.draw_label(X,Y,W,H,(Fl_Align)a); } diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx index 36a4e5cb7..5e07aaf69 100644 --- a/src/fl_draw.cxx +++ b/src/fl_draw.cxx @@ -193,7 +193,7 @@ void fl_draw( char buf[MAXBUF]; int buflen; char symbol[2][255], *symptr; - int symwidth[2], symoffset, symtotal; + int symwidth[2], symoffset, symtotal, imgtotal; // count how many lines and put the last one into the buffer: int lines; @@ -226,13 +226,14 @@ void fl_draw( } symtotal = symwidth[0] + symwidth[1]; + imgtotal = (img && (align&FL_ALIGN_IMAGE_NEXT_TO_TEXT)) ? img->w() : 0; int strw = 0; int strh; if (str) { for (p = str, lines=0; p;) { - e = fl_expand_text(p, buf, MAXBUF, w - symtotal, buflen, width, + e = fl_expand_text(p, buf, MAXBUF, w - symtotal - imgtotal, buflen, width, align&FL_ALIGN_WRAP, draw_symbols); if (strw1) e = fl_expand_text(p, buf, MAXBUF, w - symtotal, buflen, + if (lines>1) e = fl_expand_text(p, buf, MAXBUF, w - symtotal - imgtotal, buflen, width, align&FL_ALIGN_WRAP, draw_symbols); else e = ""; diff --git a/test/label.cxx b/test/label.cxx index 2d5fee5cb..39cd282c0 100644 --- a/test/label.cxx +++ b/test/label.cxx @@ -56,7 +56,7 @@ void button_cb(Fl_Widget *,void *) { if (clipb->value()) i |= FL_ALIGN_CLIP; if (wrapb->value()) i |= FL_ALIGN_WRAP; if (imageovertextb->value()) i |= FL_ALIGN_TEXT_OVER_IMAGE; - if (imagenexttotextb->value()) i |= FL_ALIGN_TEXT_NEXT_TO_IMAGE; + if (imagenexttotextb->value()) i |= FL_ALIGN_IMAGE_NEXT_TO_TEXT; if (imagebackdropb->value()) i |= FL_ALIGN_IMAGE_BACKDROP; text->align(i); window->redraw();