Hello,
I found 3 problems while using FLTK2:

- lack of maximize
- lack of easy way to by hand layout elements
- problems with crosscompilation (mingw - linux to windows target)

So, I written patch to fix this. 

It is beta quality - but please do include it into SVN.

- lack of maximize - fixed on X11 (but perhaps not on all WM) and win32
- by hand layout elements - added experimentall manual_child_layout() but it
may be helpfull for other purposes
- problems with crosscompilation - seems fixed (not sure why it ocures in
the first place)

Please tell me what do you think;






Index: README.mingw32
===================================================================
--- README.mingw32	(revision 6149)
+++ README.mingw32	(working copy)
@@ -2,3 +2,6 @@
 To compile FLTK using Mingw32, please follow the instructions in the
 README.cygwin file.  Building the toolkit requires tools from the Cygwin
 distribution and Cygwin contains a complete version of Mingw32.
+
+For crosscompiling see also README.mingw32_cross
+
Index: src/win32/run.cxx
===================================================================
--- src/win32/run.cxx	(revision 6149)
+++ src/win32/run.cxx	(working copy)
@@ -1882,8 +1882,9 @@
   } else {
     flags = 0;
   }
-  if (layout_damage() & ~LAYOUT_XY)
-    Group::layout();
+  if (layout_damage() & ~LAYOUT_XY) {
+		if (!opt_manual_child_layout) Group::layout();
+	}
   else
     layout_damage(0);
   if (i && flags) {
Index: src/osx/run.cxx
===================================================================
--- src/osx/run.cxx	(revision 6149)
+++ src/osx/run.cxx	(working copy)
@@ -1411,7 +1411,7 @@
     SetWindowBounds(i->xid, kWindowContentRgn, &rect);
   }
   if (i) i->need_new_subRegion = true;
-  Group::layout();
+	if (!opt_manual_child_layout) Group::layout();
 }
 
 ////////////////////////////////////////////////////////////////
Index: src/Window_fullscreen.cxx
===================================================================
--- src/Window_fullscreen.cxx	(revision 6149)
+++ src/Window_fullscreen.cxx	(working copy)
@@ -91,6 +91,14 @@
     // either wrong or the window managers are ignoreing it. Newer X
     // window managers seem to work without this, they probably recognize
     // attempts to make the window the size of the screen
+
+		// this method does in fact work, and is used below in my maximize()
+		// so it should probably work here as well
+		// possible problem is that sometimes one have to process/flush events
+		// i.e. by using fltk::wait(1) to have this working
+		// Perhaps below code can be done correctly(?) again - look at maximize()
+		// (or perhaps Im totally wrong, Im new to Xlib ;) --Rafal
+
     static Atom _NET_WM_STATE;
     static Atom _NET_WM_STATE_REMOVE;
     static Atom _NET_WM_STATE_ADD;
@@ -169,6 +177,48 @@
   window->resize(X, Y, W, H);
 }
 
+void Window::maximize() {
+	#ifdef __WIN32__
+		// ShowWindow - http://msdn.microsoft.com/en-us/library/ms633548.aspx
+		// idea from Edzard Egberts - thanks
+
+		HWND hWnd = fltk::xid(this);     
+		ShowWindow(hWnd, SW_MAXIMIZE);	
+
+	#elif USE_X11
+		// #elif __linux__
+		// by Rafal Maj on idea from Mans Rullgard http://tinyurl.com/68mvk3
+		// TODO: make it work on very old/simple WMs (as described in url above)
+		// TODO: test it more / cleanup (some Xlib expert, please take a look)
+
+		Display *dpy = xdisplay;
+
+		XEvent xev;
+		Atom wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
+		Atom maximizeV = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False);
+		Atom maximizeH = XInternAtom(dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
+		// XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); // that would give true fullscreen
+
+		memset(&xev, 0, sizeof(xev));
+		xev.type = ClientMessage;
+		xev.xclient.window = fltk::xid(this);
+		xev.xclient.message_type = wm_state;
+		xev.xclient.format = 32;
+		xev.xclient.data.l[0] = 1;
+		xev.xclient.data.l[1] = maximizeV;
+		xev.xclient.data.l[2] = maximizeH;
+		xev.xclient.data.l[3] = 0;
+    XSendEvent(xdisplay, RootWindow(xdisplay, xscreen), 0,
+	  	SubstructureNotifyMask|SubstructureRedirectMask, &xev);
+
+		// flush it right away? Also seems to works without this as well...
+		// XFlush(dpy);
+
+	#else
+		#warning "This method will not work on this system. (you can ignore this warning)"
+	#endif
+}
+
 /*! void Window::clear_border()
   This may only be called on a newly constructed window before the
   first call to show().  There will not be any visible border around
Index: src/Window.cxx
===================================================================
--- src/Window.cxx	(revision 6149)
+++ src/Window.cxx	(working copy)
@@ -127,6 +127,7 @@
   shortcut(EscapeKey);
   callback((Callback*)default_callback);
   set_flag(DOUBLE);
+	opt_manual_child_layout=false;
 }
 
 /*! This constructor is for \e child windows. You should use the
Index: src/x11/run.cxx
===================================================================
--- src/x11/run.cxx	(revision 6149)
+++ src/x11/run.cxx	(working copy)
@@ -2741,7 +2741,9 @@
     }
   }
   // don't redraw if only the xy position changed:
-  if (layout_damage() & ~LAYOUT_XY) Group::layout();
+  if (layout_damage() & ~LAYOUT_XY) {
+		if (!opt_manual_child_layout) Group::layout();
+	}
   else layout_damage(0);
 }
 
Index: README.mingw32_cross
===================================================================
--- README.mingw32_cross	(revision 0)
+++ README.mingw32_cross	(revision 0)
@@ -0,0 +1,66 @@
+--- CROSSCOMPILATION GOAL ---
+
+This page describes crosscompilation (building win32 programs on linux)
+
+Follow this instructions on linux (or Unix?) and you will have a library,
+which can be used on linux/unix to build win32 applications that use FLTK.
+
+Then you can use Wine for testing, and develop windows programs while being 
+windows-free \o/ (well, for real applications, do use beta testers with real
+windows).
+
+
+--- TOOLS ---
+
+You will need
+- FLTK sources
+- mingw cross compiler: you must have programs like i586-mingw32msvc-c++
+	in Ubuntu for example, they are in *mingw* package.
+	The prefix i586-mingw... was i486 i386 etc previously
+	if you have other name then adjust instructions below to match it
+- g++ and make
+- autoconfig
+
+--- DO IT ---
+Execute this long command:
+
+make clean ; autoconf ; ./configure --build="i586-mingw32msvc" --host="i586-mingw32msvc"  --target="i586-mingw32msvc" --prefix="/home/DEVEL/packs/fltk2/cross_win32" ; make -j 4 ; make install   
+
+You will see information like:
+checking for gcc... i586-mingw32msvc-gcc
+checking for C compiler default output file name... a.exe
+
+After all (around 1-5 minutes on ~2GHz) there will be errors reported about undefined references,
+but ignore them.
+
+Library should be builded now.
+
+--- CHECK ---
+Was all successfull? Check.
+
+Use: 
+file lib/*.a
+
+if it displays:
+	lib/libfltk2.a:        current ar archive
+	lib/libfltk2_gl.a:     current ar archive
+	lib/libfltk2_png.a:    current ar archive
+	(...)
+then the lib is builded
+
+Check file src/*.o to see if it was builded as windows version (crossbuilded)
+	src/fillrect.o:           80386 COFF executable not stripped - version 30821
+	src/Fl_Menu_Item.o:       80386 COFF executable not stripped - version 30821
+	(...)
+
+--- INSTALL IT ---
+Create the directory mentioned in --prefix above (or start over with another prefix)
+
+make install
+
+After this you will be able to crossbuild programs by calling i586-..-g++ 
+with proper flags (returned by fltk-config)
+
+TODO (finish this document!) --Rafal
+
+
Index: CREDITS
===================================================================
--- CREDITS	(revision 6149)
+++ CREDITS	(working copy)
@@ -60,3 +60,4 @@
     Davy Durham ([EMAIL PROTECTED])
     Jan Fechner (#1837)
     Brian Olsen <[EMAIL PROTECTED]>
+    Rafal Maj <www.limcore.com>
Index: CHANGES
===================================================================
--- CHANGES	(revision 6149)
+++ CHANGES	(working copy)
@@ -2555,3 +2555,20 @@
 fl_color_win32.cxx loads SetDCPenColor and SetDCBrushColor functions dynamically.
 Uses alternative (old) method, if those functions cannot be loaded (older windows)
 from gdi32.dll
+
+////////////////////////////////////////////////////////////////
+* Added Window::Maximize
+  so far for X11 and Win32
+  TODO: MAC OS X version, and testing
+	And added example of maximize() as part of teset/fullscreen.cxx
+
+* Probably fixed bug: gifImage.cxx:105: error: ‘U32’ was not declared
+  by adding a work around to configure.in
+  in crosscompilation with mingw (linux 64 bit to windows)
+  And documented crosscompilation (TODO - finish it)
+
+* Added window::manual_child_layout(true) to aid overloading ::layout()
+  with custom code. Applied needed change to X11 and win32 version
+	TODO MAC OS X change was trivial, but needs testing.
+
+
Index: test/fullscreen.cxx
===================================================================
--- test/fullscreen.cxx	(revision 6149)
+++ test/fullscreen.cxx	(working copy)
@@ -196,6 +196,11 @@
   }
 }
 
+void maximize_cb(fltk::Widget *o, void *p) {
+  fltk::Window *w = (fltk::Window *)p;
+	w->maximize();
+}
+
 void exit_cb(fltk::Widget *, void *) {
   // Turn fullscreen off when exit
   if(fullscreen)
@@ -203,7 +208,7 @@
   exit(0);
 }
 
-#define NUMB 4
+#define NUMB 5
 
 int twowindow = 0;
 int initfull = 0;
@@ -268,6 +273,10 @@
   b3.callback(fullscreen_cb,w);
   y+=30;
 
+  fltk::Button btnMaximize(50,y,window.w()-60,30,"Maximize me!");
+  btnMaximize.callback(maximize_cb,&window);
+  y+=30;
+
   fltk::Button eb(50,y,window.w()-60,30,"Exit");
   eb.callback(exit_cb);
   y+=30;
Index: README.unix
===================================================================
--- README.unix	(revision 6149)
+++ README.unix	(working copy)
@@ -53,3 +53,5 @@
     libraries).
 
 
+For crosscompiling see also README.mingw32_cross
+
Index: README.windows
===================================================================
--- README.windows	(revision 6149)
+++ README.windows	(working copy)
@@ -12,7 +12,12 @@
     tools. For information on how to build in this environment, please
     read the README.cygwin file.
 
+		Also, you can build windows version of the FLTK library on linux
+		using crossbuilding - see also README.mingw32_cross
+
     Current versions of FLTK may require the winsock2 DLL
     (WS2_32.DLL).  If you have an older version of Windows 95, you may
     not have this DLL and you will to get it from the Microsoft web
     site.
+
+
Index: configure.in
===================================================================
--- configure.in	(revision 6149)
+++ configure.in	(working copy)
@@ -289,6 +289,9 @@
 else
     if test $ac_cv_sizeof_long -eq 4; then
         AC_DEFINE(U32,unsigned long)
+		else
+				dnl fall back
+        AC_DEFINE(U32,unsigned long)
     fi
 fi
 if test $ac_cv_sizeof_int -eq 8; then
Index: fltk/Window.h
===================================================================
--- fltk/Window.h	(revision 6149)
+++ fltk/Window.h	(working copy)
@@ -35,6 +35,8 @@
 class CreatedWindow;
 class Monitor;
 
+// implementations of methods of Window are in different files in src/
+
 class FL_API Window : public Group {
 public:
 
@@ -96,6 +98,8 @@
   void fullscreen(const Monitor&);
   void fullscreen_off(int,int,int,int);
 
+	void maximize(); // implemented in src/Window_fullscreen.cxx
+
   static void default_callback(Window*, void* v);
 
   virtual int handle(int);
@@ -117,6 +121,9 @@
   // at least it shouldn't stay public
   void* backbuffer() const;
 
+	bool manual_child_layout() const { return opt_manual_child_layout; }
+	void manual_child_layout(bool v) { opt_manual_child_layout=v; }
+
 protected:
   virtual void create();
 
@@ -141,6 +148,7 @@
   };
   static const char* xclass_;
   void _Window(); // constructor innards
+	bool opt_manual_child_layout; // option for NOT calling children layout
 };
 
 }

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to