I try to get a group inside a scroll and inside the group I have for smaller 
groups. All have their own drawing routines.

If I resize the outer window and scroll, the drawing is totally corrupted, a 
lot of pixels are missing.

Can someone explain how to handle scroll/draw in a correct way?

----
#include <iostream>
using namespace std;

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl.H>
#include <FL/Fl_Scroll.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Menu_Bar.H>

static const unsigned int MENU_HEIGHT= 25;

class MyBox: public Fl_Group
{
    private:
        string name;

    public:
        MyBox( int x, int y, int w, int h, string _name):
            Fl_Group( x,y,w,h ),
            name(_name)
    {}

        void draw()
        {
            cout << "Draw name " << name << endl;
            cout << "Position " << x() << " " << y() << endl;
            cout << "Size " << w() << " " << h() << endl;

            fl_color(fl_rgb_color(0,0,0));
            fl_line(x()   ,y(), x()+w(), y()+h() );
            fl_line(x()   ,y()+h(), x()+w(), y() );

            Fl_Group::draw();
            cout << "End draw" << endl;
        }

        void resize(int x, int y, int w, int h)
        {
            cout << "resize called for " << name << "  " << x << " " << y << " 
" << w << " " << h << endl;
            Fl_Group::resize(x,y,w,h);
        }
};

void Do(Fl_Widget*, void* obj) {  } // dummy only

int main()
{
    Fl_Double_Window win(400,400, "Test1");
    Fl_Menu_Bar menubar(0,0, 400, MENU_HEIGHT);
    Fl_Scroll scroll(0,MENU_HEIGHT,400,400-MENU_HEIGHT);
    menubar.add( "Hallo",0, Do,(void*)&win);

    MyBox box(0, MENU_HEIGHT, 400, 400-MENU_HEIGHT, "master");
    MyBox littleBox00( 0, MENU_HEIGHT, 50,50, "sub00");
    MyBox littleBox01( 0, MENU_HEIGHT+50, 50,50, "sub01");
    MyBox littleBox10( 50, MENU_HEIGHT, 50,50, "sub10");
    MyBox littleBox11( 50, MENU_HEIGHT+50, 50,50, "sub11");

    scroll.end();
    win.end();

    win.resizable(box);
    win.show();
    return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to