summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2004-08-31 22:00:49 +0000
committerMatthias Melcher <fltk@matthiasm.com>2004-08-31 22:00:49 +0000
commit98a0be39654892de753912045a36bd7f66eac31c (patch)
treed39bb112c2484c0c8266b91df8fdacc59929a1e4 /src
parenta3155cb205973ee1ebd1bbcf807232a119e67806 (diff)
Quartz for FLTK1.1
- Pixmaps now correctly support transparency/masking - subimage drawing aligned correctly - lines with a size over 1 always anti-alias - fl_begin_points/fl_end_points works - fixed refresh problem for multiple open windows Will check Linux compile right after this commit to make sure that I didn't destroy anything. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3800 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx23
-rw-r--r--src/Fl_Bitmap.cxx6
-rw-r--r--src/Fl_Double_Window.cxx51
-rw-r--r--src/Fl_Image.cxx6
-rw-r--r--src/Fl_Pixmap.cxx17
-rw-r--r--src/Fl_Window_fullscreen.cxx8
-rw-r--r--src/Fl_get_key_mac.cxx8
-rw-r--r--src/Fl_mac.cxx33
-rw-r--r--src/fl_draw_image_mac.cxx102
-rw-r--r--src/fl_draw_pixmap.cxx56
-rw-r--r--src/fl_line_style.cxx6
-rw-r--r--src/fl_overlay.cxx9
-rw-r--r--src/fl_rect.cxx49
-rw-r--r--src/fl_vertex.cxx9
-rw-r--r--src/gl_draw.cxx6
15 files changed, 177 insertions, 212 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 251aeba1a..80129c998 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.cxx,v 1.24.2.41.2.65 2004/08/27 20:02:44 matthiaswm Exp $"
+// "$Id: Fl.cxx,v 1.24.2.41.2.66 2004/08/31 22:00:45 matthiaswm Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -371,21 +371,14 @@ void Fl::flush() {
#ifdef WIN32
GdiFlush();
-#elif defined (__APPLE_QD__)
- GrafPtr port; GetPort( &port );
- if ( port )
- {
- QDFlushPortBuffer( port, 0 );
- }
-#elif defined (__APPLE_QUARTZ__)
-# warning quartz: remove this
- GrafPtr port; GetPort( &port );
+#elif defined(__APPLE_QD__)
+ GrafPtr port;
+ GetPort( &port );
if ( port )
- {
QDFlushPortBuffer( port, 0 );
- }
-// end remove
- if (fl_gc) CGContextSynchronize(fl_gc);
+#elif defined (__APPLE_QUARTZ__)
+ if (fl_gc)
+ CGContextFlush(fl_gc);
#else
if (fl_display) XFlush(fl_display);
#endif
@@ -1028,5 +1021,5 @@ void Fl_Window::flush() {
}
//
-// End of "$Id: Fl.cxx,v 1.24.2.41.2.65 2004/08/27 20:02:44 matthiaswm Exp $".
+// End of "$Id: Fl.cxx,v 1.24.2.41.2.66 2004/08/31 22:00:45 matthiaswm Exp $".
//
diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx
index 83c44aa9f..60483db2b 100644
--- a/src/Fl_Bitmap.cxx
+++ b/src/Fl_Bitmap.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.25 2004/08/31 00:27:40 matthiaswm Exp $"
+// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.26 2004/08/31 22:00:47 matthiaswm Exp $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -393,7 +393,7 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
if (!id) id = fl_create_bitmask(w(), h(), array);
if (id && fl_gc) {
CGRect rect = { X, Y, W, H };
- Fl_X::q_begin_image(rect, cx, cy);
+ Fl_X::q_begin_image(rect, cx, cy, w(), h());
CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
Fl_X::q_end_image();
}
@@ -501,5 +501,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
//
-// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.25 2004/08/31 00:27:40 matthiaswm Exp $".
+// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.26 2004/08/31 22:00:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx
index 4c597b110..eb834c980 100644
--- a/src/Fl_Double_Window.cxx
+++ b/src/Fl_Double_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.11 2004/08/31 00:27:40 matthiaswm Exp $"
+// "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.12 2004/08/31 22:00:47 matthiaswm Exp $"
//
// Double-buffered window code for the Fast Light Tool Kit (FLTK).
//
@@ -166,7 +166,7 @@ extern void fl_restore_clip();
#elif defined(__APPLE_QUARTZ__)
Fl_Offscreen fl_create_offscreen(int w, int h) {
- void *data = malloc(w*h*4);
+ void *data = calloc(w*h,4);
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(
data, w, h, 8, w*4, lut, kCGImageAlphaNoneSkipLast);
@@ -174,19 +174,28 @@ Fl_Offscreen fl_create_offscreen(int w, int h) {
return (Fl_Offscreen)ctx;
}
+Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) {
+ void *data = calloc(w*h,4);
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGContextRef ctx = CGBitmapContextCreate(
+ data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast);
+ CGColorSpaceRelease(lut);
+ return (Fl_Offscreen)ctx;
+}
+
void fl_copy_offscreen(int x,int y,int w,int h,Fl_Offscreen osrc,int srcx,int srcy) {
-#warning : test this implementation!
CGContextRef src = (CGContextRef)osrc;
void *data = CGBitmapContextGetData(src);
int sw = CGBitmapContextGetWidth(src);
int sh = CGBitmapContextGetHeight(src);
+ CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(src);
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
CGDataProviderRef src_bytes = CGDataProviderCreateWithData( 0L, data, sw*sh*4, 0L);
- CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, kCGImageAlphaNoneSkipLast,
+ CGImageRef img = CGImageCreate( sw, sh, 8, 4*8, 4*sw, lut, alpha,
src_bytes, 0L, false, kCGRenderingIntentDefault);
// fl_push_clip();
CGRect rect = { x, y, w, h };
- Fl_X::q_begin_image(rect, srcx, srcy);
+ Fl_X::q_begin_image(rect, srcx, srcy, sw, sh);
CGContextDrawImage(fl_gc, rect, img);
Fl_X::q_end_image();
CGImageRelease(img);
@@ -242,21 +251,10 @@ void Fl_Double_Window::flush(int eraseoverlay) {
else
#endif
#ifdef __APPLE_QD__
- // the Apple OS X window manager double buffers ALL windows
- // anyway, so there is no need to waste memory and time.
- //
- // BTW: Windows2000 and later also forces doublebuffering if
- // transparent windows are beeing used (alpha channel)
if ( ( !QDIsPortBuffered( GetWindowPort(myi->xid) ) ) || force_doublebuffering_ )
myi->other_xid = fl_create_offscreen(w(), h());
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
- // the Apple OS X window manager double buffers ALL windows
- // anyway, so there is no need to waste memory and time.
- //
- // BTW: Windows2000 and later also forces doublebuffering if
- // transparent windows are beeing used (alpha channel)
- if ( ( !QDIsPortBuffered( GetWindowPort(myi->xid) ) ) || force_doublebuffering_ )
+ if (force_doublebuffering_)
myi->other_xid = fl_create_offscreen(w(), h());
#else
myi->other_xid = fl_create_offscreen(w(), h());
@@ -298,7 +296,7 @@ void Fl_Double_Window::flush(int eraseoverlay) {
draw();
DeleteDC(fl_gc);
fl_gc = _sgc;
-#elif defined(__APPLE_QD__)
+#elif defined(__APPLE__)
if ( myi->other_xid ) {
fl_begin_offscreen( myi->other_xid );
fl_clip_region( 0 );
@@ -307,16 +305,6 @@ void Fl_Double_Window::flush(int eraseoverlay) {
} else {
draw();
}
-#elif defined(__APPLE_QUARTZ__)
-#warning quartz
- if ( myi->other_xid ) {
- fl_begin_offscreen( myi->other_xid );
- fl_clip_region( 0 );
- draw();
- fl_end_offscreen();
- } else {
- draw();
- }
#else // X:
fl_window = myi->other_xid;
draw();
@@ -327,10 +315,7 @@ void Fl_Double_Window::flush(int eraseoverlay) {
// on Irix (at least) it is faster to reduce the area copied to
// the current clip region:
int X,Y,W,H; fl_clip_box(0,0,w(),h(),X,Y,W,H);
-#ifdef __APPLE_QD__
- if (myi->other_xid) fl_copy_offscreen(X, Y, W, H, myi->other_xid, X, Y);
-#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+#ifdef __APPLE__
if (myi->other_xid) fl_copy_offscreen(X, Y, W, H, myi->other_xid, X, Y);
#else
fl_copy_offscreen(X, Y, W, H, myi->other_xid, X, Y);
@@ -367,5 +352,5 @@ Fl_Double_Window::~Fl_Double_Window() {
}
//
-// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.11 2004/08/31 00:27:40 matthiaswm Exp $".
+// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.12 2004/08/31 22:00:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Image.cxx b/src/Fl_Image.cxx
index bfb0fc0ab..a21bfa008 100644
--- a/src/Fl_Image.cxx
+++ b/src/Fl_Image.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Image.cxx,v 1.5.2.3.2.36 2004/08/31 00:27:40 matthiaswm Exp $"
+// "$Id: Fl_Image.cxx,v 1.5.2.3.2.37 2004/08/31 22:00:47 matthiaswm Exp $"
//
// Image drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -381,7 +381,7 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
#elif defined(__APPLE_QUARTZ__)
if (id && fl_gc) {
CGRect rect = { X, Y, W, H };
- Fl_X::q_begin_image(rect, cx, cy);
+ Fl_X::q_begin_image(rect, cx, cy, w(), h());
CGContextDrawImage(fl_gc, rect, (CGImageRef)id);
Fl_X::q_end_image();
}
@@ -418,5 +418,5 @@ void Fl_RGB_Image::label(Fl_Menu_Item* m) {
//
-// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.36 2004/08/31 00:27:40 matthiaswm Exp $".
+// End of "$Id: Fl_Image.cxx,v 1.5.2.3.2.37 2004/08/31 22:00:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Pixmap.cxx b/src/Fl_Pixmap.cxx
index 82e8250f5..1fbd68a74 100644
--- a/src/Fl_Pixmap.cxx
+++ b/src/Fl_Pixmap.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.31 2004/08/31 01:29:54 easysw Exp $"
+// "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.32 2004/08/31 22:00:47 matthiaswm Exp $"
//
// Pixmap drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -41,6 +41,10 @@
#include "flstring.h"
#include <ctype.h>
+#ifdef __APPLE_QUARTZ__
+extern Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h);
+#endif
+
extern uchar **fl_mask_bitmap; // used by fl_draw_pixmap.cxx to store mask
void fl_restore_clip(); // in fl_rect.cxx
@@ -80,7 +84,12 @@ void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
if (cy+H > h()) H = h()-cy;
if (H <= 0) return;
if (!id) {
-//#warning : to enable masking in Quartz, write our own version of this little function!
+#ifdef __APPLE_QUARTZ__
+ id = fl_create_offscreen_with_alpha(w(), h());
+ fl_begin_offscreen((Fl_Offscreen)id);
+ fl_draw_pixmap(data(), 0, 0, FL_GREEN);
+ fl_end_offscreen();
+#else
id = fl_create_offscreen(w(), h());
fl_begin_offscreen((Fl_Offscreen)id);
uchar *bitmap = 0;
@@ -91,8 +100,8 @@ void Fl_Pixmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
mask = fl_create_bitmask(w(), h(), bitmap);
delete[] bitmap;
}
-
fl_end_offscreen();
+#endif
}
#ifdef WIN32
if (mask) {
@@ -464,5 +473,5 @@ void Fl_Pixmap::desaturate() {
}
//
-// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.31 2004/08/31 01:29:54 easysw Exp $".
+// End of "$Id: Fl_Pixmap.cxx,v 1.9.2.4.2.32 2004/08/31 22:00:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Window_fullscreen.cxx b/src/Fl_Window_fullscreen.cxx
index 09d128151..58a6c7131 100644
--- a/src/Fl_Window_fullscreen.cxx
+++ b/src/Fl_Window_fullscreen.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.7 2004/08/25 00:20:26 matthiaswm Exp $"
+// "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.8 2004/08/31 22:00:48 matthiaswm Exp $"
//
// Fullscreen window support for the Fast Light Tool Kit (FLTK).
//
@@ -52,9 +52,9 @@ void Fl_Window::border(int b) {
// not yet implemented, but it's possible
// for full fullscreen we have to make the window topmost as well
#elif defined(__APPLE_QD__)
- // \todo Mac : not yet implemeted
+ // warning: not implemented in Quickdraw/Carbon
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+ // warning: not implemented in Quartz/Carbon
#else
if (shown()) Fl_X::i(this)->sendxjunk();
#endif
@@ -79,5 +79,5 @@ void Fl_Window::fullscreen_off(int X,int Y,int W,int H) {
}
//
-// End of "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.7 2004/08/25 00:20:26 matthiaswm Exp $".
+// End of "$Id: Fl_Window_fullscreen.cxx,v 1.5.2.3.2.8 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/Fl_get_key_mac.cxx b/src/Fl_get_key_mac.cxx
index 8bd3f6bc8..e568f2111 100644
--- a/src/Fl_get_key_mac.cxx
+++ b/src/Fl_get_key_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_get_key_mac.cxx,v 1.1.2.10 2004/08/25 00:20:26 matthiaswm Exp $"
+// "$Id: Fl_get_key_mac.cxx,v 1.1.2.11 2004/08/31 22:00:48 matthiaswm Exp $"
//
// MacOS keyboard state routines for the Fast Light Tool Kit (FLTK).
//
@@ -31,10 +31,6 @@
#include <FL/x.H>
#include <config.h>
-#ifdef __APPLE_QUARTZ__
-#warning quartz
-#endif
-
// convert an FLTK (X) keysym to a MacOS symbol:
// See also the inverse converter in Fl_mac.cxx
// This table is in numeric order by FLTK symbol order for binary search:
@@ -104,5 +100,5 @@ int Fl::get_key(int k) {
}
//
-// End of "$Id: Fl_get_key_mac.cxx,v 1.1.2.10 2004/08/25 00:20:26 matthiaswm Exp $".
+// End of "$Id: Fl_get_key_mac.cxx,v 1.1.2.11 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index f1ff1621d..07a80e392 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_mac.cxx,v 1.1.2.62 2004/08/31 00:27:40 matthiaswm Exp $"
+// "$Id: Fl_mac.cxx,v 1.1.2.63 2004/08/31 22:00:48 matthiaswm Exp $"
//
// MacOS specific code for the Fast Light Tool Kit (FLTK).
//
@@ -1256,6 +1256,15 @@ unsigned short mac2fltk(ulong macKey)
void Fl_X::flush()
{
w->flush();
+#ifdef __APPLE_QD__
+ GrafPtr port;
+ GetPort( &port );
+ if ( port )
+ QDFlushPortBuffer( port, 0 );
+#elif defined (__APPLE_QUARTZ__)
+ if (fl_gc)
+ CGContextFlush(fl_gc);
+#endif
SetOrigin( 0, 0 );
}
@@ -1502,7 +1511,7 @@ static pascal OSErr dndReceiveHandler( WindowPtr w, void *userData, DragReferenc
*/
void Fl_X::make(Fl_Window* w)
{
- static int xyPos = 50;
+ static int xyPos = 100;
if ( w->parent() ) // create a subwindow
{
Fl_Group::current(0);
@@ -1578,7 +1587,7 @@ void Fl_X::make(Fl_Window* w)
w->x(xyPos+Fl::x());
w->y(xyPos+Fl::y());
xyPos += 25;
- if (xyPos>200) xyPos = 25;
+ if (xyPos>200) xyPos = 100;
} else {
if (!Fl::grab()) {
xp = xwm; yp = ywm;
@@ -1912,15 +1921,19 @@ void Fl_X::q_release_context(Fl_X *x) {
fl_gc = 0;
}
-void Fl_X::q_begin_image(CGRect &rect, int cx, int cy) {
+void Fl_X::q_begin_image(CGRect &rect, int cx, int cy, int w, int h) {
CGContextSaveGState(fl_gc);
CGAffineTransform mx = CGContextGetCTM(fl_gc);
- mx.d = -1.0;
+ CGRect r2 = rect;
+ r2.origin.x -= 0.5f;
+ r2.origin.y -= 0.5f;
+ CGContextClipToRect(fl_gc, r2);
+ mx.d = -1.0; mx.tx = -mx.tx;
CGContextConcatCTM(fl_gc, mx);
- rect.origin.y = (mx.ty-0.5f) - rect.origin.y - rect.size.height + 1;
-#warning : quartz - this needs to be fixed!
- // this version will scale images into some position. Instead, it should clip them!
- // we probably need the image size as an additional argument!
+ rect.origin.x = rect.origin.x - cx;
+ rect.origin.y = (mx.ty+0.5f) - rect.origin.y - h + cy;
+ rect.size.width = w;
+ rect.size.height = h;
}
void Fl_X::q_end_image() {
@@ -2001,6 +2014,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
//
-// End of "$Id: Fl_mac.cxx,v 1.1.2.62 2004/08/31 00:27:40 matthiaswm Exp $".
+// End of "$Id: Fl_mac.cxx,v 1.1.2.63 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/fl_draw_image_mac.cxx b/src/fl_draw_image_mac.cxx
index 08820ffd6..adc2ce645 100644
--- a/src/fl_draw_image_mac.cxx
+++ b/src/fl_draw_image_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_draw_image_mac.cxx,v 1.1.2.8 2004/08/31 00:27:40 matthiaswm Exp $"
+// "$Id: fl_draw_image_mac.cxx,v 1.1.2.9 2004/08/31 22:00:48 matthiaswm Exp $"
//
// MacOS image drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -30,10 +30,6 @@
#include <FL/fl_draw.H>
#include <FL/x.H>
-#ifdef __APPLE_QUARTZ__
-#warning quartz
-#endif
-
#define MAXBUFFER 0x40000 // 256k
/**
@@ -169,6 +165,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
}
}
#elif defined(__APPLE_QUARTZ__)
+#warning : quartz - this function is *terribly* slow. Please replace!!!!
// following the very save (and very slow) way to write the image into the give port
CGContextSetShouldAntialias(fl_gc, false);
if ( cb )
@@ -181,12 +178,13 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
for ( int j=0; j<W; j++ )
{
if ( mono )
- { fl_color( src[0], src[0], src[0] ); src++; }
+ { fl_color( src[0], src[0], src[0] ); }
else
- { fl_color( src[0], src[1], src[2] ); src+=4; }
+ { fl_color( src[0], src[1], src[2] ); }
CGContextMoveToPoint(fl_gc, X+j, Y+i);
CGContextAddLineToPoint(fl_gc, X+j, Y+i);
CGContextStrokePath(fl_gc);
+ src+=delta;
}
}
delete[] tmpBuf;
@@ -213,94 +211,6 @@ static void innards(const uchar *buf, int X, int Y, int W, int H,
#else
# error : you must defined __APPLE_QD__ or __APPLE_QUARTZ__
#endif
-// \todo Mac : the above function does not support subregions yet
-#ifdef later_we_do_this
-// \todo Mac : the following code is taken from fl_draw_image_win32 and needs to be modified for Mac Carbon
-// if (!linedelta) linedelta = W*delta;
-
- int x, y, w, h;
- fl_clip_box(X,Y,W,H,x,y,w,h);
- if (w<=0 || h<=0) return;
- if (buf) buf += (x-X)*delta + (y-Y)*linedelta;
-
-// static U32 bmibuffer[256+12];
-// BITMAPINFO &bmi = *((BITMAPINFO*)bmibuffer);
-// if (!bmi.bmiHeader.biSize) {
-// bmi.bmiHeader.biSize = sizeof(bmi)-4; // does it use this to determine type?
-// bmi.bmiHeader.biPlanes = 1;
-// bmi.bmiHeader.biCompression = BI_RGB;
-// bmi.bmiHeader.biXPelsPerMeter = 0;
-// bmi.bmiHeader.biYPelsPerMeter = 0;
-// bmi.bmiHeader.biClrUsed = 0;
-// bmi.bmiHeader.biClrImportant = 0;
-// }
-// if (mono) {
-// for (int i=0; i<256; i++) {
-// bmi.bmiColors[i].rgbBlue = i;
-// bmi.bmiColors[i].rgbGreen = i;
-// bmi.bmiColors[i].rgbRed = i;
-// bmi.bmiColors[i].rgbReserved = i;
-// }
-// }
-// bmi.bmiHeader.biWidth = w;
-// bmi.bmiHeader.biBitCount = mono ? 8 : 24;
- int pixelsize = mono ? 1 : 3;
- int linesize = (pixelsize*w+3)&~3;
-
- static U32* buffer;
- int blocking = h;
- {int size = linesize*h;
- if (size > MAXBUFFER) {
- size = MAXBUFFER;
- blocking = MAXBUFFER/linesize;
- }
- static long buffer_size;
- if (size > buffer_size) {
- delete[] buffer;
- buffer_size = size;
- buffer = new U32[(size+3)/4];
- }}
-// bmi.bmiHeader.biHeight = blocking;
- static U32* line_buffer;
- if (!buf) {
- int size = W*delta;
- static int line_buf_size;
- if (size > line_buf_size) {
- delete[] line_buffer;
- line_buf_size = size;
- line_buffer = new U32[(size+3)/4];
- }
- }
- for (int j=0; j<h; ) {
- int k;
- for (k = 0; j<h && k<blocking; k++, j++) {
- const uchar* from;
- if (!buf) { // run the converter:
- cb(userdata, x-X, y-Y+j, w, (uchar*)line_buffer);
- from = (uchar*)line_buffer;
- } else {
- from = buf;
- buf += linedelta;
- }
- uchar *to = (uchar*)buffer+(blocking-k-1)*linesize;
- if (mono) {
- for (int i=w; i--; from += delta) *to++ = *from;
- } else {
- for (int i=w; i--; from += delta, to += 3) {
- uchar r = from[0];
- to[0] = from[2];
- to[1] = from[1];
- to[2] = r;
- }
- }
- }
-// SetDIBitsToDevice(fl_gc, x, y+j-k, w, k, 0, 0, 0, k,
-// (LPSTR)((uchar*)buffer+(blocking-k)*linesize),
-// &bmi,
-// DIB_RGB_COLORS
-// );
- }
-#endif
}
void fl_draw_image(const uchar* buf, int x, int y, int w, int h, int d, int l){
@@ -324,5 +234,5 @@ void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) {
}
//
-// End of "$Id: fl_draw_image_mac.cxx,v 1.1.2.8 2004/08/31 00:27:40 matthiaswm Exp $".
+// End of "$Id: fl_draw_image_mac.cxx,v 1.1.2.9 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/fl_draw_pixmap.cxx b/src/fl_draw_pixmap.cxx
index 8c12982b3..6298d035c 100644
--- a/src/fl_draw_pixmap.cxx
+++ b/src/fl_draw_pixmap.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.14 2004/08/31 01:29:55 easysw Exp $"
+// "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.15 2004/08/31 22:00:48 matthiaswm Exp $"
//
// Pixmap drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -108,6 +108,8 @@ struct pixmap_data {
};
};
+#ifndef __APPLE_QUARTZ__
+
// callback for 1 byte per pixel:
static void cb1(void*v, int x, int y, int w, uchar* buf) {
pixmap_data& d = *(pixmap_data*)v;
@@ -129,6 +131,8 @@ static void cb2(void*v, int x, int y, int w, uchar* buf) {
#endif
+#endif
+
uchar **fl_mask_bitmap; // if non-zero, create bitmap and store pointer here
int fl_draw_pixmap(/*const*/ char* const* data, int x,int y,Fl_Color bg) {
@@ -171,7 +175,11 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) {
*c++ = *p++;
*c++ = *p++;
*c++ = *p++;
+#ifdef __APPLE_QUARTZ__
+ *c = 255;
+#else
*c = 0;
+#endif
}
} else { // normal XPM colormap with names
if (chars_per_pixel>1) memset(d.byte1, 0, sizeof(d.byte1));
@@ -211,16 +219,24 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) {
c += 4;
# endif
#endif
+#ifdef __APPLE_QUARTZ__
+ c[3] = 255;
+#endif
if (!fl_parse_color((const char*)p, c[0], c[1], c[2])) {
// assume "None" or "#transparent" for any errors
// "bg" should be transparent...
Fl::get_color(bg, c[0], c[1], c[2]);
+#ifdef __APPLE_QUARTZ__
+ c[3] = 0;
+#endif
transparent_index = ind;
}
}
}
d.data = data;
+#ifndef __APPLE_QUARTZ__
+
// build the mask bitmap used by Fl_Pixmap:
if (fl_mask_bitmap && transparent_index >= 0) {
int W = (d.w+7)/8;
@@ -255,10 +271,46 @@ int fl_draw_pixmap(const char*const* di, int x, int y, Fl_Color bg) {
}
fl_draw_image(chars_per_pixel==1 ? cb1 : cb2, &d, x, y, d.w, d.h, 4);
+
+#else // __APPLE_QUARTZ__
+
+ bool transparent = (transparent_index>=0);
+ transparent = true;
+ U32 *array = new U32[d.w * d.h], *q = array;
+ for (int Y = 0; Y < d.h; Y++) {
+ const uchar* p = data[Y];
+ if (chars_per_pixel <= 1) {
+ for (int X = 0; X < d.w; X++) {
+ *q++ = d.colors[*p++];
+ }
+ } else {
+ for (int X = 0; X < d.w; X++) {
+ U32* colors = d.byte1[*p++];
+ *q++ = colors[*p++];
+ }
+ }
+ }
+ CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
+ CGDataProviderRef src = CGDataProviderCreateWithData( 0L, array, d.w * d.h * 4, 0L);
+ CGImageRef img = CGImageCreate(d.w, d.h, 8, 4*8, 4*d.w,
+ lut, transparent?kCGImageAlphaLast:kCGImageAlphaNoneSkipLast,
+ src, 0L, false, kCGRenderingIntentDefault);
+ CGColorSpaceRelease(lut);
+ CGDataProviderRelease(src);
+ CGRect rect = { x, y, d.w, d.h };
+ Fl_X::q_begin_image(rect, x, y, d.w, d.h);
+ CGContextDrawImage(fl_gc, rect, img);
+ Fl_X::q_end_image();
+ CGContextFlush(fl_gc);
+ CGImageRelease(img);
+ delete array;
+
+#endif // __APPLE_QUARTZ__
+
if (chars_per_pixel > 1) for (int i = 0; i < 256; i++) delete[] d.byte1[i];
return 1;
}
//
-// End of "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.14 2004/08/31 01:29:55 easysw Exp $".
+// End of "$Id: fl_draw_pixmap.cxx,v 1.4.2.8.2.15 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/fl_line_style.cxx b/src/fl_line_style.cxx
index 8242c262a..4d2288909 100644
--- a/src/fl_line_style.cxx
+++ b/src/fl_line_style.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_line_style.cxx,v 1.3.2.3.2.16 2004/08/31 00:27:40 matthiaswm Exp $"
+// "$Id: fl_line_style.cxx,v 1.3.2.3.2.17 2004/08/31 22:00:48 matthiaswm Exp $"
//
// Line style code for the Fast Light Tool Kit (FLTK).
//
@@ -30,7 +30,7 @@
#include <stdio.h>
#ifdef __APPLE_QUARTZ__
-static float fl_quartz_line_width_ = 1.0f;
+float fl_quartz_line_width_ = 1.0f;
static enum CGLineCap fl_quartz_line_cap_ = kCGLineCapButt;
static enum CGLineJoin fl_quartz_line_join_ = kCGLineJoinMiter;
static float *fl_quartz_line_pattern = 0;
@@ -158,5 +158,5 @@ void fl_line_style(int style, int width, char* dashes) {
//
-// End of "$Id: fl_line_style.cxx,v 1.3.2.3.2.16 2004/08/31 00:27:40 matthiaswm Exp $".
+// End of "$Id: fl_line_style.cxx,v 1.3.2.3.2.17 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/fl_overlay.cxx b/src/fl_overlay.cxx
index 14ab40961..0baf8b69f 100644
--- a/src/fl_overlay.cxx
+++ b/src/fl_overlay.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_overlay.cxx,v 1.4.2.3.2.5 2004/08/25 00:20:27 matthiaswm Exp $"
+// "$Id: fl_overlay.cxx,v 1.4.2.3.2.6 2004/08/31 22:00:48 matthiaswm Exp $"
//
// Overlay support for the Fast Light Tool Kit (FLTK).
//
@@ -46,10 +46,9 @@ static void draw_current_rect() {
fl_rect(px, py, pw, ph);
PenMode( patCopy );
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
- PenMode( patXor );
+ // warning: Quartz does not support xor drawing
+ // Use the Fl_Overlay_Window instead.
fl_rect(px, py, pw, ph);
- PenMode( patCopy );
#else
XSetFunction(fl_display, fl_gc, GXxor);
XSetForeground(fl_display, fl_gc, 0xffffffff);
@@ -74,5 +73,5 @@ void fl_overlay_rect(int x, int y, int w, int h) {
}
//
-// End of "$Id: fl_overlay.cxx,v 1.4.2.3.2.5 2004/08/25 00:20:27 matthiaswm Exp $".
+// End of "$Id: fl_overlay.cxx,v 1.4.2.3.2.6 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index e252f8abc..2a19f8fa0 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_rect.cxx,v 1.10.2.4.2.16 2004/08/27 20:02:45 matthiaswm Exp $"
+// "$Id: fl_rect.cxx,v 1.10.2.4.2.17 2004/08/31 22:00:48 matthiaswm Exp $"
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -33,6 +33,10 @@
#include <FL/fl_draw.H>
#include <FL/x.H>
+#ifdef __APPLE_QUARTZ__
+extern float fl_quartz_line_width_;
+#endif
+
void fl_rect(int x, int y, int w, int h) {
if (w<=0 || h<=0) return;
#ifdef WIN32
@@ -46,10 +50,10 @@ void fl_rect(int x, int y, int w, int h) {
SetRect(&rect, x, y, x+w, y+h);
FrameRect(&rect);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextStrokeRect(fl_gc, rect);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1);
#endif
@@ -67,10 +71,10 @@ void fl_rectf(int x, int y, int w, int h) {
SetRect(&rect, x, y, x+w, y+h);
PaintRect(&rect);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGRect rect = CGRectMake(x, y, w-1, h-1);
CGContextFillRect(fl_gc, rect);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h);
#endif
@@ -82,11 +86,11 @@ void fl_xyline(int x, int y, int x1) {
#elif defined(__APPLE_QD__)
MoveTo(x, y); LineTo(x1, y);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y);
#endif
@@ -104,12 +108,12 @@ void fl_xyline(int x, int y, int x1, int y2) {
LineTo(x1, y);
LineTo(x1, y2);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[3];
p[0].x = x; p[0].y = p[1].y = y;
@@ -132,13 +136,13 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
LineTo(x1, y2);
LineTo(x3, y2);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y);
CGContextAddLineToPoint(fl_gc, x1, y2);
CGContextAddLineToPoint(fl_gc, x3, y2);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[4];
p[0].x = x; p[0].y = p[1].y = y;
@@ -156,11 +160,11 @@ void fl_yxline(int x, int y, int y1) {
#elif defined(__APPLE_QD__)
MoveTo(x, y); LineTo(x, y1);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1);
#endif
@@ -178,12 +182,12 @@ void fl_yxline(int x, int y, int y1, int x2) {
LineTo(x, y1);
LineTo(x2, y1);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[3];
p[0].x = p[1].x = x; p[0].y = y;
@@ -206,13 +210,13 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
LineTo(x2, y1);
LineTo(x2, y3);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y1);
CGContextAddLineToPoint(fl_gc, x2, y1);
CGContextAddLineToPoint(fl_gc, x2, y3);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XPoint p[4];
p[0].x = p[1].x = x; p[0].y = y;
@@ -233,11 +237,12 @@ void fl_line(int x, int y, int x1, int y1) {
MoveTo(x, y);
LineTo(x1, y1);
#elif defined(__APPLE_QUARTZ__)
- if ( x==x1 || y==y1 ) CGContextSetShouldAntialias(fl_gc, false);
+ if (( x==x1 || y==y1 ) && fl_quartz_line_width_!=1.0f )
+ CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x1, y1);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1);
#endif
@@ -394,11 +399,11 @@ void fl_point(int x, int y) {
#elif defined(__APPLE_QD__)
MoveTo(x, y); Line(0, 0);
#elif defined(__APPLE_QUARTZ__)
- CGContextSetShouldAntialias(fl_gc, false);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
CGContextMoveToPoint(fl_gc, x, y);
CGContextAddLineToPoint(fl_gc, x, y);
CGContextStrokePath(fl_gc);
- CGContextSetShouldAntialias(fl_gc, true);
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, true);
#else
XDrawPoint(fl_display, fl_window, fl_gc, x, y);
#endif
@@ -651,5 +656,5 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
}
//
-// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.16 2004/08/27 20:02:45 matthiaswm Exp $".
+// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.17 2004/08/31 22:00:48 matthiaswm Exp $".
//
diff --git a/src/fl_vertex.cxx b/src/fl_vertex.cxx
index 4cac4a089..ad73f5395 100644
--- a/src/fl_vertex.cxx
+++ b/src/fl_vertex.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_vertex.cxx,v 1.5.2.3.2.11 2004/08/26 18:24:11 easysw Exp $"
+// "$Id: fl_vertex.cxx,v 1.5.2.3.2.12 2004/08/31 22:00:49 matthiaswm Exp $"
//
// Portable drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -83,6 +83,7 @@ typedef int COORD_T;
typedef float COORD_T;
typedef struct { float x; float y; } QPoint;
# define XPOINT QPoint
+extern float fl_quartz_line_width_;
#else
typedef short COORD_T;
# define XPOINT XPoint
@@ -141,11 +142,13 @@ void fl_end_points() {
#elif defined(__APPLE_QD__)
for (int i=0; i<n; i++) { MoveTo(p[i].x, p[i].y); Line(0, 0); }
#elif defined(__APPLE_QUARTZ__)
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
for (int i=0; i<n; i++) {
CGContextMoveToPoint(fl_gc, p[i].x, p[i].y);
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
CGContextStrokePath(fl_gc);
}
+ if (fl_quartz_line_width_==1.0f) CGContextSetShouldAntialias(fl_gc, false);
#else
if (n>1) XDrawPoints(fl_display, fl_window, fl_gc, p, n, 0);
#endif
@@ -295,7 +298,7 @@ void fl_circle(double x, double y,double r) {
Rect rt; rt.left=llx; rt.right=llx+w; rt.top=lly; rt.bottom=lly+h;
(what == POLYGON ? PaintOval : FrameOval)(&rt);
#elif defined(__APPLE_QUARTZ__)
-# warning quartz : cicle won_t scale to current matrix!
+ // Quartz warning : circle won't scale to current matrix!
CGContextAddArc(fl_gc, xt, yt, (w+h)*0.25f, 0, 2.0f*M_PI, 1);
(what == POLYGON ? CGContextFillPath : CGContextStrokePath)(fl_gc);
#else
@@ -305,5 +308,5 @@ void fl_circle(double x, double y,double r) {
}
//
-// End of "$Id: fl_vertex.cxx,v 1.5.2.3.2.11 2004/08/26 18:24:11 easysw Exp $".
+// End of "$Id: fl_vertex.cxx,v 1.5.2.3.2.12 2004/08/31 22:00:49 matthiaswm Exp $".
//
diff --git a/src/gl_draw.cxx b/src/gl_draw.cxx
index 79a9e5968..cf8a870c9 100644
--- a/src/gl_draw.cxx
+++ b/src/gl_draw.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: gl_draw.cxx,v 1.7.2.5.2.15 2004/08/26 00:18:43 matthiaswm Exp $"
+// "$Id: gl_draw.cxx,v 1.7.2.5.2.16 2004/08/31 22:00:49 matthiaswm Exp $"
//
// OpenGL drawing support routines for the Fast Light Tool Kit (FLTK).
//
@@ -62,7 +62,7 @@ void gl_font(int fontid, int size) {
aglUseFont(aglGetCurrentContext(), fl_fontsize->font, fl_fontsize->face,
fl_fontsize->size, 0, 256, fl_fontsize->listbase);
#elif defined(__APPLE_QUARTZ__)
-#warning quartz
+#warning quartz : add ATS font calls!
#else
# if USE_XFT
fl_xfont = fl_xxfont();
@@ -209,5 +209,5 @@ void gl_draw_image(const uchar* b, int x, int y, int w, int h, int d, int ld) {
#endif
//
-// End of "$Id: gl_draw.cxx,v 1.7.2.5.2.15 2004/08/26 00:18:43 matthiaswm Exp $".
+// End of "$Id: gl_draw.cxx,v 1.7.2.5.2.16 2004/08/31 22:00:49 matthiaswm Exp $".
//