ardour/cocoatea/view.mm

63 lines
1.3 KiB
Text
Raw Normal View History

2024-11-14 14:55:44 -07:00
/* -*- c++ -*- */
#include <cstdlib>
2024-11-14 14:55:44 -07:00
#include <stdio.h>
2024-11-15 17:54:14 -07:00
2024-11-14 14:55:44 -07:00
#include "view.h"
@implementation CTView
-(BOOL)acceptsFirstResponder
{
printf ("acceptsFirstResponder\n");
return YES;
}
-(void)noop: (id)sender
{
printf ("noop\n");
}
-(BOOL)isFlipped
{
return YES;
}
2024-11-15 17:54:14 -07:00
-(void) timedUpdate
{
NSRect rect = NSMakeRect (random() % 100, random() % 100, random() % 400, random() % 400);
[self setNeedsDisplayInRect:rect];
}
2024-11-14 14:55:44 -07:00
-(void)drawRect: (NSRect)rect
{
2024-11-15 17:54:14 -07:00
//printf ("%g, %g %g x %g\n", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
const NSRect *drawn_rects;
2024-11-15 17:54:14 -07:00
long count;
int i;
[self getRectsBeingDrawn: &drawn_rects count: &count];
2024-11-15 17:54:14 -07:00
NSGraphicsContext* context = [NSGraphicsContext currentContext];
CGContextRef cg = [context CGContext];
//printf ("%ld rects to draw\n", count);
for (i = 0; i < count; i++) {
2024-11-15 17:54:14 -07:00
//printf ("\trect %d: %g, %g %g x %g\n", i, drawn_rects[i].origin.x, drawn_rects[i].origin.y, drawn_rects[i].size.width, drawn_rects[i].size.height);
// CGContextSetRGBFillColor (cg, 1.0, 1.0, 1.0, 0.0);
CGContextSetRGBStrokeColor (cg, 1.0, 1.0, 1.0, 1.0);
// CGContextFillRect (cg, drawn_rects[i]);
CGContextStrokeRect (cg, drawn_rects[i]);
}
2024-11-15 17:54:14 -07:00
}
-(void)windowWillClose:(NSNotification *)notification
{
[NSApp terminate:self];
2024-11-14 14:55:44 -07:00
}
@end