From 4a9d0081a39964c648a2dbbeacc256637fbf8e5f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 16 Aug 2015 23:44:23 -0400 Subject: [PATCH] Other build issues fixed. Now for other issues. --- redo/reredo/control.c | 2 +- redo/reredo/darwin/combobox.m | 6 +++--- redo/reredo/darwin/control.m | 2 +- redo/reredo/darwin/datetimepicker.m | 2 +- redo/reredo/darwin/entry.m | 7 ++++++- redo/reredo/darwin/label.m | 2 +- redo/reredo/darwin/menu.m | 10 ++++++---- redo/reredo/darwin/progressbar.m | 2 +- redo/reredo/darwin/slider.m | 2 +- redo/reredo/darwin/spinbox.m | 4 ++-- redo/reredo/darwin/tab.m | 7 ++++--- redo/reredo/darwin/uipriv_darwin.h | 2 +- redo/reredo/darwin/util.m | 24 ------------------------ redo/reredo/darwin/window.m | 6 +++--- redo/reredo/menu.c | 4 ++-- redo/reredo/test/test.h | 2 +- redo/reredo/ui.h | 12 ++++++------ 17 files changed, 40 insertions(+), 56 deletions(-) diff --git a/redo/reredo/control.c b/redo/reredo/control.c index c2acf1dc..2c81d9d0 100644 --- a/redo/reredo/control.c +++ b/redo/reredo/control.c @@ -10,7 +10,7 @@ struct controlBase { static uintmax_t type_uiControl = 0; -uintmax_t uiTypeControl(void) +uintmax_t uiControlType(void) { if (type_uiControl == 0) type_uiControl = uiRegisterType("uiControl", 0, sizeof (uiControl)); diff --git a/redo/reredo/darwin/combobox.m b/redo/reredo/darwin/combobox.m index 926a64ea..d4049b9c 100644 --- a/redo/reredo/darwin/combobox.m +++ b/redo/reredo/darwin/combobox.m @@ -6,7 +6,7 @@ struct uiCombobox { BOOL editable; NSPopUpButton *pb; NSComboBox *cb; - uintptr_t handle; // for uiControlHandle() + NSObject *handle; // for uiControlHandle() }; uiDarwinDefineControl( @@ -33,13 +33,13 @@ static uiCombobox *finishNewCombobox(BOOL editable) [c->cb setButtonBordered:YES]; [c->cb setCompletes:NO]; uiDarwinSetControlFont(c->cb, NSRegularControlSize); - c->handle = (uintptr_t) (c->cb); + c->handle = c->cb; } else { c->pb = [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO]; // TODO preferred edge // TODO arrow position // TODO font - c->handle = (uintptr_t) (c->pb); + c->handle = c->pb; } uiDarwinFinishNewControl(c, uiCombobox); diff --git a/redo/reredo/darwin/control.m b/redo/reredo/darwin/control.m index 0c3703e6..1a6ab658 100644 --- a/redo/reredo/darwin/control.m +++ b/redo/reredo/darwin/control.m @@ -3,7 +3,7 @@ static uintmax_t type_uiDarwinControl = 0; -uintmax_t uiTypeMenu(void) +uintmax_t uiDarwinControlType(void) { if (type_uiDarwinControl == 0) type_uiDarwinControl = uiRegisterType("uiDarwinControl", uiControlType(), sizeof (uiDarwinControl)); diff --git a/redo/reredo/darwin/datetimepicker.m b/redo/reredo/darwin/datetimepicker.m index 35e42b54..ee755eec 100644 --- a/redo/reredo/darwin/datetimepicker.m +++ b/redo/reredo/darwin/datetimepicker.m @@ -8,7 +8,7 @@ struct uiDateTimePicker { uiDarwinDefineControl( uiDateTimePicker, // type name - uiDaateTimePickerType, // type function + uiDateTimePickerType, // type function dp // handle ) diff --git a/redo/reredo/darwin/entry.m b/redo/reredo/darwin/entry.m index b7d5868a..7a5b8ecd 100644 --- a/redo/reredo/darwin/entry.m +++ b/redo/reredo/darwin/entry.m @@ -51,7 +51,7 @@ struct uiEntry { { [self->entries setObject:[NSValue valueWithPointer:e] forKey:e->textfield]; - [e->entry setDelegate:self]; + [e->textfield setDelegate:self]; } - (void)unregisterEntry:(uiEntry *)e @@ -119,6 +119,11 @@ void finishNewTextField(NSTextField *t, BOOL isEntry) [[t cell] setScrollable:YES]; } +static void defaultOnChanged(uiEntry *e, void *data) +{ + // do nothing +} + uiEntry *uiNewEntry(void) { uiEntry *e; diff --git a/redo/reredo/darwin/label.m b/redo/reredo/darwin/label.m index ae0f303c..bc8f1506 100644 --- a/redo/reredo/darwin/label.m +++ b/redo/reredo/darwin/label.m @@ -12,7 +12,7 @@ uiDarwinDefineControl( textfield // handle ) -char *uiLabelText(uiLabel *ll) +char *uiLabelText(uiLabel *l) { return uiDarwinNSStringToText([l->textfield stringValue]); } diff --git a/redo/reredo/darwin/menu.m b/redo/reredo/darwin/menu.m index 783cc1da..d007b705 100644 --- a/redo/reredo/darwin/menu.m +++ b/redo/reredo/darwin/menu.m @@ -5,12 +5,14 @@ static NSMutableArray *menus = nil; static BOOL menusFinalized = NO; struct uiMenu { + uiTyped t; NSMenu *menu; NSMenuItem *item; NSMutableArray *items; }; struct uiMenuItem { + uiTyped t; NSMenuItem *item; int type; BOOL disabled; @@ -219,7 +221,7 @@ int uiMenuItemChecked(uiMenuItem *item) return [item->item state] != NSOffState; } -void menuItemSetChecked(uiMenuItem *item, int checked) +void uiMenuItemSetChecked(uiMenuItem *item, int checked) { NSInteger state; @@ -237,7 +239,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name) complain("attempt to create a new menu item after menus have been finalized"); item = uiNew(uiMenuItem); - uiTyped(item)->Type = uiTypeMenuItem(); + uiTyped(item)->Type = uiMenuItemType(); item->type = type; switch (item->type) { @@ -288,7 +290,7 @@ uiMenuItem *uiMenuAppendQuitItem(uiMenu *m) uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m) { // duplicate check is in the register:to: selector - return newItem(mm, typePreferences, NULL); + return newItem(m, typePreferences, NULL); } uiMenuItem *uiMenuAppendAboutItem(uiMenu *m) @@ -312,7 +314,7 @@ uiMenu *uiNewMenu(const char *name) menus = [NSMutableArray new]; m = uiNew(uiMenu); - uiTyped(m)->Type = uiTypeMenu(); + uiTyped(m)->Type = uiMenuType(); m->menu = [[NSMenu alloc] initWithTitle:toNSString(name)]; // use automatic menu item enabling for all menus for consistency's sake diff --git a/redo/reredo/darwin/progressbar.m b/redo/reredo/darwin/progressbar.m index d069d70b..e8f505d6 100644 --- a/redo/reredo/darwin/progressbar.m +++ b/redo/reredo/darwin/progressbar.m @@ -12,7 +12,7 @@ uiDarwinDefineControl( pi // handle ) -void uiProgressbarSetValue(uiProgressBar *p, int value) +void uiProgressBarSetValue(uiProgressBar *p, int value) { if (value < 0 || value > 100) complain("value %d out of range in progressbarSetValue()", value); diff --git a/redo/reredo/darwin/slider.m b/redo/reredo/darwin/slider.m index b31ff724..29769373 100644 --- a/redo/reredo/darwin/slider.m +++ b/redo/reredo/darwin/slider.m @@ -3,7 +3,7 @@ // TODO events -type uiSlider { +struct uiSlider { uiDarwinControl c; NSSlider *slider; void (*onChanged)(uiSlider *, void *); diff --git a/redo/reredo/darwin/spinbox.m b/redo/reredo/darwin/spinbox.m index b6555766..c541ced1 100644 --- a/redo/reredo/darwin/spinbox.m +++ b/redo/reredo/darwin/spinbox.m @@ -35,7 +35,7 @@ static void defaultOnChanged(uiSpinbox *s, void *data) // do nothing } -uiSpinbox *uiNewSpinbox(void) +uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) { uiSpinbox *s; @@ -44,7 +44,7 @@ uiSpinbox *uiNewSpinbox(void) s->dummy = [[NSTextField alloc] initWithFrame:NSZeroRect]; [s->dummy setStringValue:@"TODO uiSpinbox not implemented"]; - uiSpinboxSetOnChanged(s, defaultOnChanged, NULL); + uiSpinboxOnChanged(s, defaultOnChanged, NULL); uiDarwinFinishNewControl(s, uiSpinbox); diff --git a/redo/reredo/darwin/tab.m b/redo/reredo/darwin/tab.m index e155b7ce..dfb59efa 100644 --- a/redo/reredo/darwin/tab.m +++ b/redo/reredo/darwin/tab.m @@ -60,7 +60,7 @@ void uiTabInsertAt(uiTab *t, const char *name, uintmax_t n, uiControl *child) [view addSubview:childView]; layoutSingleView(view, childView, 0); - [t->pages insertObject:[NSValue valueWithPointer:page] atIndex:n]; + [t->pages insertObject:[NSValue valueWithPointer:child] atIndex:n]; [t->views insertObject:view atIndex:n]; [t->margined insertObject:[NSNumber numberWithInt:0] atIndex:n]; @@ -86,13 +86,13 @@ void uiTabDelete(uiTab *t, uintmax_t n) childView = (NSView *) uiControlHandle(child); [childView removeFromSuperview]; - uiControlSetParent(childView, NULL); + uiControlSetParent(child, NULL); i = [t->tabview tabViewItemAtIndex:n]; [t->tabview removeTabViewItem:i]; } -uintmax_t uITabNumPages(uiTab *t) +uintmax_t uiTabNumPages(uiTab *t) { return [t->pages count]; } @@ -108,6 +108,7 @@ int uiTabMargined(uiTab *t, uintmax_t n) void uiTabSetMargined(uiTab *t, uintmax_t n, int margined) { NSNumber *v; + NSView *view; NSValue *childv; uiControl *child; NSView *childView; diff --git a/redo/reredo/darwin/uipriv_darwin.h b/redo/reredo/darwin/uipriv_darwin.h index f2fe7796..e69b1d32 100644 --- a/redo/reredo/darwin/uipriv_darwin.h +++ b/redo/reredo/darwin/uipriv_darwin.h @@ -41,7 +41,7 @@ extern void uninitMenus(void); extern void disableAutocorrect(NSTextView *); // entry.m -extern void finishNewTextField(uiControl *, NSTextField *, BOOL); +extern void finishNewTextField(NSTextField *, BOOL); // window.m extern uiWindow *windowFromNSWindow(NSWindow *); diff --git a/redo/reredo/darwin/util.m b/redo/reredo/darwin/util.m index 2eb9ea7e..84823829 100644 --- a/redo/reredo/darwin/util.m +++ b/redo/reredo/darwin/util.m @@ -24,27 +24,3 @@ void complain(const char *fmt, ...) va_end(ap); abort(); } - -// These are based on measurements from Interface Builder. -// These seem to be based on Auto Layout constants, but I don't see an API that exposes these... -// This one is 8 for most pairs of controls that I've tried; the only difference is between two pushbuttons, where it's 12... -#define macXPadding 8 -// Likewise, this one appears to be 12 for pairs of push buttons... -#define macYPadding 8 - -uiSizing *uiDarwinNewSizing(void) -{ - uiSizing *d; - - d = uiNew(uiSizing); - d->XPadding = macXPadding; - d->YPadding = macYPadding; - d->Sys = uiNew(uiSizingSys); - return d; -} - -void uiFreeSizing(uiSizing *d) -{ - uiFree(d->Sys); - uiFree(d); -} diff --git a/redo/reredo/darwin/window.m b/redo/reredo/darwin/window.m index acaca20e..e2076c0f 100644 --- a/redo/reredo/darwin/window.m +++ b/redo/reredo/darwin/window.m @@ -78,7 +78,7 @@ static windowDelegateClass *windowDelegate = nil; static void onDestroy(uiWindow *); -uiDarwinDefineControl( +uiDarwinDefineControlWithOnDestroy( uiWindow, // type name uiWindowType, // type function window, // handle @@ -198,8 +198,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) uiWindowOnClosing(w, defaultOnClosing, NULL); uiDarwinFinishNewControl(w, uiWindow); - uiControl(w)->CommitShow = windowCommitShow; - uiControl(w)->CommitHide = windowCommitHide; +//TODO uiControl(w)->CommitShow = windowCommitShow; +//TODO uiControl(w)->CommitHide = windowCommitHide; return w; } diff --git a/redo/reredo/menu.c b/redo/reredo/menu.c index 917e4eaf..cc216cb7 100644 --- a/redo/reredo/menu.c +++ b/redo/reredo/menu.c @@ -4,14 +4,14 @@ static uintmax_t type_uiMenu = 0; static uintmax_t type_uiMenuItem = 0; -uintmax_t uiTypeMenu(void) +uintmax_t uiMenuType(void) { if (type_uiMenu == 0) type_uiMenu = uiRegisterType("uiMenu", 0, 0); return type_uiMenu; } -uintmax_t uiTypeMenuItem(void) +uintmax_t uiMenuItemType(void) { if (type_uiMenuItem == 0) type_uiMenuItem = uiRegisterType("uiMenuItem", 0, 0); diff --git a/redo/reredo/test/test.h b/redo/reredo/test/test.h index 764656b0..9e422e9e 100644 --- a/redo/reredo/test/test.h +++ b/redo/reredo/test/test.h @@ -4,7 +4,7 @@ #include #include #include -#include "../out/ui.h" +#include "../ui.h" // main.c extern void die(const char *, ...); diff --git a/redo/reredo/ui.h b/redo/reredo/ui.h index f2d698f8..1f6cc059 100644 --- a/redo/reredo/ui.h +++ b/redo/reredo/ui.h @@ -191,7 +191,7 @@ _UI_EXTERN uiSlider *uiNewSlider(intmax_t min, intmax_t max); typedef struct uiSeparator uiSeparator; _UI_EXTERN uintmax_t uiSeparatorType(void); #define uiSeparator(this) ((uiSeparator *) uiIsA((this), uiSeparatorType(), 1)) -_UI_EXTERN uiSeparator *NewHorizontalSeparator(void); +_UI_EXTERN uiSeparator *uiNewHorizontalSeparator(void); typedef struct uiCombobox uiCombobox; _UI_EXTERN uintmax_t uiComboboxType(void); @@ -217,7 +217,7 @@ typedef struct uiMenu uiMenu; typedef struct uiMenuItem uiMenuItem; _UI_EXTERN uintmax_t uiMenuType(void); #define uiMenu(this) ((uiMenu *) uiIsA((this), uiMenuType(), 1)) -_UI_EXTERN uiMenuItem *uiMenuAppendItem(uiMenu *m, char *name); +_UI_EXTERN uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name); _UI_EXTERN uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name); _UI_EXTERN uiMenuItem *uiMenuAppendQuitItem(uiMenu *m); _UI_EXTERN uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m); @@ -233,9 +233,9 @@ _UI_EXTERN void uiMenuItemOnClicked(uiMenuItem *m, void (*f)(uiMenuItem *sender, _UI_EXTERN int uiMenuItemChecked(uiMenuItem *m); _UI_EXTERN void uiMenuItemSetChecked(uiMenuItem *m, int checked); -_UI_EXTERN char *OpenFile(void); -_UI_EXTERN char *SaveFile(void); -_UI_EXTERN void MsgBox(const char *title, const char *description); -_UI_EXTERN void MsgBoxError(const char *title, const char *description); +_UI_EXTERN char *uiOpenFile(void); +_UI_EXTERN char *uiSaveFile(void); +_UI_EXTERN void uiMsgBox(const char *title, const char *description); +_UI_EXTERN void uiMsgBoxError(const char *title, const char *description); #endif