From d0d0efce1ae1d2c106e115f440bde5e921af2fcb Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 25 Apr 2016 13:38:17 -0400 Subject: [PATCH] Fixed build errors. Now to test! --- common/control.c | 1 - darwin/box.m | 4 ++-- darwin/combobox.m | 2 +- darwin/control.m | 4 ++-- darwin/entry.m | 2 +- darwin/group.m | 13 ++++++------- darwin/separator.m | 2 +- darwin/tab.m | 7 +++---- darwin/uipriv_darwin.h | 3 +++ darwin/window.m | 11 +++++------ ui.h | 3 ++- ui_darwin.h | 8 ++++---- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/common/control.c b/common/control.c index 2c515693..04a81289 100644 --- a/common/control.c +++ b/common/control.c @@ -72,7 +72,6 @@ uiControl *uiAllocControl(size_t size, uint32_t OSsig, uint32_t typesig, const c c->Signature = uiControlSignature; c->OSSignature = OSsig; c->TypeSignature = typesig; - c->Internal = uiNew(struct controlBase); return c; } diff --git a/darwin/box.m b/darwin/box.m index 68746856..de7c4657 100644 --- a/darwin/box.m +++ b/darwin/box.m @@ -138,7 +138,7 @@ static void relayout(uiBox *b) cc = uiDarwinControl(child); childView = (NSView *) uiControlHandle(child); [views setObject:childView forKey:viewName(n)]; - (*(cc->Relayout))(cc); +//TODO (*(cc->Relayout))(cc); fittingSize = fittingAlignmentSize(childView); [metrics setObject:[NSNumber numberWithDouble:fittingSize.width] forKey:widthMetricName(n)]; @@ -228,7 +228,7 @@ void uiBoxAppend(uiBox *b, uiControl *c, int stretchy) [b->stretchy addObject:[NSNumber numberWithInt:stretchy]]; uiControlSetParent(c, uiControl(b)); - uiControlSetSuperview(c, b->view); + uiDarwinControlSetSuperview(uiDarwinControl(c), b->view); uiControlSyncEnableState(c, uiControlEnabledToUser(uiControl(b))); // TODO save the old hugging priorities diff --git a/darwin/combobox.m b/darwin/combobox.m index 4eb8a4a3..9f63157a 100644 --- a/darwin/combobox.m +++ b/darwin/combobox.m @@ -27,7 +27,7 @@ struct uiCombobox { NSPopUpButton *pb; NSArrayController *pbac; NSComboBox *cb; - NSObject *handle; // for uiControlHandle() + NSView *handle; // for uiControlHandle() void (*onSelected)(uiCombobox *, void *); void *onSelectedData; }; diff --git a/darwin/control.m b/darwin/control.m index 36d40945..fd46a66b 100644 --- a/darwin/control.m +++ b/darwin/control.m @@ -1,7 +1,7 @@ // 16 august 2015 #import "uipriv_darwin.h" -void uiDarwinControlSetSuperview(uiControl *c, NSView *superview) +void uiDarwinControlSetSuperview(uiDarwinControl *c, NSView *superview) { (*(c->SetSuperview))(c, superview); } @@ -13,7 +13,7 @@ void uiDarwinSetControlFont(NSControl *c, NSControlSize size) #define uiDarwinControlSignature 0x44617277 -uiDarwinControl *uiDarwinNewControl(size_t n, uint32_t typesig, const char *typenamestr) +uiDarwinControl *uiDarwinAllocControl(size_t n, uint32_t typesig, const char *typenamestr) { return uiDarwinControl(uiAllocControl(n, uiDarwinControlSignature, typesig, typenamestr)); } diff --git a/darwin/entry.m b/darwin/entry.m index 8121b6db..43f450d4 100644 --- a/darwin/entry.m +++ b/darwin/entry.m @@ -83,7 +83,7 @@ static void uiEntryDestroy(uiControl *c) [entryDelegate unregisterEntry:e]; [e->textfield release]; - uiFreeControl(e); + uiFreeControl(uiControl(e)); } char *uiEntryText(uiEntry *e) diff --git a/darwin/group.m b/darwin/group.m index 5d5a2107..516d9708 100644 --- a/darwin/group.m +++ b/darwin/group.m @@ -31,19 +31,18 @@ uiDarwinControlDefaultEnabled(uiGroup, box) uiDarwinControlDefaultEnable(uiGroup, box) uiDarwinControlDefaultDisable(uiGroup, box) -static void uiBoxSyncEnableState(uiControl *c, int enabled) +static void uiGroupSyncEnableState(uiControl *c, int enabled) { uiGroup *g = uiGroup(c); if (g->child != NULL) - uiControlSyncEnableState(g->child); + uiControlSyncEnableState(g->child, enabled); } uiDarwinControlDefaultSetSuperview(uiGroup, box) -static void groupRelayout(uiDarwinControl *c) +static void groupRelayout(uiGroup *g) { - uiGroup *g = uiGroup(c); uiDarwinControl *cc; NSView *childView; @@ -53,7 +52,7 @@ static void groupRelayout(uiDarwinControl *c) cc = uiDarwinControl(g->child); childView = (NSView *) uiControlHandle(g->child); // first relayout the child - (*(cc->Relayout))(cc); +//TODO (*(cc->Relayout))(cc); // now relayout ourselves // see below on using the content view layoutSingleView(g->box, childView, g->margined); @@ -89,8 +88,8 @@ void uiGroupSetChild(uiGroup *g, uiControl *child) // we have to add controls to the box itself NOT the content view // otherwise, things get really glitchy // we also need to call -sizeToFit, but we'll do that in the relayout that's triggered below (see above) - uiControlSetSuperview(c, g->box); - uiControlSyncEnableState(c, uiControlEnabledToUser(uiControl(g))); + uiDarwinControlSetSuperview(uiDarwinControl(g->child), g->box); + uiControlSyncEnableState(g->child, uiControlEnabledToUser(uiControl(g))); } groupRelayout(g); } diff --git a/darwin/separator.m b/darwin/separator.m index 08368f73..4a5b3431 100644 --- a/darwin/separator.m +++ b/darwin/separator.m @@ -17,7 +17,7 @@ uiSeparator *uiNewHorizontalSeparator(void) { uiSeparator *s; - uiDarwinNewControl(uiSeparator); + uiDarwinNewControl(uiSeparator, s); s->box = [[NSBox alloc] initWithFrame:NSMakeRect(0, 0, separatorFrameWidth, separatorFrameHeight)]; [s->box setBoxType:NSBoxSeparator]; diff --git a/darwin/tab.m b/darwin/tab.m index 60aef3d5..3ad191d9 100644 --- a/darwin/tab.m +++ b/darwin/tab.m @@ -54,9 +54,8 @@ uiDarwinControlDefaultSyncEnableState(uiTab, tabview) uiDarwinControlDefaultSetSuperview(uiTab, tabview) -static void tabRelayout(uiDarwinControl *c) +static void tabRelayout(uiTab *t) { - uiTab *t = uiTab(c); NSUInteger i; if ([t->pages count] == 0) @@ -76,7 +75,7 @@ static void tabRelayout(uiDarwinControl *c) margined = (NSNumber *) [t->margined objectAtIndex:i]; // first lay out the child cc = uiDarwinControl(child); - (*(cc->Relayout))(cc); +//TODO (*(cc->Relayout))(cc); // then lay out the page layoutSingleView(view, childView, [margined intValue]); } @@ -98,7 +97,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) childView = (NSView *) uiControlHandle(child); view = [[NSView alloc] initWithFrame:NSZeroRect]; // TODO if we turn off the autoresizing mask, nothing shows up; didn't this get documented somewhere? - uiControlSetSuperview(child, view); + uiDarwinControlSetSuperview(uiDarwinControl(child), view); uiControlSyncEnableState(child, uiControlEnabledToUser(uiControl(t))); [t->pages insertObject:[NSValue valueWithPointer:child] atIndex:n]; diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index 6774fd33..5c439a0f 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -89,3 +89,6 @@ extern void doDrawText(CGContextRef c, CGFloat cheight, double x, double y, uiDr // fontbutton.m extern BOOL fontButtonInhibitSendAction(SEL sel, id from, id to); extern BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override); + +// MASSIVE TODO +#define uiDarwinControlTriggerRelayout(...) diff --git a/darwin/window.m b/darwin/window.m index eb72f35c..958915af 100644 --- a/darwin/window.m +++ b/darwin/window.m @@ -131,7 +131,7 @@ static void uiWindowSyncEnableState(uiControl *c, int enabled) uiWindow *w = uiWindow(c); if (w->child != NULL) - uiControlSyncUpdateState(w->child, enabled); + uiControlSyncEnableState(w->child, enabled); } static void uiWindowSetSuperview(uiDarwinControl *c, NSView *superview) @@ -139,9 +139,8 @@ static void uiWindowSetSuperview(uiDarwinControl *c, NSView *superview) // TODO } -static void windowRelayout(uiDarwinControl *c) +static void windowRelayout(uiWindow *w) { - uiWindow *w = uiWindow(c); uiDarwinControl *cc; NSView *childView; NSView *contentView; @@ -153,7 +152,7 @@ static void windowRelayout(uiDarwinControl *c) contentView = [w->window contentView]; [contentView removeConstraints:[contentView constraints]]; // first relayout the child - (*(cc->Relayout))(cc); +//TODO (*(cc->Relayout))(cc); // now relayout ourselves layoutSingleView(contentView, childView, w->margined); } @@ -187,8 +186,8 @@ void uiWindowSetChild(uiWindow *w, uiControl *child) if (w->child != NULL) { uiControlSetParent(w->child, uiControl(w)); childView = (NSView *) uiControlHandle(w->child); - uiControlSetSuperview(child, [w->window contentView]); - uiControlSyncEnableState(child, uiControlEnabledToUser(uiControl(w))); + uiDarwinControlSetSuperview(uiDarwinControl(w->child), [w->window contentView]); + uiControlSyncEnableState(w->child, uiControlEnabledToUser(uiControl(w))); } windowRelayout(w); } diff --git a/ui.h b/ui.h index b68ac538..7f1d8863 100644 --- a/ui.h +++ b/ui.h @@ -78,8 +78,9 @@ _UI_EXTERN void uiControlSyncEnableState(uiControl *, int); _UI_EXTERN uiControl *uiAllocControl(size_t n, uint32_t OSsig, uint32_t typesig, const char *typenamestr); _UI_EXTERN void uiFreeControl(uiControl *); +// TODO make sure all controls have these _UI_EXTERN void uiControlVerifyDestroy(uiControl *); -_UI_EXTERN void uiControlVerifySetParent(uiControl *); +_UI_EXTERN void uiControlVerifySetParent(uiControl *, uiControl *); _UI_EXTERN int uiControlEnabledToUser(uiControl *); typedef struct uiWindow uiWindow; diff --git a/ui_darwin.h b/ui_darwin.h index d8ffa0d5..302c64e0 100644 --- a/ui_darwin.h +++ b/ui_darwin.h @@ -68,7 +68,7 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); [type(c)->handlefield setHidden:YES]; \ } #define uiDarwinControlDefaultEnabled(type, handlefield) \ - static int type ## Visible(uiControl *c) \ + static int type ## Enabled(uiControl *c) \ { \ return uiDarwinControl(c)->enabled; \ } @@ -87,8 +87,8 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); #define uiDarwinControlDefaultSyncEnableState(type, handlefield) \ static void type ## SyncEnableState(uiControl *c, int enabled) \ { \ - if ([type(e)->handlefield respondsToSelector:@selector(setEnabled:)]) \ - [type(e)->handlefield setEnabled:enabled]; \ + if ([type(c)->handlefield respondsToSelector:@selector(setEnabled:)]) \ + [((id) type(c)->handlefield) setEnabled:enabled]; /* id cast to make compiler happy; thanks mikeash in irc.freenode.net/#macdev */ \ } #define uiDarwinControlDefaultSetSuperview(type, handlefield) \ static void type ## SetSuperview(uiDarwinControl *c, NSView *superview) \ @@ -120,7 +120,7 @@ _UI_EXTERN void uiDarwinControlSetSuperview(uiDarwinControl *, NSView *); // TODO document #define uiDarwinNewControl(type, var) \ - var = type(uiDarwinNewControl(sizeof (type), type ## Signature, #type)); \ + var = type(uiDarwinAllocControl(sizeof (type), type ## Signature, #type)); \ uiControl(var)->Destroy = type ## Destroy; \ uiControl(var)->Handle = type ## Handle; \ uiControl(var)->Parent = type ## Parent; \