summaryrefslogtreecommitdiff
path: root/prefsize_darwin.m
diff options
context:
space:
mode:
Diffstat (limited to 'prefsize_darwin.m')
-rw-r--r--prefsize_darwin.m25
1 files changed, 24 insertions, 1 deletions
diff --git a/prefsize_darwin.m b/prefsize_darwin.m
index d00b2f8..4001c3e 100644
--- a/prefsize_darwin.m
+++ b/prefsize_darwin.m
@@ -2,16 +2,19 @@
#include "objc_darwin.h"
#import <AppKit/NSControl.h>
-#import <AppKit/NSView.h>
#import <AppKit/NSScrollView.h>
#import <AppKit/NSTableView.h>
#import <AppKit/NSProgressIndicator.h>
+#import <AppKit/NSView.h>
+// needed for the methods called by alignmentInfo()
+#import <AppKit/NSLayoutConstraint.h>
#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 toNSView(x) to(NSView, (x))
#define inScrollView(x) ([toNSScrollView((x)) documentView])
#define listboxInScrollView(x) toNSTableView(inScrollView((x)))
@@ -72,3 +75,23 @@ struct xsize areaPrefSize(id scrollview)
s.height = (intptr_t) r.size.height;
return s;
}
+
+struct xalignment alignmentInfo(id c, struct xrect newrect)
+{
+ NSView *v;
+ struct xalignment a;
+ NSRect r;
+
+ v = toNSView(c);
+ r = NSMakeRect((CGFloat) newrect.x,
+ (CGFloat) newrect.y,
+ (CGFloat) newrect.width,
+ (CGFloat) newrect.height);
+ r = [v alignmentRectForFrame:r];
+ a.alignmentRect.x = (intptr_t) r.origin.x;
+ a.alignmentRect.y = (intptr_t) r.origin.y;
+ a.alignmentRect.width = (intptr_t) r.size.width;
+ a.alignmentRect.height = (intptr_t) r.size.height;
+ a.baseline = (intptr_t) [v baselineOffsetFromBottom];
+ return a;
+}