Replace a few global variables by members of the Fl_Quartz_Graphics_Driver class
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11985 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
606cdf1c60
commit
04c20514f6
@ -44,8 +44,6 @@ typedef OSStatus
|
|||||||
CFStringRef graphicsContextType,
|
CFStringRef graphicsContextType,
|
||||||
void ** graphicsContext);
|
void ** graphicsContext);
|
||||||
|
|
||||||
extern void fl_quartz_restore_line_style_(CGContextRef gc);
|
|
||||||
|
|
||||||
|
|
||||||
/** Support for printing on the Apple OS X platform */
|
/** Support for printing on the Apple OS X platform */
|
||||||
class Fl_Cocoa_Printer_Driver : public Fl_Paged_Device {
|
class Fl_Cocoa_Printer_Driver : public Fl_Paged_Device {
|
||||||
@ -324,7 +322,7 @@ int Fl_Cocoa_Printer_Driver::start_page (void)
|
|||||||
else
|
else
|
||||||
CGContextTranslateCTM(gc, margins.top, margins.right + h);
|
CGContextTranslateCTM(gc, margins.top, margins.right + h);
|
||||||
CGContextScaleCTM(gc, win_scale_x, - win_scale_y);
|
CGContextScaleCTM(gc, win_scale_x, - win_scale_y);
|
||||||
fl_quartz_restore_line_style_(gc);
|
((Fl_Quartz_Graphics_Driver*)driver())->quartz_restore_line_style();
|
||||||
CGContextSetShouldAntialias(gc, false);
|
CGContextSetShouldAntialias(gc, false);
|
||||||
CGContextSaveGState(gc);
|
CGContextSaveGState(gc);
|
||||||
CGContextSaveGState(gc);
|
CGContextSaveGState(gc);
|
||||||
|
@ -49,8 +49,18 @@ protected:
|
|||||||
XPOINT *p;
|
XPOINT *p;
|
||||||
bool high_resolution_;
|
bool high_resolution_;
|
||||||
driver_feature is_printer_;
|
driver_feature is_printer_;
|
||||||
|
float quartz_line_width_;
|
||||||
|
CGLineCap quartz_line_cap_;
|
||||||
|
CGLineJoin quartz_line_join_;
|
||||||
|
CGFloat *quartz_line_pattern;
|
||||||
|
int quartz_line_pattern_size;
|
||||||
// protected constructor to ensure only derived classes are allocated
|
// protected constructor to ensure only derived classes are allocated
|
||||||
Fl_Quartz_Graphics_Driver() : Fl_Graphics_Driver(), gc_(NULL), p_size(0), p(NULL) {
|
Fl_Quartz_Graphics_Driver() : Fl_Graphics_Driver(), gc_(NULL), p_size(0), p(NULL) {
|
||||||
|
quartz_line_width_ = 1.f;
|
||||||
|
quartz_line_cap_ = kCGLineCapButt;
|
||||||
|
quartz_line_join_ = kCGLineJoinMiter;
|
||||||
|
quartz_line_pattern = 0;
|
||||||
|
quartz_line_pattern_size = 0;
|
||||||
high_resolution_ = false;
|
high_resolution_ = false;
|
||||||
is_printer_ = (driver_feature)0;
|
is_printer_ = (driver_feature)0;
|
||||||
}
|
}
|
||||||
@ -157,6 +167,7 @@ protected:
|
|||||||
virtual void set_fontname_in_fontdesc(Fl_Fontdesc *f);
|
virtual void set_fontname_in_fontdesc(Fl_Fontdesc *f);
|
||||||
virtual void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d) {}
|
virtual void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d) {}
|
||||||
// end of function group
|
// end of function group
|
||||||
|
void quartz_restore_line_style();
|
||||||
};
|
};
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||||
@ -182,7 +193,6 @@ class Fl_ATSU_Graphics_Driver : public Fl_Quartz_Graphics_Driver {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern float fl_quartz_line_width_;
|
|
||||||
|
|
||||||
#endif // FL_QUARTZ_GRAPHICS_DRIVER_H
|
#endif // FL_QUARTZ_GRAPHICS_DRIVER_H
|
||||||
|
|
||||||
|
@ -31,17 +31,11 @@ extern int fl_line_width_;
|
|||||||
|
|
||||||
#include "Fl_Quartz_Graphics_Driver.h"
|
#include "Fl_Quartz_Graphics_Driver.h"
|
||||||
|
|
||||||
float fl_quartz_line_width_ = 1.0f;
|
void Fl_Quartz_Graphics_Driver::quartz_restore_line_style() {
|
||||||
static /*enum*/ CGLineCap fl_quartz_line_cap_ = kCGLineCapButt;
|
CGContextSetLineWidth(gc_, quartz_line_width_);
|
||||||
static /*enum*/ CGLineJoin fl_quartz_line_join_ = kCGLineJoinMiter;
|
CGContextSetLineCap(gc_, quartz_line_cap_);
|
||||||
static CGFloat *fl_quartz_line_pattern = 0;
|
CGContextSetLineJoin(gc_, quartz_line_join_);
|
||||||
static int fl_quartz_line_pattern_size = 0;
|
CGContextSetLineDash(gc_, 0, quartz_line_pattern, quartz_line_pattern_size);
|
||||||
|
|
||||||
void fl_quartz_restore_line_style_(CGContextRef gc) {
|
|
||||||
CGContextSetLineWidth(gc, fl_quartz_line_width_);
|
|
||||||
CGContextSetLineCap(gc, fl_quartz_line_cap_);
|
|
||||||
CGContextSetLineJoin(gc, fl_quartz_line_join_);
|
|
||||||
CGContextSetLineDash(gc, 0, fl_quartz_line_pattern, fl_quartz_line_pattern_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::line_style(int style, int width, char* dashes) {
|
void Fl_Quartz_Graphics_Driver::line_style(int style, int width, char* dashes) {
|
||||||
@ -50,27 +44,27 @@ void Fl_Quartz_Graphics_Driver::line_style(int style, int width, char* dashes) {
|
|||||||
if (width == 0) fl_line_width_ = 1;
|
if (width == 0) fl_line_width_ = 1;
|
||||||
else fl_line_width_ = width>0 ? width : -width;
|
else fl_line_width_ = width>0 ? width : -width;
|
||||||
|
|
||||||
static /*enum*/ CGLineCap Cap[4] = { kCGLineCapButt, kCGLineCapButt,
|
static CGLineCap Cap[4] = { kCGLineCapButt, kCGLineCapButt,
|
||||||
kCGLineCapRound, kCGLineCapSquare };
|
kCGLineCapRound, kCGLineCapSquare };
|
||||||
static /*enum*/ CGLineJoin Join[4] = { kCGLineJoinMiter, kCGLineJoinMiter,
|
static CGLineJoin Join[4] = { kCGLineJoinMiter, kCGLineJoinMiter,
|
||||||
kCGLineJoinRound, kCGLineJoinBevel };
|
kCGLineJoinRound, kCGLineJoinBevel };
|
||||||
if (width<1) width = 1;
|
if (width<1) width = 1;
|
||||||
fl_quartz_line_width_ = (float)width;
|
quartz_line_width_ = (float)width;
|
||||||
fl_quartz_line_cap_ = Cap[(style>>8)&3];
|
quartz_line_cap_ = Cap[(style>>8)&3];
|
||||||
// when printing kCGLineCapSquare seems better for solid lines
|
// when printing kCGLineCapSquare seems better for solid lines
|
||||||
if ( Fl_Surface_Device::surface() != Fl_Display_Device::display_device()
|
if ( Fl_Surface_Device::surface() != Fl_Display_Device::display_device()
|
||||||
&& style == FL_SOLID && dashes == NULL )
|
&& style == FL_SOLID && dashes == NULL )
|
||||||
{
|
{
|
||||||
fl_quartz_line_cap_ = kCGLineCapSquare;
|
quartz_line_cap_ = kCGLineCapSquare;
|
||||||
}
|
}
|
||||||
fl_quartz_line_join_ = Join[(style>>12)&3];
|
quartz_line_join_ = Join[(style>>12)&3];
|
||||||
char *d = dashes;
|
char *d = dashes;
|
||||||
static CGFloat pattern[16];
|
static CGFloat pattern[16];
|
||||||
if (d && *d) {
|
if (d && *d) {
|
||||||
CGFloat *p = pattern;
|
CGFloat *p = pattern;
|
||||||
while (*d) { *p++ = (float)*d++; }
|
while (*d) { *p++ = (float)*d++; }
|
||||||
fl_quartz_line_pattern = pattern;
|
quartz_line_pattern = pattern;
|
||||||
fl_quartz_line_pattern_size = d-dashes;
|
quartz_line_pattern_size = d-dashes;
|
||||||
} else if (style & 0xff) {
|
} else if (style & 0xff) {
|
||||||
char dash, dot, gap;
|
char dash, dot, gap;
|
||||||
// adjust lengths to account for cap:
|
// adjust lengths to account for cap:
|
||||||
@ -89,13 +83,13 @@ void Fl_Quartz_Graphics_Driver::line_style(int style, int width, char* dashes) {
|
|||||||
case FL_DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; break;
|
case FL_DASHDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; break;
|
||||||
case FL_DASHDOTDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; *p++ = dot; *p++ = gap; break;
|
case FL_DASHDOTDOT: *p++ = dash; *p++ = gap; *p++ = dot; *p++ = gap; *p++ = dot; *p++ = gap; break;
|
||||||
}
|
}
|
||||||
fl_quartz_line_pattern_size = p-pattern;
|
quartz_line_pattern_size = p-pattern;
|
||||||
fl_quartz_line_pattern = pattern;
|
quartz_line_pattern = pattern;
|
||||||
} else {
|
} else {
|
||||||
fl_quartz_line_pattern = 0;
|
quartz_line_pattern = 0;
|
||||||
fl_quartz_line_pattern_size = 0;
|
quartz_line_pattern_size = 0;
|
||||||
}
|
}
|
||||||
fl_quartz_restore_line_style_((CGContextRef)gc());
|
quartz_restore_line_style();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FL_CFG_GFX_QUARTZ
|
#endif // FL_CFG_GFX_QUARTZ
|
||||||
|
@ -33,9 +33,6 @@
|
|||||||
#include "Fl_Quartz_Graphics_Driver.h"
|
#include "Fl_Quartz_Graphics_Driver.h"
|
||||||
|
|
||||||
|
|
||||||
extern float fl_quartz_line_width_;
|
|
||||||
|
|
||||||
|
|
||||||
// --- line and polygon drawing with integer coordinates
|
// --- line and polygon drawing with integer coordinates
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::point(int x, int y) {
|
void Fl_Quartz_Graphics_Driver::point(int x, int y) {
|
||||||
@ -44,10 +41,10 @@ void Fl_Quartz_Graphics_Driver::point(int x, int y) {
|
|||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::rect(int x, int y, int w, int h) {
|
void Fl_Quartz_Graphics_Driver::rect(int x, int y, int w, int h) {
|
||||||
if (w<=0 || h<=0) return;
|
if (w<=0 || h<=0) return;
|
||||||
if ( (!has_feature(PRINTER)) && fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if ( (!has_feature(PRINTER)) && quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGRect rect = CGRectMake(x, y, w-1, h-1);
|
CGRect rect = CGRectMake(x, y, w-1, h-1);
|
||||||
CGContextStrokeRect(gc_, rect);
|
CGContextStrokeRect(gc_, rect);
|
||||||
if ( (!has_feature(PRINTER)) && fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if ( (!has_feature(PRINTER)) && quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::rectf(int x, int y, int w, int h) {
|
void Fl_Quartz_Graphics_Driver::rectf(int x, int y, int w, int h) {
|
||||||
@ -57,24 +54,24 @@ void Fl_Quartz_Graphics_Driver::rectf(int x, int y, int w, int h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::line(int x, int y, int x1, int y1) {
|
void Fl_Quartz_Graphics_Driver::line(int x, int y, int x1, int y1) {
|
||||||
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x1, y1);
|
CGContextAddLineToPoint(gc_, x1, y1);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
|
void Fl_Quartz_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) {
|
||||||
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x1, y1);
|
CGContextAddLineToPoint(gc_, x1, y1);
|
||||||
CGContextAddLineToPoint(gc_, x2, y2);
|
CGContextAddLineToPoint(gc_, x2, y2);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1) {
|
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1) {
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x1, y);
|
CGContextAddLineToPoint(gc_, x1, y);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
@ -83,76 +80,76 @@ void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1) {
|
|||||||
(or one pixel) too short at both ends. This is corrected by filling at both ends rectangles
|
(or one pixel) too short at both ends. This is corrected by filling at both ends rectangles
|
||||||
of size one unit by line-width.
|
of size one unit by line-width.
|
||||||
*/
|
*/
|
||||||
CGContextFillRect(gc_, CGRectMake(x-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
|
CGContextFillRect(gc_, CGRectMake(x-0.5 , y - quartz_line_width_/2, 1 , quartz_line_width_));
|
||||||
CGContextFillRect(gc_, CGRectMake(x1-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
|
CGContextFillRect(gc_, CGRectMake(x1-0.5 , y - quartz_line_width_/2, 1 , quartz_line_width_));
|
||||||
}
|
}
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
|
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1, int y2) {
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x1, y);
|
CGContextAddLineToPoint(gc_, x1, y);
|
||||||
CGContextAddLineToPoint(gc_, x1, y2);
|
CGContextAddLineToPoint(gc_, x1, y2);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
if (high_resolution()) {
|
if (high_resolution()) {
|
||||||
CGContextFillRect(gc_, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
|
CGContextFillRect(gc_, CGRectMake(x-0.5, y - quartz_line_width_/2, 1 , quartz_line_width_));
|
||||||
CGContextFillRect(gc_, CGRectMake(x1 - fl_quartz_line_width_/2, y2-0.5, fl_quartz_line_width_, 1));
|
CGContextFillRect(gc_, CGRectMake(x1 - quartz_line_width_/2, y2-0.5, quartz_line_width_, 1));
|
||||||
}
|
}
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
|
void Fl_Quartz_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) {
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x1, y);
|
CGContextAddLineToPoint(gc_, x1, y);
|
||||||
CGContextAddLineToPoint(gc_, x1, y2);
|
CGContextAddLineToPoint(gc_, x1, y2);
|
||||||
CGContextAddLineToPoint(gc_, x3, y2);
|
CGContextAddLineToPoint(gc_, x3, y2);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
if (high_resolution()) {
|
if (high_resolution()) {
|
||||||
CGContextFillRect(gc_, CGRectMake(x-0.5, y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
|
CGContextFillRect(gc_, CGRectMake(x-0.5, y - quartz_line_width_/2, 1 , quartz_line_width_));
|
||||||
CGContextFillRect(gc_, CGRectMake(x3-0.5, y2 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
|
CGContextFillRect(gc_, CGRectMake(x3-0.5, y2 - quartz_line_width_/2, 1 , quartz_line_width_));
|
||||||
}
|
}
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1) {
|
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1) {
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x, y1);
|
CGContextAddLineToPoint(gc_, x, y1);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
if (high_resolution()) {
|
if (high_resolution()) {
|
||||||
CGContextFillRect(gc_, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
|
CGContextFillRect(gc_, CGRectMake(x - quartz_line_width_/2, y-0.5, quartz_line_width_, 1));
|
||||||
CGContextFillRect(gc_, CGRectMake(x - fl_quartz_line_width_/2, y1-0.5, fl_quartz_line_width_, 1));
|
CGContextFillRect(gc_, CGRectMake(x - quartz_line_width_/2, y1-0.5, quartz_line_width_, 1));
|
||||||
}
|
}
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
|
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1, int x2) {
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x, y1);
|
CGContextAddLineToPoint(gc_, x, y1);
|
||||||
CGContextAddLineToPoint(gc_, x2, y1);
|
CGContextAddLineToPoint(gc_, x2, y1);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
if (high_resolution()) {
|
if (high_resolution()) {
|
||||||
CGContextFillRect(gc_, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
|
CGContextFillRect(gc_, CGRectMake(x - quartz_line_width_/2, y-0.5, quartz_line_width_, 1));
|
||||||
CGContextFillRect(gc_, CGRectMake(x2-0.5, y1 - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
|
CGContextFillRect(gc_, CGRectMake(x2-0.5, y1 - quartz_line_width_/2, 1 , quartz_line_width_));
|
||||||
}
|
}
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
|
void Fl_Quartz_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) {
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
CGContextMoveToPoint(gc_, x, y);
|
CGContextMoveToPoint(gc_, x, y);
|
||||||
CGContextAddLineToPoint(gc_, x, y1);
|
CGContextAddLineToPoint(gc_, x, y1);
|
||||||
CGContextAddLineToPoint(gc_, x2, y1);
|
CGContextAddLineToPoint(gc_, x2, y1);
|
||||||
CGContextAddLineToPoint(gc_, x2, y3);
|
CGContextAddLineToPoint(gc_, x2, y3);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
if (high_resolution()) {
|
if (high_resolution()) {
|
||||||
CGContextFillRect(gc_, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
|
CGContextFillRect(gc_, CGRectMake(x - quartz_line_width_/2, y-0.5, quartz_line_width_, 1));
|
||||||
CGContextFillRect(gc_, CGRectMake(x2 - fl_quartz_line_width_/2, y3-0.5, fl_quartz_line_width_, 1));
|
CGContextFillRect(gc_, CGRectMake(x2 - quartz_line_width_/2, y3-0.5, quartz_line_width_, 1));
|
||||||
}
|
}
|
||||||
if (has_feature(PRINTER) || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (has_feature(PRINTER) || quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) {
|
void Fl_Quartz_Graphics_Driver::loop(int x, int y, int x1, int y1, int x2, int y2) {
|
||||||
@ -291,9 +288,6 @@ void Fl_Quartz_Graphics_Driver::pop_clip() {
|
|||||||
restore_clip();
|
restore_clip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper function to manage the current CGContext gc
|
|
||||||
extern void fl_quartz_restore_line_style_(CGContextRef gc);
|
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::restore_clip() {
|
void Fl_Quartz_Graphics_Driver::restore_clip() {
|
||||||
fl_clip_state_number++;
|
fl_clip_state_number++;
|
||||||
Fl_Region r = rstack[rstackptr];
|
Fl_Region r = rstack[rstackptr];
|
||||||
@ -316,7 +310,7 @@ void Fl_Quartz_Graphics_Driver::restore_clip() {
|
|||||||
CGContextScaleCTM(gc_, 1.0f, -1.0f); // now 0,0 is top-left point of the context
|
CGContextScaleCTM(gc_, 1.0f, -1.0f); // now 0,0 is top-left point of the context
|
||||||
}
|
}
|
||||||
color(color());
|
color(color());
|
||||||
fl_quartz_restore_line_style_(gc_);
|
quartz_restore_line_style();
|
||||||
if (r) { //apply program clip
|
if (r) { //apply program clip
|
||||||
CGContextClipToRects(gc_, r->rects, r->count);
|
CGContextClipToRects(gc_, r->rects, r->count);
|
||||||
}
|
}
|
||||||
|
@ -41,13 +41,13 @@ void Fl_Quartz_Graphics_Driver::vertex(double x,double y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::end_points() {
|
void Fl_Quartz_Graphics_Driver::end_points() {
|
||||||
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
if (quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, true);
|
||||||
for (int i=0; i<n; i++) {
|
for (int i=0; i<n; i++) {
|
||||||
CGContextMoveToPoint(gc_, p[i].x, p[i].y);
|
CGContextMoveToPoint(gc_, p[i].x, p[i].y);
|
||||||
CGContextAddLineToPoint(gc_, p[i].x, p[i].y);
|
CGContextAddLineToPoint(gc_, p[i].x, p[i].y);
|
||||||
CGContextStrokePath(gc_);
|
CGContextStrokePath(gc_);
|
||||||
}
|
}
|
||||||
if (fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
if (quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_Quartz_Graphics_Driver::end_line() {
|
void Fl_Quartz_Graphics_Driver::end_line() {
|
||||||
|
Loading…
Reference in New Issue
Block a user