Author: spitzak Date: 2007-06-06 15:50:47 -0400 (Wed, 06 Jun 2007) New Revision: 5883 Log: STR 1547 The ALIGN_CENTER flag, which otherwise did nothing, now forces the image() to be centered and places the label as though the image was not there.
Modified: trunk/src/Widget_draw.cxx trunk/test/label.cxx Modified: trunk/src/Widget_draw.cxx =================================================================== --- trunk/src/Widget_draw.cxx 2007-06-06 19:09:26 UTC (rev 5882) +++ trunk/src/Widget_draw.cxx 2007-06-06 19:50:47 UTC (rev 5883) @@ -197,15 +197,20 @@ } } - Rectangle ir(r, w, h, flags); - img->draw(ir); - - // figure out the rectangle that remains for text: - if (flags & ALIGN_TOP) r.set_y(ir.b()); - else if (flags & ALIGN_BOTTOM) r.set_b(ir.y()); - else if (flags & ALIGN_LEFT) r.set_x(ir.r()); - else if (flags & ALIGN_RIGHT) r.set_r(ir.x()); - else {r.set_y(ir.b()); /*flags |= ALIGN_TOP|ALIGN_INSIDE;*/} + // STR 1547: ALIGN_CENTER forces the image to center and not effect label + if (flags & ALIGN_CENTER) { + Rectangle ir(r, w, h, 0); + img->draw(ir); + } else { + Rectangle ir(r, w, h, flags); + img->draw(ir); + // figure out the rectangle that remains for text: + if (flags & ALIGN_TOP) r.set_y(ir.b()); + else if (flags & ALIGN_BOTTOM) r.set_b(ir.y()); + else if (flags & ALIGN_LEFT) r.set_x(ir.r()); + else if (flags & ALIGN_RIGHT) r.set_r(ir.x()); + else r.set_y(ir.b()); + } } // skip outside labels: Modified: trunk/test/label.cxx =================================================================== --- trunk/test/label.cxx 2007-06-06 19:09:26 UTC (rev 5882) +++ trunk/test/label.cxx 2007-06-06 19:50:47 UTC (rev 5883) @@ -37,7 +37,7 @@ using namespace fltk; -ToggleButton *leftb,*rightb,*topb,*bottomb,*insideb,*clipb,*wrapb; +ToggleButton *leftb,*rightb,*topb,*bottomb,*insideb,*centerb,*clipb,*wrapb; Widget *textbox; Input *input; ValueSlider *fontslider; @@ -51,6 +51,7 @@ if (topb->value()) i |= ALIGN_TOP; if (bottomb->value()) i |= ALIGN_BOTTOM; if (insideb->value()) i |= ALIGN_INSIDE; + if (centerb->value()) i |= ALIGN_CENTER; if (clipb->value()) i |= ALIGN_CLIP; if (wrapb->value()) i |= ALIGN_WRAP; textbox->align(i); @@ -133,8 +134,6 @@ textbox= new Widget(100,75,200,100,initial); textbox->box(ENGRAVED_BOX); - textbox->clear_flag(ALIGN_MASK); - textbox->set_flag(ALIGN_CENTER); Choice *c = new Choice(50,275,200,25); load_menu(c); @@ -148,16 +147,18 @@ Group *g = new Group(0,300,400,25); g->resizable(g); g->begin(); - leftb = new ToggleButton(50,0,50,25,"left"); + leftb = new ToggleButton(0,0,50,25,"left"); leftb->callback(button_cb); - rightb = new ToggleButton(100,0,50,25,"right"); + rightb = new ToggleButton(50,0,50,25,"right"); rightb->callback(button_cb); - topb = new ToggleButton(150,0,50,25,"top"); + topb = new ToggleButton(100,0,50,25,"top"); topb->callback(button_cb); - bottomb = new ToggleButton(200,0,50,25,"bottom"); + bottomb = new ToggleButton(150,0,50,25,"bottom"); bottomb->callback(button_cb); - insideb = new ToggleButton(250,0,50,25,"inside"); + insideb = new ToggleButton(200,0,50,25,"inside"); insideb->callback(button_cb); + centerb = new ToggleButton(250,0,50,25,"center"); + centerb->callback(button_cb); wrapb = new ToggleButton(300,0,50,25,"wrap"); wrapb->callback(button_cb); clipb = new ToggleButton(350,0,50,25,"clip"); _______________________________________________ fltk-commit mailing list fltk-commit@easysw.com http://lists.easysw.com/mailman/listinfo/fltk-commit