Usage:
   class fooWindow : public Window, public Slot<fooWindow> {
   public:
         fooWindow(...)
           ...
         {
           slot<&fooWindow::memberfunction>(barWidget);
         }
   ...
   }
No patch,only include the header.

>
>
> -----------------------------Simple Header-------------------------
> #ifndef _FLSLOT_H_
> #define _FLSLOT_H_
>
> namespace fltk {
>   class Widget;
>   template<typename windowT>
>   class Slot {
>   public:
>     template<void (windowT::*methodP)(),typename widgetT>
>     slot(widgetT* widget) {
>       widget->callback(&stub<methodP>,static_cast<void*>(this));
>     }
>     template<void (windowT::*methodP)() const,typename widgetT>
>     slot(widgetT* widget) {
>       widget->callback(&stub<methodP>,static_cast<void*>(this));
>     }
>     template<void (windowT::*methodP)(),typename widgetT>
>     slot(widgetT& widget) {
>       widget.callback(&stub<methodP>,static_cast<void*>(this));
>     }
>     template<void (windowT::*methodP)() const,typename widgetT>
>     slot(widgetT& widget) {
>       widget.callback(&stub<methodP>,static_cast<void*>(this));
>     }
>   private:
>     template<void (windowT::*methodP)()>
>     static void stub(Widget* widget,void* window){
>       (static_cast<windowT*>(window)->*methodP)();
>     }
>     template<void (windowT::*methodP)() const>
>     static void stub(Widget* widget,void* window){
>       (static_cast<windowT*>(window)->*methodP)();
>     }
>   };
> }
>
> #endif /* _FLSLOT_H_ */
>

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

Reply via email to