Re: [gtkmm] General C++ Design Question: relation of GUI toapplication



Paul Davis wrote:

>You've made it one or more steps more complex than necessary

  Your example made that clear.    My grasp of the general idea:  Suppose we need
a static function from class W which refers to functions of classes X1,X2,..
through pointers that W keeps to those classes.  Then to create the static
function within W that uses member functions of the Xi, we write such a function
that also takes those pointers as arguments.  Within a scope where all the
pointers have been assigned, we indeed have a static function.

Advantages of the method:
1) We can change the Xi dynamically
2) If W is dynamically created and destroyed in a program, We are not comitted to
keeping the Xi alive since they
     don't have global scope.
Disadvantages:
 1) When you need static member function of W that uses member functions of the
Xi, the static function
      looks slightly more complicated (versus the same function written as if the
Xi were global)  since the Xi become arguments of that function.


>         /* every 1 second, call Foo::fooFunction() on
>          whatever Foo barclass references.

>            Note that the timeout method doesn't allow you
>          to supply arguments unless they are implicitly
>            passed in the third argument. Ask if you
>         don't understand this point.
>          */

>         gtk_timeout_add(1000, Bar::_barFunction, &barclass);

  In my current simple application I don't need understand it, but this brings up
a major area of my ignorance.  On one hand I read that gtkmm makes "type safe"
callbacks possible.  I ask myself:  How could this be done?
How could gtkmm known in advance all the possible combinations of arguments that
I would want to pass to a callback?
Maybe it could work by restricting the number of combinations.   Maybe it could
work the old fashioned way by passing a pointer to a list of arguments - but that
wouldn't be "type safe" would it?  Maybe it could work by using templates, but
the web pages say it doesn't use them.

   So far, I am just taking the gtkmm1.2  examples and perturbing them in various
ways to see how the system works.
I can usually find an example of a call to slot(...) which fits what I am trying
to do.  But I really don't understand exactly what kind of animal slot(..) is and
how it can really be "type safe"?    The same for gtk_timeout_add(..).



--
Stephen Tashiro
tashiro trac wsmr army mil
tashiro zianet com
"Never let the task you are trying to accomplish
  distract you from the study of computers."






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]