> Hello,
> I've been working with fluid for a single window for quite a while now and I 
> would like my program to be able to create extra windows. Here, I just want 
> to use an example where I'd like to have a menuitem of Help->About to create 
> a little window with some text and an OK button, but it's not working.
> 
> Q1)In the code below, I only get the new about window to appear without the 
> extra Fl_Button. Could somebody please explain why?

Telling exactly what was happening under the hood is little bit tricky since
provided sample, at some point, is wrong. Instead 'while(1==1);' you
probably wanted this:

while(aboutWin->visible())
  Fl::wait();

I assuming that code before entering 'while(1==1);' would show
window, and step into infinite loop without enought time to display
button. You should use above sample for all your dialog windows since it
will nicely pool events and update window.

> Q2)Also, is it all right not to make the pointer to the new button global if 
> I don't intend to change its properties in the future?  I assume that a "new" 
> command will allocate on the object on the stack and will stay there until I 
> do a delete. (In total contradiction to my reasoning on how it's supposed to 
> work, I added the while (1==1) out of desperation to see if it will help to 
> make the button appear. I don't think that it is correct programming)

Second part of question is above. Yes, allocated objects will stay, but
you must not free them manually. Fltk will do that for you.

> Q3)Every time I create a new window, is it correct to say I do NOT need some 
> sort of low CPU hogging while () statement to keep data structures alive?

You must have some while() loop for every newly created window or how it
will receive events? Using window->visible()/Fl::wait() combination
will not create cpu hog. Also will add ability to nicely close window
cleaning it's internal stuff.

So to sum thing up, I would do the following:

void aboutWinCB(FL_Widget *, void * paramVoid) {
  aboutWin = new Fl_Window(300,180)
  Fl_Button *aboutOK= new Fl_Button (50,50,50,50,"OK");
  aboutWin->end();
  aboutWin->show();

  while(aboutWin->visible())
    Fl::wait();
}

int main() {

  // init main window etc.

  // make sure you end main() with this
  // so application can happily run :)
  return Fl::run();
}

Hoping now works :)

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

Reply via email to