My system: linux-2.6.27, X11-7.3, gcc-4.3.0 .

I have written a small FLTK1 application now using fltk-1.3.x-r6350:
a main_window contains a row of buttons, followed by an output,
followed by another window: the canvas.

The application allows to show PNG/JNG/MNG images files.

The start geometry of the canvas is 5x5. The application uses a file_chooser
to load different images into the canvas.

Images of different geometry can be loaded into the FLTK1 canvas, which
resizes error free.



I have now rewritten this application using FLTK2 (fltk-2.0.x-r6305).

If the application is started without an image ('viewer') and the first
image is loaded using the file_chooser, then the canvas resizes vertically
but not horizontally. For a very short moment the full image becomes visible.
Then the canvas shrinks back to the start width of 5.

When I (dragging with the mouse) widen the main_window horizontally by
the width of the newly loaded image, the canvas becomes visible.

I get the same result if (in the resize code shown below) I add the width
of the canvas to the width of the main_win.

When the application is started together with an image file ('viewer FILE'),
then the start image is shown completely. But when the start image has a
width of e.g. 700, and (using the file_chooser) the next chosen image has
a width of e.g. 100, then the canvas seems not to shrink: 600 pixels to
the right remain visible. The pixels do not belong to the previous image.
They are 'any' pixels.

Replacing the fltk::Window for the canvas with an fltk::Widget resizes
error free as in the FLTK1 application that uses an FL_Window for the
canvas.

winfried


APPENDIX A
==========
class NGCanvas: public fltk::Window
{
    void draw();
public:
  NGCanvas(Fl_Boxtype b,int x,int y,int w,int h)
    : fltk::Window(x,y,w,h)
     {box(fltk::NO_BOX);}
};

APPENDIX B
==========
class NGCanvas: public fltk::Widget
{
    void draw();
public:
  NGCanvas(Fl_Boxtype b,int x,int y,int w,int h)
    : fltk::Widget(x,y,w,h)
     {box(fltk::NO_BOX);}
};

APPENDIX C
==========
Both use the same draw() code:

void NGCanvas::draw()
{
    int uw, uh;

    uw = (int)user.width; uh = (int)user.height;

    if(user.rgb_buf)
   {
    fltk::drawimage(user.rgb_buf,fltk::RGB, fltk::Rectangle(uw, uh));

    return;
   }
    fltk::setcolor(user.bg_color);
    fltk::fillrect(0, 0, uw, uh);
}

APPENDIX D
==========
Both use the same resize code:

static void resize_windows(UserInfo *user)
{
    int uw, uh, mw, mh;

    mw = 460; uw = (int)user->width; uh = (int)user->height;
    if(uw + 10 > mw) mw = uw + 10;

    mh = main_win_menu_h + uh + 5;

    user->main_win->resize(user->main_win->x(),user->main_win->y(), mw, mh);
    user->canvas->resize(user->canvas->x(), user->canvas->y(), uw, uh);

}

APPENDIX E
==========
The FLTK1 application has a size of 60577 B (stripped 19944 B).
The FLTK2 application has a size of 619206 B (stripped 414848 B).

_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to