Fl.H
Go to the documentation of this file.
//
// "$Id: Fl.H 9816 2013-02-08 11:58:19Z manolo $"
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
#ifndef Fl_H
# define Fl_H
#ifdef FLTK_HAVE_CAIRO
# include <FL/Fl_Cairo.H>
#endif
# include "fl_utf8.h"
# include "Enumerations.H"
# ifndef Fl_Object
# define Fl_Object Fl_Widget
# endif
# ifdef check
# undef check
# endif
class Fl_Widget;
class Fl_Window;
class Fl_Image;
struct Fl_Label;
// Keep avoiding having the socket deps at that level but mke sure it will work in both 32 & 64 bit builds
#if defined(WIN32) && !defined(__CYGWIN__)
# if defined(_WIN64)
# define FL_SOCKET unsigned __int64
# else
# define FL_SOCKET int
# endif
#else
# define FL_SOCKET int
#endif
typedef void (Fl_Label_Draw_F)(const Fl_Label *label, int x, int y, int w, int h, Fl_Align align);
typedef void (Fl_Label_Measure_F)(const Fl_Label *label, int &width, int &height);
typedef void (Fl_Box_Draw_F)(int x, int y, int w, int h, Fl_Color color);
typedef void (*Fl_Timeout_Handler)(void *data);
typedef void (*Fl_Awake_Handler)(void *data);
typedef void (*Fl_Idle_Handler)(void *data);
typedef void (*Fl_Old_Idle_Handler)();
typedef void (*Fl_FD_Handler)(FL_SOCKET fd, void *data);
typedef int (*Fl_Event_Handler)(int event);
typedef void (*Fl_Abort_Handler)(const char *format,...);
typedef void (*Fl_Atclose_Handler)(Fl_Window *window, void *data);
typedef int (*Fl_Args_Handler)(int argc, char **argv, int &i);
typedef int (*Fl_Event_Dispatch)(int event, Fl_Window *w);
/* group callback_functions */
class FL_EXPORT Fl {
Fl() {}; // no constructor!
public: // should be private!
#ifndef FL_DOXYGEN
static int e_number;
static int e_x;
static int e_y;
static int e_x_root;
static int e_y_root;
static int e_dx;
static int e_dy;
static int e_state;
static int e_clicks;
static int e_is_click;
static int e_keysym;
static char* e_text;
static int e_length;
static Fl_Event_Dispatch e_dispatch;
static Fl_Widget* belowmouse_;
static Fl_Widget* pushed_;
static Fl_Widget* focus_;
static int damage_;
static Fl_Widget* selection_owner_;
static Fl_Window* modal_;
static Fl_Window* grab_;
static int compose_state; // used for dead keys (WIN32) or marked text (MacOS)
static void call_screen_init(); // recompute screen number and dimensions
#ifdef __APPLE__
static void reset_marked_text(); // resets marked text
static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point
#endif
#endif
static void damage(int d) {damage_ = d;}
public:
typedef enum {
OPTION_ARROW_FOCUS = 0,
// When switched on, FLTK will use the file chooser dialog that comes
// with your operating system whenever possible. When switched off, FLTK
// will present its own file chooser.
// \todo implement me
// OPTION_NATIVE_FILECHOOSER,
// When Filechooser Preview is enabled, the FLTK or native file chooser
// will show a preview of a selected file (if possible) before the user
// decides to choose the file.
// \todo implement me
//OPTION_FILECHOOSER_PREVIEW,
OPTION_VISIBLE_FOCUS,
OPTION_DND_TEXT,
OPTION_SHOW_TOOLTIPS,
// don't change this, leave it always as the last element
OPTION_LAST
} Fl_Option;
private:
static unsigned char options_[OPTION_LAST];
static unsigned char options_read_;
public:
/*
Return a global setting for all FLTK applications, possibly overridden
by a setting specifically for this application.
*/
static bool option(Fl_Option opt);
/*
Override an option while the application is running.
*/
static void option(Fl_Option opt, bool val);
static void (*idle)();
#ifndef FL_DOXYGEN
static Fl_Awake_Handler *awake_ring_;
static void **awake_data_;
static int awake_ring_size_;
static int awake_ring_head_;
static int awake_ring_tail_;
static const char* scheme_;
static Fl_Image* scheme_bg_;
static int e_original_keysym; // late addition
static int scrollbar_size_;
#endif
static int add_awake_handler_(Fl_Awake_Handler, void*);
static int get_awake_handler_(Fl_Awake_Handler&, void*&);
public:
// API version number
static double version();
// argument parsers:
static int arg(int argc, char **argv, int& i);
static int args(int argc, char **argv, int& i, Fl_Args_Handler cb = 0);
static void args(int argc, char **argv);
static const char* const help;
// things called by initialization:
static void display(const char*);
static int visual(int);
static int gl_visual(int, int *alist=0); // platform dependent
static void own_colormap();
static void get_system_colors();
static void foreground(uchar, uchar, uchar);
static void background(uchar, uchar, uchar);
static void background2(uchar, uchar, uchar);
// schemes:
static int scheme(const char*);
static const char* scheme() {return scheme_;}
static int reload_scheme(); // platform dependent
static int scrollbar_size();
static void scrollbar_size(int W);
// execution:
static int wait();
static double wait(double time);
static int check();
static int ready();
static int run();
static Fl_Widget* readqueue();
static void add_timeout(double t, Fl_Timeout_Handler,void* = 0); // platform dependent
static void repeat_timeout(double t, Fl_Timeout_Handler, void* = 0); // platform dependent
static int has_timeout(Fl_Timeout_Handler, void* = 0);
static void remove_timeout(Fl_Timeout_Handler, void* = 0);
static void add_check(Fl_Timeout_Handler, void* = 0);
static int has_check(Fl_Timeout_Handler, void* = 0);
static void remove_check(Fl_Timeout_Handler, void* = 0);
static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent
static void add_fd(int fd, Fl_FD_Handler cb, void* = 0); // platform dependent
static void remove_fd(int, int when); // platform dependent
static void remove_fd(int); // platform dependent
static void add_idle(Fl_Idle_Handler cb, void* data = 0);
static int has_idle(Fl_Idle_Handler cb, void* data = 0);
static void remove_idle(Fl_Idle_Handler cb, void* data = 0);
static int damage() {return damage_;}
static void redraw();
static void flush();
static void (*warning)(const char*, ...);
static void (*error)(const char*, ...);
static void (*fatal)(const char*, ...);
static Fl_Window* first_window();
static void first_window(Fl_Window*);
static Fl_Window* next_window(const Fl_Window*);
static Fl_Window* modal() {return modal_;}
static Fl_Window* grab() {return grab_;}
static void grab(Fl_Window*); // platform dependent
// event information:
static int event() {return e_number;}
static int event_x() {return e_x;}
static int event_y() {return e_y;}
static int event_x_root() {return e_x_root;}
static int event_y_root() {return e_y_root;}
static int event_dx() {return e_dx;}
static int event_dy() {return e_dy;}
static void get_mouse(int &,int &); // platform dependent
static int event_clicks() {return e_clicks;}
static void event_clicks(int i) {e_clicks = i;}
static int event_is_click() {return e_is_click;}
static void event_is_click(int i) {e_is_click = i;}
static int event_button() {return e_keysym-FL_Button;}
static int event_state() {return e_state;}
static int event_state(int i) {return e_state&i;}
static int event_key() {return e_keysym;}
static int event_original_key(){return e_original_keysym;}
static int event_key(int key);
static int get_key(int key); // platform dependent
static const char* event_text() {return e_text;}
static int event_length() {return e_length;}
static int compose(int &del);
static void compose_reset();
static int event_inside(int,int,int,int);
static int event_inside(const Fl_Widget*);
static int test_shortcut(Fl_Shortcut);
// event destinations:
static int handle(int, Fl_Window*);
static int handle_(int, Fl_Window*);
static Fl_Widget* belowmouse() {return belowmouse_;}
static void belowmouse(Fl_Widget*);
static Fl_Widget* pushed() {return pushed_;}
static void pushed(Fl_Widget*);
static Fl_Widget* focus() {return focus_;}
static void focus(Fl_Widget*);
static void add_handler(Fl_Event_Handler h);
static void remove_handler(Fl_Event_Handler h);
static void event_dispatch(Fl_Event_Dispatch d);
static Fl_Event_Dispatch event_dispatch();
// cut/paste:
static void copy(const char* stuff, int len, int destination = 0); // platform dependent
static void paste(Fl_Widget &receiver, int source /*=0*/); // platform dependent
static int dnd(); // platform dependent
// These are for back-compatibility only:
static Fl_Widget* selection_owner() {return selection_owner_;}
static void selection_owner(Fl_Widget*);
static void selection(Fl_Widget &owner, const char*, int len);
static void paste(Fl_Widget &receiver);
// screen size:
static int x(); // platform dependent
static int y(); // platform dependent
static int w(); // platform dependent
static int h(); // platform dependent
// multi-head support:
static int screen_count();
static void screen_xywh(int &X, int &Y, int &W, int &H) {
int x, y;
Fl::get_mouse(x, y);
screen_xywh(X, Y, W, H, x, y);
}
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
static void screen_xywh(int &X, int &Y, int &W, int &H, int n);
static void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
static void screen_dpi(float &h, float &v, int n=0);
static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
static void screen_work_area(int &X, int &Y, int &W, int &H, int n);
static void screen_work_area(int &X, int &Y, int &W, int &H) {
int x, y;
Fl::get_mouse(x, y);
screen_work_area(X, Y, W, H, x, y);
}
// color map:
static void set_color(Fl_Color, uchar, uchar, uchar);
static void set_color(Fl_Color i, unsigned c); // platform dependent
static unsigned get_color(Fl_Color i);
static void get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue);
static void free_color(Fl_Color i, int overlay = 0); // platform dependent
// fonts:
static const char* get_font(Fl_Font);
static const char* get_font_name(Fl_Font, int* attributes = 0);
static int get_font_sizes(Fl_Font, int*& sizep);
static void set_font(Fl_Font, const char*);
static void set_font(Fl_Font, Fl_Font);
static Fl_Font set_fonts(const char* = 0); // platform dependent
// <Hack to re-order the 'Drawing functions' group>
// labeltypes:
static void set_labeltype(Fl_Labeltype,Fl_Label_Draw_F*,Fl_Label_Measure_F*);
static void set_labeltype(Fl_Labeltype, Fl_Labeltype from); // is it defined ?
// boxtypes:
static Fl_Box_Draw_F *get_boxtype(Fl_Boxtype);
static void set_boxtype(Fl_Boxtype, Fl_Box_Draw_F*,uchar,uchar,uchar,uchar);
static void set_boxtype(Fl_Boxtype, Fl_Boxtype from);
static int box_dx(Fl_Boxtype);
static int box_dy(Fl_Boxtype);
static int box_dw(Fl_Boxtype);
static int box_dh(Fl_Boxtype);
static int draw_box_active();
// back compatibility:
static void set_abort(Fl_Abort_Handler f) {fatal = f;}
static void (*atclose)(Fl_Window*,void*);
static void default_atclose(Fl_Window*,void*);
static void set_atclose(Fl_Atclose_Handler f) {atclose = f;}
static int event_shift() {return e_state&FL_SHIFT;}
static int event_ctrl() {return e_state&FL_CTRL;}
static int event_command() {return e_state&FL_COMMAND;}
static int event_alt() {return e_state&FL_ALT;}
static int event_buttons() {return e_state&0x7f000000;}
static int event_button1() {return e_state&FL_BUTTON1;}
static int event_button2() {return e_state&FL_BUTTON2;}
static int event_button3() {return e_state&FL_BUTTON3;}
static void set_idle(Fl_Old_Idle_Handler cb) {idle = cb;}
static void grab(Fl_Window& win) {grab(&win);}
static void release() {grab(0);}
// Visible focus methods...
static void visible_focus(int v) { option(OPTION_VISIBLE_FOCUS, (v!=0)); }
static int visible_focus() { return option(OPTION_VISIBLE_FOCUS); }
// Drag-n-drop text operation methods...
static void dnd_text_ops(int v) { option(OPTION_DND_TEXT, (v!=0)); }
static int dnd_text_ops() { return option(OPTION_DND_TEXT); }
// Multithreading support:
static int lock();
static void unlock();
static void awake(void* message = 0);
static int awake(Fl_Awake_Handler cb, void* message = 0);
static void* thread_message(); // platform dependent
// Widget deletion:
static void delete_widget(Fl_Widget *w);
static void do_widget_deletion();
static void watch_widget_pointer(Fl_Widget *&w);
static void release_widget_pointer(Fl_Widget *&w);
static void clear_widget_pointer(Fl_Widget const *w);
#ifdef FLTK_HAVE_CAIRO
public:
// Cairo support API
static cairo_t * cairo_make_current(Fl_Window* w);
static void cairo_autolink_context(bool alink) {cairo_state_.autolink(alink);}
static bool cairo_autolink_context() {return cairo_state_.autolink();}
static cairo_t * cairo_cc() { return cairo_state_.cc(); }
static void cairo_cc(cairo_t * c, bool own=false){ cairo_state_.cc(c, own); }
private:
static cairo_t * cairo_make_current(void* gc);
static cairo_t * cairo_make_current(void* gc, int W, int H);
static Fl_Cairo_State cairo_state_;
public:
#endif // FLTK_HAVE_CAIRO
};
class FL_EXPORT Fl_Widget_Tracker {
Fl_Widget* wp_;
public:
Fl_Widget_Tracker(Fl_Widget *wi);
~Fl_Widget_Tracker();
Fl_Widget *widget() {return wp_;}
int deleted() {return wp_ == 0;}
int exists() {return wp_ != 0;}
};
#endif // !Fl_H
//
// End of "$Id: Fl.H 9816 2013-02-08 11:58:19Z manolo $".
//
- © 1998-2012 by Bill Spitzak and others.