summaryrefslogtreecommitdiff
path: root/FL
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2009-12-06 22:21:55 +0000
committerMatthias Melcher <fltk@matthiasm.com>2009-12-06 22:21:55 +0000
commitb2cffc688ea7abbddabc9ed23deea1921f59ac9d (patch)
tree74a50bdb133fd6b5af7c785541bcc46e2e8e9c15 /FL
parent1ea4b4573538f2d53960dd8a4ef4f35480d2f5f7 (diff)
Moved OS X code base to the more moder Cocoa toolkit thanks to the awesome work of Manolo Gouy (STR #2221). This is a big one! I tested all test applications under 32-bit autoconf and Xcode, and a few apps under 64bit intel. No PPC testing was done. Please verify this patch if you have the machine!
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6951 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
-rw-r--r--FL/Fl_Scroll.H8
-rw-r--r--FL/mac.H69
2 files changed, 64 insertions, 13 deletions
diff --git a/FL/Fl_Scroll.H b/FL/Fl_Scroll.H
index 035a07af9..8503de455 100644
--- a/FL/Fl_Scroll.H
+++ b/FL/Fl_Scroll.H
@@ -36,7 +36,7 @@
/**
This container widget lets you maneuver around a set of widgets much
- larger than your window. If the child widgets are larger than the size
+ larger than your window. If the child widgets are larger than the size
of this object then scrollbars will appear so that you can scroll over
to them:
\image html Fl_Scroll.gif
@@ -73,8 +73,8 @@
considered. The flags in hscrollbar however are ignored.
This widget can also be used to pan around a single child widget
- "canvas". This child widget should be of your own class, with a
- draw() method that draws the contents. The scrolling is done by
+ "canvas". This child widget should be of your own class, with a
+ draw() method that draws the contents. The scrolling is done by
changing the x() and y() of the widget, so this child
must use the x() and y() to position its drawing.
To speed up drawing it should test fl_push_clip().
@@ -86,7 +86,7 @@
of individually-openable panels.
Fluid lets you create these, but you can only lay out objects that
- fit inside the Fl_Scroll without scrolling. Be sure to leave
+ fit inside the Fl_Scroll without scrolling. Be sure to leave
space for the scrollbars, as Fluid won't show these either.
<I>You cannot use Fl_Window as a child of this since the
diff --git a/FL/mac.H b/FL/mac.H
index 9bc7068d4..5f815c7da 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -36,16 +36,47 @@
// Standard MacOS Carbon API includes...
#include <Carbon/Carbon.h>
+#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) && !__LP64__
+typedef float CGFloat;
+#endif
+#include <config.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;};
+
+#ifdef __APPLE_COCOA__
+
+typedef void *Window; //this is really a pter to the subclass FLWindow of NSWindow
+typedef struct flCocoaRegion{
+ int count;
+ CGRect *rects;
+} *Fl_Region; // a region is the union of a series of rectangles
+inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
+ Fl_Region R = (Fl_Region)malloc(sizeof(*R));
+ R->count = 1;
+ R->rects = (CGRect *)malloc(sizeof(CGRect));
+ *(R->rects) = CGRectMake(x, y, w - 1, h - 1);
+ return R;
+}
+inline void XDestroyRegion(Fl_Region r) {
+ if(r) {
+ free(r->rects);
+ free(r);
+ }
+}
+extern void *fl_default_cursor;
+extern void *fl_system_menu;
+typedef CGContextRef Fl_Offscreen;
+typedef CGImageRef Fl_Bitmask;
+
+#else
+
+typedef WindowRef Window;
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);
@@ -54,6 +85,14 @@ inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
inline void XDestroyRegion(Fl_Region r) {
DisposeRgn(r);
}
+extern CursHandle fl_default_cursor;
+extern Handle fl_system_menu;
+typedef GWorldPtr Fl_Offscreen;
+typedef GWorldPtr Fl_Bitmask; // Carbon requires a 1-bit GWorld instead of a BitMap
+
+#endif
+
+void fl_clip_region(Fl_Region);
# include "Fl_Window.H"
@@ -62,15 +101,19 @@ inline void XDestroyRegion(Fl_Region r) {
class Fl_X
{
public:
- Window xid; // Mac WindowPtr
- GWorldPtr other_xid; // pointer for offscreen bitmaps (doublebuffer)
+ Window xid; // Cocoa: FLWindow* ; Carbon: WindowRef
+ Fl_Offscreen 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; // linked tree to support subwindows
Fl_X *xidChildren, *xidNext; // more subwindow tree
int wait_for_expose;
+#ifdef __APPLE_COCOA__
+ void *cursor; // is really NSCursor*
+#else
CursHandle cursor;
+#endif
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&);
@@ -78,8 +121,10 @@ public:
void flush();
// Quartz additions:
CGContextRef gc; // graphics context (NULL when using QD)
+#ifndef __APPLE_COCOA__
static ATSUTextLayout atsu_layout; // windows share a global font
static ATSUStyle atsu_style;
+#endif
static void q_fill_context(); // fill a Quartz context with current FLTK state
static void q_clear_clipping(); // remove all clipping from a Quartz context
static void q_release_context(Fl_X *x=0); // free all resources associated with fl_gc
@@ -87,18 +132,27 @@ public:
static void q_end_image();
};
+#ifdef __APPLE_COCOA__
+extern void MacDestroyWindow(Fl_Window*,void *);
+extern void MacMapWindow(Fl_Window*,void *);
+extern void MacUnmapWindow(Fl_Window*,void *);
+extern WindowRef MACwindowRef(Fl_Window *w);
+extern Fl_Region MacRectRegionIntersect(Fl_Region current, int x,int y,int w, int h);
+extern void MacCollapseWindow(Window w);
+#else
extern void MacDestroyWindow(Fl_Window*,WindowPtr);
extern void MacMapWindow(Fl_Window*,WindowPtr);
extern void MacUnmapWindow(Fl_Window*,WindowPtr);
+#endif
+
extern int MacUnlinkWindow(Fl_X*,Fl_X*start=0L);
+extern void fl_open_callback(void (*cb)(const char *));
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;
@@ -107,10 +161,8 @@ extern struct Fl_XMap {
extern FL_EXPORT void *fl_display;
extern FL_EXPORT Window fl_window;
extern FL_EXPORT CGContextRef fl_gc;
-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);
@@ -118,7 +170,6 @@ extern void fl_delete_offscreen(Fl_Offscreen gWorld);
extern void fl_begin_offscreen(Fl_Offscreen gWorld);
extern void fl_end_offscreen();
-typedef GWorldPtr Fl_Bitmask; // Carbon requires a 1-bit GWorld instead of a BitMap
extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);