mirror of https://github.com/fltk/fltk
Quartz implementation for FLTK 1.1:
- added very crude font support - added line drawing support - added line color support - added filled shapes support - added some arc and circle support (no ovals) - attempt at getting the clipping working, however the stack oriented design of Quartz is starting to become a real hassle git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3784 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
8327822026
commit
25fe8425db
6
FL/mac.H
6
FL/mac.H
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: mac.H,v 1.1.2.11 2004/04/11 04:38:55 easysw Exp $"
|
||||
// "$Id: mac.H,v 1.1.2.12 2004/08/26 00:18:41 matthiaswm Exp $"
|
||||
//
|
||||
// Mac header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -65,6 +65,7 @@ class Fl_X
|
|||
public:
|
||||
Window xid; // Mac WindowPtr
|
||||
GWorldPtr other_xid; // pointer for offscreen bitmaps (doublebuffer)
|
||||
CGContextRef gc; // Quartz: graphics context (NULL when using QD)
|
||||
Fl_Window *w; // FLTK window for
|
||||
Fl_Region region;
|
||||
Fl_Region subRegion; // region for this specific subwindow
|
||||
|
@ -93,6 +94,7 @@ extern struct Fl_XMap {
|
|||
|
||||
extern FL_EXPORT void *fl_display;
|
||||
extern FL_EXPORT Window fl_window;
|
||||
extern FL_EXPORT CGContextRef fl_gc;
|
||||
extern FL_EXPORT Handle fl_system_menu;
|
||||
extern FL_EXPORT class Fl_Sys_Menu_Bar *fl_sys_menu_bar;
|
||||
|
||||
|
@ -118,6 +120,6 @@ extern void fl_open_callback(void (*cb)(const char *));
|
|||
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
|
||||
|
||||
//
|
||||
// End of "$Id: mac.H,v 1.1.2.11 2004/04/11 04:38:55 easysw Exp $".
|
||||
// End of "$Id: mac.H,v 1.1.2.12 2004/08/26 00:18:41 matthiaswm Exp $".
|
||||
//
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl.cxx,v 1.24.2.41.2.63 2004/08/25 00:20:25 matthiaswm Exp $"
|
||||
// "$Id: Fl.cxx,v 1.24.2.41.2.64 2004/08/26 00:18:42 matthiaswm Exp $"
|
||||
//
|
||||
// Main event handling code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -378,12 +378,14 @@ void Fl::flush() {
|
|||
QDFlushPortBuffer( port, 0 );
|
||||
}
|
||||
#elif defined (__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
# warning quartz: remove this
|
||||
GrafPtr port; GetPort( &port );
|
||||
if ( port )
|
||||
{
|
||||
QDFlushPortBuffer( port, 0 );
|
||||
}
|
||||
// end remove
|
||||
if (fl_gc) CGContextSynchronize(fl_gc);
|
||||
#else
|
||||
if (fl_display) XFlush(fl_display);
|
||||
#endif
|
||||
|
@ -1025,5 +1027,5 @@ void Fl_Window::flush() {
|
|||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl.cxx,v 1.24.2.41.2.63 2004/08/25 00:20:25 matthiaswm Exp $".
|
||||
// End of "$Id: Fl.cxx,v 1.24.2.41.2.64 2004/08/26 00:18:42 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_Font.H,v 1.6.2.3.2.6 2004/08/25 00:20:25 matthiaswm Exp $"
|
||||
// "$Id: Fl_Font.H,v 1.6.2.3.2.7 2004/08/26 00:18:42 matthiaswm Exp $"
|
||||
//
|
||||
// Font definitions for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -57,12 +57,11 @@ public:
|
|||
short width[256];
|
||||
bool knowMetrics;
|
||||
# elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
#warning : minimal quartz, use ATS instead!
|
||||
FL_EXPORT Fl_FontSize(const char* fontname, int size);
|
||||
short font, face, size;
|
||||
short ascent, descent;
|
||||
short width[256];
|
||||
bool knowMetrics;
|
||||
char *q_name;
|
||||
int size;
|
||||
short ascent, descent, q_width;
|
||||
# elif USE_XFT
|
||||
XftFont* font;
|
||||
const char* encoding;
|
||||
|
@ -103,5 +102,5 @@ FL_EXPORT char *fl_find_fontsize(char *name);
|
|||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Font.H,v 1.6.2.3.2.6 2004/08/25 00:20:25 matthiaswm Exp $".
|
||||
// End of "$Id: Fl_Font.H,v 1.6.2.3.2.7 2004/08/26 00:18:42 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_mac.cxx,v 1.1.2.57 2004/08/25 00:20:26 matthiaswm Exp $"
|
||||
// "$Id: Fl_mac.cxx,v 1.1.2.58 2004/08/26 00:18:42 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -83,6 +83,7 @@ static int FSSpec2UnixPath( FSSpec *fs, char *dst );
|
|||
|
||||
// public variables
|
||||
int fl_screen;
|
||||
CGContextRef fl_gc = 0;
|
||||
Handle fl_system_menu;
|
||||
Fl_Sys_Menu_Bar *fl_sys_menu_bar = 0;
|
||||
CursHandle fl_default_cursor;
|
||||
|
@ -1256,7 +1257,6 @@ void Fl_X::flush()
|
|||
{
|
||||
w->flush();
|
||||
SetOrigin( 0, 0 );
|
||||
//QDFlushPortBuffer( GetWindowPort(xid), 0 ); // \todo do we need this?
|
||||
}
|
||||
|
||||
|
||||
|
@ -1517,6 +1517,7 @@ void Fl_X::make(Fl_Window* w)
|
|||
x->region = 0;
|
||||
x->subRegion = 0;
|
||||
x->cursor = fl_default_cursor;
|
||||
x->gc = 0; // stay 0 for Quickdraw; fill with CGContext for Quartz
|
||||
Fl_Window *win = w->window();
|
||||
Fl_X *xo = Fl_X::i(win);
|
||||
w->set_visible();
|
||||
|
@ -1615,6 +1616,7 @@ void Fl_X::make(Fl_Window* w)
|
|||
x->cursor = fl_default_cursor;
|
||||
x->xidChildren = 0;
|
||||
x->xidNext = 0;
|
||||
x->gc = 0;
|
||||
|
||||
winattr &= GetAvailableWindowAttributes( winclass ); // make sure that the window will open
|
||||
CreateNewWindow( winclass, winattr, &wRect, &(x->xid) );
|
||||
|
@ -1852,6 +1854,25 @@ void Fl_Window::make_current()
|
|||
|
||||
fl_clip_region( 0 );
|
||||
SetPortClipRegion( GetWindowPort(i->xid), fl_window_region );
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
#warning : bracket all the QD stuff above with ifdefs!
|
||||
#warning : verbose copy of patch; please check code
|
||||
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);
|
||||
// set clipping region
|
||||
//ClipCGContextToRegion (i->gc, &portRect, fl_window_region );
|
||||
// translate coordinate system to coorespond with fltk's.
|
||||
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);
|
||||
}
|
||||
fl_gc = i->gc;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1927,6 +1948,6 @@ void Fl::paste(Fl_Widget &receiver, int clipboard) {
|
|||
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_mac.cxx,v 1.1.2.57 2004/08/25 00:20:26 matthiaswm Exp $".
|
||||
// End of "$Id: Fl_mac.cxx,v 1.1.2.58 2004/08/26 00:18:42 matthiaswm Exp $".
|
||||
//
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_arci.cxx,v 1.4.2.5.2.6 2004/08/25 00:20:26 matthiaswm Exp $"
|
||||
// "$Id: fl_arci.cxx,v 1.4.2.5.2.7 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
//
|
||||
// Arc (integer) drawing functions for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -55,10 +55,11 @@ void fl_arc(int x,int y,int w,int h,double a1,double a2) {
|
|||
a1 = a2-a1; a2 = 450-a2;
|
||||
FrameArc(&r, (short int)a2, (short int)a1);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
# warning quartz
|
||||
Rect r; r.left=x; r.right=x+w; r.top=y; r.bottom=y+h;
|
||||
a1 = a2-a1; a2 = 450-a2;
|
||||
FrameArc(&r, (short int)a2, (short int)a1);
|
||||
# warning : no support for ovals yet!
|
||||
float cx = x + 0.5f*w, cy = y + 0.5f*h;
|
||||
float r = (w+h)*0.5f;
|
||||
CGContextAddArc(fl_gc, cx, cy, r, a1/180.0f*M_PI, a2/180.0f*M_PI, 1);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XDrawArc(fl_display, fl_window, fl_gc, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64));
|
||||
#endif
|
||||
|
@ -79,15 +80,12 @@ 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 quartz
|
||||
Rect r; r.left=x; r.right=x+w; r.top=y; r.bottom=y+h;
|
||||
a1 = a2-a1; a2 = 450-a2;
|
||||
PaintArc(&r, (short int)a2, (short int)a1);
|
||||
# warning : not implemented yet
|
||||
#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.6 2004/08/25 00:20:26 matthiaswm Exp $".
|
||||
// End of "$Id: fl_arci.cxx,v 1.4.2.5.2.7 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_color_mac.cxx,v 1.1.2.7 2004/08/25 00:20:26 matthiaswm Exp $"
|
||||
// "$Id: fl_color_mac.cxx,v 1.1.2.8 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS color functions for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -28,17 +28,14 @@
|
|||
// changes can be made. Not to be confused with the X colormap, which
|
||||
// I try to hide completely.
|
||||
|
||||
// MacOS - matt: the macintosh port does not support colormaps
|
||||
// matt: Neither Quartz nor Quickdraw support colormaps in this implementation
|
||||
// matt: Quartz support done
|
||||
|
||||
#include <config.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/x.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
#warning quartz
|
||||
#endif
|
||||
|
||||
static unsigned fl_cmap[256] = {
|
||||
#include "fl_cmap.h" // this is a file produced by "cmap.cxx":
|
||||
};
|
||||
|
@ -67,20 +64,40 @@ void fl_color(Fl_Color i) {
|
|||
g = c>>16;
|
||||
b = c>> 8;
|
||||
}
|
||||
#ifdef __APPLE_QD__
|
||||
RGBColor rgb;
|
||||
rgb.red = (r<<8)|r;
|
||||
rgb.green = (g<<8)|g;
|
||||
rgb.blue = (b<<8)|b;
|
||||
RGBForeColor(&rgb);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
float fr = r/255.0f;
|
||||
float fg = g/255.0f;
|
||||
float fb = b/255.0f;
|
||||
CGContextSetRGBFillColor(fl_gc, fr, fg, fb, 1.0f);
|
||||
CGContextSetRGBStrokeColor(fl_gc, fr, fg, fb, 1.0f);
|
||||
#else
|
||||
# error : neither Quickdraw nor Quartz defined
|
||||
#endif
|
||||
}
|
||||
|
||||
void fl_color(uchar r, uchar g, uchar b) {
|
||||
RGBColor rgb;
|
||||
fl_color_ = fl_rgb_color(r, g, b);
|
||||
#ifdef __APPLE_QD__
|
||||
RGBColor rgb;
|
||||
rgb.red = (r<<8)|r;
|
||||
rgb.green = (g<<8)|g;
|
||||
rgb.blue = (b<<8)|b;
|
||||
RGBForeColor(&rgb);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
float fr = r/255.0f;
|
||||
float fg = g/255.0f;
|
||||
float fb = b/255.0f;
|
||||
CGContextSetRGBFillColor(fl_gc, fr, fg, fb, 1.0f);
|
||||
CGContextSetRGBStrokeColor(fl_gc, fr, fg, fb, 1.0f);
|
||||
#else
|
||||
# error : neither Quickdraw nor Quartz defined
|
||||
#endif
|
||||
}
|
||||
|
||||
void Fl::set_color(Fl_Color i, unsigned c) {
|
||||
|
@ -90,5 +107,5 @@ void Fl::set_color(Fl_Color i, unsigned c) {
|
|||
}
|
||||
|
||||
//
|
||||
// End of "$Id: fl_color_mac.cxx,v 1.1.2.7 2004/08/25 00:20:26 matthiaswm Exp $".
|
||||
// End of "$Id: fl_color_mac.cxx,v 1.1.2.8 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_font_mac.cxx,v 1.1.2.16 2004/08/25 00:20:27 matthiaswm Exp $"
|
||||
// "$Id: fl_font_mac.cxx,v 1.1.2.17 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
//
|
||||
// MacOS font selection routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -36,6 +36,7 @@
|
|||
//: SetFractEnable
|
||||
|
||||
Fl_FontSize::Fl_FontSize(const char* name, int Size) {
|
||||
#ifdef __APPLE_QD__
|
||||
knowMetrics = 0;
|
||||
switch (*name++) {
|
||||
case 'I': face = italic; break;
|
||||
|
@ -56,6 +57,14 @@ Fl_FontSize::Fl_FontSize(const char* name, int Size) {
|
|||
listbase = 0;
|
||||
#endif
|
||||
minsize = maxsize = size;
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
q_name = strdup(name+1);
|
||||
size = Size;
|
||||
ascent = Size*3/4;
|
||||
descent = Size-ascent;
|
||||
q_width = Size*2/3;
|
||||
minsize = maxsize = Size;
|
||||
#endif
|
||||
}
|
||||
|
||||
Fl_FontSize* fl_fontsize = 0L;
|
||||
|
@ -76,6 +85,9 @@ Fl_FontSize::~Fl_FontSize() {
|
|||
#endif
|
||||
*/
|
||||
if (this == fl_fontsize) fl_fontsize = 0;
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
free(q_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
@ -103,6 +115,7 @@ Fl_Fontdesc* fl_fonts = built_in_table;
|
|||
|
||||
void fl_font(Fl_FontSize* s) {
|
||||
fl_fontsize = s;
|
||||
#ifdef __APPLE_QD__
|
||||
if (fl_window) SetPort( GetWindowPort(fl_window) );
|
||||
TextFont(fl_fontsize->font); //: select font into current QuickDraw GC
|
||||
TextFace(fl_fontsize->face);
|
||||
|
@ -116,6 +129,11 @@ void fl_font(Fl_FontSize* s) {
|
|||
for (int i=0; i<256; i++) fl_fontsize->width[i] = f[2*i];
|
||||
fl_fontsize->knowMetrics = 1;
|
||||
}
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
CGContextSelectFont(fl_gc, s->q_name, (float)s->size, kCGEncodingMacRoman);
|
||||
#else
|
||||
# error : need to defined either Quartz or Quickdraw
|
||||
#endif
|
||||
}
|
||||
|
||||
static Fl_FontSize* find(int fnum, int size) {
|
||||
|
@ -193,13 +211,18 @@ void fl_draw(const char* str, int n, int x, int y) {
|
|||
|
||||
for (i = n, bufptr = buf; i > 0; i --)
|
||||
*bufptr++ = macroman_lut[*str++ & 255];
|
||||
|
||||
#ifdef __APPLE_QD__
|
||||
// Then draw it...
|
||||
MoveTo(x, y);
|
||||
DrawText((const char *)buf, 0, n);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
CGContextShowTextAtPoint(fl_gc, (float)x, (float)y, (const char*)buf, n);
|
||||
#else
|
||||
# error : neither Quartz no Quickdraw chosen
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: fl_font_mac.cxx,v 1.1.2.16 2004/08/25 00:20:27 matthiaswm Exp $".
|
||||
// End of "$Id: fl_font_mac.cxx,v 1.1.2.17 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
//
|
||||
|
|
144
src/fl_rect.cxx
144
src/fl_rect.cxx
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_rect.cxx,v 1.10.2.4.2.12 2004/08/25 00:20:27 matthiaswm Exp $"
|
||||
// "$Id: fl_rect.cxx,v 1.10.2.4.2.13 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
//
|
||||
// Rectangle drawing routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -46,10 +46,8 @@ 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__)
|
||||
#warning quartz
|
||||
Rect rect;
|
||||
SetRect(&rect, x, y, x+w, y+h);
|
||||
FrameRect(&rect);
|
||||
CGRect rect = CGRectMake(x, y, w, h);
|
||||
CGContextStrokeRect(fl_gc, rect);
|
||||
#else
|
||||
XDrawRectangle(fl_display, fl_window, fl_gc, x, y, w-1, h-1);
|
||||
#endif
|
||||
|
@ -67,10 +65,8 @@ 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__)
|
||||
#warning quartz
|
||||
Rect rect;
|
||||
SetRect(&rect, x, y, x+w, y+h);
|
||||
PaintRect(&rect);
|
||||
CGRect rect = CGRectMake(x, y, w, h);
|
||||
CGContextFillRect(fl_gc, rect);
|
||||
#else
|
||||
if (w && h) XFillRectangle(fl_display, fl_window, fl_gc, x, y, w, h);
|
||||
#endif
|
||||
|
@ -82,8 +78,9 @@ void fl_xyline(int x, int y, int x1) {
|
|||
#elif defined(__APPLE_QD__)
|
||||
MoveTo(x, y); LineTo(x1, y);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y); LineTo(x1, y);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y);
|
||||
#endif
|
||||
|
@ -101,10 +98,10 @@ void fl_xyline(int x, int y, int x1, int y2) {
|
|||
LineTo(x1, y);
|
||||
LineTo(x1, y2);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y);
|
||||
LineTo(x1, y2);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y2);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XPoint p[3];
|
||||
p[0].x = x; p[0].y = p[1].y = y;
|
||||
|
@ -127,11 +124,11 @@ void fl_xyline(int x, int y, int x1, int y2, int x3) {
|
|||
LineTo(x1, y2);
|
||||
LineTo(x3, y2);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y);
|
||||
LineTo(x1, y2);
|
||||
LineTo(x3, y2);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y2);
|
||||
CGContextAddLineToPoint(fl_gc, x3, y2);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XPoint p[4];
|
||||
p[0].x = x; p[0].y = p[1].y = y;
|
||||
|
@ -149,8 +146,9 @@ void fl_yxline(int x, int y, int y1) {
|
|||
#elif defined(__APPLE_QD__)
|
||||
MoveTo(x, y); LineTo(x, y1);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y); LineTo(x, y1);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x, y1);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XDrawLine(fl_display, fl_window, fl_gc, x, y, x, y1);
|
||||
#endif
|
||||
|
@ -168,10 +166,10 @@ void fl_yxline(int x, int y, int y1, int x2) {
|
|||
LineTo(x, y1);
|
||||
LineTo(x2, y1);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x, y1);
|
||||
LineTo(x2, y1);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y1);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XPoint p[3];
|
||||
p[0].x = p[1].x = x; p[0].y = y;
|
||||
|
@ -194,11 +192,11 @@ void fl_yxline(int x, int y, int y1, int x2, int y3) {
|
|||
LineTo(x2, y1);
|
||||
LineTo(x2, y3);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x, y1);
|
||||
LineTo(x2, y1);
|
||||
LineTo(x2, y3);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y3);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XPoint p[4];
|
||||
p[0].x = p[1].x = x; p[0].y = y;
|
||||
|
@ -219,9 +217,9 @@ void fl_line(int x, int y, int x1, int y1) {
|
|||
MoveTo(x, y);
|
||||
LineTo(x1, y1);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y1);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y1);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XDrawLine(fl_display, fl_window, fl_gc, x, y, x1, y1);
|
||||
#endif
|
||||
|
@ -240,10 +238,10 @@ void fl_line(int x, int y, int x1, int y1, int x2, int y2) {
|
|||
LineTo(x1, y1);
|
||||
LineTo(x2, y2);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y1);
|
||||
LineTo(x2, y2);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y2);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XPoint p[3];
|
||||
p[0].x = x; p[0].y = y;
|
||||
|
@ -265,11 +263,11 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2) {
|
|||
LineTo(x2, y2);
|
||||
LineTo(x, y);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y1);
|
||||
LineTo(x2, y2);
|
||||
LineTo(x, y);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y2);
|
||||
CGContextClosePath(fl_gc);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XPoint p[4];
|
||||
p[0].x = x; p[0].y = y;
|
||||
|
@ -294,12 +292,12 @@ void fl_loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
|
|||
LineTo(x3, y3);
|
||||
LineTo(x, y);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y1);
|
||||
LineTo(x2, y2);
|
||||
LineTo(x3, y3);
|
||||
LineTo(x, y);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y2);
|
||||
CGContextAddLineToPoint(fl_gc, x3, y3);
|
||||
CGContextClosePath(fl_gc);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XPoint p[5];
|
||||
p[0].x = x; p[0].y = y;
|
||||
|
@ -328,14 +326,11 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2) {
|
|||
PaintPoly(poly);
|
||||
KillPoly(poly);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
PolyHandle poly = OpenPoly();
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y1);
|
||||
LineTo(x2, y2);
|
||||
ClosePoly();
|
||||
PaintPoly(poly);
|
||||
KillPoly(poly);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y2);
|
||||
CGContextClosePath(fl_gc);
|
||||
CGContextFillPath(fl_gc);
|
||||
#else
|
||||
p[3].x = x; p[3].y = y;
|
||||
XFillPolygon(fl_display, fl_window, fl_gc, p, 3, Convex, 0);
|
||||
|
@ -362,15 +357,12 @@ void fl_polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3) {
|
|||
PaintPoly(poly);
|
||||
KillPoly(poly);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
PolyHandle poly = OpenPoly();
|
||||
MoveTo(x, y);
|
||||
LineTo(x1, y1);
|
||||
LineTo(x2, y2);
|
||||
LineTo(x3, y3);
|
||||
ClosePoly();
|
||||
PaintPoly(poly);
|
||||
KillPoly(poly);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x1, y1);
|
||||
CGContextAddLineToPoint(fl_gc, x2, y2);
|
||||
CGContextAddLineToPoint(fl_gc, x3, y3);
|
||||
CGContextClosePath(fl_gc);
|
||||
CGContextFillPath(fl_gc);
|
||||
#else
|
||||
p[4].x = x; p[4].y = y;
|
||||
XFillPolygon(fl_display, fl_window, fl_gc, p, 4, Convex, 0);
|
||||
|
@ -384,8 +376,9 @@ void fl_point(int x, int y) {
|
|||
#elif defined(__APPLE_QD__)
|
||||
MoveTo(x, y); Line(0, 0);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
MoveTo(x, y); Line(0, 0);
|
||||
CGContextMoveToPoint(fl_gc, x, y);
|
||||
CGContextAddLineToPoint(fl_gc, x, y);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
XDrawPoint(fl_display, fl_window, fl_gc, x, y);
|
||||
#endif
|
||||
|
@ -455,7 +448,18 @@ void fl_restore_clip() {
|
|||
CopyRgn( fl_window_region, portClip ); // changed
|
||||
if ( r )
|
||||
SectRgn( portClip, r, portClip );
|
||||
SetPortClipRegion( port, 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);
|
||||
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!
|
||||
DisposeRgn( portClip );
|
||||
}
|
||||
}
|
||||
|
@ -635,5 +639,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.12 2004/08/25 00:20:27 matthiaswm Exp $".
|
||||
// End of "$Id: fl_rect.cxx,v 1.10.2.4.2.13 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_vertex.cxx,v 1.5.2.3.2.9 2004/08/25 00:20:27 matthiaswm Exp $"
|
||||
// "$Id: fl_vertex.cxx,v 1.5.2.3.2.10 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
//
|
||||
// Portable drawing routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -26,6 +26,9 @@
|
|||
// Portable drawing code for drawing arbitrary shapes with
|
||||
// simple 2D transformations. See also fl_arc.cxx
|
||||
|
||||
// matt: the Quartz implementation purposly doesn't use the Quartz matrix
|
||||
// operations for reasons of compatibility and maintainability
|
||||
|
||||
#include <config.h>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/x.H>
|
||||
|
@ -72,14 +75,21 @@ void fl_rotate(double d) {
|
|||
}
|
||||
}
|
||||
|
||||
static XPoint *p = (XPoint *)0;
|
||||
// typedef what the x,y fields in a point are:
|
||||
#ifdef WIN32
|
||||
typedef int COORD_T;
|
||||
#define XPOINT XPoint
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
typedef float COORD_T;
|
||||
typedef struct { float x; float y; } QPoint;
|
||||
#define XPOINT QPoint
|
||||
#else
|
||||
typedef short COORD_T;
|
||||
#define XPOINT XPoint;
|
||||
#endif
|
||||
|
||||
static XPOINT *p = (XPOINT *)0;
|
||||
|
||||
static int p_size;
|
||||
static int n;
|
||||
static int what;
|
||||
|
@ -105,7 +115,7 @@ static void fl_transformed_vertex(COORD_T x, COORD_T y) {
|
|||
if (!n || x != p[n-1].x || y != p[n-1].y) {
|
||||
if (n >= p_size) {
|
||||
p_size = p ? 2*p_size : 16;
|
||||
p = (XPoint *)realloc((void*)p, p_size*sizeof(*p));
|
||||
p = (XPOINT*)realloc((void*)p, p_size*sizeof(*p));
|
||||
}
|
||||
p[n].x = x;
|
||||
p[n].y = y;
|
||||
|
@ -114,7 +124,11 @@ static void fl_transformed_vertex(COORD_T x, COORD_T y) {
|
|||
}
|
||||
|
||||
void fl_transformed_vertex(double xf, double yf) {
|
||||
#ifdef __APPLE_QUARTZ__
|
||||
fl_transformed_vertex(COORD_T(xf), COORD_T(yf));
|
||||
#else
|
||||
fl_transformed_vertex(COORD_T(rint(xf)), COORD_T(rint(yf)));
|
||||
#endif
|
||||
}
|
||||
|
||||
void fl_vertex(double x,double y) {
|
||||
|
@ -127,8 +141,11 @@ 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__)
|
||||
#warning quartz
|
||||
for (int i=0; i<n; i++) { MoveTo(p[i].x, p[i].y); Line(0, 0); }
|
||||
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);
|
||||
}
|
||||
#else
|
||||
if (n>1) XDrawPoints(fl_display, fl_window, fl_gc, p, n, 0);
|
||||
#endif
|
||||
|
@ -146,10 +163,11 @@ void fl_end_line() {
|
|||
MoveTo(p[0].x, p[0].y);
|
||||
for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning
|
||||
if (n<=1) return;
|
||||
MoveTo(p[0].x, p[0].y);
|
||||
for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y);
|
||||
CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
|
||||
for (int i=1; i<n; i++)
|
||||
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
|
||||
CGContextStrokePath(fl_gc);
|
||||
#else
|
||||
if (n>1) XDrawLines(fl_display, fl_window, fl_gc, p, n, 0);
|
||||
#endif
|
||||
|
@ -185,14 +203,12 @@ void fl_end_polygon() {
|
|||
PaintPoly(ph);
|
||||
KillPoly(ph);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
if (n<=1) return;
|
||||
PolyHandle ph = OpenPoly();
|
||||
MoveTo(p[0].x, p[0].y);
|
||||
for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y);
|
||||
ClosePoly();
|
||||
PaintPoly(ph);
|
||||
KillPoly(ph);
|
||||
CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
|
||||
for (int i=1; i<n; i++)
|
||||
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
|
||||
CGContextClosePath(fl_gc);
|
||||
CGContextFillPath(fl_gc);
|
||||
#else
|
||||
if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, Convex, 0);
|
||||
#endif
|
||||
|
@ -245,14 +261,12 @@ void fl_end_complex_polygon() {
|
|||
PaintPoly(ph);
|
||||
KillPoly(ph);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
if (n<=1) return;
|
||||
PolyHandle ph = OpenPoly();
|
||||
MoveTo(p[0].x, p[0].y);
|
||||
for (int i=1; i<n; i++) LineTo(p[i].x, p[i].y);
|
||||
ClosePoly();
|
||||
PaintPoly(ph);
|
||||
KillPoly(ph);
|
||||
CGContextMoveToPoint(fl_gc, p[0].x, p[0].y);
|
||||
for (int i=1; i<n; i++)
|
||||
CGContextAddLineToPoint(fl_gc, p[i].x, p[i].y);
|
||||
CGContextClosePath(fl_gc);
|
||||
CGContextFillPath(fl_gc);
|
||||
#else
|
||||
if (n>2) XFillPolygon(fl_display, fl_window, fl_gc, p, n, 0, 0);
|
||||
#endif
|
||||
|
@ -281,9 +295,9 @@ 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
|
||||
Rect rt; rt.left=llx; rt.right=llx+w; rt.top=lly; rt.bottom=lly+h;
|
||||
(what == POLYGON ? PaintOval : FrameOval)(&rt);
|
||||
# warning quartz : cicle 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
|
||||
(what == POLYGON ? XFillArc : XDrawArc)
|
||||
(fl_display, fl_window, fl_gc, llx, lly, w, h, 0, 360*64);
|
||||
|
@ -291,5 +305,5 @@ void fl_circle(double x, double y,double r) {
|
|||
}
|
||||
|
||||
//
|
||||
// End of "$Id: fl_vertex.cxx,v 1.5.2.3.2.9 2004/08/25 00:20:27 matthiaswm Exp $".
|
||||
// End of "$Id: fl_vertex.cxx,v 1.5.2.3.2.10 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: gl_draw.cxx,v 1.7.2.5.2.14 2004/08/25 00:20:27 matthiaswm Exp $"
|
||||
// "$Id: gl_draw.cxx,v 1.7.2.5.2.15 2004/08/26 00:18:43 matthiaswm Exp $"
|
||||
//
|
||||
// OpenGL drawing support routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -63,10 +63,6 @@ void gl_font(int fontid, int size) {
|
|||
fl_fontsize->size, 0, 256, fl_fontsize->listbase);
|
||||
#elif defined(__APPLE_QUARTZ__)
|
||||
#warning quartz
|
||||
// undefined characters automatically receive an empty GL list in aglUseFont
|
||||
fl_fontsize->listbase = glGenLists(256);
|
||||
aglUseFont(aglGetCurrentContext(), fl_fontsize->font, fl_fontsize->face,
|
||||
fl_fontsize->size, 0, 256, fl_fontsize->listbase);
|
||||
#else
|
||||
# if USE_XFT
|
||||
fl_xfont = fl_xxfont();
|
||||
|
@ -213,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.14 2004/08/25 00:20:27 matthiaswm Exp $".
|
||||
// End of "$Id: gl_draw.cxx,v 1.7.2.5.2.15 2004/08/26 00:18:43 matthiaswm Exp $".
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue