FLTK: Fl_Window.H Source File

FLTK

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:
125 struct shape_data_type {
126 int lw_;
127 int lh_;
128 Fl_Image* shape_;
129 #if defined(__APPLE__)
130 typedef struct CGImage* CGImageRef;
131 CGImageRef mask;
132 #endif
133 Fl_Bitmap *todelete_;
134 };
135
136 #if FLTK_ABI_VERSION < 10303 && !defined(FL_DOXYGEN)
137 static
138 #endif
139 shape_data_type *shape_data_;
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
161 // unimplemented copy ctor and assignment operator
162 Fl_Window(const Fl_Window&);
163 Fl_Window& operator=(const Fl_Window&);
164
165 protected:
166
168 static Fl_Window *current_;
169 virtual void draw();
171 virtual void flush();
172
181 void force_position(int force) {
182 if (force) set_flag(FORCE_POSITION);
183 else clear_flag(FORCE_POSITION);
184 }
193 int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
194
195 void free_icons();
196
197 public:
198
227 Fl_Window(int w, int h, const char* title= 0);
232 Fl_Window(int x, int y, int w, int h, const char* title = 0);
241 virtual ~Fl_Window();
242
243 virtual int handle(int);
244
261 virtual void resize(int X,int Y,int W,int H);
269 void border(int b);
274 void clear_border() {set_flag(NOBORDER);}
276 unsigned int border() const {return !(flags() & NOBORDER);}
278 void set_override() {set_flag(NOBORDER|OVERRIDE);}
280 unsigned int override() const { return flags()&OVERRIDE; }
289 void set_modal() {set_flag(MODAL);}
291 unsigned int modal() const {return flags() & MODAL;}
298 void set_non_modal() {set_flag(NON_MODAL);}
300 unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);}
301
339 void clear_modal_states() {clear_flag(NON_MODAL | MODAL);}
340
354 void set_menu_window() {set_flag(MENU_WINDOW);}
355
357 unsigned int menu_window() const {return flags() & MENU_WINDOW;}
358
375 void set_tooltip_window() { set_flag(TOOLTIP_WINDOW);
376 clear_flag(MENU_WINDOW); }
378 unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
379
387 void hotspot(int x, int y, int offscreen = 0);
389 void hotspot(const Fl_Widget*, int offscreen = 0);
391 void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);}
392
401 void free_position() {clear_flag(FORCE_POSITION);}
438 void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0) {
439 this->minw = minw;
440 this->minh = minh;
441 this->maxw = maxw;
442 this->maxh = maxh;
443 this->dw = dw;
444 this->dh = dh;
445 this->aspect = aspect;
446 size_range_();
447 }
448
450 const char* label() const {return Fl_Widget::label();}
452 const char* iconlabel() const {return iconlabel_;}
454 void label(const char*);
456 void iconlabel(const char*);
458 void label(const char* label, const char* iconlabel); // platform dependent
459 void copy_label(const char* a);
460
461 static void default_xclass(const char*);
462 static const char *default_xclass();
463 const char* xclass() const;
464 void xclass(const char* c);
465
466 static void default_icon(const Fl_RGB_Image*);
467 static void default_icons(const Fl_RGB_Image*[], int);
468 void icon(const Fl_RGB_Image*);
469 void icons(const Fl_RGB_Image*[], int);
470
471 #ifdef WIN32
472 static void default_icons(HICON big_icon, HICON small_icon);
473 void icons(HICON big_icon, HICON small_icon);
474 #endif
475
476 /* for legacy compatibility */
477 const void* icon() const;
478 void icon(const void * ic);
479
485 int shown() {return i != 0;}
512 virtual void show();
517 virtual void hide();
538 void show(int argc, char **argv);
539
540 // Enables synchronous show(), docs in Fl_Window.cxx
541 void wait_for_expose();
542
554 void fullscreen();
558 void fullscreen_off();
563 void fullscreen_off(int X,int Y,int W,int H);
567 unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
578 void fullscreen_screens(int top, int bottom, int left, int right);
594 void iconize();
595
596 int x_root() const ;
597 int y_root() const ;
598
599 static Fl_Window *current();
609 void make_current();
610
611 // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
612 virtual Fl_Window* as_window() { return this; }
613
624 void cursor(Fl_Cursor);
625 void cursor(const Fl_RGB_Image*, int, int);
626 void default_cursor(Fl_Cursor);
627
628 /* for legacy compatibility */
629 void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
630 void default_cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
631
632 static void default_callback(Fl_Window*, void* v);
633
638 int decorated_w();
644 int decorated_h();
645
646 };
647
648 #endif
649
650 //
651 // End of "$Id$".
652 //
Fl_Window::show
virtual void show()
Puts the window on the screen.
Fl_Window::modal
unsigned int modal() const
Returns true if this window is modal.
Definition: Fl_Window.H:291
Fl_Window::set_menu_window
void set_menu_window()
Marks the window as a menu window.
Definition: Fl_Window.H:354
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:934
Fl_Window::shape
void shape(const Fl_Image &b)
Set the window's shape with an Fl_Image.
Definition: Fl_Window.H:149
Fl_Window::hotspot
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:391
Fl_Widget::show
virtual void show()
Makes a widget visible.
Definition: Fl_Widget.cxx:271
Fl_Widget::MENU_WINDOW
@ MENU_WINDOW
a temporary popup window, dismissed by clicking outside (Fl_Window)
Definition: Fl_Widget.H:168
Fl_Widget::NOBORDER
@ NOBORDER
don't draw a decoration (Fl_Window)
Definition: Fl_Widget.H:159
Fl_Window::shape_data_type
Data supporting a non-rectangular window shape.
Definition: Fl_Window.H:125
Fl_Image
Base class for image caching and drawing.
Definition: Fl_Image.H:55
Fl_Window::fullscreen_active
unsigned int fullscreen_active() const
Returns non zero if FULLSCREEN flag is set, 0 otherwise.
Definition: Fl_Window.H:567
Fl_Window::menu_window
unsigned int menu_window() const
Returns true if this window is a menu window.
Definition: Fl_Window.H:357
Fl_Group::draw
void draw()
Draws the widget.
Definition: Fl_Group.cxx:738
Fl_Widget::set_flag
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition: Fl_Widget.H:149
Fl_Window::border
unsigned int border() const
See void Fl_Window::border(int)
Definition: Fl_Window.H:276
Fl_Widget::FULLSCREEN
@ FULLSCREEN
a fullscreen window (Fl_Window)
Definition: Fl_Widget.H:174
Fl_Window::set_tooltip_window
void set_tooltip_window()
Marks the window as a tooltip window.
Definition: Fl_Window.H:375
Fl_Widget::MODAL
@ MODAL
a window blocking input to all other winows (Fl_Window)
Definition: Fl_Widget.H:170
Fl_Window::force_position
void force_position(int force)
Sets an internal flag that tells FLTK and the window manager to honor position requests.
Definition: Fl_Window.H:181
Fl_Window::resize
virtual void resize(int X, int Y, int W, int H)
Changes the size and position of the window.
Fl_Window::force_position
int force_position() const
Returns the internal state of the window's FORCE_POSITION flag.
Definition: Fl_Window.H:193
Fl_Window::make_current
void make_current()
Sets things up so that the drawing functions in <FL/fl_draw.H> will go into this window.
Fl_Bitmap
The Fl_Bitmap class supports caching and drawing of mono-color (bitmap) images.
Definition: Fl_Bitmap.H:33
Fl_Widget::copy_label
void copy_label(const char *new_label)
Sets the current label.
Definition: Fl_Widget.cxx:324
Fl_Widget::OVERRIDE
@ OVERRIDE
position window on top (Fl_Window)
Definition: Fl_Widget.H:164
Fl_Widget::flags
unsigned int flags() const
Gets the widget flags mask.
Definition: Fl_Widget.H:147
Fl_Window::decorated_h
int decorated_h()
Returns the window height including any window title bar and any frame added by the window manager.
Fl_Window::current_
static Fl_Window * current_
Stores the last window that was made current.
Definition: Fl_Window.H:168
Fl_Window::non_modal
unsigned int non_modal() const
Returns true if this window is modal or non-modal.
Definition: Fl_Window.H:300
Fl_Window::set_modal
void set_modal()
A "modal" window, when shown(), will prevent any events from being delivered to other windows in the ...
Definition: Fl_Window.H:289
Fl_Window::shape_data_type::shape_
Fl_Image * shape_
shape image
Definition: Fl_Window.H:128
Fl_Window::clear_modal_states
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:339
Fl_Window::size_range
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:438
Fl_Window
This widget produces an actual window.
Definition: Fl_Window.H:57
Fl_Widget::hide
virtual void hide()
Makes a widget invisible.
Definition: Fl_Widget.cxx:283
Fl_Widget::TOOLTIP_WINDOW
@ TOOLTIP_WINDOW
a temporary popup, transparent to events, and dismissed easily (Fl_Window)
Definition: Fl_Widget.H:169
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:101
Fl_Group
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:41
Fl_Group::current
static Fl_Group * current()
Returns the currently active group.
Definition: Fl_Group.cxx:84
Fl_Window::free_position
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:401
Fl_Window::shape_data_type::lw_
int lw_
width of shape image
Definition: Fl_Window.H:126
Fl_Window::shown
int shown()
Returns non-zero if show() has been called (but not hide() ).
Definition: Fl_Window.H:485
Fl_Widget::label
const char * label() const
Gets the current label text.
Definition: Fl_Widget.H:421
Fl_Window::label
const char * label() const
See void Fl_Window::label(const char*)
Definition: Fl_Window.H:450
Fl_Window::iconlabel
const char * iconlabel() const
See void Fl_Window::iconlabel(const char*)
Definition: Fl_Window.H:452
Fl_Group::handle
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:147
Fl_Widget::default_callback
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
Fl_Window::shape_data_type::todelete_
Fl_Bitmap * todelete_
auxiliary bitmap image
Definition: Fl_Window.H:133
Fl_Window::set_non_modal
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:298
Fl_Window::label
void label(const char *label, const char *iconlabel)
Sets the icon label.
Fl_Window::shape_data_type::lh_
int lh_
height of shape image
Definition: Fl_Window.H:127
Fl_Cursor
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:1048
Fl_Window::set_override
void set_override()
Activates the flags NOBORDER|FL_OVERRIDE.
Definition: Fl_Window.H:278
Fl_Window::shape_data_
shape_data_type * shape_data_
non-null means the window has a non-rectangular shape
Definition: Fl_Window.H:139
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
Fl_Window::as_window
virtual Fl_Window * as_window()
Returns an Fl_Window pointer if this widget is an Fl_Window.
Definition: Fl_Window.H:612
Fl_RGB_Image
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
Fl_Widget::clear_flag
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition: Fl_Widget.H:151
Fl_Window::decorated_w
int decorated_w()
Returns the window width including any frame added by the window manager.
Fl_Window::tooltip_window
unsigned int tooltip_window() const
Returns true if this window is a tooltip window.
Definition: Fl_Window.H:378
Fl_Window::clear_border
void clear_border()
Fast inline function to turn the window manager border off.
Definition: Fl_Window.H:274
- © 1998-2016 by Bill Spitzak and others.