/* * Class def of a Athena-style function button, with a call-back function * associated with the button. Here's the idea: * * -- FuncButton is a subclass iv's PushButton * -- The member CallBack points to the callback for the button. * -- The FuncButton constructor takes the name of the callback as a parm * and initializes the CallBack member to the parm value. * -- The callback decl is parameterized with a two formal parms: (1) a * void* StaticParm that is set when the function button is * constructed; (2) an Event* DynamicParm that is sent in by Press when * the function button is pressed. * -- FuncButton reimplements PushButton's virtual Press function to call * the CallBack member. */ #include /* * Note: the following type def is REQUIRED to avoid a g++ error (version 1.39) * described in ~gfisher/c++/func-parm-bug.c */ typedef void (*FuncPtr)(void*, Event*); class FuncButton : public PushButton { public: FuncButton(FuncPtr Func, char* Label, void* StaticParm); void (*CallBack)(void* StaticParm, Event* DynamicParm); protected: void Press(Event*); void Handle (register Event&); void *CallBackParm; };