DataDirector API
dynamic_fl_choice.h
1 #ifndef _DYNAMIC_FL_CHOICE
2 #define _DYNAMIC_FL_CHOICE
3 
4 #include <FL/Fl_Choice.H>
5 
7 typedef void (Dynamic_Fl_Choice_Callback )(Dynamic_Fl_Choice*, void*);
8 
9 class Dynamic_Fl_Choice : public Fl_Choice
10 {
11 public:
12 
13  Dynamic_Fl_Choice_Callback* beforePopCallback_;
14  void* beforePopUserData_;
15 
16  Dynamic_Fl_Choice(int x,int y,int w,int h,const char *n = 0)
17  : Fl_Choice(x,y,w,h,n),
18  beforePopCallback_(NULL),
19  beforePopUserData_(NULL)
20  {
21  }
22 
23  void BeforePopCallback(Dynamic_Fl_Choice_Callback callback, void* userData = NULL)
24  {
25  beforePopCallback_ = callback;
26  beforePopUserData_ = userData;
27  }
28 
29  int handle(int e)
30  {
31  // Give the user the opertunity to modify the menu
32  // before poping it up.
33  if ((e == FL_PUSH ||
34  e == FL_SHORTCUT) &&
35  beforePopCallback_)
36  {
37  (beforePopCallback_)(this, beforePopUserData_);
38  }
39  // Call the normal handle
40  return Fl_Choice::handle(e);
41  }
42 };
43 
44 #endif
45 
Definition: dynamic_fl_choice.h:9