Wrote Control.preferredSize() (including Tab.preferredSize()) on Mac OS X.
This commit is contained in:
parent
37cf0a20c0
commit
85fb097ab9
|
@ -19,6 +19,7 @@ func newTab() Tab {
|
||||||
t := new(tab)
|
t := new(tab)
|
||||||
id := C.newTab(unsafe.Pointer(t))
|
id := C.newTab(unsafe.Pointer(t))
|
||||||
t.controlbase = newControl(id)
|
t.controlbase = newControl(id)
|
||||||
|
t.fpreferredSize = t.tabpreferredSize
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +33,12 @@ func (t *tab) Append(name string, control Control) {
|
||||||
s.child.setParent(&controlParent{tabview})
|
s.child.setParent(&controlParent{tabview})
|
||||||
}
|
}
|
||||||
|
|
||||||
// no need to override Control.allocate() as only prepared the tabbed control; its children will be reallocated when that one is resized
|
func (t *tab) tabpreferredSize(d *sizing) (width, height int) {
|
||||||
|
s := C.tabPrefSize(t.id)
|
||||||
|
return int(s.width), int(s.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
// no need to override Control.commitResize() as only prepared the tabbed control; its children will be reallocated when that one is resized
|
||||||
|
|
||||||
//export tabResized
|
//export tabResized
|
||||||
func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) {
|
func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) {
|
||||||
|
|
|
@ -30,8 +30,8 @@ func newControl(id C.id) *controlbase {
|
||||||
}
|
}
|
||||||
c.fallocate = baseallocate(c)
|
c.fallocate = baseallocate(c)
|
||||||
c.fpreferredSize = func(d *sizing) (int, int) {
|
c.fpreferredSize = func(d *sizing) (int, int) {
|
||||||
// TODO
|
s := C.controlPrefSize(c.id)
|
||||||
return 64, 32
|
return int(s.width), int(s.height)
|
||||||
}
|
}
|
||||||
c.fcommitResize = func(a *allocation, d *sizing) {
|
c.fcommitResize = func(a *allocation, d *sizing) {
|
||||||
//TODO
|
//TODO
|
||||||
|
|
|
@ -81,6 +81,7 @@ struct xalignment {
|
||||||
intptr_t baseline;
|
intptr_t baseline;
|
||||||
};
|
};
|
||||||
extern struct xsize controlPrefSize(id);
|
extern struct xsize controlPrefSize(id);
|
||||||
|
extern struct xsize tabPrefSize(id);
|
||||||
extern struct xsize areaPrefSize(id);
|
extern struct xsize areaPrefSize(id);
|
||||||
extern struct xalignment alignmentInfo(id, struct xrect);
|
extern struct xalignment alignmentInfo(id, struct xrect);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#define toNSControl(x) ((NSControl *) (x))
|
#define toNSControl(x) ((NSControl *) (x))
|
||||||
|
#define toNSTabView(x) ((NSTabView *) (x))
|
||||||
#define toNSScrollView(x) ((NSScrollView *) (x))
|
#define toNSScrollView(x) ((NSScrollView *) (x))
|
||||||
#define toNSView(x) ((NSView *) (x))
|
#define toNSView(x) ((NSView *) (x))
|
||||||
|
|
||||||
|
@ -24,6 +25,19 @@ struct xsize controlPrefSize(id control)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct xsize tabPrefSize(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 use this, possibly update to not need scrollview
|
// TODO use this, possibly update to not need scrollview
|
||||||
/*
|
/*
|
||||||
struct xsize areaPrefSize(id scrollview)
|
struct xsize areaPrefSize(id scrollview)
|
||||||
|
|
Loading…
Reference in New Issue