Added new Fl_Window:: flags() and methods:

- set_menu_window() to mark a window as a menu window
 - set_tooltip_window() to mark a window as a tooltip window

and the corresponding get methods:

 - menu_window()
 - tooltip_window().

This is a first step for providing more information for correct parenting
and properties to support modern (X) window managers (STR #2230).

Please see also the information in fltk.development:

http://www.fltk.org/newsgroups.php?gfltk.development+v:8003

ToDo: Another point is to be able to handle menu windows and popup windows
that are opened while a menu is active properly (will follow later).


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6841 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2009-08-03 06:26:32 +00:00
parent 7e8ba419c6
commit 5e21c7ce23
3 changed files with 46 additions and 2 deletions

View File

@ -75,7 +75,9 @@ class FL_EXPORT Fl_Window : public Fl_Group {
FL_NOBORDER = 8,
FL_FORCE_POSITION = 16,
FL_NON_MODAL = 32,
FL_OVERRIDE = 256
FL_OVERRIDE = 256,
FL_MENU_WINDOW = 4096,
FL_TOOLTIP_WINDOW = 8192
};
void _Fl_Window(); // constructor innards
@ -177,7 +179,7 @@ public:
being delivered to other windows in the same program, and will also
remain on top of the other windows (if the X window manager supports
the "transient for" property). Several modal windows may be shown at
once, in which case only the last one shown gets events. You can See
once, in which case only the last one shown gets events. You can see
which window (if any) is modal by calling
Fl::modal().
*/
@ -194,6 +196,45 @@ public:
/** Returns true if this window is modal or non-modal. */
int non_modal() const {return flags() & (FL_NON_MODAL|FL_MODAL);}
/**
Marks the window as a menu window.
This is intended for internal use, but it can also be used if you
write your own menu handling. However, this is not recommended.
This flag is used for correct "parenting" of windows in communication
with the windowing system. Modern X window managers can use different
flags to distinguish menu and tooltip windows from normal windows.
This must be called before the window is shown and cannot be changed
later.
*/
void set_menu_window() {set_flag(FL_MENU_WINDOW);}
/** Returns true if this window is a menu window. */
int menu_window() const {return flags() & FL_MENU_WINDOW;}
/**
Marks the window as a tooltip window.
This is intended for internal use, but it can also be used if you
write your own tooltip handling. However, this is not recommended.
This flag is used for correct "parenting" of windows in communication
with the windowing system. Modern X window managers can use different
flags to distinguish menu and tooltip windows from normal windows.
This must be called before the window is shown and cannot be changed
later.
\note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this
also \b clears the menu_window() state.
*/
void set_tooltip_window() { set_flag(FL_TOOLTIP_WINDOW);
clear_flag(FL_MENU_WINDOW); }
/** Returns true if this window is a tooltip window. */
int tooltip_window() const {return flags() & FL_TOOLTIP_WINDOW;}
/**
Position the window so that the mouse is pointing at the
given position, or at the center of the given widget, which may be the

View File

@ -268,6 +268,7 @@ menutitle::menutitle(int X, int Y, int W, int H, const Fl_Menu_Item* L) :
end();
set_modal();
clear_border();
set_menu_window();
menu = L;
if (L->labelcolor_ || Fl::scheme() || L->labeltype_ > FL_NO_LABEL) clear_overlay();
}
@ -286,6 +287,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
end();
set_modal();
clear_border();
set_menu_window();
menu = m;
if (m) m = m->first(); // find the first item that needs to be rendered
drawn_selected = -1;

View File

@ -52,6 +52,7 @@ public:
/** Creates the box window */
Fl_TooltipBox() : Fl_Menu_Window(0, 0) {
set_override();
set_tooltip_window();
end();
}
void draw();