summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2001-11-27 17:44:08 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2001-11-27 17:44:08 +0000
commit2b85bf81680e2243ef5a5daf85d9eb04321c7278 (patch)
treedc7d3e1cdbd44ed10b358412098b73d24b64d143 /FL
parent4dc5732a3e0f376786d1d6b788e5cf601439e890 (diff)
Preliminary commit of my MacOS X work.
**** THIS CODE COMPILES BUT DOES NOT WORK. **** TODO: fix event handling - getting blank windows, etc. TODO: re-port OpenGL code. TODO: add support for images with alpha. TODO: add support for more then just beeps in fl_beep(). TODO: other stuff I'm sure... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1765 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl.H8
-rw-r--r--FL/Fl_Sys_Menu_Bar.H46
-rw-r--r--FL/mac.H125
-rw-r--r--FL/win32.H16
-rw-r--r--FL/x.H62
5 files changed, 215 insertions, 42 deletions
diff --git a/FL/Fl.H b/FL/Fl.H
index 7abf3ae9e..d74126f42 100644
--- a/FL/Fl.H
+++ b/FL/Fl.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.H,v 1.8.2.11.2.3 2001/11/03 05:11:33 easysw Exp $"
+// "$Id: Fl.H,v 1.8.2.11.2.4 2001/11/27 17:44:06 easysw Exp $"
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
@@ -159,13 +159,13 @@ public:
static FL_EXPORT void paste(Fl_Widget &receiver);
// screen size:
-#if defined(WIN32)
+#if defined(WIN32) || defined(__APPLE__)
static FL_EXPORT int x();
static FL_EXPORT int y();
#else
static FL_EXPORT int x() {return 0;}
static FL_EXPORT int y() {return 0;}
-#endif /* WIN32 */
+#endif /* WIN32 || __APPLE__ */
static FL_EXPORT int w();
static FL_EXPORT int h();
@@ -220,5 +220,5 @@ public:
#endif
//
-// End of "$Id: Fl.H,v 1.8.2.11.2.3 2001/11/03 05:11:33 easysw Exp $".
+// End of "$Id: Fl.H,v 1.8.2.11.2.4 2001/11/27 17:44:06 easysw Exp $".
//
diff --git a/FL/Fl_Sys_Menu_Bar.H b/FL/Fl_Sys_Menu_Bar.H
new file mode 100644
index 000000000..a1cf92185
--- /dev/null
+++ b/FL/Fl_Sys_Menu_Bar.H
@@ -0,0 +1,46 @@
+//
+// "$Id: Fl_Sys_Menu_Bar.H,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $"
+//
+// MacOS system menu bar header file for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2001 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs@fltk.org".
+//
+
+#ifndef Fl_Sys_Menu_Bar_H
+#define Fl_Sys_Menu_Bar_H
+
+#include "Fl_Menu_Bar.H"
+
+class Fl_Sys_Menu_Bar : public Fl_Menu_Bar {
+protected:
+ FL_EXPORT void draw();
+public:
+//FL_EXPORT int handle(int);
+ Fl_Sys_Menu_Bar(int x,int y,int w,int h,const char *l=0)
+ : Fl_Menu_Bar(x,y,w,h,l) {}
+ FL_EXPORT void menu(const Fl_Menu_Item *m);
+// FL_EXPORT Fl_Menu_Item* picked(const Fl_Menu_Item* v);
+};
+
+#endif
+
+//
+// End of "$Id: Fl_Sys_Menu_Bar.H,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $".
+//
diff --git a/FL/mac.H b/FL/mac.H
new file mode 100644
index 000000000..4aa179947
--- /dev/null
+++ b/FL/mac.H
@@ -0,0 +1,125 @@
+//
+// "$Id: mac.H,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $"
+//
+// Mac header file for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2001 by Bill Spitzak and others.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems to "fltk-bugs@fltk.org".
+//
+
+// Do not directly include this file, instead use <FL/x.H>. It will
+// include this file if "__APPLE__" is defined. This is to encourage
+// portability of even the system-specific code...
+
+
+#ifndef FL_MAC_H
+# define FL_MAC_H
+
+// Standard MacOS Carbon API includes...
+# include <Carbon/Carbon.h>
+
+// Now make some fixes to the headers...
+# undef check // Dunno where this comes from...
+
+// Some random X equivalents
+typedef WindowPtr Window;
+struct XPoint { int x, y; };
+struct XRectangle {int x, y, width, height;};
+typedef RgnHandle Fl_Region;
+void fl_clip_region(Fl_Region);
+inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
+ Fl_Region R = NewRgn();
+ SetRectRgn(R, x, y, x+w, y+h);
+ return R;
+}
+inline void XDestroyRegion(Fl_Region r) {
+ DisposeRgn(r);
+}
+
+# define XDestroyWindow(a,b) DisposeWindow(b)
+# define XMapWindow(a,b) ShowWindow(b)
+# define XUnmapWindow(a,b) HideWindow(b)
+
+# include "Fl_Window.H"
+
+// This object contains all mac-specific stuff about a window:
+// WARNING: this object is highly subject to change!
+class Fl_X
+{
+public:
+ Window xid; // Mac WindowPtr
+ GWorldPtr other_xid; // pointer for offscreen bitmaps (doublebuffer)
+ Fl_Window *w; // FLTK window for
+ Fl_Region region;
+ Fl_Region subRegion; // region for this specific subwindow
+ Fl_X *next;
+ Fl_X *xidChildren, *xidNext;
+ int wait_for_expose;
+ //+ int backbuffer_bad;
+ CursHandle cursor;
+ static Fl_X* first;
+ static Fl_X* i(const Fl_Window* w) {return w->i;}
+ static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
+ static void make(Fl_Window*);
+ static void MacGrowWindow(WindowPtr xid, const EventRecord &macevent);
+ static void MacDragWindow(WindowPtr xid, const EventRecord &macevent);
+ static int MacModifiers(const EventRecord &macevent, unsigned short prev);
+ void flush();
+};
+
+inline Window fl_xid(const Fl_Window*w)
+{
+ return Fl_X::i(w)->xid;
+}
+
+extern CursHandle fl_default_cursor;
+
+extern struct Fl_XMap {
+ RGBColor rgb;
+ ulong pen;
+} *fl_current_xmap;
+
+extern FL_EXPORT void *fl_display; //++ read yourself into multiple screen support!
+extern FL_EXPORT Window fl_window;
+extern FL_EXPORT Handle fl_system_menu;
+extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
+
+typedef GWorldPtr Fl_Offscreen;
+
+extern Fl_Offscreen fl_create_offscreen(int w, int h);
+extern void fl_copy_offscreen(int x,int y,int w,int h, Fl_Offscreen gWorld, int srcx,int srcy);
+extern void fl_delete_offscreen(Fl_Offscreen gWorld);
+extern void fl_begin_offscreen(Fl_Offscreen gWorld);
+extern void fl_end_offscreen();
+
+typedef GrafPtr Fl_Bitmask;
+
+extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
+extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
+
+extern void fl_open_display();
+
+extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
+
+#endif // !FL_MAC_H
+
+//
+// End of "$Id: mac.H,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $".
+//
+
diff --git a/FL/win32.H b/FL/win32.H
index 5927dccb1..3c6b8955f 100644
--- a/FL/win32.H
+++ b/FL/win32.H
@@ -1,5 +1,5 @@
//
-// "$Id: win32.H,v 1.15.2.3.2.2 2001/11/19 20:59:59 easysw Exp $"
+// "$Id: win32.H,v 1.15.2.3.2.3 2001/11/27 17:44:06 easysw Exp $"
//
// WIN32 header file for the Fast Light Tool Kit (FLTK).
//
@@ -42,13 +42,13 @@
typedef HWND Window;
typedef POINT XPoint;
struct XRectangle {int x, y, width, height;};
-typedef HRGN Region;
-FL_EXPORT void fl_clip_region(Region);
-inline Region XRectangleRegion(int x, int y, int w, int h) {
+typedef HRGN Fl_Region;
+FL_EXPORT void fl_clip_region(Fl_Region);
+inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
return CreateRectRgn(x,y,x+w,y+h);
}
-inline void XDestroyRegion(Region r) {DeleteObject(r);}
-inline void XClipBox(Region r,XRectangle* rect) {
+inline void XDestroyRegion(Fl_Region r) {DeleteObject(r);}
+inline void XClipBox(Fl_Region r,XRectangle* rect) {
RECT win_rect; GetRgnBox(r,&win_rect);
rect->x=win_rect.left;
rect->y=win_rect.top;
@@ -67,7 +67,7 @@ public:
Window xid;
HBITMAP other_xid; // for double-buffered windows
Fl_Window* w;
- Region region;
+ Fl_Region region;
Fl_X *next;
int wait_for_expose;
HDC private_dc; // used for OpenGL
@@ -129,5 +129,5 @@ extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
//
-// End of "$Id: win32.H,v 1.15.2.3.2.2 2001/11/19 20:59:59 easysw Exp $".
+// End of "$Id: win32.H,v 1.15.2.3.2.3 2001/11/27 17:44:06 easysw Exp $".
//
diff --git a/FL/x.H b/FL/x.H
index a56424a23..c7b7ff7ff 100644
--- a/FL/x.H
+++ b/FL/x.H
@@ -1,5 +1,5 @@
//
-// "$Id: x.H,v 1.10.2.8.2.1 2001/11/18 20:52:27 easysw Exp $"
+// "$Id: x.H,v 1.10.2.8.2.2 2001/11/27 17:44:06 easysw Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -29,26 +29,28 @@
// systems.
#ifndef Fl_X_H
-#define Fl_X_H
-
-#include "Enumerations.H"
-
-#ifdef WIN32
-
-#include "win32.H"
-
-#else
-
-#if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
-#pragma set woff 3322
-#endif
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#if defined(_ABIN32) || defined(_ABI64)
-#pragma reset woff 3322
-#endif
-#include <X11/Xatom.h>
-#include "Fl_Window.H"
+# define Fl_X_H
+
+# include "Enumerations.H"
+
+# ifdef WIN32
+# include "win32.H"
+# elif defined(__APPLE__)
+# include "mac.H"
+# else
+# if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
+# pragma set woff 3322
+# endif
+# include <X11/Xlib.h>
+# include <X11/Xutil.h>
+# if defined(_ABIN32) || defined(_ABI64)
+# pragma reset woff 3322
+# endif
+# include <X11/Xatom.h>
+# include "Fl_Window.H"
+
+// Mirror X definition of Region to Fl_Region, for portability...
+typedef Region Fl_Region
FL_EXPORT void fl_open_display();
FL_EXPORT void fl_open_display(Display*);
@@ -66,8 +68,8 @@ extern FL_EXPORT Window fl_window;
extern FL_EXPORT XFontStruct* fl_xfont;
FL_EXPORT ulong fl_xpixel(Fl_Color i);
FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
-FL_EXPORT void fl_clip_region(Region);
-FL_EXPORT Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
+FL_EXPORT void fl_clip_region(Fl_Region);
+FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
// feed events into fltk:
FL_EXPORT int fl_handle(const XEvent&);
@@ -81,14 +83,14 @@ typedef ulong Fl_Offscreen;
#define fl_create_offscreen(w,h) \
XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth)
// begin/end are macros that save the old state in local variables:
-#define fl_begin_offscreen(pixmap) \
+# define fl_begin_offscreen(pixmap) \
Window _sw=fl_window; fl_window=pixmap; fl_push_no_clip()
-#define fl_end_offscreen() \
+# define fl_end_offscreen() \
fl_pop_clip(); fl_window = _sw
-#define fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy) \
+# define fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy) \
XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y)
-#define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
+# define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
// Bitmap masks
typedef ulong Fl_Bitmask;
@@ -104,7 +106,7 @@ public:
Window xid;
Window other_xid;
Fl_Window *w;
- Region region;
+ Fl_Region region;
Fl_X *next;
char wait_for_expose;
char backbuffer_bad; // used for XDBE
@@ -127,9 +129,9 @@ FL_EXPORT Fl_Window* fl_find(Window xid);
extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
-#endif
+# endif
#endif
//
-// End of "$Id: x.H,v 1.10.2.8.2.1 2001/11/18 20:52:27 easysw Exp $".
+// End of "$Id: x.H,v 1.10.2.8.2.2 2001/11/27 17:44:06 easysw Exp $".
//