Renamed toNSString() and fromNSString() to uiprivToNSString() and uiprivFromNSString(), respectively.
This commit is contained in:
parent
4fe74fbd56
commit
5a113e1e0b
|
@ -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
|
// menu.m
|
||||||
@interface menuManager : NSObject {
|
@interface menuManager : NSObject {
|
||||||
struct mapTable *items;
|
struct mapTable *items;
|
||||||
|
|
|
@ -75,7 +75,7 @@ char *uiButtonText(uiButton *b)
|
||||||
|
|
||||||
void uiButtonSetText(uiButton *b, const char *text)
|
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)
|
void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data)
|
||||||
|
@ -96,7 +96,7 @@ uiButton *uiNewButton(const char *text)
|
||||||
uiDarwinNewControl(uiButton, b);
|
uiDarwinNewControl(uiButton, b);
|
||||||
|
|
||||||
b->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
b->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
||||||
[b->button setTitle:toNSString(text)];
|
[b->button setTitle:uiprivToNSString(text)];
|
||||||
[b->button setButtonType:NSMomentaryPushInButton];
|
[b->button setButtonType:NSMomentaryPushInButton];
|
||||||
[b->button setBordered:YES];
|
[b->button setBordered:YES];
|
||||||
[b->button setBezelStyle:NSRoundedBezelStyle];
|
[b->button setBezelStyle:NSRoundedBezelStyle];
|
||||||
|
|
|
@ -75,7 +75,7 @@ char *uiCheckboxText(uiCheckbox *c)
|
||||||
|
|
||||||
void uiCheckboxSetText(uiCheckbox *c, const char *text)
|
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)
|
void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *, void *), void *data)
|
||||||
|
@ -111,7 +111,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
||||||
uiDarwinNewControl(uiCheckbox, c);
|
uiDarwinNewControl(uiCheckbox, c);
|
||||||
|
|
||||||
c->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
c->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
||||||
[c->button setTitle:toNSString(text)];
|
[c->button setTitle:uiprivToNSString(text)];
|
||||||
[c->button setButtonType:NSSwitchButton];
|
[c->button setButtonType:NSSwitchButton];
|
||||||
// doesn't seem to have an associated bezel style
|
// doesn't seem to have an associated bezel style
|
||||||
[c->button setBordered:NO];
|
[c->button setBordered:NO];
|
||||||
|
|
|
@ -78,7 +78,7 @@ static void uiComboboxDestroy(uiControl *cc)
|
||||||
|
|
||||||
void uiComboboxAppend(uiCombobox *c, const char *text)
|
void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
{
|
{
|
||||||
[c->pbac addObject:toNSString(text)];
|
[c->pbac addObject:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
int uiComboboxSelected(uiCombobox *c)
|
int uiComboboxSelected(uiCombobox *c)
|
||||||
|
|
|
@ -106,7 +106,7 @@ static void uiEditableComboboxDestroy(uiControl *cc)
|
||||||
|
|
||||||
void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text)
|
void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text)
|
||||||
{
|
{
|
||||||
[c->cb addItemWithObjectValue:toNSString(text)];
|
[c->cb addItemWithObjectValue:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
char *uiEditableComboboxText(uiEditableCombobox *c)
|
char *uiEditableComboboxText(uiEditableCombobox *c)
|
||||||
|
@ -118,7 +118,7 @@ void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text)
|
||||||
{
|
{
|
||||||
NSString *t;
|
NSString *t;
|
||||||
|
|
||||||
t = toNSString(text);
|
t = uiprivToNSString(text);
|
||||||
[c->cb setStringValue:t];
|
[c->cb setStringValue:t];
|
||||||
// yes, let's imitate the behavior that caused uiEditableCombobox to be separate in the first place!
|
// 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
|
// just to avoid confusion when users see an option in the list in the text field but not selected in the list
|
||||||
|
|
|
@ -145,7 +145,7 @@ char *uiEntryText(uiEntry *e)
|
||||||
|
|
||||||
void uiEntrySetText(uiEntry *e, const char *text)
|
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
|
// don't queue the control for resize; entry sizes are independent of their contents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// or at leat allow this and implicitly turn it into a spacer
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
uiprivUserBug("You cannot add NULL to a uiForm.");
|
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)
|
void uiFormDelete(uiForm *f, int n)
|
||||||
|
|
|
@ -131,7 +131,7 @@ char *uiGroupTitle(uiGroup *g)
|
||||||
|
|
||||||
void uiGroupSetTitle(uiGroup *g, const char *title)
|
void uiGroupSetTitle(uiGroup *g, const char *title)
|
||||||
{
|
{
|
||||||
[g->box setTitle:toNSString(title)];
|
[g->box setTitle:uiprivToNSString(title)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiGroupSetChild(uiGroup *g, uiControl *child)
|
void uiGroupSetChild(uiGroup *g, uiControl *child)
|
||||||
|
@ -178,7 +178,7 @@ uiGroup *uiNewGroup(const char *title)
|
||||||
uiDarwinNewControl(uiGroup, g);
|
uiDarwinNewControl(uiGroup, g);
|
||||||
|
|
||||||
g->box = [[NSBox alloc] initWithFrame:NSZeroRect];
|
g->box = [[NSBox alloc] initWithFrame:NSZeroRect];
|
||||||
[g->box setTitle:toNSString(title)];
|
[g->box setTitle:uiprivToNSString(title)];
|
||||||
[g->box setBoxType:NSBoxPrimary];
|
[g->box setBoxType:NSBoxPrimary];
|
||||||
[g->box setBorderType:NSLineBorder];
|
[g->box setBorderType:NSLineBorder];
|
||||||
[g->box setTransparent:NO];
|
[g->box setTransparent:NO];
|
||||||
|
|
|
@ -15,7 +15,7 @@ char *uiLabelText(uiLabel *l)
|
||||||
|
|
||||||
void uiLabelSetText(uiLabel *l, const char *text)
|
void uiLabelSetText(uiLabel *l, const char *text)
|
||||||
{
|
{
|
||||||
[l->textfield setStringValue:toNSString(text)];
|
[l->textfield setStringValue:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSTextField *newLabel(NSString *str)
|
NSTextField *newLabel(NSString *str)
|
||||||
|
@ -37,7 +37,7 @@ uiLabel *uiNewLabel(const char *text)
|
||||||
|
|
||||||
uiDarwinNewControl(uiLabel, l);
|
uiDarwinNewControl(uiLabel, l);
|
||||||
|
|
||||||
l->textfield = newLabel(toNSString(text));
|
l->textfield = newLabel(uiprivToNSString(text));
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,7 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
||||||
[m->menu addItem:item->item];
|
[m->menu addItem:item->item];
|
||||||
break;
|
break;
|
||||||
default:
|
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];
|
[item->item setTarget:appDelegate().menuManager];
|
||||||
[m->menu addItem:item->item];
|
[m->menu addItem:item->item];
|
||||||
break;
|
break;
|
||||||
|
@ -321,10 +321,10 @@ uiMenu *uiNewMenu(const char *name)
|
||||||
|
|
||||||
m = uiprivNew(uiMenu);
|
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
|
// 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->item setSubmenu:m->menu];
|
||||||
|
|
||||||
m->items = [NSMutableArray new];
|
m->items = [NSMutableArray new];
|
||||||
|
|
|
@ -78,7 +78,7 @@ char *uiMultilineEntryText(uiMultilineEntry *e)
|
||||||
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
[[e->tv textStorage] replaceCharactersInRange:NSMakeRange(0, [[e->tv string] length])
|
[[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:
|
// must be called explicitly according to the documentation of shouldChangeTextInRange:replacementString:
|
||||||
e->changing = YES;
|
e->changing = YES;
|
||||||
[e->tv didChangeText];
|
[e->tv didChangeText];
|
||||||
|
@ -89,7 +89,7 @@ void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
||||||
void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)
|
void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
[[e->tv textStorage] replaceCharactersInRange:NSMakeRange([[e->tv string] length], 0)
|
[[e->tv textStorage] replaceCharactersInRange:NSMakeRange([[e->tv string] length], 0)
|
||||||
withString:toNSString(text)];
|
withString:uiprivToNSString(text)];
|
||||||
e->changing = YES;
|
e->changing = YES;
|
||||||
[e->tv didChangeText];
|
[e->tv didChangeText];
|
||||||
e->changing = NO;
|
e->changing = NO;
|
||||||
|
|
|
@ -87,7 +87,7 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
||||||
NSLayoutConstraint *constraint;
|
NSLayoutConstraint *constraint;
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame:NSZeroRect];
|
b = [[NSButton alloc] initWithFrame:NSZeroRect];
|
||||||
[b setTitle:toNSString(text)];
|
[b setTitle:uiprivToNSString(text)];
|
||||||
[b setButtonType:NSRadioButton];
|
[b setButtonType:NSRadioButton];
|
||||||
// doesn't seem to have an associated bezel style
|
// doesn't seem to have an associated bezel style
|
||||||
[b setBordered:NO];
|
[b setBordered:NO];
|
||||||
|
|
|
@ -103,8 +103,8 @@ static void msgbox(NSWindow *parent, const char *title, const char *description,
|
||||||
[a setAlertStyle:style];
|
[a setAlertStyle:style];
|
||||||
[a setShowsHelp:NO];
|
[a setShowsHelp:NO];
|
||||||
[a setShowsSuppressionButton:NO];
|
[a setShowsSuppressionButton:NO];
|
||||||
[a setMessageText:toNSString(title)];
|
[a setMessageText:uiprivToNSString(title)];
|
||||||
[a setInformativeText:toNSString(description)];
|
[a setInformativeText:uiprivToNSString(description)];
|
||||||
[a addButtonWithTitle:@"OK"];
|
[a addButtonWithTitle:@"OK"];
|
||||||
cm = [[libuiCodeModalAlertPanel alloc] initWithPanel:a parent:parent];
|
cm = [[libuiCodeModalAlertPanel alloc] initWithPanel:a parent:parent];
|
||||||
[cm run];
|
[cm run];
|
||||||
|
|
|
@ -220,7 +220,7 @@ void uiTabInsertAt(uiTab *t, const char *name, int n, uiControl *child)
|
||||||
[t->pages insertObject:page atIndex:n];
|
[t->pages insertObject:page atIndex:n];
|
||||||
|
|
||||||
i = [[[NSTabViewItem alloc] initWithIdentifier:pageID] autorelease];
|
i = [[[NSTabViewItem alloc] initWithIdentifier:pageID] autorelease];
|
||||||
[i setLabel:toNSString(name)];
|
[i setLabel:uiprivToNSString(name)];
|
||||||
[i setView:view];
|
[i setView:view];
|
||||||
[t->tabview insertTabViewItem:i atIndex:n];
|
[t->tabview insertTabViewItem:i atIndex:n];
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,14 @@
|
||||||
#error Sorry, libui cannot be compiled with ARC.
|
#error Sorry, libui cannot be compiled with ARC.
|
||||||
#endif
|
#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"
|
#import "OLD_uipriv_darwin.h"
|
||||||
|
|
|
@ -252,7 +252,7 @@ char *uiWindowTitle(uiWindow *w)
|
||||||
|
|
||||||
void uiWindowSetTitle(uiWindow *w, const char *title)
|
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)
|
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
|
styleMask:defaultStyleMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:YES];
|
defer:YES];
|
||||||
[w->window setTitle:toNSString(title)];
|
[w->window setTitle:uiprivToNSString(title)];
|
||||||
|
|
||||||
// do NOT release when closed
|
// do NOT release when closed
|
||||||
// we manually do this in uiWindowDestroy() above
|
// we manually do this in uiWindowDestroy() above
|
||||||
|
|
Loading…
Reference in New Issue