summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2001-12-06 00:17:47 +0000
committerMatthias Melcher <fltk@matthiasm.com>2001-12-06 00:17:47 +0000
commite07200c4e847ddff8a46ea9fdc23e17437d74c15 (patch)
treed894e182e410b76b62fdeefbb4122ab4ac8665b6 /src
parent39109694e1873fce011df470f2edd57a0028e0a3 (diff)
Implemeted 95% of all Mac OS X support. Makefiles still need modifications.
Almost all test applications run out of the box (->Makefile). See more information in README.mac . Changes: - message handling - access to opaque port structures - image, bitmap, pixmap support - most OpenGL stuff - window styles git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1812 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx13
-rw-r--r--src/Fl_Bitmap.cxx86
-rw-r--r--src/Fl_Double_Window.cxx25
-rw-r--r--src/Fl_Gl_Choice.H11
-rw-r--r--src/Fl_Gl_Choice.cxx44
-rw-r--r--src/Fl_Gl_Window.cxx20
-rw-r--r--src/Fl_Sys_Menu_Bar.cxx8
-rw-r--r--src/Fl_mac.cxx83
-rw-r--r--src/fl_rect.cxx22
9 files changed, 194 insertions, 118 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 51bf7d61c..d803583ce 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.cxx,v 1.24.2.41.2.10 2001/11/28 20:43:44 easysw Exp $"
+// "$Id: Fl.cxx,v 1.24.2.41.2.11 2001/12/06 00:17:47 matthiaswm Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -361,7 +361,14 @@ void Fl::flush() {
#ifdef WIN32
GdiFlush();
-#elif !defined(__APPLE__)
+#elif defined (__APPLE__)
+ GrafPtr port; GetPort( &port );
+ if ( port )
+ {
+ QDFlushPortBuffer( port, 0 );
+ //printf("DBG: Fl::flush\n");
+ }
+#else
if (fl_display) XFlush(fl_display);
#endif
}
@@ -834,5 +841,5 @@ void Fl_Window::flush() {
}
//
-// End of "$Id: Fl.cxx,v 1.24.2.41.2.10 2001/11/28 20:43:44 easysw Exp $".
+// End of "$Id: Fl.cxx,v 1.24.2.41.2.11 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Bitmap.cxx b/src/Fl_Bitmap.cxx
index 272067ddf..4d03d5ae8 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.7 2001/11/27 17:44:06 easysw Exp $"
+// "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.8 2001/12/06 00:17:47 matthiaswm Exp $"
//
// Bitmap drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -34,49 +34,48 @@
#ifdef __APPLE__ // MacOS bitmask functions
Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *array) {
Rect srcRect;
- RgnHandle r = NewRgn();
srcRect.left = 0; srcRect.right = w;
srcRect.top = 0; srcRect.bottom = h;
GrafPtr savePort;
- GrafPtr newPort;
GetPort(&savePort); // remember the current port
- newPort = CreateNewPort();
-
- SetPortBounds(newPort, &srcRect); // make bitmap the size of the bounds that caller supplied
- RectRgn( GetPortClipRegion(newPort, r), &srcRect );
- RectRgn( GetPortVisibleRegion(newPort, r), &srcRect );
- DisposeRgn(r);
-
- //++ rowBytes is size of row, it must be rounded up to an even number of bytes
-// int rowBytes = newPort->portBits.rowBytes = (( w + 15 ) >> 4 ) << 1;
-// int rowBytesSrc = (( w + 7 ) >> 3 );
-// newPort->portBits.baseAddr = NewPtr( rowBytes * h );
-// if ( !newPort->portBits.baseAddr )
-// {
-// SetPort(savePort);
-// ClosePort(newPort);
-// DisposePtr((Ptr)newPort);
-// return 0L;
-// }
-//
-// 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 = (uchar*)newPort->portBits.baseAddr;
-// const uchar *src = array;
-// int rowPatch = ( rowBytes!=rowBytesSrc ) ? 1 : 0 ;
-// 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);
+ 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 newPort; /* tell caller we succeeded! */
+ return gw; /* tell caller we succeeded! */
}
void fl_delete_bitmask(Fl_Bitmask id) {
- if (id) DisposePort(id);
+ if (id) DisposeGWorld(id);
}
#elif defined(WIN32) // Windows bitmask functions...
// 'fl_create_bitmap()' - Create a 1-bit bitmap for drawing...
@@ -236,16 +235,17 @@ 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);
GrafPtr dstPort;
GetPort( &dstPort );
- Rect dst;
- dst.left = X; dst.right = X+W;
- dst.top = Y; dst.bottom = Y+H;
+ Rect src, dst;
+ GetPortBounds( id, &src );
+ SetRect( &src, cx, cy, cx+W, cy+H );
+ SetRect( &dst, X, Y, X+W, Y+H );
CopyBits(
- GetPortBitMapForCopyBits((GrafPtr)id),
- GetPortBitMapForCopyBits(dstPort),
- GetPortBounds((GrafPtr)id, 0),
- &dst,
- srcOr,
- 0L);
+ GetPortBitMapForCopyBits(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);
@@ -340,5 +340,5 @@ Fl_Image *Fl_Bitmap::copy(int W, int H) {
//
-// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.7 2001/11/27 17:44:06 easysw Exp $".
+// End of "$Id: Fl_Bitmap.cxx,v 1.5.2.4.2.8 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx
index 8145dfdf1..9bf615e2d 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.2 2001/12/04 03:03:17 matthiaswm Exp $"
+// "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.3 2001/12/06 00:17:47 matthiaswm Exp $"
//
// Double-buffered window code for the Fast Light Tool Kit (FLTK).
//
@@ -103,7 +103,7 @@ GWorldPtr fl_create_offscreen(int w, int h) {
GWorldPtr gw;
Rect bounds;
bounds.left=0; bounds.right=w; bounds.top=0; bounds.bottom=h;
- QDErr err = NewGWorld(&gw, 0, &bounds, 0L, 0L, useTempMem);
+ QDErr err = NewGWorld(&gw, 0, &bounds, 0L, 0L, 0); // 'useTempMem' should not be used (says the Carbon port manual)
if ( err == -108 )
{ }
// fl_message( "The application memory is low. Please increase the initial memory assignment.\n" );
@@ -116,6 +116,7 @@ GWorldPtr fl_create_offscreen(int w, int h) {
*/
void fl_copy_offscreen(int x,int y,int w,int h,GWorldPtr gWorld,int srcx,int srcy) {
Rect src;
+ if ( !gWorld ) return;
src.top = srcy; src.left = srcx; src.bottom = srcy+h; src.right = srcx+w;
Rect dst;
GrafPtr dstPort; GetPort(&dstPort);
@@ -145,11 +146,10 @@ void fl_begin_offscreen(GWorldPtr gWorld) {
GetGWorld( &prevPort, &prevGD );
if ( gWorld )
{
- SetGWorld( gWorld, 0L );
+ SetGWorld( gWorld, 0L ); // sets the correct port
PixMapHandle pm = GetGWorldPixMap(gWorld);
LockPixels(pm);
- fl_window = (Window)prevPort;
- SetPort( GetWindowPort(fl_window) );
+ fl_window = GetWindowFromPort( gWorld );
}
fl_push_no_clip();
}
@@ -164,8 +164,8 @@ void fl_end_offscreen() {
fl_pop_clip();
PixMapHandle pm = GetGWorldPixMap(currPort);
UnlockPixels(pm);
- fl_window = (Window)prevPort;
SetGWorld( prevPort, prevGD );
+ fl_window = GetWindowFromPort( prevPort );
}
extern void fl_restore_clip();
@@ -187,7 +187,14 @@ void Fl_Double_Window::flush(int eraseoverlay) {
XdbeAllocateBackBufferName(fl_display, fl_xid(this), XdbeUndefined);
else
#endif
+#ifdef __APPLE__
+ // 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) ) )
myi->other_xid = fl_create_offscreen(w(), h());
+#else
+ myi->other_xid = fl_create_offscreen(w(), h());
+#endif
clear_damage(FL_DAMAGE_ALL);
}
#if USE_XDBE
@@ -242,7 +249,11 @@ 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__
+ 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);
+#endif
}
void Fl_Double_Window::resize(int X,int Y,int W,int H) {
@@ -275,5 +286,5 @@ Fl_Double_Window::~Fl_Double_Window() {
}
//
-// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.2 2001/12/04 03:03:17 matthiaswm Exp $".
+// End of "$Id: Fl_Double_Window.cxx,v 1.12.2.4.2.3 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Gl_Choice.H b/src/Fl_Gl_Choice.H
index 82dad8f20..4f3057871 100644
--- a/src/Fl_Gl_Choice.H
+++ b/src/Fl_Gl_Choice.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.1 2001/11/27 17:44:06 easysw Exp $"
+// "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $"
//
// OpenGL definitions for the Fast Light Tool Kit (FLTK).
//
@@ -58,8 +58,9 @@
# include <FL/gl.h>
# define GLContext HGLRC
#elif defined(__APPLE__)
-# include <OpenGL.h>
-# define GLContext CGLContextObj
+# include <OpenGL/gl.h>
+# include <AGL/agl.h>
+# define GLContext AGLContext
#else
# include <GL/glx.h>
# define GLContext GLXContext
@@ -94,7 +95,7 @@ GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
#elif defined(__APPLE__)
-//++
+GLContext fl_create_gl_context(Fl_Window*, const Fl_Gl_Choice*, int layer=0);
#else
@@ -114,5 +115,5 @@ void fl_delete_gl_context(GLContext);
#endif
//
-// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.1 2001/11/27 17:44:06 easysw Exp $".
+// End of "$Id: Fl_Gl_Choice.H,v 1.4.2.6.2.2 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx
index fe5d702b0..a94c239b7 100644
--- a/src/Fl_Gl_Choice.cxx
+++ b/src/Fl_Gl_Choice.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.2 2001/11/27 17:44:06 easysw Exp $"
+// "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.3 2001/12/06 00:17:47 matthiaswm Exp $"
//
// OpenGL visual selection code for the Fast Light Tool Kit (FLTK).
//
@@ -31,6 +31,10 @@
#include <stdlib.h>
#include "Fl_Gl_Choice.H"
+#ifdef __APPLE__
+# include <Fl/Fl_Window.H>
+#endif
+
static Fl_Gl_Choice *first;
// this assummes one of the two arguments is zero:
@@ -195,16 +199,16 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay
AGL_NONE };
AGLPixelFormat fmt;
fmt = aglChoosePixelFormat(NULL, 0, attrib);
- context = aglCreateContext(fmt, fl_first_context);
- if ( !fl_first_context ) fl_first_context = (GLXContext)context;
+ context = aglCreateContext(fmt, first_context);
+ if ( !first_context ) first_context = (GLContext)context;
aglDestroyPixelFormat( fmt );
- if ( parent() ) {
- CGrafPort *port = (CGrafPort*)fl_xid(this);
- GLint rect[] = { x(), port->portRect.bottom-h()-y(), w(), h() };
- aglSetInteger( (GLXContext)context, AGL_BUFFER_RECT, rect );
- aglEnable( (GLXContext)context, AGL_BUFFER_RECT );
+ if ( window->parent() ) {
+ Rect wrect; GetWindowPortBounds( fl_xid(window), &wrect );
+ GLint rect[] = { window->x(), wrect.bottom-window->h()-window->y(), window->w(), window->h() };
+ aglSetInteger( (GLContext)context, AGL_BUFFER_RECT, rect );
+ aglEnable( (GLContext)context, AGL_BUFFER_RECT );
}
- aglSetDrawable((GLXContext)context, (CGrafPort*)fl_xid(window));
+ aglSetDrawable( context, GetWindowPort( fl_xid(window) ) );
return (context);
}
#else
@@ -228,13 +232,13 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) {
wglMakeCurrent(Fl_X::i(w)->private_dc, context);
#elif defined(__APPLE__)
if ( w->parent() ) { //: resize our GL buffer rectangle
- CGrafPort *port = (CGrafPort*)fl_xid(w);
- GLint rect[] = { w->x(), port->portRect.bottom-w->h()-w->y(), w->w(), w->h() };
- aglSetInteger( c, AGL_BUFFER_RECT, rect );
- aglEnable( c, AGL_BUFFER_RECT );
+ Rect wrect; GetWindowPortBounds( fl_xid(w), &wrect );
+ GLint rect[] = { w->x(), wrect.bottom-w->h()-w->y(), w->w(), w->h() };
+ aglSetInteger( context, AGL_BUFFER_RECT, rect );
+ aglEnable( context, AGL_BUFFER_RECT );
}
- aglSetDrawable(c, (CGrafPort*)fl_xid(w)); //++ here or in Fl_Gl_Window::make_current creation part?
- aglSetCurrentContext(c);
+ aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); //++ here or in Fl_Gl_Window::make_current creation part?
+ aglSetCurrentContext(context);
#else
glXMakeCurrent(fl_display, fl_xid(w), context);
#endif
@@ -258,10 +262,10 @@ void fl_delete_gl_context(GLContext context) {
if (context != first_context) {
#ifdef WIN32
wglDeleteContext(context);
-#elif defined(__APPLE)
- aglSetCurrentContext(NULL);
- aglSetDrawable((AGLContext)context, NULL);
- aglDestroyContext((AGLContext)context);
+#elif defined(__APPLE__)
+ aglSetCurrentContext( NULL );
+ aglSetDrawable( context, NULL );
+ aglDestroyContext( context );
#else
glXDestroyContext(fl_display, context);
#endif
@@ -271,5 +275,5 @@ void fl_delete_gl_context(GLContext context) {
#endif
//
-// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.2 2001/11/27 17:44:06 easysw Exp $".
+// End of "$Id: Fl_Gl_Choice.cxx,v 1.5.2.7.2.3 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx
index 31142185c..e4a16c81e 100644
--- a/src/Fl_Gl_Window.cxx
+++ b/src/Fl_Gl_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.2 2001/12/04 04:12:58 matthiaswm Exp $"
+// "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.3 2001/12/06 00:17:47 matthiaswm Exp $"
//
// OpenGL window code for the Fast Light Tool Kit (FLTK).
//
@@ -202,8 +202,12 @@ void Fl_Gl_Window::flush() {
#ifdef __APPLE__
//: clear previous clipping in this shared port
- CGrafPort *port = (CGrafPort*)fl_xid(this);
- SetRectRgn( port->clipRgn, 0, 0, 0x7fff, 0x7fff );
+ GrafPtr port = GetWindowPort( fl_xid(this) );
+ Rect rect; SetRect( &rect, 0, 0, 0x7fff, 0x7fff );
+ GrafPtr old; GetPort( &old );
+ SetPort( port );
+ ClipRect( &rect );
+ SetPort( old );
#endif
make_current();
@@ -296,10 +300,10 @@ void Fl_Gl_Window::resize(int X,int Y,int W,int H) {
valid(0);
#ifdef __APPLE__
if ( parent() ) { //: resize our GL buffer rectangle
- CGrafPort *port = (CGrafPort*)fl_xid(this);
- GLint rect[] = { X, port->portRect.bottom-h()-y(), W, H };
- aglSetInteger( (GLXContext)context_, AGL_BUFFER_RECT, rect );
- aglEnable( (GLXContext)context_, AGL_BUFFER_RECT );
+ Rect wrect; GetWindowPortBounds( fl_xid(this), &wrect );
+ GLint rect[] = { X, wrect.bottom-h()-y(), W, H };
+ aglSetInteger( context_, AGL_BUFFER_RECT, rect );
+ aglEnable( context_, AGL_BUFFER_RECT );
}
#elif !defined(WIN32)
if (!resizable() && overlay && overlay != this)
@@ -347,5 +351,5 @@ void Fl_Gl_Window::draw_overlay() {}
#endif
//
-// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.2 2001/12/04 04:12:58 matthiaswm Exp $".
+// End of "$Id: Fl_Gl_Window.cxx,v 1.12.2.22.2.3 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/Fl_Sys_Menu_Bar.cxx b/src/Fl_Sys_Menu_Bar.cxx
index 399b22c61..5ae4e3ddb 100644
--- a/src/Fl_Sys_Menu_Bar.cxx
+++ b/src/Fl_Sys_Menu_Bar.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $"
+// "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $"
//
// MacOS system menu bar widget for the Fast Light Tool Kit (FLTK).
//
@@ -24,7 +24,7 @@
//
/**
- * Tis code is a quick hack! It was written as a proove of concept.
+ * This code is a quick hack! It was written as a proof of concept.
* It has been tested on the "menubar" sample program and provides
* basic functionality.
*
@@ -252,7 +252,7 @@ void Fl_Sys_Menu_Bar::menu(const Fl_Menu_Item *m)
}
InsertMenu( mh, 0 );
- if ( mm->flags & FL_MENU_INACTIVE ) DisableItem( mh, 0 );
+ if ( mm->flags & FL_MENU_INACTIVE ) DisableMenuItem( mh, 0 );
mm++;
}
DrawMenuBar();
@@ -310,5 +310,5 @@ int Fl_Menu_Bar::handle(int event) {
*/
//
-// End of "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.1 2001/11/27 17:44:06 easysw Exp $".
+// End of "$Id: Fl_Sys_Menu_Bar.cxx,v 1.1.2.2 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx
index 9cab1e8e3..db33c1d7b 100644
--- a/src/Fl_mac.cxx
+++ b/src/Fl_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_mac.cxx,v 1.1.2.2 2001/12/04 03:03:17 matthiaswm Exp $"
+// "$Id: Fl_mac.cxx,v 1.1.2.3 2001/12/06 00:17:47 matthiaswm Exp $"
//
// MacOS specific code for the Fast Light Tool Kit (FLTK).
//
@@ -28,6 +28,8 @@
// still be useful.
#define CONSOLIDATE_MOTION 0
+// use TARGET_API_MAC_CARBON if needed
+
#include <config.h>
#include <FL/Fl.H>
#include <FL/x.H>
@@ -164,6 +166,13 @@ int fl_ready()
/**
+ */
+void printMacEvent( const EventRecord &ev )
+{
+printf("Event: w:0x%04x m:0x%08x mod:0x%04x flags:%08x x:%d, y:%d\n", ev.what, ev.message, ev.modifiers, 0, ev.where.h, ev.where.v );
+}
+
+/**
* This function iss the central event handler.
* It reads events from the event queue using the given maximum time
* Funny enough, it returns the same time that it got as the argument.
@@ -206,7 +215,7 @@ static double do_queued_events( double time = 0.0 )
#else
EventRecord ev;
unsigned long ticks = (int)(time*60.0);
- while ( WaitNextEvent(everyEvent, &ev, ticks, rgn) )
+ if ( WaitNextEvent(everyEvent, &ev, ticks, rgn) )
{
fl_handle(ev); //: handle the nullEvent to get mouse up events
SetRectRgn(rgn, ev.where.h, ev.where.v, ev.where.h+1, ev.where.v+1 );
@@ -448,7 +457,7 @@ static void set_shift_states(const EventRecord &macevent)
{
ulong state = Fl::e_state & 0xff000000;
if (macevent.modifiers&shiftKey) state |= FL_SHIFT;
- if ( (macevent.modifiers&controlKey) && (macevent.modifiers&btnState) ) state |= FL_META; // try to fetch the right mouse button
+ if ( (macevent.modifiers&controlKey) && (!Button()) ) state |= FL_META; // try to fetch the right mouse button
if (macevent.modifiers&optionKey) state |= FL_ALT;
if (macevent.modifiers&cmdKey) state |= FL_CTRL;
if (macevent.modifiers&alphaLock) state |= FL_CAPS_LOCK;
@@ -610,6 +619,8 @@ void Fl_X::flush()
{
w->flush();
SetOrigin( 0, 0 );
+ //QDFlushPortBuffer( GetWindowPort(xid), 0 ); // easy way out - remove!
+ //printf("DBG: Fl_X::flush\n");
}
@@ -639,8 +650,8 @@ void handleUpdateEvent( WindowPtr xid )
}
BeginUpdate( xid );
- DrawControls(xid); // do we need this?
- DrawGrowIcon(xid); // do we need this?
+ //DrawControls(xid); // do we need this?
+ //DrawGrowIcon(xid); // do we need this?
for ( Fl_X *cx = i->xidChildren; cx; cx = cx->xidNext )
{
cx->w->clear_damage(window->damage()|FL_DAMAGE_EXPOSE);
@@ -652,6 +663,8 @@ void handleUpdateEvent( WindowPtr xid )
window->clear_damage();
EndUpdate( xid );
+ //QDFlushPortBuffer( GetWindowPort(xid), 0 ); // should not be needed here!
+ //printf("DBG: handleUpdate::flush\n");
SetPort( oldPort );
}
@@ -685,12 +698,13 @@ int fl_handle(const EventRecord &macevent)
WindowPtr xid;
int event = 0;
Fl_Window *window = 0L;
+ //printMacEvent( macevent );
switch (macevent.what)
{
case mouseDown: {
// handle the differnt mouseDown events in various areas of the screen
int part = FindWindow(macevent.where, &xid);
- printf("mousedown in part %d\n", part );
+ //printf("mousedown in part %d\n", part );
prevMouseDownXid = xid;
switch (part) {
case inDesk: break;
@@ -701,9 +715,10 @@ int fl_handle(const EventRecord &macevent)
window = fl_find(xid);
if (!window) break;
SetPort( GetWindowPort(xid) ); SetOrigin(0, 0);
- Fl::e_keysym = FL_Button+((macevent.modifiers&controlKey)?3:1); //++ simulate three button using modifiers
+ //printMacEvent( macevent );
+ Fl::e_keysym = FL_Button+((macevent.modifiers&0x1000)?3:1); //++ simulate three button using modifiers
set_event_xy(macevent); checkdouble();
- Fl::e_state |= ((macevent.modifiers&controlKey)?FL_BUTTON3:FL_BUTTON1);
+ Fl::e_state |= ((macevent.modifiers&0x1000)?FL_BUTTON3:FL_BUTTON1);
return Fl::handle(FL_PUSH, window); }
case inDrag: Fl_X::MacDragWindow(xid, macevent); break;
case inGrow: Fl_X::MacGrowWindow(xid, macevent); break;
@@ -805,7 +820,7 @@ int fl_handle(const EventRecord &macevent)
send_motion = fl_xmousewin = window;
return 0;
#else
- return Fl::handle( (macevent.modifiers & btnState)?FL_MOVE:FL_DRAG, window);
+ return Fl::handle( Button()?FL_DRAG:FL_MOVE, window);
#endif
// if (!Fl::grab()) ReleaseCapture();
}
@@ -936,6 +951,7 @@ void Fl_X::make(Fl_Window* w)
int winclass = kDocumentWindowClass;
int winattr = kWindowCloseBoxAttribute
| kWindowCollapseBoxAttribute
+ //| kWindowLiveResizeAttribute // activate this as soon as we ported to Carbon Events!
//| kWindowStandardHandlerAttribute
;
// int winattr = kWindowStandardHandlerAttribute;
@@ -944,7 +960,9 @@ void Fl_X::make(Fl_Window* w)
int yp = w->y();
int wp = w->w();
int hp = w->h();
- if (!w->size_range_set) {
+ if (w->size_range_set) {
+ winattr |= kWindowFullZoomAttribute | kWindowResizableAttribute;
+ } else {
if (w->resizable()) {
Fl_Widget *o = w->resizable();
int minw = o->w(); if (minw > 100) minw = 100;
@@ -957,9 +975,28 @@ void Fl_X::make(Fl_Window* w)
}
}
int xwm = xp, ywm = yp, bt, bx, by;
- if (!fake_X_wm(w, xwm, ywm, bt, bx, by)) winclass = kFloatingWindowClass;
- else if (w->modal()) winclass = kModalWindowClass;
- else if (w->non_modal()) winclass = kToolbarWindowClass;
+ // classes:
+ // kAlertWindowClass: small up frame - nice
+ // kModalWindowClass: as above
+ // kFloatingWindowClass: does not deactivate app window, but has small title bar (medium decoration)
+ // kDocumentWindowClass: transparent huge upper title (large decoration) -- last standard definition
+ // kUtilityWindowClass: like 'floating (small decoration)
+ // kHelpWindowClass: perfect: no decoration, keeps master active, stays on top of ALL windows, not modal though
+ // kSheetWindowClass: no deco, deactivates parent
+ // kToolbarWindowClass: no deco, passive, under other menues
+ // kPlainWindowClass: no deco, active, under
+ // kOverlayWindowClass: invisible!
+ // kSheetAlertWindowClass: no deco, active, under
+ // kAltPlainWindowClass: no deco, active, under
+ // attributes:
+ // kWindowCloseBoxAttribute, HorizontalZoom, VerticalZoom, FullZoom, CollapsBox, Resizable,
+ // SideTitlebar(floatin only), NoUpdates, NoActivates, Macros: StandardDocument, StandardFloating
+ if (!fake_X_wm(w, xwm, ywm, bt, bx, by))
+ { winclass = kHelpWindowClass; winattr = 0; }
+ else if (w->modal())
+ winclass = kFloatingWindowClass; // basically fine, but not modal! The modal window however does nor show
+ else if (w->non_modal())
+ winclass = kFloatingWindowClass; // we need to call 'InitFloatingWindows for OS 8, 9
if (by+bt) {
//++ if (!w->non_modal()) style |= WS_SYSMENU | WS_MINIMIZEBOX;
wp += 2*bx;
@@ -1003,7 +1040,7 @@ void Fl_X::make(Fl_Window* w)
x->cursor = fl_default_cursor;
x->xidChildren = 0;
x->xidNext = 0;
- CreateNewWindow(winclass, winattr, &wRect, &(x->xid));
+ CreateNewWindow( winclass, winattr, &wRect, &(x->xid) );
SetWTitle(x->xid, pTitle);
x->w = w; w->i = x;
x->wait_for_expose = 1;
@@ -1013,12 +1050,19 @@ void Fl_X::make(Fl_Window* w)
w->set_visible();
w->handle(FL_SHOW);
w->redraw(); // force draw to happen
- TransitionWindow( x->xid, kWindowZoomTransitionEffect, kWindowShowTransitionAction, 0 );
+ //TransitionWindow( x->xid, kWindowZoomTransitionEffect, kWindowShowTransitionAction, 0 );
ShowWindow( x->xid );
fl_show_iconic = 0;
//++ hmmm, this should maybe set by the activate event?!
Fl::handle(FL_FOCUS, w);
//++ if (w->modal()) { Fl::modal_ = w; fl_fix_focus(); }
+ if ( ! Fl_X::first->next ) // if this is the first window, we need to bring the application to the front
+ {
+ ProcessSerialNumber psn;
+ OSErr err = GetCurrentProcess( &psn );
+ if ( err==noErr ) SetFrontProcess( &psn );
+ // or 'BringToFront'
+ }
}
}
@@ -1102,8 +1146,8 @@ void Fl_Window::resize(int X,int Y,int W,int H) {
MoveWindow(i->xid, X, Y, 0);
if (is_a_resize) {
SizeWindow(i->xid, W>0 ? W : 1, H>0 ? H : 1, 1);
-// Rect all; all.top=-32000; all.bottom=32000; all.left=-32000; all.right=32000;
-// InvalRect(&all);
+ Rect all; all.top=-32000; all.bottom=32000; all.left=-32000; all.right=32000;
+ InvalWindowRect( i->xid, &all );
}
}
if (is_a_resize) {
@@ -1158,7 +1202,8 @@ void Fl_Window::make_current()
}
fl_clip_region( 0 );
- CopyRgn( fl_window_region, GetPortClipRegion( GetWindowPort(i->xid), 0) ); // for Fl_GL_Window
+ SetPortClipRegion( GetWindowPort(i->xid), fl_window_region );
+ //CopyRgn( fl_window_region, GetPortClipRegion( GetWindowPort(i->xid), 0) ); // for Fl_GL_Window
return;
}
@@ -1223,6 +1268,6 @@ elapsedNanoseconds = AbsoluteToNanoseconds(elapsedTime);
*/
//
-// End of "$Id: Fl_mac.cxx,v 1.1.2.2 2001/12/04 03:03:17 matthiaswm Exp $".
+// End of "$Id: Fl_mac.cxx,v 1.1.2.3 2001/12/06 00:17:47 matthiaswm Exp $".
//
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index ea4f9c08e..e58ecffd3 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.3 2001/12/04 03:03:17 matthiaswm Exp $"
+// "$Id: fl_rect.cxx,v 1.10.2.4.2.4 2001/12/06 00:17:47 matthiaswm Exp $"
//
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
//
@@ -340,9 +340,13 @@ void fl_restore_clip() {
SelectClipRgn(fl_gc, r); //if r is NULL, clip is automatically cleared
#elif defined(__APPLE__)
# if 1
- CopyRgn( fl_window_region, GetPortClipRegion( GetWindowPort(fl_window), 0) ); // changed
+ RgnHandle portClip = NewRgn();
+ GrafPtr port = GetWindowPort( fl_window );
+ CopyRgn( fl_window_region, portClip ); // changed
if ( r )
- SectRgn( GetPortClipRegion( GetWindowPort(fl_window), 0), r, GetPortClipRegion( GetWindowPort(fl_window), 0) );
+ SectRgn( portClip, r, portClip );
+ SetPortClipRegion( port, portClip );
+ DisposeRgn( portClip );
# else
if (r) SetClip(r);
else {
@@ -462,11 +466,11 @@ int fl_clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H){
RgnHandle rr = NewRgn();
SetRectRgn( rr, x, y, x+w, y+h );
SectRgn( r, rr, rr );
- Rect *rp = GetRegionBounds(rr, 0);
- X = rp->left;
- Y = rp->top;
- W = rp->right - X;
- H = rp->bottom - Y;
+ Rect rp; GetRegionBounds(rr, &rp);
+ X = rp.left;
+ Y = rp.top;
+ W = rp.right - X;
+ H = rp.bottom - Y;
DisposeRgn( rr );
if ( H==0 ) return 2;
if ( h==H && w==W ) return 0;
@@ -494,5 +498,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.3 2001/12/04 03:03:17 matthiaswm Exp $".
+// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.4 2001/12/06 00:17:47 matthiaswm Exp $".
//