Started splitting apart xsizing_darwin.m and rearranging objc_darwin.h.
This commit is contained in:
parent
ea3dd093f7
commit
62938635a2
|
@ -3,9 +3,26 @@
|
|||
#import "objc_darwin.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#define toNSControl(x) ((NSControl *) (x))
|
||||
#define toNSView(x) ((NSView *) (x))
|
||||
|
||||
// also good for NSTableView (TODO might not do what we want) and NSProgressIndicator
|
||||
struct xsize controlPreferredSize(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;
|
||||
}
|
||||
|
||||
// TODO verify this when we add more scrolling controls
|
||||
// TODO no borders on Area
|
||||
id newScrollView(id content)
|
||||
{
|
||||
NSScrollView *sv;
|
||||
|
|
|
@ -13,6 +13,29 @@
|
|||
#include <objc/objc.h>
|
||||
#include <objc/runtime.h>
|
||||
|
||||
/* Objective-C -> Go types for max safety */
|
||||
struct xsize {
|
||||
intptr_t width;
|
||||
intptr_t height;
|
||||
};
|
||||
|
||||
struct xrect {
|
||||
intptr_t x;
|
||||
intptr_t y;
|
||||
intptr_t width;
|
||||
intptr_t height;
|
||||
};
|
||||
|
||||
struct xalignment {
|
||||
struct xrect rect;
|
||||
intptr_t baseline;
|
||||
};
|
||||
|
||||
struct xpoint {
|
||||
intptr_t x;
|
||||
intptr_t y;
|
||||
};
|
||||
|
||||
/* uitask_darwin.m */
|
||||
extern id getAppDelegate(void); /* used by the other .m files */
|
||||
extern BOOL uiinit(void);
|
||||
|
@ -58,6 +81,7 @@ extern void moveControl(id, intptr_t, intptr_t, intptr_t, intptr_t);
|
|||
/* tab_darwin.m */
|
||||
extern id newTab(void);
|
||||
extern void tabAppend(id, char *, id);
|
||||
extern struct xsize tabPreferredSize(id);
|
||||
|
||||
/* table_darwin.m */
|
||||
extern id newTable(void);
|
||||
|
@ -66,33 +90,14 @@ extern void tableUpdate(id);
|
|||
extern void tableMakeDataSource(id, void *);
|
||||
|
||||
/* control_darwin.m */
|
||||
extern struct xsize controlPreferredSize(id);
|
||||
extern id newScrollView(id);
|
||||
|
||||
/* xsizing_darwin.m */
|
||||
struct xsize {
|
||||
intptr_t width;
|
||||
intptr_t height;
|
||||
};
|
||||
struct xrect {
|
||||
intptr_t x;
|
||||
intptr_t y;
|
||||
intptr_t width;
|
||||
intptr_t height;
|
||||
};
|
||||
struct xalignment {
|
||||
struct xrect rect;
|
||||
intptr_t baseline;
|
||||
};
|
||||
extern struct xsize controlPreferredSize(id);
|
||||
extern struct xsize tabPreferredSize(id);
|
||||
extern struct xalignment alignmentInfo(id, struct xrect);
|
||||
extern struct xrect frame(id);
|
||||
|
||||
/* area_darwin.h */
|
||||
struct xpoint {
|
||||
intptr_t x;
|
||||
intptr_t y;
|
||||
};
|
||||
extern Class getAreaClass(void);
|
||||
extern id newArea(void *);
|
||||
extern void drawImage(void *, intptr_t, intptr_t, intptr_t, intptr_t, intptr_t);
|
||||
|
|
|
@ -25,3 +25,16 @@ void tabAppend(id t, char *name, id view)
|
|||
[i setView:toNSView(view)];
|
||||
[toNSTabView(t) addTabViewItem:i];
|
||||
}
|
||||
|
||||
struct xsize tabPreferredSize(id control)
|
||||
{
|
||||
NSTabView *tv;
|
||||
NSSize s;
|
||||
struct xsize t;
|
||||
|
||||
tv = toNSTabView(control);
|
||||
s = [tv minimumSize];
|
||||
t.width = (intptr_t) s.width;
|
||||
t.height = (intptr_t) s.height;
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -8,35 +8,7 @@
|
|||
#define toNSScrollView(x) ((NSScrollView *) (x))
|
||||
#define toNSView(x) ((NSView *) (x))
|
||||
|
||||
// TODO merge into control_darwin.m or sizing_darwin.m? really need to figure out what to do about the Go-side container struct...
|
||||
|
||||
// also good for NSTableView (TODO might not do what we want) and NSProgressIndicator
|
||||
struct xsize controlPreferredSize(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 tabPreferredSize(id control)
|
||||
{
|
||||
NSTabView *tv;
|
||||
NSSize s;
|
||||
struct xsize t;
|
||||
|
||||
tv = toNSTabView(control);
|
||||
s = [tv minimumSize];
|
||||
t.width = (intptr_t) s.width;
|
||||
t.height = (intptr_t) s.height;
|
||||
return t;
|
||||
}
|
||||
// TODO figure out where these should go
|
||||
|
||||
// this function is safe to call on Areas; it'll just return the frame and a baseline of 0 since it uses the default NSView implementations
|
||||
struct xalignment alignmentInfo(id c, struct xrect newrect)
|
||||
|
@ -61,6 +33,7 @@ struct xalignment alignmentInfo(id c, struct xrect newrect)
|
|||
return a;
|
||||
}
|
||||
|
||||
// TODO remove?
|
||||
struct xrect frame(id c)
|
||||
{
|
||||
NSRect r;
|
||||
|
|
Loading…
Reference in New Issue