michael sephton wrote:
> 
> 
> David Ibbitson wrote:
>> I'm just subclassing Fl_Double_Window and overriding the draw() method.
>> My subclass is basically just a composite widget.  I've been following
>> the docs but the window just isn't being drawn correctly. Its just
>> full of garbage, like the buffer hasnt been properly initialized.
>> Here's the code:
>>
>>
>>
>> #include <FL/Fl.H>
>> #include <FL/Fl_Double_Window.H>
>> #include <FL/fl_draw.H>
>>
>> class mywin : public Fl_Double_Window {
>>
>> public:
>>
>>     mywin(int x,int y,int w,int h,const char * label = 0)
>>         : Fl_Double_Window(x,y,w,h,label) {
>>         box(FL_THIN_UP_BOX);
>>         color(fl_rgb_color(190,192,190));
>>     }
>>
>>     ~mywin() { }
>>
>> protected:
>>
>>     void draw();
>>
>> };
>>
>> void mywin::draw() {
>>     Fl_Widget * const * a = array();
>>     if(damage() == FL_DAMAGE_CHILD) {
>>         for(int i = children(); i--; a++)
>>             update_child(**a);
>>     }
>>     else if(damage() == FL_DAMAGE_ALL) {
>>         draw_box(box(),color());
>>         for(int i = children(); i--; a++)
>>             draw_child(**a);
>>     }
>>     else if(damage() & (FL_DAMAGE_ALL | 1)) {
>>         // update area 1 ...
>>     }
>> }
>>
>> int main(int argc, char ** argv) {
>>
>>     mywin * w = new mywin(200,200,200,200,"mywin");
>>     w->end();
>>
>>     w->show();
>>
>>     return Fl::run();
>> }
> 
> 
> 
> I think that in David's example, the window is filled with junk because 
> Fl_Double_Window::draw() is not called at the start of the mywin::draw() 
> function.
> So try:
> void mywin::draw() {
>      Fl_Double_Window::draw();
>      //Your code here
>  }

Hi Michael,

I've tried that as well, same result...
However it does work if I remove the box() call from the constructor.
Very strange..

Cheers,
David
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to