Fixed label alignment (STR #2436)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7782 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2010-10-30 21:32:15 +00:00
parent 9b6f68dd7c
commit b5a73c78e6
5 changed files with 21 additions and 12 deletions

View File

@ -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)

View File

@ -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) {

View File

@ -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<Fl_Group*>(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);
}

View File

@ -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 (strw<width) strw = (int)width;
lines++;
@ -299,7 +300,7 @@ void fl_draw(
if (str) {
int desc = fl_descent();
for (p=str; ; ypos += height) {
if (lines>1) 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 = "";

View File

@ -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();