summaryrefslogtreecommitdiff
path: root/redo/control_darwin.m
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-14 10:12:28 -0400
committerPietro Gagliardi <[email protected]>2014-08-14 10:12:28 -0400
commit7ddc99fd7fe36184b8b29388fde412faeee7dac5 (patch)
tree9a28a2c5cc36c9560b5ac080e628b4c740c5d2ba /redo/control_darwin.m
parenteb4b082d7f4377cb73a0b91993210d41e40ad431 (diff)
Merged xsizing_darwin.m into control_darwin.m. Even though alignment info is only currently used by Label, these functions are called in basegetAuxResizeInfo(), and who knows what will happen future.
Diffstat (limited to 'redo/control_darwin.m')
-rw-r--r--redo/control_darwin.m38
1 files changed, 38 insertions, 0 deletions
diff --git a/redo/control_darwin.m b/redo/control_darwin.m
index ce1eca7..1b06114 100644
--- a/redo/control_darwin.m
+++ b/redo/control_darwin.m
@@ -58,3 +58,41 @@ id newScrollView(id content, BOOL bordered)
[sv setBorderType:NSNoBorder];
return (id) sv;
}
+
+// these function are safe to call on Areas; they'll just return the frame and a baseline of 0 since they use the default NSView implementations
+
+static struct xalignment doAlignmentInfo(NSView *v, NSRect r)
+{
+ struct xalignment a;
+
+ r = [v alignmentRectForFrame:r];
+ a.rect.x = (intptr_t) r.origin.x;
+ a.rect.y = (intptr_t) r.origin.y;
+ a.rect.width = (intptr_t) r.size.width;
+ a.rect.height = (intptr_t) r.size.height;
+ // I'm not sure if we need to set the frame for -[NSView baselineOffsetFromBottom], but let's do it just to be safe
+ [v setFrame:r];
+ a.baseline = (intptr_t) [v baselineOffsetFromBottom];
+ return a;
+}
+
+struct xalignment alignmentInfo(id c, struct xrect newrect)
+{
+ NSView *v;
+ NSRect r;
+
+ v = toNSView(c);
+ r = NSMakeRect((CGFloat) newrect.x,
+ (CGFloat) newrect.y,
+ (CGFloat) newrect.width,
+ (CGFloat) newrect.height);
+ return doAlignmentInfo(v, r);
+}
+
+struct xalignment alignmentInfoFrame(id c)
+{
+ NSView *v;
+
+ v = toNSView(c);
+ return doAlignmentInfo(v, [v frame]);
+}