FLTK
Fl_Window.H
Go to the documentation of this file.
1 //
2 // Window header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2016 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
20 #ifndef Fl_Window_H
21 #define Fl_Window_H
22 
23 #include <FL/Fl.H>
24 #include <FL/Fl_Group.H>
25 #include <FL/Fl_Bitmap.H>
26 #include <stdlib.h>
27 
28 #define FL_WINDOW 0xF0
29 #define FL_DOUBLE_WINDOW 0xF1
30 
31 class Fl_X;
32 class Fl_Window_Driver;
33 class Fl_RGB_Image;
34 class Fl_Double_Window;
35 
53 class FL_EXPORT Fl_Window : public Fl_Group {
54  friend int Fl::arg(int argc, char **argv, int &i);
55  friend class Fl_X;
56  friend class Fl_Window_Driver;
57 private:
58  static char *default_xclass_;
59  static char show_iconic_; // 1 means create next window in iconic form
60 
61  int no_fullscreen_x;
62  int no_fullscreen_y;
63  int no_fullscreen_w;
64  int no_fullscreen_h;
65  int fullscreen_screen_top;
66  int fullscreen_screen_bottom;
67  int fullscreen_screen_left;
68  int fullscreen_screen_right;
69 
70  // TODO: it would make sense to merge the use of Fl_X and Fl_Window_Driver, maybe simply by
71  // TODO: deriving Fl_Window_Driver from Fl_X. However, there are a lot of historic kludges
72  // TODO: for some platforms around Fl_X.
73  Fl_X *i; // points at the system-specific stuff, but exists only after the window is mapped
74  Fl_Window_Driver *pWindowDriver; // points at the system-specific stuff at window creation time
75 
76  const char* iconlabel_;
77  char* xclass_;
78  // size_range stuff:
79  int minw, minh, maxw, maxh;
80  int dw, dh, aspect;
81  uchar size_range_set;
82  // cursor stuff
83  Fl_Cursor cursor_default;
84 
85  void _Fl_Window(); // constructor innards
86 
87  // unimplemented copy ctor and assignment operator
88  Fl_Window(const Fl_Window&);
89  Fl_Window& operator=(const Fl_Window&);
90 
91 protected:
92 
95  void draw();
97  virtual void flush();
98 
107  void force_position(int force) {
108  if (force) set_flag(FORCE_POSITION);
109  else clear_flag(FORCE_POSITION);
110  }
119  int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
120 
121  void free_icons();
122 
123 public:
124 
153  Fl_Window(int w, int h, const char *title = 0);
158  Fl_Window(int x, int y, int w, int h, const char *title = 0);
167  virtual ~Fl_Window();
168 
169  virtual int handle(int);
170 
187  virtual void resize(int X,int Y,int W,int H);
192  void border(int b);
197  void clear_border() {set_flag(NOBORDER);}
199  unsigned int border() const {return !(flags() & NOBORDER);}
201  void set_override() {set_flag(NOBORDER|OVERRIDE);}
203  unsigned int override() const { return flags()&OVERRIDE; }
212  void set_modal() {set_flag(MODAL);}
214  unsigned int modal() const {return flags() & MODAL;}
221  void set_non_modal() {set_flag(NON_MODAL);}
223  unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);}
224 
262  void clear_modal_states() {clear_flag(NON_MODAL | MODAL);}
263 
277  void set_menu_window() {set_flag(MENU_WINDOW);}
278 
280  unsigned int menu_window() const {return flags() & MENU_WINDOW;}
281 
298  void set_tooltip_window() { set_flag(TOOLTIP_WINDOW);
299  clear_flag(MENU_WINDOW); }
301  unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
302 
310  void hotspot(int x, int y, int offscreen = 0);
312  void hotspot(const Fl_Widget*, int offscreen = 0);
314  void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);}
315 
324  void free_position() {clear_flag(FORCE_POSITION);}
325  void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0);
326 
328  const char* label() const {return Fl_Widget::label();}
330  const char* iconlabel() const {return iconlabel_;}
332  void label(const char*);
334  void iconlabel(const char*);
336  void label(const char* label, const char* iconlabel); // platform dependent
337  void copy_label(const char* a);
338 
339  static void default_xclass(const char*);
340  static const char *default_xclass();
341  const char* xclass() const;
342  void xclass(const char* c);
343 
344  static void default_icon(const Fl_RGB_Image*);
345  static void default_icons(const Fl_RGB_Image*[], int);
346  void icon(const Fl_RGB_Image*);
347  void icons(const Fl_RGB_Image*[], int);
348 
349 #if defined(_WIN32) && !defined(FL_DOXYGEN)
350  typedef struct HICON__* HICON;
351  // These 2 member functions break the driver model but are kept for back compatibility.
352  // They are implemented in Fl_win32.cxx
353  static void default_icons(HICON big_icon, HICON small_icon);
354  void icons(HICON big_icon, HICON small_icon);
355 #endif
356 
357  /* for legacy compatibility */
358  const void* icon() const;
359  void icon(const void * ic);
360 
366  int shown() {return i != 0;}
393  virtual void show();
398  virtual void hide();
419  void show(int argc, char **argv);
420 
421  // Enables synchronous show(), docs in Fl_Window.cxx
422  void wait_for_expose();
423 
435  void fullscreen();
439  void fullscreen_off();
444  void fullscreen_off(int X,int Y,int W,int H);
448  unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
459  void fullscreen_screens(int top, int bottom, int left, int right);
475  void iconize();
476 
477  int x_root() const ;
478  int y_root() const ;
479 
480  static Fl_Window *current();
490  void make_current();
491 
503  void cursor(Fl_Cursor);
504  void cursor(const Fl_RGB_Image*, int, int);
505  void default_cursor(Fl_Cursor);
506 
507  /* for legacy compatibility */
508  void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
509  void default_cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
510 
511  static void default_callback(Fl_Window*, void* v);
512 
517  int decorated_w() const;
518 
524  int decorated_h() const;
525 
526  // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
527  virtual Fl_Window* as_window() { return this; }
528 
532  virtual class Fl_Overlay_Window *as_overlay_window() {return 0L; }
533 
537  virtual class Fl_Double_Window *as_double_window() {return 0L;}
538 
539  void shape(const Fl_Image* img);
540  void shape(const Fl_Image& b) ;
541  const Fl_Image *shape();
542  int screen_num();
543  void screen_num(int screen_num);
544  static bool is_a_rescale();
545 };
546 
547 #endif
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
void set_non_modal()
A "non-modal" window (terminology borrowed from Microsoft Windows) acts like a modal() one in that it...
Definition: Fl_Window.H:221
This widget produces an actual window.
Definition: Fl_Window.H:53
void force_position(int force)
Sets an internal flag that tells FLTK and the window manager to honor position requests.
Definition: Fl_Window.H:107
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:1156
virtual void hide()
Makes a widget invisible.
Definition: Fl_Widget.cxx:251
const char * label() const
Gets the current label text.
Definition: Fl_Widget.H:408
int force_position() const
Returns the internal state of the window&#39;s FORCE_POSITION flag.
Definition: Fl_Window.H:119
a temporary popup, transparent to events, and dismissed easily (Fl_Window)
Definition: Fl_Widget.H:154
Fl static class.
void set_override()
Activates the flags NOBORDER|FL_OVERRIDE.
Definition: Fl_Window.H:201
static void default_callback(Fl_Widget *widget, void *data)
The default callback for all widgets that don&#39;t set a callback.
Definition: Fl_Widget.cxx:38
a temporary popup window, dismissed by clicking outside (Fl_Window)
Definition: Fl_Widget.H:153
The Fl_Double_Window provides a double-buffered window.
Definition: Fl_Double_Window.H:38
unsigned int non_modal() const
Returns true if this window is modal or non-modal.
Definition: Fl_Window.H:223
void clear_modal_states()
Clears the "modal" flags and converts a "modal" or "non-modal" window back into a "normal" window...
Definition: Fl_Window.H:262
static int arg(int argc, char **argv, int &i)
Parse a single switch from argv, starting at word i.
Definition: Fl_arg.cxx:116
virtual Fl_Window * as_window()
Returns an Fl_Window pointer if this widget is an Fl_Window.
Definition: Fl_Window.H:527
void free_position()
Undoes the effect of a previous resize() or show() so that the next time show() is called the window ...
Definition: Fl_Window.H:324
don&#39;t draw a decoration (Fl_Window)
Definition: Fl_Widget.H:144
const char * label() const
See void Fl_Window::label(const char*)
Definition: Fl_Window.H:328
Base class for image caching, scaling and drawing.
Definition: Fl_Image.H:62
const char * iconlabel() const
See void Fl_Window::iconlabel(const char*)
Definition: Fl_Window.H:330
position window on top (Fl_Window)
Definition: Fl_Widget.H:149
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:287
virtual class Fl_Overlay_Window * as_overlay_window()
Return non-null if this is an Fl_Overlay_Window object.
Definition: Fl_Window.H:532
void draw()
Draws the widget.
Definition: Fl_Group.cxx:817
static bool is_a_rescale()
Returns true when a window is being rescaled.
Definition: Fl_Window.cxx:710
unsigned int fullscreen_active() const
Returns non zero if FULLSCREEN flag is set, 0 otherwise.
Definition: Fl_Window.H:448
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:42
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition: Fl_Widget.H:136
a fullscreen window (Fl_Window)
Definition: Fl_Widget.H:159
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:144
static Fl_Window * current_
Stores the last window that was made current.
Definition: Fl_Window.H:94
unsigned int border() const
Returns whether the window possesses a border.
Definition: Fl_Window.H:199
void set_tooltip_window()
Marks the window as a tooltip window.
Definition: Fl_Window.H:298
unsigned int menu_window() const
Returns true if this window is a menu window.
Definition: Fl_Window.H:280
virtual void show()
Makes a widget visible.
Definition: Fl_Widget.cxx:239
unsigned int tooltip_window() const
Returns true if this window is a tooltip window.
Definition: Fl_Window.H:301
void clear_border()
Fast inline function to turn the window manager border off.
Definition: Fl_Window.H:197
virtual class Fl_Double_Window * as_double_window()
Return non-null if this is an Fl_Double_Window object.
Definition: Fl_Window.H:537
a window blocking input to all other winows (Fl_Window)
Definition: Fl_Widget.H:155
int screen_num()
The number of the screen containing the mapped window.
Definition: Fl_Window.cxx:641
void resize(int, int, int, int)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Group.cxx:700
unsigned int modal() const
Returns true if this window is modal.
Definition: Fl_Window.H:214
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:1042
const Fl_Image * shape()
Returns the image controlling the window shape or NULL.
Definition: Fl_Window.cxx:707
void hotspot(const Fl_Widget &p, int offscreen=0)
See void Fl_Window::hotspot(int x, int y, int offscreen = 0)
Definition: Fl_Window.H:314
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition: Fl_Widget.H:134
void set_menu_window()
Marks the window as a menu window.
Definition: Fl_Window.H:277
void set_modal()
A "modal" window, when shown(), will prevent any events from being delivered to other windows in the ...
Definition: Fl_Window.H:212
int shown()
Returns non-zero if show() has been called (but not hide() ).
Definition: Fl_Window.H:366
This window provides double buffering and also the ability to draw the "overlay" which is another pic...
Definition: Fl_Overlay_Window.H:36
unsigned int flags() const
Gets the widget flags mask.
Definition: Fl_Widget.H:132
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:81
void copy_label(const char *new_label)
Sets the current label.
Definition: Fl_Widget.cxx:290
unsigned char uchar
unsigned char
Definition: fl_types.h:28