FLTK 1.3.11
Fl_Window.H
Go to the documentation of this file.
1 //
2 // "$Id$"
3 //
4 // Window header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2012 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18 
22 #ifndef Fl_Window_H
23 #define Fl_Window_H
24 
25 #ifdef WIN32
26 #include <windows.h>
27 #endif
28 
29 #include "Fl_Group.H"
30 #include "Fl_Bitmap.H"
31 #include <stdlib.h>
32 
33 #define FL_WINDOW 0xF0
34 #define FL_DOUBLE_WINDOW 0xF1
35 
36 class Fl_X;
37 class Fl_RGB_Image;
38 
39 
57 class FL_EXPORT Fl_Window : public Fl_Group {
58 
59  static char *default_xclass_;
60  // Note: we must use separate statements for each of the following 8 variables,
61  // with the static attribute, otherwise MS VC++ 2008/2010 complains :-(
62  // AlbrechtS 04/2012
63 #if FLTK_ABI_VERSION < 10301
64  static // when these members are static, ABI compatibility with 1.3.0 is respected
65 #endif
66  int no_fullscreen_x;
67 #if FLTK_ABI_VERSION < 10301
68  static // when these members are static, ABI compatibility with 1.3.0 is respected
69 #endif
70  int no_fullscreen_y;
71 #if FLTK_ABI_VERSION < 10301
72  static // when these members are static, ABI compatibility with 1.3.0 is respected
73 #endif
74  int no_fullscreen_w;
75 #if FLTK_ABI_VERSION < 10301
76  static // when these members are static, ABI compatibility with 1.3.0 is respected
77 #endif
78  int no_fullscreen_h;
79 #if FLTK_ABI_VERSION < 10303
80  static // when these members are static, ABI compatibility with 1.3.0 is respected
81 #endif
82  int fullscreen_screen_top;
83 #if FLTK_ABI_VERSION < 10303
84  static // when these members are static, ABI compatibility with 1.3.0 is respected
85 #endif
86  int fullscreen_screen_bottom;
87 #if FLTK_ABI_VERSION < 10303
88  static // when these members are static, ABI compatibility with 1.3.0 is respected
89 #endif
90  int fullscreen_screen_left;
91 #if FLTK_ABI_VERSION < 10303
92  static // when these members are static, ABI compatibility with 1.3.0 is respected
93 #endif
94  int fullscreen_screen_right;
95 
96  friend class Fl_X;
97  Fl_X *i; // points at the system-specific stuff
98 
99  struct icon_data {
100  const void *legacy_icon;
101  Fl_RGB_Image **icons;
102  int count;
103 #ifdef WIN32
104  HICON big_icon;
105  HICON small_icon;
106 #endif
107  };
108 
109  const char* iconlabel_;
110  char* xclass_;
111  struct icon_data *icon_;
112  // size_range stuff:
113  int minw, minh, maxw, maxh;
114  int dw, dh, aspect;
115  uchar size_range_set;
116  // cursor stuff
117  Fl_Cursor cursor_default;
118 #if FLTK_ABI_VERSION < 10303
119  // legacy, not used
120  Fl_Color cursor_fg, cursor_bg;
121 #endif
122 
123 protected:
126  int lw_;
127  int lh_;
129 #if defined(__APPLE__)
130  typedef struct CGImage* CGImageRef;
131  CGImageRef mask;
132 #endif
134  };
135 
136 #if FLTK_ABI_VERSION < 10303 && !defined(FL_DOXYGEN)
137  static
138 #endif
140 private:
141  void shape_bitmap_(Fl_Image* b);
142  void shape_alpha_(Fl_Image* img, int offset);
143  void shape_pixmap_(Fl_Image* pixmap);
144 public:
145  void shape(const Fl_Image* img);
149  inline void shape(const Fl_Image& b) { shape(&b); }
150 #if ! (defined(WIN32) || defined(__APPLE__) || defined(FL_DOXYGEN))
151  void combine_mask(void);
152 #endif
153 private:
154 
155 
156  void size_range_();
157  void _Fl_Window(); // constructor innards
158  void fullscreen_x(); // platform-specific part of sending a window to full screen
159  void fullscreen_off_x(int X, int Y, int W, int H);// platform-specific part of leaving full screen
160  void fullscreen_screens_x(bool on_off)
161 #if __APPLE__
162  ;
163 #else
164  {}
165 #endif
166 
167  // unimplemented copy ctor and assignment operator
168  Fl_Window(const Fl_Window&);
169  Fl_Window& operator=(const Fl_Window&);
170 
171 protected:
172 
175  virtual void draw();
177  virtual void flush();
178 
187  void force_position(int force) {
188  if (force) set_flag(FORCE_POSITION);
189  else clear_flag(FORCE_POSITION);
190  }
199  int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
200 
201  void free_icons();
202 
203 public:
204 
233  Fl_Window(int w, int h, const char* title= 0);
238  Fl_Window(int x, int y, int w, int h, const char* title = 0);
247  virtual ~Fl_Window();
248 
249  virtual int handle(int);
250 
267  virtual void resize(int X,int Y,int W,int H);
275  void border(int b);
280  void clear_border() {set_flag(NOBORDER);}
282  unsigned int border() const {return !(flags() & NOBORDER);}
284  void set_override() {set_flag(NOBORDER|OVERRIDE);}
286  unsigned int override() const { return flags()&OVERRIDE; }
295  void set_modal() {set_flag(MODAL);}
297  unsigned int modal() const {return flags() & MODAL;}
304  void set_non_modal() {set_flag(NON_MODAL);}
306  unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);}
307 
345  void clear_modal_states() {clear_flag(NON_MODAL | MODAL);}
346 
360  void set_menu_window() {set_flag(MENU_WINDOW);}
361 
363  unsigned int menu_window() const {return flags() & MENU_WINDOW;}
364 
381  void set_tooltip_window() { set_flag(TOOLTIP_WINDOW);
382  clear_flag(MENU_WINDOW); }
384  unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
385 
393  void hotspot(int x, int y, int offscreen = 0);
395  void hotspot(const Fl_Widget*, int offscreen = 0);
397  void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);}
398 
407  void free_position() {clear_flag(FORCE_POSITION);}
444  void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0) {
445  this->minw = minw;
446  this->minh = minh;
447  this->maxw = maxw;
448  this->maxh = maxh;
449  this->dw = dw;
450  this->dh = dh;
451  this->aspect = aspect;
452  size_range_();
453  }
454 
456  const char* label() const {return Fl_Widget::label();}
458  const char* iconlabel() const {return iconlabel_;}
460  void label(const char*);
462  void iconlabel(const char*);
464  void label(const char* label, const char* iconlabel); // platform dependent
465  void copy_label(const char* a);
466 
467  static void default_xclass(const char*);
468  static const char *default_xclass();
469  const char* xclass() const;
470  void xclass(const char* c);
471 
472  static void default_icon(const Fl_RGB_Image*);
473  static void default_icons(const Fl_RGB_Image*[], int);
474  void icon(const Fl_RGB_Image*);
475  void icons(const Fl_RGB_Image*[], int);
476 
477 #ifdef WIN32
478  static void default_icons(HICON big_icon, HICON small_icon);
479  void icons(HICON big_icon, HICON small_icon);
480 #endif
481 
482  /* for legacy compatibility */
483  const void* icon() const;
484  void icon(const void * ic);
485 
491  int shown() {return i != 0;}
518  virtual void show();
523  virtual void hide();
544  void show(int argc, char **argv);
545 
546  // Enables synchronous show(), docs in Fl_Window.cxx
547  void wait_for_expose();
548 
560  void fullscreen();
564  void fullscreen_off();
569  void fullscreen_off(int X,int Y,int W,int H);
573  unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
584  void fullscreen_screens(int top, int bottom, int left, int right);
600  void iconize();
601 
602  int x_root() const ;
603  int y_root() const ;
604 
605  static Fl_Window *current();
615  void make_current();
616 
617  // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
618  virtual Fl_Window* as_window() { return this; }
619 
630  void cursor(Fl_Cursor);
631  void cursor(const Fl_RGB_Image*, int, int);
632  void default_cursor(Fl_Cursor);
633 
634  /* for legacy compatibility */
635  void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
636  void default_cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
637 
638  static void default_callback(Fl_Window*, void* v);
639 
644  int decorated_w();
650  int decorated_h();
651 
652 };
653 
654 #endif
655 
656 //
657 // End of "$Id$".
658 //
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:101
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:304
This widget produces an actual window.
Definition: Fl_Window.H:57
void force_position(int force)
Sets an internal flag that tells FLTK and the window manager to honor position requests.
Definition: Fl_Window.H:187
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:1055
virtual void hide()
Makes a widget invisible.
Definition: Fl_Widget.cxx:283
const char * label() const
See void Fl_Window::label(const char*)
Definition: Fl_Window.H:456
Data supporting a non-rectangular window shape.
Definition: Fl_Window.H:125
int force_position() const
Returns the internal state of the window's FORCE_POSITION flag.
Definition: Fl_Window.H:199
a temporary popup, transparent to events, and dismissed easily (Fl_Window)
Definition: Fl_Widget.H:169
unsigned int border() const
See void Fl_Window::border(int)
Definition: Fl_Window.H:282
void set_override()
Activates the flags NOBORDER|FL_OVERRIDE.
Definition: Fl_Window.H:284
a temporary popup window, dismissed by clicking outside (Fl_Window)
Definition: Fl_Widget.H:168
Fl_Image * shape_
shape image
Definition: Fl_Window.H:128
int lw_
width of shape image
Definition: Fl_Window.H:126
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:345
static void default_callback(Fl_Widget *cb, void *d)
The default callback for all widgets that don't set a callback.
Definition: Fl_Widget.cxx:39
shape_data_type * shape_data_
non-null means the window has a non-rectangular shape
Definition: Fl_Window.H:139
virtual Fl_Window * as_window()
Returns an Fl_Window pointer if this widget is an Fl_Window.
Definition: Fl_Window.H:618
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:407
don't draw a decoration (Fl_Window)
Definition: Fl_Widget.H:159
unsigned int non_modal() const
Returns true if this window is modal or non-modal.
Definition: Fl_Window.H:306
unsigned int modal() const
Returns true if this window is modal.
Definition: Fl_Window.H:297
Base class for image caching and drawing.
Definition: Fl_Image.H:55
position window on top (Fl_Window)
Definition: Fl_Widget.H:164
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:202
void draw()
Draws the widget.
Definition: Fl_Group.cxx:738
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:41
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition: Fl_Widget.H:151
a fullscreen window (Fl_Window)
Definition: Fl_Widget.H:174
void shape(const Fl_Image &b)
Set the window's shape with an Fl_Image.
Definition: Fl_Window.H:149
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:147
int lh_
height of shape image
Definition: Fl_Window.H:127
void set_tooltip_window()
Marks the window as a tooltip window.
Definition: Fl_Window.H:381
virtual void show()
Makes a widget visible.
Definition: Fl_Widget.cxx:271
void clear_border()
Fast inline function to turn the window manager border off.
Definition: Fl_Window.H:280
a window blocking input to all other winows (Fl_Window)
Definition: Fl_Widget.H:170
void resize(int, int, int, int)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Group.cxx:634
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:941
static Fl_Window * current_
Stores the last window that was made current.
Definition: Fl_Window.H:174
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:397
Fl_Bitmap * todelete_
auxiliary bitmap image
Definition: Fl_Window.H:133
void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0)
Sets the allowable range the user can resize this window to.
Definition: Fl_Window.H:444
unsigned int menu_window() const
Returns true if this window is a menu window.
Definition: Fl_Window.H:363
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition: Fl_Widget.H:149
The Fl_Bitmap class supports caching and drawing of mono-color (bitmap) images.
Definition: Fl_Bitmap.H:33
void set_menu_window()
Marks the window as a menu window.
Definition: Fl_Window.H:360
void set_modal()
A "modal" window, when shown(), will prevent any events from being delivered to other windows in the ...
Definition: Fl_Window.H:295
int shown()
Returns non-zero if show() has been called (but not hide() ).
Definition: Fl_Window.H:491
const char * label() const
Gets the current label text.
Definition: Fl_Widget.H:421
unsigned int flags() const
Gets the widget flags mask.
Definition: Fl_Widget.H:147
unsigned int fullscreen_active() const
Returns non zero if FULLSCREEN flag is set, 0 otherwise.
Definition: Fl_Window.H:573
const char * iconlabel() const
See void Fl_Window::iconlabel(const char*)
Definition: Fl_Window.H:458
unsigned int tooltip_window() const
Returns true if this window is a tooltip window.
Definition: Fl_Window.H:384
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:84
void copy_label(const char *new_label)
Sets the current label.
Definition: Fl_Widget.cxx:324
unsigned char uchar
unsigned char
Definition: fl_types.h:30