Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

UGenCallImpl Class Reference

UCall and its template subclasses define a family of classes for adding callback functions and methods to other bricks. More...

#include <ucall.hpp>

Inheritance diagram for UGenCallImpl:

UBrick List of all members.

Detailed Description

UCall and its template subclasses define a family of classes for adding callback functions and methods to other bricks.

UClass is never instanciated nor used directly. Instead, you must use a variety of ucall( ) or uset( ) functions as explained below.

1. Adding callbacks to UGroup / UBox / UWin objets (and subclasses)

a) Calling non-member functions


      ubutton("Click Me" + UOn::action / ucall(arg, func1))
      ubutton("Click Me" + ucallref(arg1, arg2, func2))
 

b) Calling member functions (ie. "methods")


      ucheckbox("Select Me" + UOn::select / ucall(obj, &Myclass::memfunc1))
      uhbox("Press Me" + UOn::mpress / ucallref(obj, arg1, arg2, &Myclass::memfunc2)

c) Adding callbacks after object creation

This can be done by using the add( ) method:


      UBox& b = ubutton("Click Me");
      b.add(UOn::mclick / ucall(....));

d) Callback Prototypes

They must have the same arguments as those that are passed to ucall(). Note that the types must be IDENTICAL. Prototypes can also have an optional UEvent& argument (which must be the first argument when present).

Exemples:


      void func1(bool state) { ...}
     or:
      void func1(UEvent& e, bool state) { ...}

      ucheckbox("Select Me" 
                + UOn::select   / ucall(true, func1)
                + UOn::unselect / ucall(false, func1)
                );

      void MyClass::memfunc2(UColor& fg, UBgolor& bg) { ...}
     or:
      void MyClass::memfunc2(UEvent& e, UColor& fg, UBgolor& bg) { ...}

      MyClass*  obj = new MyClass();
      UColor&   col1 = ...;
      UBgcolor& col2 = ...;
      ubutton("Click Me" + ucallref(obj, col1, col2, &Myclass::memfunc2);

2. Predefined Callback objects

Examples:

     UStr s1;
     UStr s2 = "toto";

     ubutton("Press Me" + UOn::mpress / uset(&a, &b))
   or:
     ubutton("Press Me" + UOn::mpress / usetref(&a, b))
 

Example: the dialog will be closed when the "Close" button is clicked or released:

          udialog( ... + ubutton("Close" + ucloseWin()) + ... )
          udialog( ... + ubutton("Close" + UOn::mrelease / ucloseWin()) + ... )
 


The documentation for this class was generated from the following files:
Generated on Fri Jun 3 03:30:16 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.2