diff options
| -rw-r--r-- | redo/control_darwin.m | 38 | ||||
| -rw-r--r-- | redo/objc_darwin.h | 2 | ||||
| -rw-r--r-- | redo/xsizing_darwin.m | 49 |
3 files changed, 38 insertions, 51 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]); +} diff --git a/redo/objc_darwin.h b/redo/objc_darwin.h index dd5ff9d..41b91f6 100644 --- a/redo/objc_darwin.h +++ b/redo/objc_darwin.h @@ -93,8 +93,6 @@ extern void setStandardControlFont(id); extern void setSmallControlFont(id); extern struct xsize controlPreferredSize(id); extern id newScrollView(id, BOOL); - -/* xsizing_darwin.m */ extern struct xalignment alignmentInfo(id, struct xrect); extern struct xalignment alignmentInfoFrame(id); diff --git a/redo/xsizing_darwin.m b/redo/xsizing_darwin.m deleted file mode 100644 index 1c9f123..0000000 --- a/redo/xsizing_darwin.m +++ /dev/null @@ -1,49 +0,0 @@ -// 15 may 2014 - -#include "objc_darwin.h" -#import <Cocoa/Cocoa.h> - -#define toNSControl(x) ((NSControl *) (x)) -#define toNSTabView(x) ((NSTabView *) (x)) -#define toNSScrollView(x) ((NSScrollView *) (x)) -#define toNSView(x) ((NSView *) (x)) - -// TODO figure out where this should go - -// 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]); -} |
