diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 5 | ||||
| -rw-r--r-- | src/Fl_mac.cxx | 55 | ||||
| -rw-r--r-- | src/fl_color_mac.cxx | 5 | ||||
| -rw-r--r-- | src/fl_font_mac.cxx | 5 | ||||
| -rw-r--r-- | src/fl_rect.cxx | 19 |
5 files changed, 64 insertions, 25 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index a5b0b8f7e..251aeba1a 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl.cxx,v 1.24.2.41.2.64 2004/08/26 00:18:42 matthiaswm Exp $" +// "$Id: Fl.cxx,v 1.24.2.41.2.65 2004/08/27 20:02:44 matthiaswm Exp $" // // Main event handling code for the Fast Light Tool Kit (FLTK). // @@ -798,6 +798,7 @@ void Fl_Window::hide() { fl_window = 0; #elif defined(__APPLE_QUARTZ__) # warning quartz + Fl_X::q_release_context(ip); if ( ip->xid == fl_window ) fl_window = 0; #else @@ -1027,5 +1028,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl.cxx,v 1.24.2.41.2.64 2004/08/26 00:18:42 matthiaswm Exp $". +// End of "$Id: Fl.cxx,v 1.24.2.41.2.65 2004/08/27 20:02:44 matthiaswm Exp $". // diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index c70a649f8..76aae83a4 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_mac.cxx,v 1.1.2.60 2004/08/26 22:24:23 matthiaswm Exp $" +// "$Id: Fl_mac.cxx,v 1.1.2.61 2004/08/27 20:02:44 matthiaswm Exp $" // // MacOS specific code for the Fast Light Tool Kit (FLTK). // @@ -1820,6 +1820,9 @@ void Fl_Window::resize(int X,int Y,int W,int H) { */ void Fl_Window::make_current() { +#ifdef __APPLE_QUARTZ__ + Fl_X::q_release_context(); +#endif if ( !fl_window_region ) fl_window_region = NewRgn(); fl_window = i->xid; @@ -1857,14 +1860,13 @@ void Fl_Window::make_current() #ifdef __APPLE_QUARTZ__ #warning : bracket all the QD stuff above with ifdefs! #warning : verbose copy of patch; please check code +#if 0 Rect portRect; GetPortBounds(GetWindowPort(i->xid), &portRect); short port_height = portRect.bottom - portRect.top; if (!i->gc) { //CreateCGContextForPort(GetWindowPort(i->xid), &i->gc); QDBeginCGContext(GetWindowPort(i->xid), &i->gc); -#warning : line capping should not be set. Check AA settings to make this work - CGContextSetLineCap(i->gc, kCGLineCapSquare); // save the unclipped state for later CGContextSaveGState(i->gc); // translate coordinate system to coorespond with fltk's. @@ -1874,10 +1876,55 @@ void Fl_Window::make_current() CGContextSetTextMatrix(i->gc, font_mx); } fl_gc = i->gc; +#else + QDBeginCGContext(GetWindowPort(i->xid), &i->gc); + fl_gc = i->gc; + CGContextSaveGState(fl_gc); + Fl_X::q_fill_context(); +#endif #endif return; } +// helper function to manage the current CGContext fl_gc +#ifdef __APPLE_QUARTZ__ +extern Fl_Color fl_color_; +extern class Fl_FontSize *fl_fontsize; +extern void fl_font(class Fl_FontSize*); + +// FLTK has only on global graphics state. This function copies the FLTK state into the +// current Quartz context +void Fl_X::q_fill_context() { + if (!fl_gc) return; + Rect portRect; + GetPortBounds(GetWindowPort( fl_window ), &portRect); + CGContextTranslateCTM(fl_gc, 0.5, portRect.bottom-portRect.top-0.5f); + CGContextScaleCTM(fl_gc, 1.0f, -1.0f); + static CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 }; + CGContextSetTextMatrix(fl_gc, font_mx); + fl_font(fl_fontsize); + fl_color(fl_color_); +} + +// The only way to reste clipping to its original state is to pop the current graphics +// state and restore the global state. +void Fl_X::q_clear_clipping() { + if (!fl_gc) return; + CGContextRestoreGState(fl_gc); + CGContextSaveGState(fl_gc); +} + +// Give the Quartz context back to the system +void Fl_X::q_release_context(Fl_X *x) { + if (x && x->gc!=fl_gc) return; + if (!fl_gc) return; + CGContextRestoreGState(fl_gc); + QDEndCGContext(GetWindowPort(fl_window), &fl_gc); + fl_gc = 0; +} + +#endif + //////////////////////////////////////////////////////////////// // Cut & paste. @@ -1950,6 +1997,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) { // -// End of "$Id: Fl_mac.cxx,v 1.1.2.60 2004/08/26 22:24:23 matthiaswm Exp $". +// End of "$Id: Fl_mac.cxx,v 1.1.2.61 2004/08/27 20:02:44 matthiaswm Exp $". // diff --git a/src/fl_color_mac.cxx b/src/fl_color_mac.cxx index d05d5f986..b64f5501b 100644 --- a/src/fl_color_mac.cxx +++ b/src/fl_color_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_color_mac.cxx,v 1.1.2.8 2004/08/26 00:18:43 matthiaswm Exp $" +// "$Id: fl_color_mac.cxx,v 1.1.2.9 2004/08/27 20:02:44 matthiaswm Exp $" // // MacOS color functions for the Fast Light Tool Kit (FLTK). // @@ -71,6 +71,7 @@ void fl_color(Fl_Color i) { rgb.blue = (b<<8)|b; RGBForeColor(&rgb); #elif defined(__APPLE_QUARTZ__) + if (!fl_gc) return; // no context yet? We will assign the color later. float fr = r/255.0f; float fg = g/255.0f; float fb = b/255.0f; @@ -107,5 +108,5 @@ void Fl::set_color(Fl_Color i, unsigned c) { } // -// End of "$Id: fl_color_mac.cxx,v 1.1.2.8 2004/08/26 00:18:43 matthiaswm Exp $". +// End of "$Id: fl_color_mac.cxx,v 1.1.2.9 2004/08/27 20:02:44 matthiaswm Exp $". // diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx index ce5e3ba34..613df6ec4 100644 --- a/src/fl_font_mac.cxx +++ b/src/fl_font_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_font_mac.cxx,v 1.1.2.18 2004/08/26 06:18:12 matthiaswm Exp $" +// "$Id: fl_font_mac.cxx,v 1.1.2.19 2004/08/27 20:02:45 matthiaswm Exp $" // // MacOS font selection routines for the Fast Light Tool Kit (FLTK). // @@ -131,6 +131,7 @@ void fl_font(Fl_FontSize* s) { } #elif defined(__APPLE_QUARTZ__) if (!s) return; + if (!fl_gc) return; // no worries, we will assign the font to the context later CGContextSelectFont(fl_gc, s->q_name, (float)s->size, kCGEncodingMacRoman); #else # error : need to defined either Quartz or Quickdraw @@ -225,5 +226,5 @@ void fl_draw(const char* str, int n, int x, int y) { // -// End of "$Id: fl_font_mac.cxx,v 1.1.2.18 2004/08/26 06:18:12 matthiaswm Exp $". +// End of "$Id: fl_font_mac.cxx,v 1.1.2.19 2004/08/27 20:02:45 matthiaswm Exp $". // diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx index d7b2549e2..e252f8abc 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.15 2004/08/26 22:24:24 matthiaswm Exp $" +// "$Id: fl_rect.cxx,v 1.10.2.4.2.16 2004/08/27 20:02:45 matthiaswm Exp $" // // Rectangle drawing routines for the Fast Light Tool Kit (FLTK). // @@ -429,9 +429,6 @@ extern Fl_Region fl_window_region; #elif defined(__APPLE_QUARTZ__) #warning quartz extern Fl_Region fl_window_region; -extern Fl_Color fl_color_; -extern class Fl_FontSize *fl_fontsize; -extern void fl_font(class Fl_FontSize*); #endif // undo any clobbering of clip done by your program: @@ -472,17 +469,9 @@ void fl_restore_clip() { if ( r ) SectRgn( portClip, r, portClip ); Rect portRect; GetPortBounds(port, &portRect); - // remove all clipping -# warning : Quartz will now destroy all font, color and line settings - CGContextRestoreGState(fl_gc); - // get rid of the following call for performance reasons + Fl_X::q_clear_clipping(); ClipCGContextToRegion(fl_gc, &portRect, portClip ); - // restore settings lost by "Restore" - CGContextSaveGState(fl_gc); - CGContextTranslateCTM(fl_gc, 0.5, portRect.bottom-portRect.top-0.5f); - CGContextScaleCTM(fl_gc, 1.0f, -1.0f); - fl_font(fl_fontsize); - fl_color(fl_color_); + Fl_X::q_fill_context(); DisposeRgn( portClip ); } } @@ -662,5 +651,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.15 2004/08/26 22:24:24 matthiaswm Exp $". +// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.16 2004/08/27 20:02:45 matthiaswm Exp $". // |
