123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #ifndef app_h
- #define app_h
-
- class Fl_HSplitter;
- class Fl_Text_Buffer;
- class Fl_Text_Display;
- class Fl_Box;
- class Fl_Tabs;
- struct Fl_Menu_Item;
- class Fl_Menu_Bar;
- class Fl_Group;
- class Fl_Button;
- class Fl_Valuator;
- class Fl_Input;
- class drawWnd;
-
- class app : public Fl_Double_Window
- {
-
- public:
-
- // widget id's for widgets created by createControls()
- enum
- {
- kFileOpenMId,
- kFileNewMId,
- kEditCopyMId,
- kEditPasteMId,
-
- kBtn1MId,
- kBtn2MId,
- kBtn3MId,
-
- kMenuBtn1MId,
- kMenuBtn2MId,
-
- kValue1MId,
- kValue2MId,
-
- kInput1MId
- };
-
- app(cmCtx_t* ctx, cmTsMp1cH_t printqH, int w, int h, const char *l, int argc, char *argv[]);
- virtual ~app();
-
- // Example tabbed window initialization example function
- // which also demonstrates some widgets
- void createControls(Fl_Group* grp);
-
- // called once from app() to initialize each tabbed window
- virtual void initializeTab(int tabIndex, int x, int y, int w, int h, const char* label);
-
- // Create the application menu
- virtual void createMenu( int menuWidth, int menuHeight );
-
- // Widget type specific callbacks
- virtual void menuCallback( const Fl_Menu_Item* ip, long int id ); // menu and menu btn callback
- virtual void btnCallback( const Fl_Button* bp, int id ); // btn callback
- virtual void valueCallback(const Fl_Valuator* vp, int id ); // valuator callback
- virtual void inputCallback(const Fl_Input* ip, int id ); // text input callback
-
- virtual void appCallback(Fl_Widget* wp); // app event callback
- virtual bool idleCallback(); // return false to stop callback
- virtual bool timerCallback(); // return false to stop callback
-
- void error( const char* fmt, ... ); // report on error
-
- // print to the console
- virtual void vprint( const char* fmt, va_list vl );
- virtual void print( const char* fmt, ... );
-
- protected:
- enum
- {
- kStatusH = 30,
- kMenuH = 30,
- kCtlH = 30
- };
-
- // static callbacks
- static void _s_menu_cb( Fl_Widget* wp, void* data); // menu item callback
- static void _s_menu_btn_cb(Fl_Widget* wp, void* data); // menu btn callback
- static void _s_btn_cb( Fl_Widget* wp, long data); // button callback
- static void _s_value_cb( Fl_Widget* wp, long data); // value input or slider callback
- static void _s_input_cb( Fl_Widget* wp, long data); // text input callback
- static void _s_callback( Fl_Widget* wp, void* data); // main app callback
-
- static void _s_idle_cb( void* data); // idle callback
- static void _s_timer_cb( void* userPtr); // timer callback
- static void _s_print( void* userPtr, const char* text ); // print text to the console
-
- void _create_tabs(int titleCnt, const char* titleArray[]);
-
- // walk down the widget tree until the app (root) widget is located
- static app* _getApp( Fl_Widget* w );
-
- // called internally by cmTsQueueDequeue() to send text to _print()
- static cmRC_t _s_print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr );
-
- // called periodically to check the print queue for waiting text.
- void _checkPrintQueue();
-
- // send a string of text directly to the output console window
- void _print( const char* text );
-
- double _timerPeriodSecs; // repeat period for the timer callback
-
- cmCtx_t* _ctx; //
- Fl_HSplitter* _splt; // main splitter window
- Fl_Text_Buffer* _buf; // text buffer used by _con
- Fl_Text_Display* _con; // text console output window
- Fl_Tabs* _tabs; // tabs window
- Fl_Menu_Bar* _menu; // app. menu
- drawWnd* _draw; // custom widget
- cmTsMp1cH_t _printqH; // thread-safe queue for controlling access to the output console from multiple threads
- int _printFl; // used to prevent recursion due to throwing printing error
- };
-
- #endif
|