Started establishing a tabPage for uiTab on OS X. The constraints code was added now, I guess.
This commit is contained in:
parent
7d874ee911
commit
1f96ee9b54
81
darwin/tab.m
81
darwin/tab.m
|
@ -1,23 +1,88 @@
|
||||||
// 15 august 2015
|
// 15 august 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// TODO for this and group, make sure simply relaying ourselves out is enough (are the buttons and title, respectively, intrinsic?)
|
@interface tabPage : NSObject {
|
||||||
|
struct singleChildConstraints constraints;
|
||||||
|
int margined;
|
||||||
|
NSView *view; // the NSTabViewItem view itself
|
||||||
|
NSObject *pageID;
|
||||||
|
}
|
||||||
|
@property uiControl *c;
|
||||||
|
- (id)initWithView:(NSView *)v pageID:(NSObject *)o;
|
||||||
|
- (NSView *)childView;
|
||||||
|
- (void)establishChildConstraints;
|
||||||
|
- (void)removeChildConstraints;
|
||||||
|
- (int)isMargined;
|
||||||
|
- (void)setMargined:(int)m;
|
||||||
|
@end
|
||||||
|
|
||||||
struct uiTab {
|
struct uiTab {
|
||||||
uiDarwinControl c;
|
uiDarwinControl c;
|
||||||
NSTabView *tabview;
|
NSTabView *tabview;
|
||||||
// TODO either rename all uses of child to page or rename this to children
|
NSMutableArray *pages;
|
||||||
NSMutableArray *pages; // []NSValue<uiControl *>
|
|
||||||
// the views that contain the children's views
|
|
||||||
// these are the views that are assigned to each NSTabViewItem
|
|
||||||
NSMutableArray *views; // []NSView
|
|
||||||
NSMutableArray *margined; // []NSNumber
|
|
||||||
NSMutableArray *pageIDs; // []NSObject
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@implementation tabPage
|
||||||
|
|
||||||
|
- (id)initWithView:(NSView *)v pageID:(NSObject *o)
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil) {
|
||||||
|
self->view = v;
|
||||||
|
self->pageID = o;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
[self removeChildConstraints];
|
||||||
|
[self->view release];
|
||||||
|
[self->pageID release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSView *)childView
|
||||||
|
{
|
||||||
|
return (NSView *) uiControlHandle(self.c);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)establishChildConstraints
|
||||||
|
{
|
||||||
|
[self removeChildConstraints]
|
||||||
|
if (self.c == NULL)
|
||||||
|
return;
|
||||||
|
singleChildConstraintsEstablish(&(self->constraints),
|
||||||
|
self->view, [self childView],
|
||||||
|
uiDarwinControlHugsTrailingEdge(uiDarwinControl(self.c)),
|
||||||
|
uiDarwinControlHugsBottom(uiDarwinControl(self.c)),
|
||||||
|
self->margined,
|
||||||
|
@"uiTab page");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)removeChildConstraints
|
||||||
|
{
|
||||||
|
singleChildConstraintsRemove(&(self->constraints), self->view);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (int)isMargined
|
||||||
|
{
|
||||||
|
return self->margined;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setMargined:(int)m
|
||||||
|
{
|
||||||
|
self->margined = m;
|
||||||
|
singleChildConstraintsSetMargined(&(self->constraints), self->margined);
|
||||||
|
// TODO issue a relayout command?
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
static void uiTabDestroy(uiControl *c)
|
static void uiTabDestroy(uiControl *c)
|
||||||
{
|
{
|
||||||
uiTab *t = uiTab(c);
|
uiTab *t = uiTab(c);
|
||||||
|
tabPage *page;
|
||||||
|
|
||||||
// first remove all tab pages so we can destroy all the children
|
// first remove all tab pages so we can destroy all the children
|
||||||
while ([t->tabview numberOfTabViewItems] != 0)
|
while ([t->tabview numberOfTabViewItems] != 0)
|
||||||
|
|
Loading…
Reference in New Issue