diff --git a/CHANGES b/CHANGES index 01a265585..2f3f6da6d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ CHANGES IN FLTK 1.3.0 + - Fixed a name conflict with new (VC 2008 Express) winsock2.h + versions and another conflict that produced compile errors + with VC 2008 (STR #2301). - Widgets now remove stale entries from the default callback queue when they are deleted (STR #2302) - Moved OS X code base to the more moder Cocoa toolkit thanks diff --git a/FL/Fl_Window.H b/FL/Fl_Window.H index e2ef7744f..2b7fdf84a 100644 --- a/FL/Fl_Window.H +++ b/FL/Fl_Window.H @@ -43,15 +43,17 @@ class Fl_X; window, with a border and title and all the window management controls, or a "subwindow" inside a window. This is controlled by whether or not the window has a parent(). -
Once you create a window, you usually add children Fl_Widget - 's to it by using window->add(child) for each new widget. See Fl_Group for more information - on how to add and remove children.
-There are several subclasses of Fl_Window that provide - double-buffering, overlay, menu, and OpenGL support.
-The window's callback is done if the user tries to close a window - using the window manager and - Fl::modal() is zero or equal to the window. Fl_Window - has a default callback that calls Fl_Window::hide(). + + Once you create a window, you usually add children Fl_Widget + 's to it by using window->add(child) for each new widget. + See Fl_Group for more information on how to add and remove children. + + There are several subclasses of Fl_Window that provide + double-buffering, overlay, menu, and OpenGL support. + + The window's callback is done if the user tries to close a window + using the window manager and Fl::modal() is zero or equal to the + window. Fl_Window has a default callback that calls Fl_Window::hide(). */ class FL_EXPORT Fl_Window : public Fl_Group { @@ -77,20 +79,42 @@ class FL_EXPORT Fl_Window : public Fl_Group { protected: - /** Stores the last window that was made current. See current() const */ + /** Stores the last window that was made current. See current() const */ static Fl_Window *current_; virtual void draw(); /** Forces the window to be drawn, this window is also made current and calls draw(). */ virtual void flush(); + /** + Sets an internal flag that tells FLTK and the window manager to + honor position requests. + + This is used internally and should not be needed by user code. + + \param[in] force 1 to set the FORCE_POSITION flag, 0 to clear it + */ + void force_position(int force) { + if (force) set_flag(FORCE_POSITION); + else clear_flag(FORCE_POSITION); + } + /** + Returns the internal state of the window's FORCE_POSITION flag. + + \retval 1 if flag is set + \retval 0 otherwise + + \see force_position(int) + */ + int force_position() const { return ((flags() & FORCE_POSITION)?1:0); } + public: /** Creates a window from the given size and title. If Fl_Group::current() is not NULL, the window is created as a - subwindow of the parent window.
+ subwindow of the parent window. -The first form of the constructor creates a top-level window + The first form of the constructor creates a top-level window and asks the window manager to position the window. The second form of the constructor either creates a subwindow or a top-level window at the specified location (x,y) , subject to window @@ -99,28 +123,31 @@ public: or allow the user to pick a location. Use position(x,y) or hotspot() before calling show() to request a position on the screen. See Fl_Window::resize() - for some more details on positioning windows.
+ for some more details on positioning windows. -Top-level windows initially have visible() set to 0 + Top-level windows initially have visible() set to 0 and parent() set to NULL. Subwindows initially have visible() set to 1 and parent() set to - the parent window pointer.
+ the parent window pointer. -Fl_Widget::box() defaults to FL_FLAT_BOX. If you - plan to completely fill the window with children widgets you should + Fl_Widget::box() defaults to FL_FLAT_BOX. If you plan to + completely fill the window with children widgets you should change this to FL_NO_BOX. If you turn the window border off you may want to change this to FL_UP_BOX. + + \see Fl_Window(int x, int y, int w, int h, const char* title = 0) */ Fl_Window(int w, int h, const char* title= 0); - /** Creates a window from the given position, size and title. - See Fl_Window::Fl_Window(int w, int h, const char *title = 0) + /** Creates a window from the given position, size and title. + + \see Fl_Window::Fl_Window(int w, int h, const char *title = 0) */ Fl_Window(int x, int y, int w, int h, const char* title = 0); /** The destructor also deletes all the children. This allows a whole tree to be deleted at once, without having to keep a pointer to all the children in the user code. A kludge has been done so the - Fl_Window and all of it's children can be automatic (local) + Fl_Window and all of its children can be automatic (local) variables, but you must declare the Fl_Window first so that it is destroyed last. */ @@ -129,16 +156,16 @@ public: virtual int handle(int); /** - Changes the size and position of the window. If shown() is - true, these changes are communicated to the window server (which may + Changes the size and position of the window. If shown() is true, + these changes are communicated to the window server (which may refuse that size and cause a further resize). If shown() is false, the size and position are used when show() is called. - See Fl_Group for the effect - of resizing on the child widgets. -
You can also call the Fl_Widget methods size(x,y) - and position(w,h), which are inline wrappers for this virtual - function.
-A top-level window can not force, but merely suggest a position and + See Fl_Group for the effect of resizing on the child widgets. + + You can also call the Fl_Widget methods size(x,y) and position(w,h), + which are inline wrappers for this virtual function. + + A top-level window can not force, but merely suggest a position and size to the operating system. The window manager may not be willing or able to display a window at the desired position or with the given dimensions. It is up to the application developer to verify window @@ -146,21 +173,21 @@ public: */ virtual void resize(int,int,int,int); /** - Gets or sets whether or not the window manager border is around the - window. The default value is true. border(n) can be used to - turn the border on and off, and returns non-zero if the value has been - changed. Under most X window managers this does not work after - show() has been called, although SGI's 4DWM does work. + Sets whether or not the window manager border is around the + window. The default value is true. void border(int) can be + used to turn the border on and off. Under most X window + managers this does not work after show() has been called, + although SGI's 4DWM does work. */ void border(int b); /** - Fast inline function to turn the border + Fast inline function to turn the window manager border off. It only works before show() is called. */ void clear_border() {set_flag(NOBORDER);} - /** See int Fl_Window::border(int) */ + /** See void Fl_Window::border(int) */ unsigned int border() const {return !(flags() & NOBORDER);} - /** Activate the flags NOBORDER|FL_OVERRIDE */ + /** Activates the flags NOBORDER|FL_OVERRIDE */ void set_override() {set_flag(NOBORDER|OVERRIDE);} /** Returns non zero if FL_OVERRIDE flag is set, 0 otherwise. */ unsigned int override() const { return flags()&OVERRIDE; } @@ -170,8 +197,7 @@ public: 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 - which window (if any) is modal by calling - Fl::modal(). + which window (if any) is modal by calling Fl::modal(). */ void set_modal() {set_flag(MODAL);} /** Returns true if this window is modal. */ @@ -188,14 +214,14 @@ public: /** 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. */ @@ -206,14 +232,14 @@ public: /** 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. @@ -226,8 +252,8 @@ public: unsigned int tooltip_window() const {return flags() & 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 + Positions the window so that the mouse is pointing at the given + position, or at the center of the given widget, which may be the window itself. If the optional offscreen parameter is non-zero, then the window is allowed to extend off the screen (this does not work with some X window managers). \see position() @@ -237,43 +263,49 @@ public: void hotspot(const Fl_Widget*, int offscreen = 0); /** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */ void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);} + /** - Undoes the effect of a previous resize() or show() - so that the next time show() is called the window manager is - free to position the window. + Undoes the effect of a previous resize() or show() so that the next time + show() is called the window manager is free to position the window. + + This is for Forms compatibility only. + + \deprecated please use force_position(0) instead */ void free_position() {clear_flag(FORCE_POSITION);} /** - Set the allowable range the user can resize this window to. This only - works for top-level windows. + Sets the allowable range the user can resize this window to. + This only works for top-level windows.
Under Microsoft Windows this string is used as the name of the + + Under Microsoft Windows this string is used as the name of the WNDCLASS structure, though it is not clear if this can have any visible effect. The passed pointer is stored unchanged. The string is not copied. */ void xclass(const char* c) {xclass_ = c;} - /** Gets the current icon window target dependent data */ + /** Gets the current icon window target dependent data. */ const void* icon() const {return icon_;} - /** Sets the current icon window target dependent data */ + /** Sets the current icon window target dependent data. */ void icon(const void * ic) {icon_ = ic;} /** Returns non-zero if show() has been called (but not hide() - ). You can tell if a window is iconified with (w->shown() - &!w->visible()). + ). You can tell if a window is iconified with (w->shown() + && !w->visible()). */ int shown() {return i != 0;} /** - Put the window on the screen. Usually this has the side effect of - opening the display. The second form is used for top-level - windows and allow standard arguments to be parsed from the + Puts the window on the screen. Usually (on X) this has the side + effect of opening the display. The second form is used for top-level + windows and allows standard arguments to be parsed from the command-line. -
If the window is already shown then it is restored and raised to the + + If the window is already shown then it is restored and raised to the top. This is really convenient because your program can call show() at any time, even if the window is already up. It also means that show() serves the purpose of raise() in other toolkits. */ virtual void show(); /** - Remove the window from the screen. If the window is already hidden or + Removes the window from the screen. If the window is already hidden or has not been shown then this does nothing and is harmless. */ virtual void hide(); @@ -353,11 +387,14 @@ public: Iconifies the window. If you call this when shown() is false it will show() it as an icon. If the window is already iconified this does nothing. -
Call show() to restore the window.
-When a window is iconified/restored (either by these calls or by the + + Call show() to restore the window. + + When a window is iconified/restored (either by these calls or by the user) the handle() method is called with FL_HIDE and - FL_SHOW events and visible() is turned on and off.
-There is no way to control what is drawn in the icon except with the
+ FL_SHOW events and visible() is turned on and off.
+
+ There is no way to control what is drawn in the icon except with the
string passed to Fl_Window::xclass(). You should not rely on
window managers displaying the icons.
*/
@@ -368,13 +405,13 @@ public:
static Fl_Window *current();
/**
- Sets things up so that the drawing functions in <FL/fl_draw.H> will go into this
- window. This is useful for incremental update of windows, such as in an
- idle callback, which will make your program behave much better if it
- draws a slow graphic. Danger: incremental update is very hard to
+ Sets things up so that the drawing functions in This method only works for the Fl_Window and
- Fl_Gl_Window derived classes.
+
+ This method only works for the Fl_Window and Fl_Gl_Window derived classes.
*/
void make_current();
@@ -382,14 +419,15 @@ public:
/**
Changes the cursor for this window. This always calls the system, if
you are changing the cursor a lot you may want to keep track of how
- you set it in a static varaible and call this only if the new cursor
- is different.
+ you set it in a static variable and call this only if the new cursor
+ is different.
- The type Fl_Cursor is an enumeration defined in <Enumerations.H>.
+ The type Fl_Cursor is an enumeration defined in For back compatibility only.
+
+ For back compatibility only.
*/
void cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE); // platform dependent
void default_cursor(Fl_Cursor, Fl_Color=FL_BLACK, Fl_Color=FL_WHITE);
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 136b3ee0f..8db05169d 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -101,11 +101,10 @@
#endif
typedef int (WINAPI* fl_wsk_select_f)(int, fd_set*, fd_set*, fd_set*, const struct timeval*);
typedef int (WINAPI* fl_wsk_fd_is_set_f)(SOCKET, fd_set *);
-typedef int (WINAPI* fl_wsk_async_select_f)(SOCKET,HWND,u_int,long);
+
static HMODULE s_wsock_mod = 0;
static fl_wsk_select_f s_wsock_select=0;
static fl_wsk_fd_is_set_f fl_wsk_fd_is_set=0;
-static fl_wsk_async_select_f fl_wsk_async_select=0;
static HMODULE get_wsock_mod() {
if (!s_wsock_mod) {
@@ -114,7 +113,6 @@ static HMODULE get_wsock_mod() {
Fl::fatal("FLTK Lib Error: %s file not found! Please check your winsock dll accessibility.\n",WSCK_DLL_NAME);
s_wsock_select = (fl_wsk_select_f) GetProcAddress(s_wsock_mod, "select");
fl_wsk_fd_is_set = (fl_wsk_fd_is_set_f) GetProcAddress(s_wsock_mod, "__WSAFDIsSet");
- fl_wsk_async_select = (fl_wsk_async_select_f) GetProcAddress(s_wsock_mod, "WSAAsyncSelect");
}
return s_wsock_mod;
}
@@ -229,14 +227,18 @@ static Fl_Window *track_mouse_win=0; // current TrackMouseEvent() window
//
// Microsoft provides the Berkeley select() call and an asynchronous
// select function that sends a WIN32 message when the select condition
-// exists...
+// exists. However, we don't try to use the asynchronous WSAAsyncSelect()
+// any more for good reasons (see above).
+//
+// A.S. Dec 2009: We got reports that current winsock2.h files define
+// POLLIN, POLLOUT, and POLLERR with conflicting values WRT what we
+// used before (STR #2301). Therefore we must not use these values
+// for our internal purposes, but use FL_READ, FL_WRITE, and
+// FL_EXCEPT, as defined for use in Fl::add_fd().
+//
static int maxfd = 0;
static fd_set fdsets[3];
-# define POLLIN 1
-# define POLLOUT 4
-# define POLLERR 8
-
#if !defined(__GNUC__) || __GNUC__ >= 3
extern IDropTarget *flIDropTarget;
#endif // !__GNUC__ || __GNUC__ >= 3
@@ -292,14 +294,14 @@ void Fl::add_fd(int n, int events, void (*cb)(int, void*), void *v) {
fd[i].cb = cb;
fd[i].arg = v;
- if (events & POLLIN) FD_SET((unsigned)n, &fdsets[0]);
- if (events & POLLOUT) FD_SET((unsigned)n, &fdsets[1]);
- if (events & POLLERR) FD_SET((unsigned)n, &fdsets[2]);
+ if (events & FL_READ) FD_SET((unsigned)n, &fdsets[0]);
+ if (events & FL_WRITE) FD_SET((unsigned)n, &fdsets[1]);
+ if (events & FL_EXCEPT) FD_SET((unsigned)n, &fdsets[2]);
if (n > maxfd) maxfd = n;
}
void Fl::add_fd(int fd, void (*cb)(int, void*), void* v) {
- Fl::add_fd(fd, POLLIN, cb, v);
+ Fl::add_fd(fd, FL_READ, cb, v);
}
void Fl::remove_fd(int n, int events) {
@@ -318,9 +320,9 @@ void Fl::remove_fd(int n, int events) {
}
nfds = j;
- if (events & POLLIN) FD_CLR(unsigned(n), &fdsets[0]);
- if (events & POLLOUT) FD_CLR(unsigned(n), &fdsets[1]);
- if (events & POLLERR) FD_CLR(unsigned(n), &fdsets[2]);
+ if (events & FL_READ) FD_CLR(unsigned(n), &fdsets[0]);
+ if (events & FL_WRITE) FD_CLR(unsigned(n), &fdsets[1]);
+ if (events & FL_EXCEPT) FD_CLR(unsigned(n), &fdsets[2]);
}
void Fl::remove_fd(int n) {
@@ -374,9 +376,9 @@ int fl_wait(double time_to_wait) {
for (int i = 0; i < nfds; i ++) {
SOCKET f = fd[i].fd;
short revents = 0;
- if (fl_wsk_fd_is_set(f, &fdt[0])) revents |= POLLIN;
- if (fl_wsk_fd_is_set(f, &fdt[1])) revents |= POLLOUT;
- if (fl_wsk_fd_is_set(f, &fdt[2])) revents |= POLLERR;
+ if (fl_wsk_fd_is_set(f, &fdt[0])) revents |= FL_READ;
+ if (fl_wsk_fd_is_set(f, &fdt[1])) revents |= FL_WRITE;
+ if (fl_wsk_fd_is_set(f, &fdt[2])) revents |= FL_EXCEPT;
if (fd[i].events & revents) fd[i].cb(f, fd[i].arg);
}
time_to_wait = 0.0; // just peek for any messages
@@ -1292,7 +1294,7 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
int resize_from_program = (this != resize_bug_fix);
if (!resize_from_program) resize_bug_fix = 0;
if (X != x() || Y != y()) {
- set_flag(FORCE_POSITION);
+ force_position(1);
} else {
if (!is_a_resize) return;
flags |= SWP_NOMOVE;
@@ -1474,7 +1476,7 @@ Fl_X* Fl_X::make(Fl_Window* w) {
wp += 2*bx;
hp += 2*by+bt;
}
- if (!(w->flags() & Fl_Widget::FORCE_POSITION)) {
+ if (!w->force_position()) {
xp = yp = CW_USEDEFAULT;
} else {
if (!Fl::grab()) {