diff --git a/darwin/OLD_uipriv_darwin.h b/darwin/OLD_uipriv_darwin.h index c45e450f..3cc41922 100644 --- a/darwin/OLD_uipriv_darwin.h +++ b/darwin/OLD_uipriv_darwin.h @@ -1,13 +1,4 @@ -#define toNSString(str) [NSString stringWithUTF8String:(str)] -#define fromNSString(str) [(str) UTF8String] - -#ifndef NSAppKitVersionNumber10_9 -#define NSAppKitVersionNumber10_9 1265 -#endif - -/*TODO remove this*/typedef struct uiImage uiImage; - // menu.m @interface menuManager : NSObject { struct mapTable *items; diff --git a/darwin/button.m b/darwin/button.m index baccabbb..8e3fa51b 100644 --- a/darwin/button.m +++ b/darwin/button.m @@ -75,7 +75,7 @@ char *uiButtonText(uiButton *b) void uiButtonSetText(uiButton *b, const char *text) { - [b->button setTitle:toNSString(text)]; + [b->button setTitle:uiprivToNSString(text)]; } void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data) @@ -96,7 +96,7 @@ uiButton *uiNewButton(const char *text) uiDarwinNewControl(uiButton, b); b->button = [[NSButton alloc] initWithFrame:NSZeroRect]; - [b->button setTitle:toNSString(text)]; + [b->button setTitle:uiprivToNSString(text)]; [b->button setButtonType:NSMomentaryPushInButton]; [b->button setBordered:YES]; [b->button setBezelStyle:NSRoundedBezelStyle]; diff --git a/darwin/checkbox.m b/darwin/checkbox.m index dd1ce093..124258cd 100644 --- a/darwin/checkbox.m +++ b/darwin/checkbox.m @@ -75,7 +75,7 @@ char *uiCheckboxText(uiCheckbox *c) void uiCheckboxSetText(uiCheckbox *c, const char *text) { - [c->button setTitle:toNSString(text)]; + [c->button setTitle:uiprivToNSString(text)]; } void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *, void *), void *data) @@ -111,7 +111,7 @@ uiCheckbox *uiNewCheckbox(const char *text) uiDarwinNewControl(uiCheckbox, c); c->button = [[NSButton alloc] initWithFrame:NSZeroRect]; - [c->button setTitle:toNSString(text)]; + [c->button setTitle:uiprivToNSString(text)]; [c->button setButtonType:NSSwitchButton]; // doesn't seem to have an associated bezel style [c->button setBordered:NO]; diff --git a/darwin/combobox.m b/darwin/combobox.m index 89a2e28c..c282a2fc 100644 --- a/darwin/combobox.m +++ b/darwin/combobox.m @@ -78,7 +78,7 @@ static void uiComboboxDestroy(uiControl *cc) void uiComboboxAppend(uiCombobox *c, const char *text) { - [c->pbac addObject:toNSString(text)]; + [c->pbac addObject:uiprivToNSString(text)]; } int uiComboboxSelected(uiCombobox *c) diff --git a/darwin/editablecombo.m b/darwin/editablecombo.m index 434add70..d7f6c7e1 100644 --- a/darwin/editablecombo.m +++ b/darwin/editablecombo.m @@ -106,7 +106,7 @@ static void uiEditableComboboxDestroy(uiControl *cc) void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text) { - [c->cb addItemWithObjectValue:toNSString(text)]; + [c->cb addItemWithObjectValue:uiprivToNSString(text)]; } char *uiEditableComboboxText(uiEditableCombobox *c) @@ -118,7 +118,7 @@ void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text) { NSString *t; - t = toNSString(text); + t = uiprivToNSString(text); [c->cb setStringValue:t]; // yes, let's imitate the behavior that caused uiEditableCombobox to be separate in the first place! // just to avoid confusion when users see an option in the list in the text field but not selected in the list diff --git a/darwin/entry.m b/darwin/entry.m index 219d0805..821515b3 100644 --- a/darwin/entry.m +++ b/darwin/entry.m @@ -145,7 +145,7 @@ char *uiEntryText(uiEntry *e) void uiEntrySetText(uiEntry *e, const char *text) { - [e->textfield setStringValue:toNSString(text)]; + [e->textfield setStringValue:uiprivToNSString(text)]; // don't queue the control for resize; entry sizes are independent of their contents } diff --git a/darwin/form.m b/darwin/form.m index 613818a9..f9b9b2a8 100644 --- a/darwin/form.m +++ b/darwin/form.m @@ -531,7 +531,7 @@ void uiFormAppend(uiForm *f, const char *label, uiControl *c, int stretchy) // or at leat allow this and implicitly turn it into a spacer if (c == NULL) uiprivUserBug("You cannot add NULL to a uiForm."); - [f->view append:toNSString(label) c:c stretchy:stretchy]; + [f->view append:uiprivToNSString(label) c:c stretchy:stretchy]; } void uiFormDelete(uiForm *f, int n) diff --git a/darwin/group.m b/darwin/group.m index 0050bbdd..9c5824a7 100644 --- a/darwin/group.m +++ b/darwin/group.m @@ -131,7 +131,7 @@ char *uiGroupTitle(uiGroup *g) void uiGroupSetTitle(uiGroup *g, const char *title) { - [g->box setTitle:toNSString(title)]; + [g->box setTitle:uiprivToNSString(title)]; } void uiGroupSetChild(uiGroup *g, uiControl *child) @@ -178,7 +178,7 @@ uiGroup *uiNewGroup(const char *title) uiDarwinNewControl(uiGroup, g); g->box = [[NSBox alloc] initWithFrame:NSZeroRect]; - [g->box setTitle:toNSString(title)]; + [g->box setTitle:uiprivToNSString(title)]; [g->box setBoxType:NSBoxPrimary]; [g->box setBorderType:NSLineBorder]; [g->box setTransparent:NO]; diff --git a/darwin/label.m b/darwin/label.m index 897bc3ff..c06cb24a 100644 --- a/darwin/label.m +++ b/darwin/label.m @@ -15,7 +15,7 @@ char *uiLabelText(uiLabel *l) void uiLabelSetText(uiLabel *l, const char *text) { - [l->textfield setStringValue:toNSString(text)]; + [l->textfield setStringValue:uiprivToNSString(text)]; } NSTextField *newLabel(NSString *str) @@ -37,7 +37,7 @@ uiLabel *uiNewLabel(const char *text) uiDarwinNewControl(uiLabel, l); - l->textfield = newLabel(toNSString(text)); + l->textfield = newLabel(uiprivToNSString(text)); return l; } diff --git a/darwin/menu.m b/darwin/menu.m index 79adbae6..aba63d2e 100644 --- a/darwin/menu.m +++ b/darwin/menu.m @@ -259,7 +259,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name) [m->menu addItem:item->item]; break; default: - item->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:@selector(onClicked:) keyEquivalent:@""]; + item->item = [[NSMenuItem alloc] initWithTitle:uiprivToNSString(name) action:@selector(onClicked:) keyEquivalent:@""]; [item->item setTarget:appDelegate().menuManager]; [m->menu addItem:item->item]; break; @@ -321,10 +321,10 @@ uiMenu *uiNewMenu(const char *name) m = uiprivNew(uiMenu); - m->menu = [[NSMenu alloc] initWithTitle:toNSString(name)]; + m->menu = [[NSMenu alloc] initWithTitle:uiprivToNSString(name)]; // use automatic menu item enabling for all menus for consistency's sake - m->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:NULL keyEquivalent:@""]; + m->item = [[NSMenuItem alloc] initWithTitle:uiprivToNSString(name) action:NULL keyEquivalent:@""]; [m->item setSubmenu:m->menu]; m->items = [NSMutableArray new]; diff --git a/darwin/multilineentry.m b/darwin/multilineentry.m index 605e9004..fdd7cf11 100644 --- a/darwin/multilineentry.m +++ b/darwin/multilineentry.m @@ -78,7 +78,7 @@ char *uiMultilineEntryText(uiMultilineEntry *e) void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text) { [[e->tv textStorage] replaceCharactersInRange:NSMakeRange(0, [[e->tv string] length]) - withString:toNSString(text)]; + withString:uiprivToNSString(text)]; // must be called explicitly according to the documentation of shouldChangeTextInRange:replacementString: e->changing = YES; [e->tv didChangeText]; @@ -89,7 +89,7 @@ void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text) void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text) { [[e->tv textStorage] replaceCharactersInRange:NSMakeRange([[e->tv string] length], 0) - withString:toNSString(text)]; + withString:uiprivToNSString(text)]; e->changing = YES; [e->tv didChangeText]; e->changing = NO; diff --git a/darwin/radiobuttons.m b/darwin/radiobuttons.m index 25d773c9..986c477d 100644 --- a/darwin/radiobuttons.m +++ b/darwin/radiobuttons.m @@ -87,7 +87,7 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text) NSLayoutConstraint *constraint; b = [[NSButton alloc] initWithFrame:NSZeroRect]; - [b setTitle:toNSString(text)]; + [b setTitle:uiprivToNSString(text)]; [b setButtonType:NSRadioButton]; // doesn't seem to have an associated bezel style [b setBordered:NO]; diff --git a/darwin/stddialogs.m b/darwin/stddialogs.m index 57ce9596..be7e2dd6 100644 --- a/darwin/stddialogs.m +++ b/darwin/stddialogs.m @@ -103,8 +103,8 @@ static void msgbox(NSWindow *parent, const char *title, const char *description, [a setAlertStyle:style]; [a setShowsHelp:NO]; [a setShowsSuppressionButton:NO]; - [a setMessageText:toNSString(title)]; - [a setInformativeText:toNSString(description)]; + [a setMessageText:uiprivToNSString(title)]; + [a setInformativeText:uiprivToNSString(description)]; [a addButtonWithTitle:@"OK"]; cm = [[libuiCodeModalAlertPanel alloc] initWithPanel:a parent:parent]; [cm run]; diff --git a/darwin/tab.m b/darwin/tab.m index 3d2ca9f0..4ca2bec3 100644 --- a/darwin/tab.m +++ b/darwin/tab.m @@ -220,7 +220,7 @@ void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child) [t->pages insertObject:page atIndex:n]; i = [[[NSTabViewItem alloc] initWithIdentifier:pageID] autorelease]; - [i setLabel:toNSString(name)]; + [i setLabel:uiprivToNSString(name)]; [i setView:view]; [t->tabview insertTabViewItem:i atIndex:n]; diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index 6b8c1179..33e7e486 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -12,4 +12,14 @@ #error Sorry, libui cannot be compiled with ARC. #endif +#define uiprivToNSString(str) [NSString stringWithUTF8String:(str)] +#define uiprivFromNSString(str) [(str) UTF8String] + +// TODO find a better place for this +#ifndef NSAppKitVersionNumber10_9 +#define NSAppKitVersionNumber10_9 1265 +#endif + +/*TODO remove this*/typedef struct uiImage uiImage; + #import "OLD_uipriv_darwin.h" diff --git a/darwin/window.m b/darwin/window.m index 97c22e62..cf14a1f5 100644 --- a/darwin/window.m +++ b/darwin/window.m @@ -252,7 +252,7 @@ char *uiWindowTitle(uiWindow *w) void uiWindowSetTitle(uiWindow *w, const char *title) { - [w->window setTitle:toNSString(title)]; + [w->window setTitle:uiprivToNSString(title)]; } void uiWindowContentSize(uiWindow *w, int *width, int *height) @@ -379,7 +379,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) styleMask:defaultStyleMask backing:NSBackingStoreBuffered defer:YES]; - [w->window setTitle:toNSString(title)]; + [w->window setTitle:uiprivToNSString(title)]; // do NOT release when closed // we manually do this in uiWindowDestroy() above