2014-05-16 05:38:18 -05:00
|
|
|
// 15 may 2014
|
|
|
|
|
|
|
|
#include "objc_darwin.h"
|
2014-05-20 07:08:55 -05:00
|
|
|
#import <Foundation/NSString.h>
|
2014-05-20 06:46:57 -05:00
|
|
|
|
|
|
|
// see delegateuitask_darwin.m
|
|
|
|
// in this case, NSScrollView.h includes NSApplication.h
|
2014-05-20 07:08:55 -05:00
|
|
|
#import <AppKit/NSView.h>
|
2014-05-20 06:46:57 -05:00
|
|
|
|
2014-05-20 07:35:39 -05:00
|
|
|
#ifdef MAC_OS_X_VERSION_10_7
|
2014-05-20 06:46:57 -05:00
|
|
|
#undef MAC_OS_X_VERSION_MIN_REQUIRED
|
|
|
|
#undef MAC_OS_X_VERSION_MAX_ALLOWED
|
|
|
|
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_7
|
|
|
|
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_7
|
2014-05-20 07:35:39 -05:00
|
|
|
#endif
|
2014-05-20 07:08:55 -05:00
|
|
|
#import <AppKit/NSApplication.h>
|
2014-05-20 06:46:57 -05:00
|
|
|
#undef MAC_OS_X_VERSION_MIN_REQUIRED
|
|
|
|
#undef MAC_OS_X_VERSION_MAX_ALLOWED
|
|
|
|
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
|
|
|
|
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_6
|
|
|
|
|
2014-05-20 07:08:55 -05:00
|
|
|
#import <AppKit/NSView.h>
|
|
|
|
#import <AppKit/NSScrollView.h>
|
2014-05-16 05:38:18 -05:00
|
|
|
|
|
|
|
#define to(T, x) ((T *) (x))
|
|
|
|
#define _toNSString(x) to(NSString, (x))
|
|
|
|
#define toNSView(x) to(NSView, (x))
|
|
|
|
#define toNSScrollView(x) to(NSScrollView, (x))
|
|
|
|
|
2014-05-16 08:13:11 -05:00
|
|
|
// because the only way to make a new NSControl/NSView is with a frame (it gets overridden later)
|
|
|
|
NSRect dummyRect;
|
|
|
|
|
2014-05-16 05:38:18 -05:00
|
|
|
id toNSString(char *str)
|
|
|
|
{
|
|
|
|
return [NSString stringWithUTF8String:str];
|
|
|
|
}
|
|
|
|
|
|
|
|
char *fromNSString(id str)
|
|
|
|
{
|
|
|
|
return [_toNSString(str) UTF8String];
|
|
|
|
}
|
|
|
|
|
|
|
|
void display(id view)
|
|
|
|
{
|
|
|
|
[toNSView(view) display];
|
|
|
|
}
|
|
|
|
|
|
|
|
struct xrect frame(id view)
|
|
|
|
{
|
|
|
|
NSRect r;
|
|
|
|
struct xrect s;
|
|
|
|
|
|
|
|
r = [toNSView(view) frame];
|
|
|
|
s.x = (intptr_t) r.origin.x;
|
|
|
|
s.y = (intptr_t) r.origin.y;
|
|
|
|
s.width = (intptr_t) r.size.width;
|
|
|
|
s.height = (intptr_t) r.size.height;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
id makeScrollView(id content)
|
|
|
|
{
|
|
|
|
NSScrollView *scrollview;
|
|
|
|
|
|
|
|
scrollview = [[NSScrollView alloc]
|
2014-05-16 08:13:11 -05:00
|
|
|
initWithFrame:dummyRect];
|
2014-05-16 05:38:18 -05:00
|
|
|
[scrollview setHasHorizontalScroller:YES];
|
|
|
|
[scrollview setHasVerticalScroller:YES];
|
|
|
|
[scrollview setAutohidesScrollers:YES];
|
2014-05-17 19:21:48 -05:00
|
|
|
// Interface Builder sets this for NSTableViews; we also want this on Areas
|
|
|
|
[scrollview setDrawsBackground:YES];
|
2014-05-16 05:38:18 -05:00
|
|
|
[scrollview setDocumentView:toNSView(content)];
|
|
|
|
return scrollview;
|
|
|
|
}
|
|
|
|
|
|
|
|
void giveScrollViewBezelBorder(id scrollview)
|
|
|
|
{
|
|
|
|
[toNSScrollView(scrollview) setBorderType:NSBezelBorder];
|
|
|
|
}
|
|
|
|
|
|
|
|
id scrollViewContent(id scrollview)
|
|
|
|
{
|
|
|
|
return [toNSScrollView(scrollview) documentView];
|
|
|
|
}
|