2014-08-04 16:03:07 -05:00
|
|
|
// 4 august 2014
|
|
|
|
|
|
|
|
#include "objc_darwin.h"
|
|
|
|
#include "_cgo_export.h"
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
|
2014-08-04 16:46:08 -05:00
|
|
|
#define toNSView(x) ((NSView *) (x))
|
|
|
|
|
2014-08-04 16:03:07 -05:00
|
|
|
// calling -[className] on the content views of NSWindow, NSTabItem, and NSBox all return NSView, so I'm assuming I just need to override these
|
2014-08-04 16:28:53 -05:00
|
|
|
// fornunately:
|
|
|
|
// - NSWindow resizing calls -[setFrameSize:] (but not -[setFrame:])
|
|
|
|
// - NSTab resizing calls both -[setFrame:] and -[setFrameSIze:] on the current tab
|
|
|
|
// - NSTab switching tabs calls both -[setFrame:] and -[setFrameSize:] on the new tab
|
|
|
|
// so we just override setFrameSize:
|
2014-08-04 16:31:43 -05:00
|
|
|
// (TODO NSBox)
|
|
|
|
// thanks to mikeash and JtRip in irc.freenode.net/#macdev
|
2014-08-04 16:03:07 -05:00
|
|
|
@interface goContainerView : NSView {
|
|
|
|
@public
|
|
|
|
void *gocontainer;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation goContainerView
|
|
|
|
|
2014-08-04 16:28:53 -05:00
|
|
|
- (void)setFrameSize:(NSSize)s
|
2014-08-04 16:03:07 -05:00
|
|
|
{
|
2014-08-04 16:28:53 -05:00
|
|
|
[super setFrameSize:s];
|
2014-08-04 16:46:08 -05:00
|
|
|
containerResized(self->gocontainer, (intptr_t) s.width, (intptr_t) s.height);
|
2014-08-04 16:03:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
id newContainerView(void *gocontainer)
|
|
|
|
{
|
|
|
|
goContainerView *c;
|
|
|
|
|
|
|
|
c = [[goContainerView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
|
|
|
c->gocontainer = gocontainer;
|
|
|
|
return (id) c;
|
|
|
|
}
|
2014-08-04 16:46:08 -05:00
|
|
|
|
|
|
|
void moveControl(id c, intptr_t x, intptr_t y, intptr_t width, intptr_t height)
|
|
|
|
{
|
|
|
|
[toNSView(c) setFrame:NSMakeRect((CGFloat) x, (CGFloat) y, (CGFloat) width, (CGFloat) height)];
|
|
|
|
}
|