0

I want an 'expandable' window/widget.When clicking a button on the current window, another widget will shows up, which is attached to the current window, and it can be 'fold' back if clicking the button again.

It is not a pop-up window which is free to move with respect to the main window. I want it to be attached to the main window. Anyone has any idea? Thanks a lot.

I tried making a large window consisting of two box, with one being tackled to show or hide, but the window size does not change. If you resize the window, then the position does not look right.

2 Answers2

2

Have you had a look at http://seriss.com/people/erco/fltk/ and the test programs that come with the fltk distribution?

Basically you need to set one resizable widget for the window/dialog. Make this the group that you are showing/hiding when you press the button.

If you have an FLTK distribution, have a look at the program test/resize.cxx as an example of how to do resizing based on button clicks.

cup
  • 7,589
  • 4
  • 19
  • 42
0

I'm not sure I understand what your exact problem is... Perhaps you need a widget that's not always shown on your main Fl_Window. Then pressing another button makes it visible and attached somewhere in the window, according to the window's size... And when you resize the window, it changes its position, so it is always located, let's say, at the bottom right of it. If I have understood your problem correctly, then make a class, myWindow or whatever, a subclass of Fl_Window. And override the resize function, which is called when the window is being resized.

class myWindow:public Fl_Window{
     Fl_Button *mySpecialWidget; //the movable widget (not allways a button ofc)
     public:
     myWindow(int x, int y, int w, int h, const char *L=NULL):
                                              Fl_Window(x,y,w,h,L){ 
        mySpecialWidget = new Fl_Button(.....);  //initialize subwidget here
        add(mySpecialWidget);                //add it as a subwidget of myWindow
        //may also include all the other needed widgets here...
     }
     void resize(int x, int y, int w, int h){
         //override this Fl_Window function, with
         //any extra functionality that you need
         //example, check window size-> set relevant position for mySpecialWidget
     }
}
Frustrated Soul
  • 341
  • 3
  • 11