|
Let's call it a bug. :-) Or a bug fix. Here it is if you want it. ![]() Images left or right of text in buttons. I haven't got my alpha drawing wired into fltk yet (not sure yet where to insert it) so the translucent part still looks white. I haven't tested any of these alignments except FL_ALIGN_LEFT so far. This is in fl_draw.cxx. Most of the code is new. // The normal call for a draw() method: void Fl_Widget::draw_label() const { int X = x_+Fl::box_dx(box()); int W = w_-Fl::box_dw(box()); // rs-> int state = 0; if(align()&(FL_ALIGN_LEFT|FL_ALIGN_RIGHT)) state = 1; // bit 0; if (W > 11 && state == 1) { X += 3; W -= 6; } if((label_.image) && (label())) state |= 2; // bit 1 // not planning to mess with align_center, but I might... // if((align() == 0) || (align() & FL_ALIGN_INSIDE)) if((align() & FL_ALIGN_INSIDE)) state |= 4; // bit 3 // rs-> if(state == 7) { // It's aligned left or right (or center <- scratch that), and inside and has // both text and image. Save and restore coords and draw // the text and the image separately. // Need some handles to make the read-only stuff accessible // and we'll name them in accordance with other usage.. Fl_Image** po_image = (Fl_Image**)&label_.image; char** po_label = (char**) &label_.value; int ww = W, xx = X; Fl_Image* saved_image = *po_image; char* saved_label = *po_label; int image_margin = label_.image->w() + 4; // left aligned? do this... if(align() & FL_ALIGN_LEFT) { // first the text only xx += image_margin; ww -= image_margin; *po_image = 0; draw_label(xx, y_+Fl::box_dy(box()), ww, h_-Fl::box_dh(box())); *po_image = saved_image; // then the image only, at the original coordinates *po_label = 0; draw_label(X, y_+Fl::box_dy(box()), W, h_-Fl::box_dh(box())); *po_label = saved_label; } else // if(align() & FL_ALIGN_RIGHT) { // first the text, then the image to the right of it *po_image = 0; draw_label(X, y_+Fl::box_dy(box()), W, h_-Fl::box_dh(box())); *po_image = saved_image; // Then the image, right-aligned! or we'd have to measure the // length of the text written. xx = xx + ww - image_margin; ww = image_margin; *po_label = 0; draw_label(xx, y_+Fl::box_dy(box()), ww, h_-Fl::box_dh(box())); *po_label = saved_label; } // else // it's center aligned: default // { // xx += 2 * image_margin; // ww -= 2 * image_margin; // *po_image = 0; // draw_label(xx, y_+Fl::box_dy(box()), ww, h_-Fl::box_dh(box())); // *po_image = saved_image; // xx = X; // ww = W - 2 * image_margin; // *po_label = 0; // draw_label(xx, y_+Fl::box_dy(box()), ww, h_-Fl::box_dh(box())); // *po_label = saved_label; // // } } else draw_label(X, y_+Fl::box_dy(box()), W, h_-Fl::box_dh(box())); } |
_______________________________________________ fltk-bugs mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-bugs

