Consolidated all possible flag values into a single enum in Fl_Widget (STR #2161)

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6905 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher
2009-09-27 12:06:35 +00:00
parent a735162e98
commit c26809e0ea
8 changed files with 42 additions and 44 deletions
+1
View File
@@ -1,5 +1,6 @@
CHANGES IN FLTK 1.3.0 CHANGES IN FLTK 1.3.0
- Managing all Widget flags in a single location now (STR #2161)
- Fixed all color related call to Fl_Color type (STR #2208) - Fixed all color related call to Fl_Color type (STR #2208)
- File chooser preview now recognizes utf8 encoded - File chooser preview now recognizes utf8 encoded
text files (STR #2218) text files (STR #2218)
+15 -8
View File
@@ -144,14 +144,21 @@ protected:
See activate(), output(), visible(), changed(), set_visible_focus() See activate(), output(), visible(), changed(), set_visible_focus()
*/ */
enum { enum {
INACTIVE=1, ///< the widget can't receive focus, and is disabled but potentially visible INACTIVE = 1, ///< the widget can't receive focus, and is disabled but potentially visible
INVISIBLE=2, ///< the widget is not drawn but can receive events INVISIBLE, ///< the widget is not drawn but can receive events
OUTPUT=4, ///< for output only OUTPUT, ///< for output only
SHORTCUT_LABEL=64, ///< the label contains a shortcut we need to draw NOBORDER, ///< don't draw a decoration (Fl_Window)
CHANGED=128, ///< the widget value changed FORCE_POSITION, ///< don't let the window manager position thi window (Fl_Window)
VISIBLE_FOCUS=512, ///< accepts keyboard focus navigation if the widget can have the focus NON_MODAL, ///< thisis a hovering toolbar window (Fl_Window)
COPIED_LABEL=1024, ///< the widget label is internally copied, its destruction is handled by the widget SHORTCUT_LABEL, ///< the label contains a shortcut we need to draw
CLIP_CHILDREN = 2048 ///< all drawing within this widget will be clipped (Fl_Group) CHANGED, ///< the widget value changed
OVERRIDE, ///< position window on top (Fl_Window)
VISIBLE_FOCUS, ///< accepts keyboard focus navigation if the widget can have the focus
COPIED_LABEL, ///< the widget label is internally copied, its destruction is handled by the widget
CLIP_CHILDREN, ///< all drawing within this widget will be clipped (Fl_Group)
MENU_WINDOW, ///< a temporary popup window, dismissed by clicking outside (Fl_Window)
TOOLTIP_WINDOW, ///< a temporary popup, transparent to events, and dismissed easily (Fl_Window)
MODAL, ///< a window blocking input to all other winows (Fl_Window)
}; };
void draw_box() const; void draw_box() const;
void draw_box(Fl_Boxtype t, Fl_Color c) const; void draw_box(Fl_Boxtype t, Fl_Color c) const;
+15 -25
View File
@@ -69,16 +69,6 @@ class FL_EXPORT Fl_Window : public Fl_Group {
Fl_Cursor cursor_default; Fl_Cursor cursor_default;
Fl_Color cursor_fg, cursor_bg; Fl_Color cursor_fg, cursor_bg;
void size_range_(); void size_range_();
// values for flags():
enum {
FL_MODAL = 64,
FL_NOBORDER = 8,
FL_FORCE_POSITION = 16,
FL_NON_MODAL = 32,
FL_OVERRIDE = 256,
FL_MENU_WINDOW = 4096,
FL_TOOLTIP_WINDOW = 8192
};
void _Fl_Window(); // constructor innards void _Fl_Window(); // constructor innards
// unimplemented copy ctor and assignment operator // unimplemented copy ctor and assignment operator
@@ -167,13 +157,13 @@ public:
Fast inline function to turn the border Fast inline function to turn the border
off. It only works before show() is called. off. It only works before show() is called.
*/ */
void clear_border() {set_flag(FL_NOBORDER);} void clear_border() {set_flag(NOBORDER);}
/** See int Fl_Window::border(int) */ /** See int Fl_Window::border(int) */
int border() const {return !(flags() & FL_NOBORDER);} int border() const {return !(flags() & NOBORDER);}
/** Activate the flags FL_NOBORDER|FL_OVERRIDE */ /** Activate the flags NOBORDER|FL_OVERRIDE */
void set_override() {set_flag(FL_NOBORDER|FL_OVERRIDE);} void set_override() {set_flag(NOBORDER|OVERRIDE);}
/** Returns non zero if FL_OVERRIDE flag is set, 0 otherwise. */ /** Returns non zero if FL_OVERRIDE flag is set, 0 otherwise. */
int override() const { return flags()&FL_OVERRIDE; } int override() const { return flags()&OVERRIDE; }
/** /**
A "modal" window, when shown(), will prevent any events from A "modal" window, when shown(), will prevent any events from
being delivered to other windows in the same program, and will also being delivered to other windows in the same program, and will also
@@ -183,18 +173,18 @@ public:
which window (if any) is modal by calling which window (if any) is modal by calling
Fl::modal(). Fl::modal().
*/ */
void set_modal() {set_flag(FL_MODAL);} void set_modal() {set_flag(MODAL);}
/** Returns true if this window is modal. */ /** Returns true if this window is modal. */
int modal() const {return flags() & FL_MODAL;} int modal() const {return flags() & MODAL;}
/** /**
A "non-modal" window (terminology borrowed from Microsoft Windows) A "non-modal" window (terminology borrowed from Microsoft Windows)
acts like a modal() one in that it remains on top, but it has acts like a modal() one in that it remains on top, but it has
no effect on event delivery. There are <I>three</I> states for a no effect on event delivery. There are <I>three</I> states for a
window: modal, non-modal, and normal. window: modal, non-modal, and normal.
*/ */
void set_non_modal() {set_flag(FL_NON_MODAL);} void set_non_modal() {set_flag(NON_MODAL);}
/** Returns true if this window is modal or non-modal. */ /** Returns true if this window is modal or non-modal. */
int non_modal() const {return flags() & (FL_NON_MODAL|FL_MODAL);} int non_modal() const {return flags() & (NON_MODAL|MODAL);}
/** /**
Marks the window as a menu window. Marks the window as a menu window.
@@ -209,10 +199,10 @@ public:
This must be called before the window is shown and cannot be changed This must be called before the window is shown and cannot be changed
later. later.
*/ */
void set_menu_window() {set_flag(FL_MENU_WINDOW);} void set_menu_window() {set_flag(MENU_WINDOW);}
/** Returns true if this window is a menu window. */ /** Returns true if this window is a menu window. */
int menu_window() const {return flags() & FL_MENU_WINDOW;} int menu_window() const {return flags() & MENU_WINDOW;}
/** /**
Marks the window as a tooltip window. Marks the window as a tooltip window.
@@ -230,10 +220,10 @@ public:
\note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this \note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this
also \b clears the menu_window() state. also \b clears the menu_window() state.
*/ */
void set_tooltip_window() { set_flag(FL_TOOLTIP_WINDOW); void set_tooltip_window() { set_flag(TOOLTIP_WINDOW);
clear_flag(FL_MENU_WINDOW); } clear_flag(MENU_WINDOW); }
/** Returns true if this window is a tooltip window. */ /** Returns true if this window is a tooltip window. */
int tooltip_window() const {return flags() & FL_TOOLTIP_WINDOW;} int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
/** /**
Position the window so that the mouse is pointing at the Position the window so that the mouse is pointing at the
@@ -252,7 +242,7 @@ public:
so that the next time show() is called the window manager is so that the next time show() is called the window manager is
free to position the window. free to position the window.
*/ */
void free_position() {clear_flag(FL_FORCE_POSITION);} void free_position() {clear_flag(FORCE_POSITION);}
/** /**
Set the allowable range the user can resize this window to. This only Set the allowable range the user can resize this window to. This only
works for top-level windows. works for top-level windows.
+1 -1
View File
@@ -66,7 +66,7 @@ Fl_Window::Fl_Window(int X,int Y,int W, int H, const char *l)
cursor_bg = FL_WHITE; cursor_bg = FL_WHITE;
_Fl_Window(); _Fl_Window();
set_flag(FL_FORCE_POSITION); set_flag(FORCE_POSITION);
} }
Fl_Window::Fl_Window(int W, int H, const char *l) Fl_Window::Fl_Window(int W, int H, const char *l)
+2 -2
View File
@@ -43,10 +43,10 @@
void Fl_Window::border(int b) { void Fl_Window::border(int b) {
if (b) { if (b) {
if (border()) return; if (border()) return;
clear_flag(FL_NOBORDER); clear_flag(NOBORDER);
} else { } else {
if (!border()) return; if (!border()) return;
set_flag(FL_NOBORDER); set_flag(NOBORDER);
} }
#if defined(USE_X11) #if defined(USE_X11)
if (shown()) Fl_X::i(this)->sendxjunk(); if (shown()) Fl_X::i(this)->sendxjunk();
+3 -3
View File
@@ -2177,7 +2177,7 @@ void Fl_X::make(Fl_Window* w)
wp += 2*bx; wp += 2*bx;
hp += 2*by+bt; hp += 2*by+bt;
} }
if (!(w->flags() & Fl_Window::FL_FORCE_POSITION)) { if (!(w->flags() & Fl_Widget::FORCE_POSITION)) {
// use the Carbon functions below for default window positioning // use the Carbon functions below for default window positioning
w->x(xyPos+Fl::x()); w->x(xyPos+Fl::x());
w->y(xyPos+Fl::y()); w->y(xyPos+Fl::y());
@@ -2224,7 +2224,7 @@ void Fl_X::make(Fl_Window* w)
SetWindowClass(x->xid, kFloatingWindowClass); SetWindowClass(x->xid, kFloatingWindowClass);
SetWindowActivationScope(x->xid, kWindowActivationScopeAll); SetWindowActivationScope(x->xid, kWindowActivationScopeAll);
} }
if (!(w->flags() & Fl_Window::FL_FORCE_POSITION)) if (!(w->flags() & Fl_Widget::FORCE_POSITION))
{ {
WindowRef pw = Fl_X::first ? Fl_X::first->xid : 0 ; WindowRef pw = Fl_X::first ? Fl_X::first->xid : 0 ;
if (w->modal()) { if (w->modal()) {
@@ -2404,7 +2404,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
int is_a_resize = (W != w() || H != h()); int is_a_resize = (W != w() || H != h());
// printf("Fl_Winodw::resize(X=%d, Y=%d, W=%d, H=%d), is_a_resize=%d, resize_from_system=%p, this=%p\n", // printf("Fl_Winodw::resize(X=%d, Y=%d, W=%d, H=%d), is_a_resize=%d, resize_from_system=%p, this=%p\n",
// X, Y, W, H, is_a_resize, resize_from_system, this); // X, Y, W, H, is_a_resize, resize_from_system, this);
if (X != x() || Y != y()) set_flag(FL_FORCE_POSITION); if (X != x() || Y != y()) set_flag(FORCE_POSITION);
else if (!is_a_resize) return; else if (!is_a_resize) return;
if ( (resize_from_system!=this) && (!parent()) && shown()) { if ( (resize_from_system!=this) && (!parent()) && shown()) {
if (is_a_resize) { if (is_a_resize) {
+2 -2
View File
@@ -1292,7 +1292,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
int resize_from_program = (this != resize_bug_fix); int resize_from_program = (this != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0; if (!resize_from_program) resize_bug_fix = 0;
if (X != x() || Y != y()) { if (X != x() || Y != y()) {
set_flag(FL_FORCE_POSITION); set_flag(FORCE_POSITION);
} else { } else {
if (!is_a_resize) return; if (!is_a_resize) return;
flags |= SWP_NOMOVE; flags |= SWP_NOMOVE;
@@ -1474,7 +1474,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
wp += 2*bx; wp += 2*bx;
hp += 2*by+bt; hp += 2*by+bt;
} }
if (!(w->flags() & Fl_Window::FL_FORCE_POSITION)) { if (!(w->flags() & Fl_Widget::FORCE_POSITION)) {
xp = yp = CW_USEDEFAULT; xp = yp = CW_USEDEFAULT;
} else { } else {
if (!Fl::grab()) { if (!Fl::grab()) {
+3 -3
View File
@@ -1352,7 +1352,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
int is_a_resize = (W != w() || H != h()); int is_a_resize = (W != w() || H != h());
int resize_from_program = (this != resize_bug_fix); int resize_from_program = (this != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0; if (!resize_from_program) resize_bug_fix = 0;
if (is_a_move && resize_from_program) set_flag(FL_FORCE_POSITION); if (is_a_move && resize_from_program) set_flag(FORCE_POSITION);
else if (!is_a_resize && !is_a_move) return; else if (!is_a_resize && !is_a_move) return;
if (is_a_resize) { if (is_a_resize) {
Fl_Group::resize(X,Y,W,H); Fl_Group::resize(X,Y,W,H);
@@ -1430,7 +1430,7 @@ void Fl_X::make_xid(Fl_Window* win, XVisualInfo *visual, Colormap colormap)
if (!win->parent() && !Fl::grab()) { if (!win->parent() && !Fl::grab()) {
// center windows in case window manager does not do anything: // center windows in case window manager does not do anything:
#ifdef FL_CENTER_WINDOWS #ifdef FL_CENTER_WINDOWS
if (!(win->flags() & Fl_Window::FL_FORCE_POSITION)) { if (!(win->flags() & Fl_Widget::FORCE_POSITION)) {
win->x(X = scr_x+(scr_w-W)/2); win->x(X = scr_x+(scr_w-W)/2);
win->y(Y = scr_y+(scr_h-H)/2); win->y(Y = scr_y+(scr_h-H)/2);
} }
@@ -1636,7 +1636,7 @@ void Fl_X::sendxjunk() {
prop[1] = 1|2|16; // MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE prop[1] = 1|2|16; // MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE
} }
if (w->flags() & Fl_Window::FL_FORCE_POSITION) { if (w->flags() & Fl_Widget::FORCE_POSITION) {
hints->flags |= USPosition; hints->flags |= USPosition;
hints->x = w->x(); hints->x = w->x();
hints->y = w->y(); hints->y = w->y();