mac: implement polygon function
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
efa43456c1
commit
cc2d3008d0
1 changed files with 34 additions and 18 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "Mw/BaseTypes.h"
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
@ -97,6 +98,7 @@
|
||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
MilskoCocoa *p = parent->cocoa.real;
|
MilskoCocoa *p = parent->cocoa.real;
|
||||||
[p->window addChildWindow:c->window ordered:NSWindowAbove];
|
[p->window addChildWindow:c->window ordered:NSWindowAbove];
|
||||||
|
[c->window setHasShadow:MwFALSE];
|
||||||
} else {
|
} else {
|
||||||
[c->application activateIgnoringOtherApps:true];
|
[c->application activateIgnoringOtherApps:true];
|
||||||
}
|
}
|
||||||
|
|
@ -111,25 +113,40 @@
|
||||||
- (void)polygonWithPoints:(MwPoint *)points
|
- (void)polygonWithPoints:(MwPoint *)points
|
||||||
points_count:(int)points_count
|
points_count:(int)points_count
|
||||||
color:(MwLLColor)color {
|
color:(MwLLColor)color {
|
||||||
int i;
|
NSGraphicsContext *ctx = [self->view context];
|
||||||
CGContextRef cg = [self->view context];
|
if (ctx) {
|
||||||
|
int i;
|
||||||
|
NSBezierPath *path = [NSBezierPath bezierPath];
|
||||||
|
NSColor *nscolor = [NSColor colorWithRed:color->common.red / 255.
|
||||||
|
green:color->common.green / 255.
|
||||||
|
blue:color->common.blue / 255.
|
||||||
|
alpha:1.0];
|
||||||
|
|
||||||
[self->view lockFocus];
|
[NSGraphicsContext saveGraphicsState];
|
||||||
|
[NSGraphicsContext setCurrentContext:ctx];
|
||||||
|
|
||||||
CGContextSetRGBFillColor(cg, color->common.red / 255.,
|
[nscolor setFill];
|
||||||
color->common.blue / 255.,
|
for (i = 0; i < points_count; i++) {
|
||||||
color->common.green / 255., 1);
|
if (i == 0) {
|
||||||
CGContextBeginPath(cg);
|
[path moveToPoint:NSMakePoint(points[i].x,
|
||||||
for (i = 0; i < points_count; i++) {
|
[self->window frame].size.height -
|
||||||
CGContextMoveToPoint(cg, points[i].x, points[i].y);
|
points[i].y)];
|
||||||
if (i < points_count - 1) {
|
} else {
|
||||||
CGContextAddLineToPoint(cg, points[i + 1].x, points[i + 1].y);
|
[path lineToPoint:NSMakePoint(points[i].x,
|
||||||
|
[self->window frame].size.height -
|
||||||
|
points[i].y)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
CGContextFillPath(cg);
|
|
||||||
[self->view unlockFocus];
|
|
||||||
|
|
||||||
[self->view setNeedsDisplay:true];
|
[path closePath];
|
||||||
|
[path fill];
|
||||||
|
|
||||||
|
[NSGraphicsContext restoreGraphicsState];
|
||||||
|
|
||||||
|
[self->view setNeedsDisplay:YES];
|
||||||
|
|
||||||
|
[nscolor dealloc];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
- (void)lineWithPoints:(MwPoint *)points color:(MwLLColor)color {
|
- (void)lineWithPoints:(MwPoint *)points color:(MwLLColor)color {
|
||||||
};
|
};
|
||||||
|
|
@ -204,7 +221,6 @@
|
||||||
[NSGraphicsContext saveGraphicsState];
|
[NSGraphicsContext saveGraphicsState];
|
||||||
[NSGraphicsContext setCurrentContext:ctx];
|
[NSGraphicsContext setCurrentContext:ctx];
|
||||||
|
|
||||||
[[NSColor redColor] setFill];
|
|
||||||
[[p image] drawInRect:NSMakeRect(_rect->x, _rect->y, _rect->width,
|
[[p image] drawInRect:NSMakeRect(_rect->x, _rect->y, _rect->width,
|
||||||
_rect->height)
|
_rect->height)
|
||||||
fromRect:NSZeroRect
|
fromRect:NSZeroRect
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue