2014-05-15 18:21:54 -05:00
|
|
|
// 15 may 2014
|
|
|
|
|
|
|
|
#include "objc_darwin.h"
|
2014-05-20 07:08:55 -05:00
|
|
|
#import <AppKit/NSControl.h>
|
2014-05-20 06:46:57 -05:00
|
|
|
|
|
|
|
// see delegateuitask_darwin.m
|
|
|
|
// in this case, NSScrollView.h, NSTableView.h, AND NSProgressIndicator.h all include NSApplication.h
|
|
|
|
|
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/NSScrollView.h>
|
|
|
|
#import <AppKit/NSTableView.h>
|
|
|
|
#import <AppKit/NSProgressIndicator.h>
|
2014-05-15 18:21:54 -05:00
|
|
|
|
|
|
|
#define to(T, x) ((T *) (x))
|
|
|
|
#define toNSControl(x) to(NSControl, (x))
|
|
|
|
#define toNSScrollView(x) to(NSScrollView, (x))
|
|
|
|
#define toNSTableView(x) to(NSTableView, (x))
|
|
|
|
#define toNSProgressIndicator(x) to(NSProgressIndicator, (x))
|
|
|
|
|
|
|
|
#define inScrollView(x) ([toNSScrollView((x)) documentView])
|
|
|
|
#define listboxInScrollView(x) toNSTableView(inScrollView((x)))
|
|
|
|
#define areaInScrollView(x) inScrollView((x))
|
|
|
|
|
|
|
|
struct xsize controlPrefSize(id control)
|
|
|
|
{
|
|
|
|
NSControl *c;
|
|
|
|
NSRect r;
|
|
|
|
struct xsize s;
|
|
|
|
|
|
|
|
c = toNSControl(control);
|
|
|
|
[c sizeToFit];
|
|
|
|
r = [c frame];
|
|
|
|
s.width = (intptr_t) r.size.width;
|
|
|
|
s.height = (intptr_t) r.size.height;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct xsize listboxPrefSize(id scrollview)
|
|
|
|
{
|
|
|
|
NSTableView *c;
|
|
|
|
NSRect r;
|
|
|
|
struct xsize s;
|
|
|
|
|
|
|
|
c = listboxInScrollView(toNSScrollView(scrollview));
|
|
|
|
[c sizeToFit];
|
|
|
|
r = [c frame];
|
|
|
|
s.width = (intptr_t) r.size.width;
|
|
|
|
s.height = (intptr_t) r.size.height;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct xsize pbarPrefSize(id control)
|
|
|
|
{
|
|
|
|
NSProgressIndicator *c;
|
|
|
|
NSRect r;
|
|
|
|
struct xsize s;
|
|
|
|
|
|
|
|
c = toNSProgressIndicator(control);
|
|
|
|
[c sizeToFit];
|
|
|
|
r = [c frame];
|
|
|
|
s.width = (intptr_t) r.size.width;
|
|
|
|
s.height = (intptr_t) r.size.height;
|
|
|
|
return s;
|
2014-06-06 22:03:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct xsize areaPrefSize(id scrollview)
|
|
|
|
{
|
|
|
|
NSView *c;
|
|
|
|
NSRect r;
|
|
|
|
struct xsize s;
|
|
|
|
|
|
|
|
c = areaInScrollView(toNSScrollView(scrollview));
|
|
|
|
// don't size to fit; the frame size is already the size we want
|
|
|
|
r = [c frame];
|
|
|
|
s.width = (intptr_t) r.size.width;
|
|
|
|
s.height = (intptr_t) r.size.height;
|
|
|
|
return s;
|
2014-05-15 18:21:54 -05:00
|
|
|
}
|