summaryrefslogtreecommitdiff
path: root/src/Fl.cxx
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 /src/Fl.cxx
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 'src/Fl.cxx')
-rw-r--r--src/Fl.cxx52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 1c39c0323..87379ed4f 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -40,6 +40,10 @@
#include <stdlib.h>
#include "flstring.h"
+#if defined(__APPLE__) && defined(__APPLE_COCOA__)
+#import <Cocoa/Cocoa.h>
+#endif
+
#ifdef DEBUG
# include <stdio.h>
#endif // DEBUG
@@ -406,10 +410,17 @@ double Fl::wait(double time_to_wait) {
// the idle function may turn off idle, we can then wait:
if (idle) time_to_wait = 0.0;
}
+#ifdef __APPLE_COCOA__
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+#endif
flush();
if (idle && !in_idle) // 'idle' may have been set within flush()
time_to_wait = 0.0;
- return fl_wait(time_to_wait);
+ double retval = fl_wait(time_to_wait);
+#ifdef __APPLE_COCOA__
+ [pool release];
+#endif
+ return retval;
#else
@@ -586,12 +597,13 @@ Fl_Window* fl_find(Window xid) {
Fl_X *window;
for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next)
#if defined(WIN32) || defined(USE_X11)
- if (window->xid == xid) {
+ if (window->xid == xid)
#elif defined(__APPLE_QUARTZ__)
- if (window->xid == xid && !window->w->window()) {
+ if (window->xid == xid && !window->w->window())
#else
# error unsupported platform
#endif // __APPLE__
+ {
if (window != Fl_X::first && !Fl::modal()) {
// make this window be first to speed up searches
// this is not done if modal is true to avoid messing up modal stack
@@ -1278,7 +1290,11 @@ int Fl_Window::handle(int ev)
#if defined(USE_X11) || defined(WIN32)
XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless
#elif defined(__APPLE_QUARTZ__)
- MacMapWindow(this, fl_xid(this));
+#ifdef __APPLE_COCOA__
+ MacMapWindow(this, i->xid);
+#else
+ MacMapWindow(this, fl_xid(this));
+#endif
#else
# error unsupported platform
#endif // __APPLE__
@@ -1300,7 +1316,11 @@ int Fl_Window::handle(int ev)
#if defined(USE_X11) || defined(WIN32)
XUnmapWindow(fl_display, fl_xid(this));
#elif defined(__APPLE_QUARTZ__)
+#ifdef __APPLE_COCOA__
+ MacUnmapWindow(this, i->xid);
+#else
MacUnmapWindow(this, fl_xid(this));
+#endif
#else
# error platform unsupported
#endif
@@ -1453,10 +1473,22 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) {
CombineRgn(i->region, i->region, R, RGN_OR);
XDestroyRegion(R);
#elif defined(__APPLE_QUARTZ__)
- Fl_Region R = NewRgn();
- SetRectRgn(R, X, Y, X+W, Y+H);
- UnionRgn(R, i->region, i->region);
- DisposeRgn(R);
+#ifdef __APPLE_COCOA__
+ CGRect arg = CGRectMake(X,Y,W - 1,H - 1);
+ int j;//don't add a rectangle totally inside the Fl_Region
+ for(j = 0; j < i->region->count; j++) {
+ if(CGRectContainsRect(i->region->rects[j], arg)) break;
+ }
+ if( j >= i->region->count) {
+ i->region->rects = (CGRect*)realloc(i->region->rects, (++(i->region->count)) * sizeof(CGRect));
+ i->region->rects[i->region->count - 1] = arg;
+ }
+#else
+ Fl_Region R = NewRgn();
+ SetRectRgn(R, X, Y, X+W, Y+H);
+ UnionRgn(R, i->region, i->region);
+ DisposeRgn(R);
+#endif
#else
# error unsupported platform
#endif
@@ -1480,8 +1512,12 @@ void Fl_Window::flush() {
#ifdef WIN32
# include "Fl_win32.cxx"
#elif defined(__APPLE__)
+#ifdef __APPLE_COCOA__
+# include "Fl_cocoa.mm"
+#else
# include "Fl_mac.cxx"
#endif
+#endif
//
// The following methods allow callbacks to schedule the deletion of