Programmable real-time audio signal processing application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Fl_CbLinker.cpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //| Copyright: (C) 2019-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. #include <FL/Fl.H>
  4. #include <FL/Fl_Widget.H>
  5. #include <FL/Fl_Button.H>
  6. #include <FL/Fl_Scrollbar.H>
  7. #include <FL/Fl_Menu_Button.H>
  8. #include <FL/Fl_Menu_Item.H>
  9. #include <vector>
  10. #include <assert.h>
  11. #include "Fl_CbLinker.h"
  12. Fl_CbLinker::Fl_CbLinker()
  13. {}
  14. Fl_CbLinker::~Fl_CbLinker()
  15. {
  16. unsigned i;
  17. for(i=0; i<_ctlV.size(); ++i)
  18. delete _ctlV[i];
  19. }
  20. void Fl_CbLinker::registerCtl( Fl_Button* c, unsigned id )
  21. {
  22. ctl_t* r;
  23. _ctlV.push_back( r = new ctl_t(this,c,id) );
  24. c->callback(_s_callback,r);
  25. }
  26. void Fl_CbLinker::registerCtl( Fl_Scrollbar* c, unsigned id )
  27. {
  28. ctl_t* r;
  29. _ctlV.push_back( r = new ctl_t(this,c,id) );
  30. c->callback(_s_callback,r);
  31. }
  32. void Fl_CbLinker::registerCtl( Fl_Menu_Button* c, unsigned id )
  33. {
  34. ctl_t* r;
  35. _ctlV.push_back( r = new ctl_t(this,c,id) );
  36. c->callback(_s_callback,r);
  37. }
  38. void Fl_CbLinker::registerCtl( Fl_Menu_Item* c, unsigned id )
  39. {
  40. ctl_t* r;
  41. _ctlV.push_back( r = new ctl_t(this,c,id) );
  42. c->callback(_s_callback,r);
  43. }
  44. void Fl_CbLinker::onButton( Fl_Button* c, unsigned id )
  45. {}
  46. void Fl_CbLinker::onScrollbar( Fl_Scrollbar* c, unsigned id )
  47. {}
  48. void Fl_CbLinker::onMenuBtn( Fl_Menu_Button* c, unsigned id )
  49. {}
  50. void Fl_CbLinker::onMenuItem( Fl_Menu_Item* c, unsigned id )
  51. {}
  52. void Fl_CbLinker::_s_callback( Fl_Widget* w, void* arg )
  53. {
  54. ctl_t* r = static_cast<ctl_t*>(arg);
  55. unsigned i;
  56. for(i=0; i<r->thisPtr->_ctlV.size(); ++i)
  57. if( r->thisPtr->_ctlV[i] == arg )
  58. {
  59. switch( r->typeId )
  60. {
  61. case kButtonTId: r->thisPtr->onButton( r->u.btn, r->ctlId); break;
  62. case kScrollbarTId: r->thisPtr->onScrollbar( r->u.sb, r->ctlId); break;
  63. case kMenuBtnTId: r->thisPtr->onMenuBtn( r->u.mbtn, r->ctlId); break;
  64. case kMenuItemTId: r->thisPtr->onMenuItem( r->u.mitem, r->ctlId); break;
  65. default:
  66. { assert(0); }
  67. }
  68. }
  69. }