Implemented tab disabling on OS X.
This commit is contained in:
parent
7f41a3982f
commit
c6229271cc
57
darwin/tab.m
57
darwin/tab.m
|
@ -1,13 +1,14 @@
|
||||||
// 12 april 2015
|
// 12 april 2015
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// TODO enable/disable
|
|
||||||
|
|
||||||
struct tab {
|
struct tab {
|
||||||
uiTab t;
|
uiTab t;
|
||||||
NSTabView *tabview;
|
NSTabView *tabview;
|
||||||
NSMutableArray *pages;
|
NSMutableArray *pages;
|
||||||
NSMutableArray *margined;
|
NSMutableArray *margined;
|
||||||
|
void (*baseEnable)(uiControl *);
|
||||||
|
void (*baseDisable)(uiControl *);
|
||||||
|
void (*baseSysFunc)(uiControl *, uiControlSysFuncParams *);
|
||||||
};
|
};
|
||||||
|
|
||||||
static void destroy(void *data)
|
static void destroy(void *data)
|
||||||
|
@ -33,7 +34,7 @@ static void destroy(void *data)
|
||||||
|
|
||||||
// the default new control implementation uses -sizeToFit, which we don't have with NSTabView
|
// the default new control implementation uses -sizeToFit, which we don't have with NSTabView
|
||||||
// fortunately, we do have -minimumSize
|
// fortunately, we do have -minimumSize
|
||||||
static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
static void tabPreferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *height)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) c;
|
struct tab *t = (struct tab *) c;
|
||||||
NSSize s;
|
NSSize s;
|
||||||
|
@ -43,6 +44,48 @@ static void preferredSize(uiControl *c, uiSizing *d, intmax_t *width, intmax_t *
|
||||||
*height = (intmax_t) (s.height);
|
*height = (intmax_t) (s.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tabEnable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct tab *t = (struct tab *) c;
|
||||||
|
|
||||||
|
(*(t->baseEnable))(uiControl(t));
|
||||||
|
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||||
|
NSValue *v = (NSValue *) obj;
|
||||||
|
uiContainer *p;
|
||||||
|
|
||||||
|
p = (uiContainer *) [v pointerValue];
|
||||||
|
uiControlEnable(uiControl(p));
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tabDisable(uiControl *c)
|
||||||
|
{
|
||||||
|
struct tab *t = (struct tab *) c;
|
||||||
|
|
||||||
|
(*(t->baseDisable))(uiControl(t));
|
||||||
|
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||||
|
NSValue *v = (NSValue *) obj;
|
||||||
|
uiContainer *p;
|
||||||
|
|
||||||
|
p = (uiContainer *) [v pointerValue];
|
||||||
|
uiControlDisable(uiControl(p));
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tabSysFunc(uiControl *c, uiControlSysFuncParams *p)
|
||||||
|
{
|
||||||
|
struct tab *t = (struct tab *) c;
|
||||||
|
|
||||||
|
(*(t->baseSysFunc))(uiControl(t), p);
|
||||||
|
[t->pages enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) {
|
||||||
|
NSValue *v = (NSValue *) obj;
|
||||||
|
uiContainer *pp;
|
||||||
|
|
||||||
|
pp = (uiContainer *) [v pointerValue];
|
||||||
|
uiControlSysFunc(uiControl(pp), p);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
|
static void tabAppendPage(uiTab *tt, const char *name, uiControl *child)
|
||||||
{
|
{
|
||||||
struct tab *t = (struct tab *) tt;
|
struct tab *t = (struct tab *) tt;
|
||||||
|
@ -143,7 +186,13 @@ uiTab *uiNewTab(void)
|
||||||
t->pages = [NSMutableArray new];
|
t->pages = [NSMutableArray new];
|
||||||
t->margined = [NSMutableArray new];
|
t->margined = [NSMutableArray new];
|
||||||
|
|
||||||
uiControl(t)->PreferredSize = preferredSize;
|
uiControl(t)->PreferredSize = tabPreferredSize;
|
||||||
|
t->baseEnable = uiControl(t)->Enable;
|
||||||
|
uiControl(t)->Enable = tabEnable;
|
||||||
|
t->baseDisable = uiControl(t)->Disable;
|
||||||
|
uiControl(t)->Disable = tabDisable;
|
||||||
|
t->baseSysFunc = uiControl(t)->SysFunc;
|
||||||
|
uiControl(t)->SysFunc = tabSysFunc;
|
||||||
|
|
||||||
uiTab(t)->AppendPage = tabAppendPage;
|
uiTab(t)->AppendPage = tabAppendPage;
|
||||||
uiTab(t)->DeletePage = tabDeletePage;
|
uiTab(t)->DeletePage = tabDeletePage;
|
||||||
|
|
Loading…
Reference in New Issue