[773] | 1 | // |
---|
| 2 | // "$Id: run.h 4218 2005-03-31 05:14:08Z spitzak $" |
---|
| 3 | // |
---|
| 4 | // The basic fltk runtime. Every program needs to call this somewhere. |
---|
| 5 | // |
---|
| 6 | // Copyright 1998-2003 by Bill Spitzak and others. |
---|
| 7 | // |
---|
| 8 | // This library is free software; you can redistribute it and/or |
---|
| 9 | // modify it under the terms of the GNU Library General Public |
---|
| 10 | // License as published by the Free Software Foundation; either |
---|
| 11 | // version 2 of the License, or (at your option) any later version. |
---|
| 12 | // |
---|
| 13 | // This library is distributed in the hope that it will be useful, |
---|
| 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 16 | // Library General Public License for more details. |
---|
| 17 | // |
---|
| 18 | // You should have received a copy of the GNU Library General Public |
---|
| 19 | // License along with this library; if not, write to the Free Software |
---|
| 20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
| 21 | // USA. |
---|
| 22 | // |
---|
| 23 | // Please report all bugs and problems to "fltk-bugs@fltk.org". |
---|
| 24 | // |
---|
| 25 | |
---|
| 26 | #ifndef fltk_run_h |
---|
| 27 | #define fltk_run_h |
---|
| 28 | |
---|
| 29 | #include "FL_API.h" |
---|
| 30 | #ifdef check |
---|
| 31 | # undef check |
---|
| 32 | #endif |
---|
| 33 | |
---|
| 34 | namespace fltk { |
---|
| 35 | |
---|
| 36 | /*! \addtogroup startup |
---|
| 37 | \{ */ |
---|
| 38 | FL_API float version(); |
---|
| 39 | FL_API void display(const char*); |
---|
| 40 | FL_API int arg(int, char**, int&); |
---|
| 41 | FL_API int args(int, char**, int&, int (*)(int,char**,int&) = 0); |
---|
| 42 | extern FL_API const char* const help; |
---|
| 43 | FL_API void args(int, char**); |
---|
| 44 | FL_API bool enable_tablet_events(); |
---|
| 45 | |
---|
| 46 | /*! \} */ |
---|
| 47 | |
---|
| 48 | /*! \addtogroup execution |
---|
| 49 | \{ */ |
---|
| 50 | FL_API int wait(); |
---|
| 51 | FL_API int wait(float time); |
---|
| 52 | FL_API int check(); |
---|
| 53 | FL_API int ready(); |
---|
| 54 | FL_API int run(); |
---|
| 55 | FL_API void flush(); |
---|
| 56 | FL_API void redraw(); |
---|
| 57 | extern FL_API int damage_; |
---|
| 58 | inline void damage(int d) {damage_ = d;} |
---|
| 59 | inline int damage() {return damage_;} |
---|
| 60 | |
---|
| 61 | /*! Type of function passed to add_timeout(), add_check(), and add_idle() */ |
---|
| 62 | typedef void (*TimeoutHandler)(void*); |
---|
| 63 | |
---|
| 64 | FL_API void add_timeout(float t, TimeoutHandler, void* v = 0); |
---|
| 65 | FL_API void repeat_timeout(float t, TimeoutHandler,void* = 0); |
---|
| 66 | FL_API bool has_timeout(TimeoutHandler, void* = 0); |
---|
| 67 | FL_API void remove_timeout(TimeoutHandler, void* = 0); |
---|
| 68 | |
---|
| 69 | FL_API void add_check(TimeoutHandler, void* = 0); |
---|
| 70 | FL_API bool has_check(TimeoutHandler, void* = 0); |
---|
| 71 | FL_API void remove_check(TimeoutHandler, void* = 0); |
---|
| 72 | |
---|
| 73 | FL_API void add_idle(TimeoutHandler, void* = 0); |
---|
| 74 | FL_API bool has_idle(TimeoutHandler, void* = 0); |
---|
| 75 | FL_API void remove_idle(TimeoutHandler, void* = 0); |
---|
| 76 | |
---|
| 77 | // For back-compatability only: |
---|
| 78 | extern FL_API void (*idle)(); |
---|
| 79 | inline void set_idle(void (*cb)()) {idle = cb;} |
---|
| 80 | |
---|
| 81 | /*! Type of function passed to add_fd() */ |
---|
| 82 | typedef void (*FileHandler)(int fd, void*); |
---|
| 83 | enum {READ = 1, WRITE = 4, EXCEPT = 8}; |
---|
| 84 | FL_API void add_fd(int fd, int when, FileHandler, void* =0); |
---|
| 85 | FL_API void add_fd(int fd, FileHandler, void* = 0); |
---|
| 86 | FL_API void remove_fd(int, int when = -1); |
---|
| 87 | |
---|
| 88 | /*! \} */ |
---|
| 89 | |
---|
| 90 | extern FL_API bool in_main_thread_; |
---|
| 91 | |
---|
| 92 | /*! \addtogroup multithreading |
---|
| 93 | \{ */ |
---|
| 94 | FL_API void lock(); |
---|
| 95 | FL_API void unlock(); |
---|
| 96 | FL_API void awake(void* message = 0); |
---|
| 97 | FL_API void* thread_message(); |
---|
| 98 | inline bool in_main_thread() {return in_main_thread_;} |
---|
| 99 | /*! \} */ |
---|
| 100 | |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | #endif |
---|