MacArthur, Ian (SELEX GALILEO, UK) wrote:

[ ... lots of useful and hopefully helpful stuff (removed) ]

I'll add a few comments ...

>> Questions:
>>
>> - Is simply the first window which is defined the parent 
>> window? Or has 
>> it to do with the special show() with the arguments argc and argv 
>> inside? -> How does FLTK know which window the main window is?
> 
> I think that whichever window is "current" is taken as the parent for
> attaching a modal window to.

Yes, that's true. It's the last window that got an event, unless there is 
another modal window - then this one stays on top of the (internal) list for 
candidates to become the parent window.

> So you can have several "top level" windows, each with some sub-windows
> modal to it, if that is what you want.
> You can set which top-level window is current in several ways, but the
> simplest way is often just to call show() on the window before making
> the sub-windows modal.

Technically spoken, it would be "before show()ing the new modal window the 
first 
time", emphasis on _show()ing_, not only calling modal().

>> - How does FLTK know that a window is a child window?
> 
> See above.

The point here is that a real child window (embedded in the parent window) has 
a 
parent() set (a window or another group in another window). You do this by 
add()ing it to the group or creating it between begin() and end().

If you want to be sure to create a top level window, you can call 
Fl_Group::current(0) before creating the window (this would prevent it from 
becoming a child window, if you didn't end() another window or group before, 
which is likely to happen, if you change your program and rearrange widgets, 
groups, and windows).

Just another note: "end() is exactly the same as current(this->parent()). Any 
new widgets added to the widget tree will be added to the parent of the group."

see <http://www.fltk.org/doc-1.1/Fl_Group.html#Fl_Group.end>

Sometimes this can be surprising: if you want to add some widgets to a group 
with begin() and end() *without* having the parent group or window become the 
[Fl_Group::]current() group.

>> Is simply every 
>> window definitioned after show(argc, argv) of the parent 
>> window a child?
> 
> No, unless you make a window explicitly modal or non-modal it will be a
> full top-level window in its own right. 

... unless you added it as a child to another window (see above).

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

Reply via email to