23 #include <Appkit/NSGraphicsContext.h> 24 #include <Appkit/NSWindow.h> 25 #include <AppKit/NSView.h> 26 #include <cairo/cairo-quartz.h> 37 -(void) drawRect: (NSRect)rect;
39 -(NSView*) hitTest: (NSPoint)aPoint;
40 -(void) setWinfo: (
minsky::WindowInformation*)winfo;
50 ~
ViewImpl() {[cairoView removeFromSuperview]; [cairoView release];}
51 ViewImpl(
const ViewImpl&)=
delete;
52 void operator=(
const ViewImpl&)=
delete;
55 NSContext::NSContext(NSContext&&)=
default;
66 throw runtime_error(
"Different process space not supported on MacOSX");
71 NSContext::NSContext(
void* nativeHandle,
int xoffs,
int yoffs,
int width,
int height,
75 NSView* view=
reinterpret_cast<NSView*
>(nativeHandle);
83 throw runtime_error(
"Different process space not supported on MacOSX");
86 impl=make_unique<ViewImpl>();
93 [
impl->cairoView setFrameSize: NSMakeSize(width,height)];
94 [
impl->cairoView setWinfo: &winfo];
95 [view addSubview: impl->cairoView];
98 NSContext::~NSContext()=
default;
100 void NSContext::requestRedraw()
102 [
impl->cairoView setNeedsDisplay: true];
108 -(void) drawRect: (NSRect)rect
110 auto context = [[NSGraphicsContext currentContext] CGContext];
111 auto frame=[
self frame];
113 CGContextScaleCTM(context,1,-1);
114 winfo->
bufferSurface=make_shared<ecolab::cairo::Surface>(cairo_quartz_surface_create_for_cg_context(context, NSWidth(frame), NSHeight(frame)));
120 - (NSView *) hitTest: (NSPoint) aPoint
125 -(void) setWinfo: (
minsky::WindowInformation*)w
struct TCLcmd::trap::init_t init
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
static void signal_caught(int)
minsky::WindowInformation * winfo
std::unique_ptr< ViewImpl > impl