> But like Colombo...'just one more thing..' >

Actually - you asked two more questions...!


> button->callback(button_cb);
> 
> why only one argument in this?

Because the second argument is defined as being optional (you can do
that in C++) so if you don't pass it in here, the compiler defaults it
to whatever you defined in the declaration of the method - NULL in this
case I think...




> int when = 0;
> Fl_Input *input[5];
> 
> void toggle_cb(Fl_Widget *o, long v) {
>   if (((Fl_Toggle_Button*)o)->value()) when |= v; else when 
> &= ~v; //this line! (from 'when', i understand the part in the if())

OK, here we go; this is all standard C though, so a little time with a
decent C manual would possibly help.

At the top of the code fragment, "when" is declared as an int and set to
zero.

Later, after the if() we see:

        when |= v;

Which expands to:

        when = when | v;  ( the |= notation is a shorthand form for
that...)

Which says that when becomes equal to the binary OR of when and v. Here,
when and v are bitmasks, with each bit having a specific meaning, and we
are OR'ing in new bits from v into when.

The else condition says:

        when &= ~v;

Which similarly expands to:

        when = when & (~v);

This means that when becomes equal to the binary AND of when and the
1-compliment (binary inversion) of v (the ~v notation means every 1
flipped to 0 and v.v.)
What this does is to *remove* from when any bits that are set in v.
Though you might have to write that out on paper to see it working!

>   for (int i=0; i<5; i++) input[i]->when(when);

And here we have two different "when" items - the "when" that is a
member of input[i] and the one we have just created locally.




SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to