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!
@ -54,6 +85,14 @@ inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
@@ -54,6 +85,14 @@ inline Fl_Region XRectangleRegion(int x, int y, int w, int h) {
inlinevoidXDestroyRegion(Fl_Regionr){
DisposeRgn(r);
}
externCursHandlefl_default_cursor;
externHandlefl_system_menu;
typedefGWorldPtrFl_Offscreen;
typedefGWorldPtrFl_Bitmask;// Carbon requires a 1-bit GWorld instead of a BitMap
// this is not done if modal is true to avoid messing up modal stack
@ -1278,7 +1290,11 @@ int Fl_Window::handle(int ev)
@@ -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__)
#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)
@@ -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) {
@@ -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__)
#ifdef __APPLE_COCOA__
CGRectarg=CGRectMake(X,Y,W-1,H-1);
intj;//don't add a rectangle totally inside the Fl_Region
@ -281,6 +339,30 @@ void fl_text_extents(const UniChar* txt, int n, int &dx, int &dy, int &w, int &h
@@ -281,6 +339,30 @@ void fl_text_extents(const UniChar* txt, int n, int &dx, int &dy, int &w, int &h
@ -304,6 +386,10 @@ void fl_text_extents(const UniChar* txt, int n, int &dx, int &dy, int &w, int &h
@@ -304,6 +386,10 @@ void fl_text_extents(const UniChar* txt, int n, int &dx, int &dy, int &w, int &h
@ -360,9 +524,20 @@ void fl_draw(int angle, const char *str, int n, int x, int y) {
@@ -360,9 +524,20 @@ void fl_draw(int angle, const char *str, int n, int x, int y) {
// 'fl_read_image()' - Read an image from the current window.
@ -41,6 +41,29 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
@@ -41,6 +41,29 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
intw,// I - Width of area to read
inth,// I - Height of area to read
intalpha){// I - Alpha value for image (0 for none)
GWorldPtrosbuffer;// Temporary off-screen buffer for copy
@ -128,6 +151,7 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
@@ -128,6 +151,7 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
@ -155,13 +187,21 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
@@ -155,13 +187,21 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
@ -234,13 +290,21 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
@@ -234,13 +290,21 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
@ -287,12 +359,20 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) {
@@ -287,12 +359,20 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) {
// functions will not draw the last point ("it's a feature!"...)
@ -315,11 +395,17 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {
@@ -315,11 +395,17 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {
LineTo(fl_gc,x2,y2);
LineTo(fl_gc,x,y);
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,true);
#endif
CGContextMoveToPoint(fl_gc,x,y);
CGContextAddLineToPoint(fl_gc,x1,y1);
CGContextAddLineToPoint(fl_gc,x2,y2);
CGContextClosePath(fl_gc);
CGContextStrokePath(fl_gc);
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,false);
#endif
#else
# error unsupported platform
#endif
@ -344,12 +430,18 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
@@ -344,12 +430,18 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
LineTo(fl_gc,x3,y3);
LineTo(fl_gc,x,y);
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,true);
#endif
CGContextMoveToPoint(fl_gc,x,y);
CGContextAddLineToPoint(fl_gc,x1,y1);
CGContextAddLineToPoint(fl_gc,x2,y2);
CGContextAddLineToPoint(fl_gc,x3,y3);
CGContextClosePath(fl_gc);
CGContextStrokePath(fl_gc);
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,false);
#endif
#else
# error unsupported platform
#endif
@ -371,11 +463,17 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {
@@ -371,11 +463,17 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {
SelectObject(fl_gc,fl_brush());
Polygon(fl_gc,p,3);
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,true);
#endif
CGContextMoveToPoint(fl_gc,x,y);
CGContextAddLineToPoint(fl_gc,x1,y1);
CGContextAddLineToPoint(fl_gc,x2,y2);
CGContextClosePath(fl_gc);
CGContextFillPath(fl_gc);
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,false);
#endif
#else
# error unsupported platform
#endif
@ -398,12 +496,18 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
@@ -398,12 +496,18 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
SelectObject(fl_gc,fl_brush());
Polygon(fl_gc,p,4);
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,true);
#endif
CGContextMoveToPoint(fl_gc,x,y);
CGContextAddLineToPoint(fl_gc,x1,y1);
CGContextAddLineToPoint(fl_gc,x2,y2);
CGContextAddLineToPoint(fl_gc,x3,y3);
CGContextClosePath(fl_gc);
CGContextFillPath(fl_gc);
#ifdef __APPLE_COCOA__
CGContextSetShouldAntialias(fl_gc,false);
#endif
#else
# error unsupported platform
#endif
@ -418,11 +522,19 @@ void fl_point(int x, int y) {
@@ -418,11 +522,19 @@ void fl_point(int x, int y) {
@ -673,6 +824,24 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
@@ -673,6 +824,24 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
DeleteObject(rr);
returnret;
#elif defined(__APPLE_QUARTZ__)
#ifdef __APPLE_COCOA__
CGRectarg=CGRectMake(x,y,w-1,h-1);
CGRectu=CGRectMake(0,0,0,0);
CGRecttest;
for(inti=0;i<r->count;i++){
test=CGRectIntersection(r->rects[i],arg);
if(!CGRectIsEmpty(test)){
if(CGRectIsEmpty(u))u=test;
elseu=CGRectUnion(u,test);
}
}
X=u.origin.x;
Y=u.origin.y;
W=u.size.width;
H=u.size.height;
if(CGRectIsEmpty(u))W=H=0;
return!CGRectEqualToRect(arg,u);
#else
RgnHandlerr=NewRgn();
SetRectRgn(rr,x,y,x+w,y+h);
SectRgn(r,rr,rr);
@ -685,6 +854,7 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
@@ -685,6 +854,7 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
@ -151,6 +151,16 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
@@ -151,6 +151,16 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
// warning: there does not seem to be an equivalent to this function in Quartz
// ScrollWindowRect is a QuickDraw function and won't work here.
// Since on OS X all windows are fully double buffered, we need not
@ -161,6 +171,8 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
@@ -161,6 +171,8 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
@ -351,6 +367,95 @@ void gl_draw_image(const uchar* b, int x, int y, int w, int h, int d, int ld) {
@@ -351,6 +367,95 @@ void gl_draw_image(const uchar* b, int x, int y, int w, int h, int d, int ld) {