Skip to content

Commit

Permalink
Updated config stuff to allow for --enable-quartz ofr Mac OS X which in
Browse files Browse the repository at this point in the history
turn defined USE_QUARTZ to 1 and defines __APPLE_QUARTZ__. If Quartz
is not disabled, it will define __APPLE_QD__ for Quickdraw.

I also replaced all relevand #ifdef __APPLE__ with #ifdef __APPLE_QD__
#elif defined(__APPLE_QUARTZ__). This does not affect the compile at
this time and both version will generate the same Quickdraw code.

I will start to replace all QD calls with Quartz calls for the
remainder of the week until I can completely remove all QD calls from
the Quartz branch.

Thanks to Robert Smith for a great initial Quartz implementation.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3782 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Aug 25, 2004
1 parent 522f98d commit 8327822
Show file tree
Hide file tree
Showing 30 changed files with 813 additions and 143 deletions.
18 changes: 16 additions & 2 deletions configh.in
@@ -1,5 +1,5 @@
/*
* "$Id: configh.in,v 1.11.2.11.2.17 2004/04/11 04:38:53 easysw Exp $"
* "$Id: configh.in,v 1.11.2.11.2.18 2004/08/25 00:20:24 matthiaswm Exp $"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
* @configure_input@
Expand Down Expand Up @@ -98,6 +98,20 @@

#define USE_XDBE HAVE_XDBE

/*
* USE_QUARTZ:
*
* Use Quartz instead of Quickdraw on Apple Mac OS X machines.
* FLTK was originally ported to Quickdraw which is no longer
* supported by Apple. If USE_QUARTZ is defined, FLTK will be
* compiled using Quartz instead. This flag has no meaning on
* other operating systems.
*/

#define USE_QUARTZ 0
#undef __APPLE_QUARTZ__
#undef __APPLE_QD__

/*
* HAVE_OVERLAY:
*
Expand Down Expand Up @@ -220,5 +234,5 @@


/*
* End of "$Id: configh.in,v 1.11.2.11.2.17 2004/04/11 04:38:53 easysw Exp $".
* End of "$Id: configh.in,v 1.11.2.11.2.18 2004/08/25 00:20:24 matthiaswm Exp $".
*/
16 changes: 14 additions & 2 deletions configure.in
@@ -1,7 +1,7 @@
dnl -*- sh -*-
dnl the "configure" script is made from this by running GNU "autoconf"
dnl
dnl "$Id: configure.in,v 1.33.2.31.2.116 2004/07/29 18:13:10 easysw Exp $"
dnl "$Id: configure.in,v 1.33.2.31.2.117 2004/08/25 00:20:25 matthiaswm Exp $"
dnl
dnl Configuration script for the Fast Light Tool Kit (FLTK).
dnl
Expand Down Expand Up @@ -223,6 +223,18 @@ AC_ARG_ENABLE(threads, [ --enable-threads enable multi-threading support

AC_ARG_WITH(optim, [ --with-optim="flags" use custom optimization flags])

case $uname in
Darwin*)
AC_ARG_ENABLE(quartz, [ --enable-quartz use Quartz instead of Quickdraw (default=no)])
if test "x$enable_quartz" = "xyes"; then
AC_DEFINE(USE_QUARTZ, 1)
AC_DEFINE(__APPLE_QUARTZ__)
else
AC_DEFINE(__APPLE_QD__)
fi
;;
esac

dnl Find commands...
AC_PROG_CC
AC_PROG_CXX
Expand Down Expand Up @@ -899,5 +911,5 @@ dnl Make sure the fltk-config script is executable...
chmod +x fltk-config

dnl
dnl End of "$Id: configure.in,v 1.33.2.31.2.116 2004/07/29 18:13:10 easysw Exp $".
dnl End of "$Id: configure.in,v 1.33.2.31.2.117 2004/08/25 00:20:25 matthiaswm Exp $".
dnl
58 changes: 49 additions & 9 deletions src/Fl.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl.cxx,v 1.24.2.41.2.62 2004/04/11 04:38:56 easysw Exp $"
// "$Id: Fl.cxx,v 1.24.2.41.2.63 2004/08/25 00:20:25 matthiaswm Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -317,7 +317,10 @@ Fl_X* Fl_X::first;
Fl_Window* fl_find(Window xid) {
Fl_X *window;
for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next)
#ifdef __APPLE__
#ifdef __APPLE_QD__
if (window->xid == xid && !window->w->window()) {
#elif defined(__APPLE_QUARTZ__)
# warning QUARTZ
if (window->xid == xid && !window->w->window()) {
#else
if (window->xid == xid) {
Expand Down Expand Up @@ -368,12 +371,19 @@ void Fl::flush() {

#ifdef WIN32
GdiFlush();
#elif defined (__APPLE__)
#elif defined (__APPLE_QD__)
GrafPtr port; GetPort( &port );
if ( port )
{
QDFlushPortBuffer( port, 0 );
}
#elif defined (__APPLE_QUARTZ__)
#warning quartz
GrafPtr port; GetPort( &port );
if ( port )
{
QDFlushPortBuffer( port, 0 );
}
#else
if (fl_display) XFlush(fl_display);
#endif
Expand Down Expand Up @@ -734,13 +744,21 @@ void Fl_Window::hide() {
for (; *pp != ip; pp = &(*pp)->next) if (!*pp) return;
*pp = ip->next;

#ifdef __APPLE__
#ifdef __APPLE_QD__
// remove all childwindow links
for ( Fl_X *pc = Fl_X::first; pc; pc = pc->next )
{
if ( pc->xidNext == ip ) pc->xidNext = ip->xidNext;
if ( pc->xidChildren == ip ) pc->xidChildren = ip->xidNext;
}
#elif defined(__APPLE_QUARTZ__)
# warning quartz
// remove all childwindow links
for ( Fl_X *pc = Fl_X::first; pc; pc = pc->next )
{
if ( pc->xidNext == ip ) pc->xidNext = ip->xidNext;
if ( pc->xidChildren == ip ) pc->xidChildren = ip->xidNext;
}
#endif // __APPLE__

i = 0;
Expand Down Expand Up @@ -773,14 +791,26 @@ void Fl_Window::hide() {
fl_window = (HWND)-1;
fl_gc = 0;
}
#elif defined(__APPLE__)
#elif defined(__APPLE_QD__)
if ( ip->xid == fl_window )
fl_window = 0;
#elif defined(__APPLE_QUARTZ__)
# warning quartz
if ( ip->xid == fl_window )
fl_window = 0;
#else
if (ip->region) XDestroyRegion(ip->region);
#endif

#ifdef __APPLE__
#ifdef __APPLE_QD__
if ( !parent() ) // don't destroy shared windows!
{
//+ RemoveTrackingHandler( dndTrackingHandler, ip->xid );
//+ RemoveReceiveHandler( dndReceiveHandler, ip->xid );
XDestroyWindow(fl_display, ip->xid);
}
#elif defined(__APPLE_QUARTZ__)
# warning quartz
if ( !parent() ) // don't destroy shared windows!
{
//+ RemoveTrackingHandler( dndTrackingHandler, ip->xid );
Expand Down Expand Up @@ -835,9 +865,13 @@ int Fl_Window::handle(int ev)
Fl_Widget* p = parent(); for (;p->visible();p = p->parent()) {}
if (p->type() >= FL_WINDOW) break; // don't do the unmap
}
#ifdef __APPLE__
#ifdef __APPLE_QD__
hide();
set_visible();
#elif defined(__APPLE_QUARTZ__)
# warning quartz
hide();
set_visible();
#else
XUnmapWindow(fl_display, fl_xid(this));
#endif // __APPLE__
Expand Down Expand Up @@ -956,11 +990,17 @@ void Fl_Widget::damage(uchar fl, int X, int Y, int W, int H) {
Fl_Region R = XRectangleRegion(X, Y, W, H);
CombineRgn(i->region, i->region, R, RGN_OR);
XDestroyRegion(R);
#elif defined(__APPLE__)
#elif defined(__APPLE_QD__)
Fl_Region R = NewRgn();
SetRectRgn(R, X, Y, X+W, Y+H);
UnionRgn(R, i->region, i->region);
DisposeRgn(R);
#elif defined(__APPLE_QUARTZ__)
# warning quartz
Fl_Region R = NewRgn();
SetRectRgn(R, X, Y, X+W, Y+H);
UnionRgn(R, i->region, i->region);
DisposeRgn(R);
#else
XRectangle R;
R.x = X; R.y = Y; R.width = W; R.height = H;
Expand All @@ -985,5 +1025,5 @@ void Fl_Window::flush() {
}

//
// End of "$Id: Fl.cxx,v 1.24.2.41.2.62 2004/04/11 04:38:56 easysw Exp $".
// End of "$Id: Fl.cxx,v 1.24.2.41.2.63 2004/08/25 00:20:25 matthiaswm Exp $".
//
70 changes: 65 additions & 5 deletions src/Fl_Bitmap.cxx
@@ -1,5 +1,5 @@
//
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.23 2004/04/11 04:38:57 easysw Exp $"
// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.24 2004/08/25 00:20:25 matthiaswm Exp $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
Expand Down Expand Up @@ -31,7 +31,7 @@
#include <FL/Fl_Bitmap.H>
#include "flstring.h"

#ifdef __APPLE__ // MacOS bitmask functions
#ifdef __APPLE_QD__ // MacOS bitmask functions
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
Rect srcRect;
srcRect.left = 0; srcRect.right = w;
Expand Down Expand Up @@ -74,6 +74,51 @@ Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
return gw; /* tell caller we succeeded! */
}

void fl_delete_bitmask(Fl_Bitmask id) {
if (id) DisposeGWorld(id);
}
#elif defined(__APPLE_QUARTZ__)
# warning quartz
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
Rect srcRect;
srcRect.left = 0; srcRect.right = w;
srcRect.top = 0; srcRect.bottom = h;
GrafPtr savePort;

GetPort(&savePort); // remember the current port

Fl_Bitmask gw;
NewGWorld( &gw, 1, &srcRect, 0L, 0L, 0 );
PixMapHandle pm = GetGWorldPixMap( gw );
if ( pm )
{
LockPixels( pm );
if ( *pm )
{
uchar *base = (uchar*)GetPixBaseAddr( pm );
if ( base )
{
PixMapPtr pmp = *pm;
// verify the parameters for direct memory write
if ( pmp->pixelType == 0 || pmp->pixelSize == 1 || pmp->cmpCount == 1 || pmp->cmpSize == 1 )
{
static uchar reverse[16] = /* Bit reversal lookup table */
{ 0x00, 0x88, 0x44, 0xcc, 0x22, 0xaa, 0x66, 0xee, 0x11, 0x99, 0x55, 0xdd, 0x33, 0xbb, 0x77, 0xff };
uchar *dst = base;
const uchar *src = array;
int rowBytesSrc = (w+7)>>3 ;
int rowPatch = (pmp->rowBytes&0x3fff) - rowBytesSrc;
for ( int j=0; j<h; j++,dst+=rowPatch )
for ( int i=0; i<rowBytesSrc; i++,src++ )
*dst++ = (reverse[*src & 0x0f] & 0xf0) | (reverse[(*src >> 4) & 0x0f] & 0x0f);
}
}
UnlockPixels( pm );
}
}
SetPort(savePort);
return gw; /* tell caller we succeeded! */
}
void fl_delete_bitmask(Fl_Bitmask id) {
if (id) DisposeGWorld(id);
}
Expand Down Expand Up @@ -213,7 +258,7 @@ void fl_delete_bitmask(Fl_Bitmask bm) {
// If you want to test/fix this, uncomment the "#ifdef __APPLE__" and comment out
// the "#if 0" here. Also see Fl_Image.cxx for a similar check...

//#ifdef __APPLE__
//#ifdef __APPLE_QD__
#if 0
// Create an 8-bit mask used for alpha blending
Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *array) {
Expand Down Expand Up @@ -356,7 +401,7 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
// secret bitblt code found in old MSWindows reference manual:
BitBlt(fl_gc, X, Y, W, H, tempdc, cx, cy, 0xE20746L);
DeleteDC(tempdc);
#elif defined(__APPLE__)
#elif defined(__APPLE_QD__)
if (!id) id = fl_create_bitmask(w(), h(), array);
GrafPtr dstPort;
GetPort( &dstPort );
Expand All @@ -370,6 +415,21 @@ void Fl_Bitmap::draw(int XP, int YP, int WP, int HP, int cx, int cy) {
&dst, // dst bounds
srcOr, // mode
0L); // mask region
#elif defined(__APPLE_QUARTZ__)
# warning quartz
if (!id) id = fl_create_bitmask(w(), h(), array);
GrafPtr dstPort;
GetPort( &dstPort );
Rect src, dst;
GetPortBounds( (Fl_Offscreen)id, &src );
SetRect( &src, cx, cy, cx+W, cy+H );
SetRect( &dst, X, Y, X+W, Y+H );
CopyBits(GetPortBitMapForCopyBits((Fl_Offscreen)id), // srcBits
GetPortBitMapForCopyBits(dstPort), // dstBits
&src, // src bounds
&dst, // dst bounds
srcOr, // mode
0L); // mask region
#else
if (!id) id = fl_create_bitmask(w(), h(), array);

Expand Down Expand Up @@ -474,5 +534,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {


//
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.23 2004/04/11 04:38:57 easysw Exp $".
// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.24 2004/08/25 00:20:25 matthiaswm Exp $".
//

0 comments on commit 8327822

Please sign in to comment.