mirror of https://github.com/fltk/fltk
Mac Quartz:
- attempt at making the clipping work well - improved drawing (still many 1-off bugs) - 'arc' test seems to run well - beware! the Quartz version is pretty unstable at this point git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3785 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
25fe8425db
commit
329f84671e
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_mac.cxx,v 1.1.2.58 2004/08/26 00:18:42 matthiaswm Exp $"
|
||||
// "$Id: Fl_mac.cxx,v 1.1.2.59 2004/08/26 06:18:12 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -1863,10 +1863,10 @@ void Fl_Window::make_current()
|
|||
if (!i->gc) {
|
||||
//CreateCGContextForPort(GetWindowPort(i->xid), &i->gc);
|
||||
QDBeginCGContext(GetWindowPort(i->xid), &i->gc);
|
||||
// set clipping region
|
||||
//ClipCGContextToRegion (i->gc, &portRect, fl_window_region );
|
||||
// save the unclipped state for later
|
||||
CGContextSaveGState(i->gc);
|
||||
// translate coordinate system to coorespond with fltk's.
|
||||
CGContextTranslateCTM(i->gc, -0.5f, port_height+0.5f);
|
||||
CGContextTranslateCTM(i->gc, 0.5f, port_height-0.5f);
|
||||
CGContextScaleCTM(i->gc, 1.0f, -1.0f);
|
||||
static CGAffineTransform font_mx = { 1, 0, 0, -1, 0, 0 };
|
||||
CGContextSetTextMatrix(i->gc, font_mx);
|
||||
|
@ -1948,6 +1948,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
|
|||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_mac.cxx,v 1.1.2.58 2004/08/26 00:18:42 matthiaswm Exp $".
|
||||
// End of "$Id: Fl_mac.cxx,v 1.1.2.59 2004/08/26 06:18:12 matthiaswm Exp $".
|
||||
//
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_arci.cxx,v 1.4.2.5.2.7 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
// "$Id: fl_arci.cxx,v 1.4.2.5.2.8 2004/08/26 06:18:12 matthiaswm Exp $"
|
||||
//
|
||||
// Arc (integer) drawing functions for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -57,7 +57,7 @@ void fl_arc(int x,int y,int w,int h,double a1,double a2) {
|
|||
#elif defined(__APPLE_QUARTZ__)
|
||||
# warning : no support for ovals yet!
|
||||
float cx = x + 0.5f*w, cy = y + 0.5f*h;
|
||||
float r = (w+h)*0.5f;
|
||||
float r = (w+h)*0.25f;
|
||||
CGContextAddArc(fl_gc, cx, cy, r, a1/180.0f*M_PI, a2/180.0f*M_PI, 1);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
|
@ -80,12 +80,16 @@ void fl_pie(int x,int y,int w,int h,double a1,double a2) {
|
|||
a1 = a2-a1; a2 = 450-a2;
|
||||
PaintArc(&r, (short int)a2, (short int)a1);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
# warning : not implemented yet
|
||||
# warning : no support for ovals yet!
|
||||
float cx = x + 0.5f*w, cy = y + 0.5f*h;
|
||||
float r = (w+h)*0.25f;
|
||||
CGContextAddArc(fl_gc, cx, cy, r, a1/180.0f*M_PI, a2/180.0f*M_PI, 1);
|
||||
CGContextFillPath(fl_gc);
|
||||
#else
|
||||
XFillArc(fl_display, fl_window, fl_gc, x,y,w,h, int(a1*64),int((a2-a1)*64));
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: fl_arci.cxx,v 1.4.2.5.2.7 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
// End of "$Id: fl_arci.cxx,v 1.4.2.5.2.8 2004/08/26 06:18:12 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_font_mac.cxx,v 1.1.2.17 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
// "$Id: fl_font_mac.cxx,v 1.1.2.18 2004/08/26 06:18:12 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS font selection routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -130,6 +130,7 @@ void fl_font(Fl_FontSize* s) {
|
|||
fl_fontsize->knowMetrics = 1;
|
||||
}
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
if (!s) return;
|
||||
CGContextSelectFont(fl_gc, s->q_name, (float)s->size, kCGEncodingMacRoman);
|
||||
#else
|
||||
# error : need to defined either Quartz or Quickdraw
|
||||
|
@ -224,5 +225,5 @@ void fl_draw(const char* str, int n, int x, int y) {
|
|||
|
||||
|
||||
//
|
||||
// End of "$Id: fl_font_mac.cxx,v 1.1.2.17 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
// End of "$Id: fl_font_mac.cxx,v 1.1.2.18 2004/08/26 06:18:12 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_rect.cxx,v 1.10.2.4.2.13 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
// "$Id: fl_rect.cxx,v 1.10.2.4.2.14 2004/08/26 06:18:12 matthiaswm Exp $"
|
||||
//
|
||||
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -46,7 +46,7 @@ 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__)
|
||||
CGRect rect = CGRectMake(x, y, w, h);
|
||||
CGRect rect = CGRectMake(x-1.0f, y-1.0f, w, h);
|
||||
CGContextStrokeRect(fl_gc, rect);
|
||||
#else
|
||||
XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1);
|
||||
|
@ -65,7 +65,7 @@ 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__)
|
||||
CGRect rect = CGRectMake(x, y, w, h);
|
||||
CGRect rect = CGRectMake(x-1.0f, y-1.0f, w, h);
|
||||
CGContextFillRect(fl_gc, rect);
|
||||
#else
|
||||
if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h);
|
||||
|
@ -409,6 +409,9 @@ 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:
|
||||
|
@ -448,18 +451,18 @@ void fl_restore_clip() {
|
|||
CopyRgn( fl_window_region, portClip ); // changed
|
||||
if ( r )
|
||||
SectRgn( portClip, r, portClip );
|
||||
//SetPortClipRegion( port, portClip );
|
||||
// the following code is inefficient and should be replaced with
|
||||
// Carbon clipping - which unfortunatly has some problems on its own...
|
||||
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
|
||||
ClipCGContextToRegion(fl_gc, &portRect, portClip );
|
||||
// restore settings lost by "Restore"
|
||||
CGContextSaveGState(fl_gc);
|
||||
CGAffineTransform tf = CGContextGetCTM(fl_gc);
|
||||
tf.d = -1.0f; tf.tx = -tf.tx; tf.ty = tf.ty;
|
||||
//CGContextConcatCTM(fl_gc, tf);
|
||||
tf = CGContextGetCTM(fl_gc);
|
||||
tf.a = 1;
|
||||
ClipCGContextToRegion(fl_gc, &portRect, portClip ); // this call uses transformed coords!
|
||||
CGContextRestoreGState(fl_gc); // DOH! Restores the clipping region!
|
||||
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_);
|
||||
DisposeRgn( portClip );
|
||||
}
|
||||
}
|
||||
|
@ -639,5 +642,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.13 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.14 2004/08/26 06:18:12 matthiaswm Exp $".
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue