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.

app.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef app_h
  2. #define app_h
  3. class Fl_HSplitter;
  4. class Fl_Text_Buffer;
  5. class Fl_Text_Display;
  6. class Fl_Box;
  7. class Fl_Tabs;
  8. struct Fl_Menu_Item;
  9. class Fl_Menu_Bar;
  10. class Fl_Group;
  11. class Fl_Button;
  12. class Fl_Valuator;
  13. class Fl_Input;
  14. class drawWnd;
  15. class app : public Fl_Double_Window
  16. {
  17. public:
  18. // widget id's for widgets created by createControls()
  19. enum
  20. {
  21. kFileOpenMId,
  22. kFileNewMId,
  23. kEditCopyMId,
  24. kEditPasteMId,
  25. kBtn1MId,
  26. kBtn2MId,
  27. kBtn3MId,
  28. kMenuBtn1MId,
  29. kMenuBtn2MId,
  30. kValue1MId,
  31. kValue2MId,
  32. kInput1MId
  33. };
  34. app(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const char *l, int argc, char *argv[]);
  35. virtual ~app();
  36. // Example tabbed window initialization example function
  37. // which also demonstrates some widgets
  38. void createControls(Fl_Group* grp);
  39. // called once from app() to initialize each tabbed window
  40. virtual void initializeTab(int tabIndex, int x, int y, int w, int h, const char* label);
  41. // Create the application menu
  42. virtual void createMenu( int menuWidth, int menuHeight );
  43. // Widget type specific callbacks
  44. virtual void menuCallback( const Fl_Menu_Item* ip, long int id ); // menu and menu btn callback
  45. virtual void btnCallback( const Fl_Button* bp, int id ); // btn callback
  46. virtual void valueCallback(const Fl_Valuator* vp, int id ); // valuator callback
  47. virtual void inputCallback(const Fl_Input* ip, int id ); // text input callback
  48. virtual void appCallback(Fl_Widget* wp); // app event callback
  49. virtual bool idleCallback(); // return false to stop callback
  50. virtual bool timerCallback(); // return false to stop callback
  51. void error( const char* fmt, ... ); // report on error
  52. // print to the console
  53. virtual void vprint( const char* fmt, va_list vl );
  54. virtual void print( const char* fmt, ... );
  55. protected:
  56. enum
  57. {
  58. kStatusH = 30,
  59. kMenuH = 30,
  60. kCtlH = 30
  61. };
  62. // static callbacks
  63. static void _s_menu_cb( Fl_Widget* wp, void* data); // menu item callback
  64. static void _s_menu_btn_cb(Fl_Widget* wp, void* data); // menu btn callback
  65. static void _s_btn_cb( Fl_Widget* wp, long data); // button callback
  66. static void _s_value_cb( Fl_Widget* wp, long data); // value input or slider callback
  67. static void _s_input_cb( Fl_Widget* wp, long data); // text input callback
  68. static void _s_callback( Fl_Widget* wp, void* data); // main app callback
  69. static void _s_idle_cb( void* data); // idle callback
  70. static void _s_timer_cb( void* userPtr); // timer callback
  71. static void _s_print( void* userPtr, const char* text ); // print text to the console
  72. void _create_tabs(int titleCnt, const char* titleArray[]);
  73. // walk down the widget tree until the app (root) widget is located
  74. static app* _getApp( Fl_Widget* w );
  75. // called internally by cmTsQueueDequeue() to send text to _print()
  76. static cmRC_t _s_print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr );
  77. // called periodically to check the print queue for waiting text.
  78. void _checkPrintQueue();
  79. // send a string of text directly to the output console window
  80. void _print( const char* text );
  81. double _timerPeriodSecs; // repeat period for the timer callback
  82. cmCtx_t* _ctx; //
  83. Fl_HSplitter* _splt; // main splitter window
  84. Fl_Text_Buffer* _buf; // text buffer used by _con
  85. Fl_Text_Display* _con; // text console output window
  86. Fl_Tabs* _tabs; // tabs window
  87. Fl_Menu_Bar* _menu; // app. menu
  88. drawWnd* _draw; // custom widget
  89. cmTsMp1cH_t _printqH; // thread-safe queue for controlling access to the output console from multiple threads
  90. int _printFl; // used to prevent recursion due to throwing printing error
  91. };
  92. #endif