Cleaned up Mac OS X Tab code from the previous commit.
This commit is contained in:
parent
1ba1f475ba
commit
84297ad7e1
|
@ -54,7 +54,7 @@ extern id newLabel(void);
|
||||||
extern void moveControl(id, intptr_t, intptr_t, intptr_t, intptr_t);
|
extern void moveControl(id, intptr_t, intptr_t, intptr_t, intptr_t);
|
||||||
|
|
||||||
/* tab_darwin.m */
|
/* tab_darwin.m */
|
||||||
extern id newTab(void *);
|
extern id newTab(void);
|
||||||
extern void tabAppend(id, char *, id);
|
extern void tabAppend(id, char *, id);
|
||||||
|
|
||||||
/* table_darwin.m */
|
/* table_darwin.m */
|
||||||
|
|
|
@ -15,9 +15,9 @@ type tab struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTab() Tab {
|
func newTab() Tab {
|
||||||
t := new(tab)
|
return &tab{
|
||||||
t._id = C.newTab(unsafe.Pointer(t))
|
_id: C.newTab(),
|
||||||
return t
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tab) Append(name string, control Control) {
|
func (t *tab) Append(name string, control Control) {
|
||||||
|
@ -28,15 +28,6 @@ func (t *tab) Append(name string, control Control) {
|
||||||
C.tabAppend(t._id, cname, c.view)
|
C.tabAppend(t._id, cname, c.view)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export tabResized
|
|
||||||
func tabResized(data unsafe.Pointer, width C.intptr_t, height C.intptr_t) {
|
|
||||||
// t := (*tab)(unsafe.Pointer(data))
|
|
||||||
// for _, c := range t.tabs {
|
|
||||||
// the tab area's coordinate system is localized, so the origin is (0, 0)
|
|
||||||
// c.resize(0, 0, int(width), int(height))
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *tab) id() C.id {
|
func (t *tab) id() C.id {
|
||||||
return t._id
|
return t._id
|
||||||
}
|
}
|
||||||
|
@ -54,7 +45,7 @@ func (t *tab) preferredSize(d *sizing) (width, height int) {
|
||||||
return int(s.width), int(s.height)
|
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
|
// no need to override Control.commitResize() as only prepared the tabbed control; its children will be resized when that one is resized (and NSTabView itself will call setFrame: for us)
|
||||||
func (t *tab) commitResize(a *allocation, d *sizing) {
|
func (t *tab) commitResize(a *allocation, d *sizing) {
|
||||||
basecommitResize(t, a, d)
|
basecommitResize(t, a, d)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,32 +7,12 @@
|
||||||
#define toNSTabView(x) ((NSTabView *) (x))
|
#define toNSTabView(x) ((NSTabView *) (x))
|
||||||
#define toNSView(x) ((NSView *) (x))
|
#define toNSView(x) ((NSView *) (x))
|
||||||
|
|
||||||
@interface goTabView : NSTabView {
|
id newTab(void)
|
||||||
@public
|
|
||||||
void *gotab;
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation goTabView
|
|
||||||
|
|
||||||
- (void)setFrame:(NSRect)r
|
|
||||||
{
|
{
|
||||||
NSRect content;
|
NSTabView *t;
|
||||||
|
|
||||||
[super setFrame:r];
|
t = [[NSTabView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||||
content = [self contentRect];
|
|
||||||
tabResized(self->gotab, (intptr_t) content.size.width, (intptr_t) content.size.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
id newTab(void *gotab)
|
|
||||||
{
|
|
||||||
goTabView *t;
|
|
||||||
|
|
||||||
t = [[goTabView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
|
||||||
setStandardControlFont((id) t); // safe; same selector provided by NSTabView
|
setStandardControlFont((id) t); // safe; same selector provided by NSTabView
|
||||||
t->gotab = gotab;
|
|
||||||
return (id) t;
|
return (id) t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue