• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

Fl.H

Go to the documentation of this file.
00001 //
00002 // "$Id$"
00003 //
00004 // Main header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2016 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00023 #ifndef Fl_H
00024 #  define Fl_H
00025 
00026 #include <FL/Fl_Export.H>
00027 
00028 #ifdef FLTK_HAVE_CAIRO
00029 # include <FL/Fl_Cairo.H>
00030 #endif
00031 
00032 #  include "fl_utf8.h"
00033 #  include "Enumerations.H"
00034 #  ifndef Fl_Object
00035 #    define Fl_Object Fl_Widget 
00036 #  endif
00037 
00038 #  ifdef check
00039 #    undef check
00040 #  endif
00041 
00042 
00043 class Fl_Widget;
00044 class Fl_Window;
00045 class Fl_Image;
00046 struct Fl_Label;
00047 
00048 // Keep avoiding having the socket deps at that level but mke sure it will work in both 32 & 64 bit builds
00049 #if defined(WIN32) && !defined(__CYGWIN__)
00050 # if defined(_WIN64)
00051 #  define FL_SOCKET unsigned __int64
00052 # else
00053 #  define FL_SOCKET int
00054 # endif
00055 #else
00056 # define FL_SOCKET int
00057 #endif
00058 
00059 
00060 // Pointers you can use to change FLTK to a foreign language.
00061 // Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx
00062 extern FL_EXPORT const char* fl_local_ctrl;
00063 extern FL_EXPORT const char* fl_local_meta;
00064 extern FL_EXPORT const char* fl_local_alt;
00065 extern FL_EXPORT const char* fl_local_shift;
00066 
00083 typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
00084 
00086 typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height);
00087 
00089 typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color);
00090 
00092 typedef void (*Fl_Timeout_Handler)(void *data);
00093 
00095 typedef void (*Fl_Awake_Handler)(void *data);
00096 
00098 typedef void (*Fl_Idle_Handler)(void *data);
00099 
00101 typedef void (*Fl_Old_Idle_Handler)();
00102 
00104 typedef void (*Fl_FD_Handler)(FL_SOCKET fd, void *data);
00105 
00107 typedef int (*Fl_Event_Handler)(int event);
00108 
00110 typedef int (*Fl_System_Handler)(void *event, void *data);
00111 
00113 typedef void (*Fl_Abort_Handler)(const char *format,...);
00114 
00116 typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data);
00117 
00119 typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
00120 
00123 typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
00124 
00126 typedef void (*Fl_Clipboard_Notify_Handler)(int source, void *data);
00127  /* group callback_functions */
00129 
00130 
00135 class FL_EXPORT Fl {
00136   Fl() {}; // no constructor!
00137   
00138 private:
00139   static int use_high_res_GL_;
00140   
00141 public: // should be private!
00142 #ifndef FL_DOXYGEN
00143   static int e_number;
00144   static int e_x;
00145   static int e_y;
00146   static int e_x_root;
00147   static int e_y_root;
00148   static int e_dx;
00149   static int e_dy;
00150   static int e_state;
00151   static int e_clicks;
00152   static int e_is_click;
00153   static int e_keysym;
00154   static char* e_text;
00155   static int e_length;
00156   static void *e_clipboard_data;
00157   static const char *e_clipboard_type;
00158   static Fl_Event_Dispatch e_dispatch;
00159   static Fl_Widget* belowmouse_;
00160   static Fl_Widget* pushed_;
00161   static Fl_Widget* focus_;
00162   static int damage_;
00163   static Fl_Widget* selection_owner_;
00164   static Fl_Window* modal_;
00165   static Fl_Window* grab_;
00166   static int compose_state; // used for dead keys (WIN32) or marked text (MacOS)
00167   static void call_screen_init(); // recompute screen number and dimensions
00168 #ifdef __APPLE__
00169   static void reset_marked_text(); // resets marked text
00170   static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point
00171 #endif
00172 #endif // FL_DOXYGEN
00173   
00174   
00178   static void damage(int d) {damage_ = d;}
00179   
00180 public:
00187   typedef enum {
00197     OPTION_ARROW_FOCUS = 0,
00198       // When switched on, FLTK will use the file chooser dialog that comes 
00199       // with your operating system whenever possible. When switched off, FLTK
00200       // will present its own file chooser.
00201       // \todo implement me
00202     // OPTION_NATIVE_FILECHOOSER,
00203       // When Filechooser Preview is enabled, the FLTK or native file chooser
00204       // will show a preview of a selected file (if possible) before the user
00205       // decides to choose the file.
00206       // \todo implement me
00207     //OPTION_FILECHOOSER_PREVIEW,
00212     OPTION_VISIBLE_FOCUS,
00216     OPTION_DND_TEXT,
00220     OPTION_SHOW_TOOLTIPS,
00224     OPTION_FNFC_USES_GTK,
00225       // don't change this, leave it always as the last element
00227     OPTION_LAST
00228   } Fl_Option;
00229 
00230 private:  
00231   static unsigned char options_[OPTION_LAST];
00232   static unsigned char options_read_;
00233   
00234 public:  
00235   /*
00236    Return a global setting for all FLTK applications, possibly overridden
00237    by a setting specifically for this application.
00238    */
00239   static bool option(Fl_Option opt);
00240   
00241   /*
00242    Override an option while the application is running.
00243    */
00244   static void option(Fl_Option opt, bool val);
00245   
00253   static void (*idle)();
00254 
00255 #ifndef FL_DOXYGEN
00256   static Fl_Awake_Handler *awake_ring_;
00257   static void **awake_data_;
00258   static int awake_ring_size_;
00259   static int awake_ring_head_;
00260   static int awake_ring_tail_;
00261   static const char* scheme_;
00262   static Fl_Image* scheme_bg_;
00263 
00264   static int e_original_keysym; // late addition
00265   static int scrollbar_size_;
00266 #endif
00267 
00268 
00269   static int add_awake_handler_(Fl_Awake_Handler, void*);
00270   static int get_awake_handler_(Fl_Awake_Handler&, void*&);
00271 
00272 public:
00273 
00274   // API version number
00275   static double version();
00276   static int api_version();
00277 
00278   // ABI version number
00279   static int abi_version();
00280 
00303   static inline int abi_check(const int val = FL_ABI_VERSION) {
00304     return val == abi_version();
00305   }
00306 
00307   // argument parsers:
00308   static int arg(int argc, char **argv, int& i);
00309   static int args(int argc, char **argv, int& i, Fl_Args_Handler cb = 0);
00310   static void args(int argc, char **argv);
00315   static const char* const help;
00316 
00317   // things called by initialization:
00318   static void display(const char*);
00319   static int visual(int);
00329   static int gl_visual(int, int *alist=0); // platform dependent
00330   static void own_colormap();
00331   static void get_system_colors();
00332   static void foreground(uchar, uchar, uchar);
00333   static void background(uchar, uchar, uchar);
00334   static void background2(uchar, uchar, uchar);
00335 
00336   // schemes:
00337   static int scheme(const char *name);
00339   static const char* scheme() {return scheme_;}
00340 
00368   static int is_scheme(const char *name) {
00369     return (scheme_ && name && !strcmp(name,scheme_));
00370   }
00376   static int reload_scheme(); // platform dependent
00377   static int scrollbar_size();
00378   static void scrollbar_size(int W);
00379 
00380   // execution:
00381   static int wait();
00382   static double wait(double time);
00383   static int check();
00384   static int ready();
00385   static int run();
00386   static Fl_Widget* readqueue();
00417   static void add_timeout(double t, Fl_Timeout_Handler,void* = 0); // platform dependent
00438   static void repeat_timeout(double t, Fl_Timeout_Handler, void* = 0); // platform dependent
00439   static int  has_timeout(Fl_Timeout_Handler, void* = 0);
00440   static void remove_timeout(Fl_Timeout_Handler, void* = 0);
00441   static void add_check(Fl_Timeout_Handler, void* = 0);
00442   static int  has_check(Fl_Timeout_Handler, void* = 0);
00443   static void remove_check(Fl_Timeout_Handler, void* = 0);
00463   static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent
00465   static void add_fd(int fd, Fl_FD_Handler cb, void* = 0); // platform dependent
00467   static void remove_fd(int, int when); // platform dependent
00469   static void remove_fd(int); // platform dependent
00470 
00471   static void add_idle(Fl_Idle_Handler cb, void* data = 0);
00472   static int  has_idle(Fl_Idle_Handler cb, void* data = 0);
00473   static void remove_idle(Fl_Idle_Handler cb, void* data = 0);
00475   static int damage() {return damage_;}
00476   static void redraw();
00477   static void flush();
00498   static void (*warning)(const char*, ...);
00513   static void (*error)(const char*, ...);
00530   static void (*fatal)(const char*, ...);
00536   static Fl_Window* first_window();
00537   static void first_window(Fl_Window*);
00538   static Fl_Window* next_window(const Fl_Window*);
00539 
00549   static Fl_Window* modal() {return modal_;}
00555   static Fl_Window* grab() {return grab_;}
00580   static void grab(Fl_Window*); // platform dependent
00587   // event information:
00593   static int event()            {return e_number;}
00598   static int event_x()  {return e_x;}
00603   static int event_y()  {return e_y;}
00610   static int event_x_root()     {return e_x_root;}
00617   static int event_y_root()     {return e_y_root;}
00622   static int event_dx() {return e_dx;}
00627   static int event_dy() {return e_dy;}
00636   static void get_mouse(int &,int &); // platform dependent
00645   static int event_clicks()     {return e_clicks;}
00653   static void event_clicks(int i) {e_clicks = i;}
00661   static int event_is_click()   {return e_is_click;}
00668   static void event_is_click(int i) {e_is_click = i;}
00678   static int event_button()     {return e_keysym-FL_Button;}
00704   static int event_state()      {return e_state;}
00705 
00711   static int event_state(int mask) {return e_state&mask;}
00723   static int event_key()        {return e_keysym;}
00732   static int event_original_key(){return e_original_keysym;}
00771   static int event_key(int key);
00777   static int get_key(int key); // platform dependent
00792   static const char* event_text() {return e_text;}
00799   static int event_length() {return e_length;}
00800   
00804   static void *event_clipboard() { return e_clipboard_data; }
00808   static const char *event_clipboard_type() {return e_clipboard_type; }
00809 
00810 
00811   static int compose(int &del);
00812   static void compose_reset();
00813   static int event_inside(int,int,int,int);
00814   static int event_inside(const Fl_Widget*);
00815   static int test_shortcut(Fl_Shortcut);
00816 
00821   static void enable_im();
00826   static void disable_im();
00827 
00828   // event destinations:
00829   static int handle(int, Fl_Window*);
00830   static int handle_(int, Fl_Window*);
00833   static Fl_Widget* belowmouse() {return belowmouse_;}
00834   static void belowmouse(Fl_Widget*);
00837   static Fl_Widget* pushed()    {return pushed_;}
00838   static void pushed(Fl_Widget*);
00840   static Fl_Widget* focus()     {return focus_;}
00841   static void focus(Fl_Widget*);
00842   static void add_handler(Fl_Event_Handler h);
00843   static void remove_handler(Fl_Event_Handler h);
00844   static void add_system_handler(Fl_System_Handler h, void *data);
00845   static void remove_system_handler(Fl_System_Handler h);
00846   static void event_dispatch(Fl_Event_Dispatch d);
00847   static Fl_Event_Dispatch event_dispatch();
00853   // cut/paste:
00869 #if FLTK_ABI_VERSION >= 10303 || defined(FL_DOXYGEN)
00870   static void copy(const char* stuff, int len, int destination = 0, const char *type = Fl::clipboard_plain_text); // platform dependent
00871 #else
00872   static void copy(const char* stuff, int len, int destination, const char *type);
00873   static void copy(const char* stuff, int len, int destination = 0);
00874 #endif
00875   
00876 #if !(defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN))
00877   static void copy_image(const unsigned char* data, int W, int H, int destination = 0); // platform dependent
00878 #endif
00879 
00917 #if FLTK_ABI_VERSION >= 10303 || defined(FL_DOXYGEN)
00918   static void paste(Fl_Widget &receiver, int source, const char *type = Fl::clipboard_plain_text); // platform dependent
00919 #else
00920   static void paste(Fl_Widget &receiver, int source, const char *type);
00921   static void paste(Fl_Widget &receiver, int source /*=0*/);
00922 #endif
00923 
00944   static void add_clipboard_notify(Fl_Clipboard_Notify_Handler h, void *data = 0);
00949   static void remove_clipboard_notify(Fl_Clipboard_Notify_Handler h);
00953   static int clipboard_contains(const char *type);
00956   static char const * const clipboard_plain_text;
00959   static char const * const clipboard_image;
00960 
00970   static int dnd(); // platform dependent
00971 
00972   // These are for back-compatibility only:
00975   static Fl_Widget* selection_owner() {return selection_owner_;}
00976   static void selection_owner(Fl_Widget*);
00977   static void selection(Fl_Widget &owner, const char*, int len);
00978   static void paste(Fl_Widget &receiver);
00983   // screen size:
00985   static int x(); // platform dependent
00987   static int y(); // platform dependent
00989   static int w(); // platform dependent
00991   static int h(); // platform dependent
00992 
00993   // multi-head support:
00994   static int screen_count();
01000   static void screen_xywh(int &X, int &Y, int &W, int &H) {
01001     int x, y;
01002     Fl::get_mouse(x, y);
01003     screen_xywh(X, Y, W, H, x, y);
01004   }
01005   static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
01006   static void screen_xywh(int &X, int &Y, int &W, int &H, int n); 
01007   static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
01008   static int screen_num(int x, int y);
01009   static int screen_num(int x, int y, int w, int h);
01010   static void screen_dpi(float &h, float &v, int n=0);
01011   static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
01012   static void screen_work_area(int &X, int &Y, int &W, int &H, int n);
01018   static void screen_work_area(int &X, int &Y, int &W, int &H) {
01019     int x, y;
01020     Fl::get_mouse(x, y);
01021     screen_work_area(X, Y, W, H, x, y);
01022   }
01023 
01031   // color map:
01032   static void   set_color(Fl_Color, uchar, uchar, uchar);
01037   static void   set_color(Fl_Color i, unsigned c); // platform dependent
01038   static unsigned get_color(Fl_Color i);
01039   static void   get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue);
01045   static void   free_color(Fl_Color i, int overlay = 0); // platform dependent
01046 
01047   // fonts:
01048   static const char* get_font(Fl_Font);
01061   static const char* get_font_name(Fl_Font, int* attributes = 0);
01073   static int get_font_sizes(Fl_Font, int*& sizep);
01074   static void set_font(Fl_Font, const char*);
01075   static void set_font(Fl_Font, Fl_Font);
01094   static Fl_Font set_fonts(const char* = 0); // platform dependent
01095 
01102   // <Hack to re-order the 'Drawing functions' group>
01105   // labeltypes:
01106   static void set_labeltype(Fl_Labeltype,Fl_Label_Draw_F*,Fl_Label_Measure_F*);
01108   static void set_labeltype(Fl_Labeltype, Fl_Labeltype from); // is it defined ?
01109 
01110   // boxtypes:
01111   static Fl_Box_Draw_F *get_boxtype(Fl_Boxtype);
01112   static void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F*,uchar,uchar,uchar,uchar);
01113   static void set_boxtype(Fl_Boxtype, Fl_Boxtype from);
01114   static int box_dx(Fl_Boxtype);
01115   static int box_dy(Fl_Boxtype);
01116   static int box_dw(Fl_Boxtype);
01117   static int box_dh(Fl_Boxtype);
01118 
01119   static int draw_box_active();
01120   static Fl_Color box_color(Fl_Color);
01121   static void set_box_color(Fl_Color);
01122 
01123   // back compatibility:
01127   static void set_abort(Fl_Abort_Handler f) {fatal = f;}
01128   static void (*atclose)(Fl_Window*,void*);
01129   static void default_atclose(Fl_Window*,void*);
01133   static void set_atclose(Fl_Atclose_Handler f) {atclose = f;}
01139   static int event_shift() {return e_state&FL_SHIFT;}
01141   static int event_ctrl() {return e_state&FL_CTRL;}
01143   static int event_command() {return e_state&FL_COMMAND;}
01145   static int event_alt() {return e_state&FL_ALT;}
01154   static int event_buttons() {return e_state&0x7f000000;}
01159   static int event_button1() {return e_state&FL_BUTTON1;}
01164   static int event_button2() {return e_state&FL_BUTTON2;}
01169   static int event_button3() {return e_state&FL_BUTTON3;}
01177   static void set_idle(Fl_Old_Idle_Handler cb) {idle = cb;}
01179   static void grab(Fl_Window& win) {grab(&win);}
01183   static void release() {grab(0);}
01184 
01185   // Visible focus methods...
01191   static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); }
01197   static int  visible_focus() { return option(OPTION_VISIBLE_FOCUS); }
01198 
01199   // Drag-n-drop text operation methods...
01206   static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); }
01213   static int  dnd_text_ops() { return option(OPTION_DND_TEXT); }
01218   // Multithreading support:
01219   static int lock();
01220   static void unlock();
01221   static void awake(void* message = 0);
01223   static int awake(Fl_Awake_Handler cb, void* message = 0);
01230   static void* thread_message(); // platform dependent
01262   // Widget deletion:
01263   static void delete_widget(Fl_Widget *w);
01264   static void do_widget_deletion();
01265   static void watch_widget_pointer(Fl_Widget *&w);
01266   static void release_widget_pointer(Fl_Widget *&w);
01267   static void clear_widget_pointer(Fl_Widget const *w);
01274   static void use_high_res_GL(int val) { use_high_res_GL_ = val; }
01280   static int use_high_res_GL() { return use_high_res_GL_; }
01281 
01282 #ifdef FLTK_HAVE_CAIRO
01283 
01286 public:
01287   // Cairo support API
01288   static cairo_t * cairo_make_current(Fl_Window* w);
01303   static void cairo_autolink_context(bool alink) {cairo_state_.autolink(alink);}
01311   static bool cairo_autolink_context() {return cairo_state_.autolink();}
01313   static cairo_t * cairo_cc() { return cairo_state_.cc(); }
01318   static void cairo_cc(cairo_t * c, bool own=false){ cairo_state_.cc(c, own); } 
01319 
01320 private:
01321   static cairo_t * cairo_make_current(void* gc);
01322   static cairo_t * cairo_make_current(void* gc, int W, int H);
01323   static Fl_Cairo_State cairo_state_;
01324 public:
01327 #endif // FLTK_HAVE_CAIRO
01328 
01329 };
01330 
01371 class FL_EXPORT Fl_Widget_Tracker {
01372 
01373   Fl_Widget* wp_;
01374 
01375 public:
01376 
01377   Fl_Widget_Tracker(Fl_Widget *wi);
01378   ~Fl_Widget_Tracker();
01379 
01385   Fl_Widget *widget() {return wp_;}
01386 
01396   int deleted() {return wp_ == 0;}
01397 
01407   int exists()  {return wp_ != 0;}
01408 
01409 };
01410 
01416 #endif // !Fl_H
01417 
01418 //
01419 // End of "$Id$".
01420 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.