Merge branch 'darwin-namespace-cleanup'
Doesn't handle Objective-C data yet; that'll come later. Also starts a naming document. Update #308
This commit is contained in:
commit
55023a5f99
|
@ -58,31 +58,8 @@ list(APPEND _LIBUI_INCLUDEDIRS
|
|||
set(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE)
|
||||
|
||||
set(_LIBUINAME libui PARENT_SCOPE)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
set(_LIBUINAME libui-temporary PARENT_SCOPE)
|
||||
endif()
|
||||
# thanks to Mr-Hide in irc.freenode.net/#cmake
|
||||
# TODO remove all these temporary files after linking the final archive file
|
||||
macro(_handle_static)
|
||||
set_target_properties(${_LIBUINAME} PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
|
||||
set(_aname $<TARGET_FILE:${_LIBUINAME}>)
|
||||
set(_lname libui-combined.list)
|
||||
set(_oname libui-combined.o)
|
||||
add_custom_command(
|
||||
OUTPUT ${_oname}
|
||||
COMMAND
|
||||
nm -m ${_aname} | sed -E -n "'s/^[0-9a-f]* \\([A-Z_]+,[a-z_]+\\) external //p'" > ${_lname}
|
||||
COMMAND
|
||||
ld -exported_symbols_list ${_lname} -r -all_load ${_aname} -o ${_oname}
|
||||
COMMENT "Removing hidden symbols")
|
||||
add_library(libui STATIC ${_oname})
|
||||
# otherwise cmake won't know which linker to use
|
||||
set_target_properties(libui PROPERTIES
|
||||
LINKER_LANGUAGE C)
|
||||
set(_aname)
|
||||
set(_lname)
|
||||
set(_oname)
|
||||
# do nothing
|
||||
endmacro()
|
||||
|
||||
set(_LIBUI_LIBS
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
#import "uipriv_darwin.h"
|
||||
|
||||
static NSMutableArray *allocations;
|
||||
NSMutableArray *delegates;
|
||||
NSMutableArray *uiprivDelegates;
|
||||
|
||||
void initAlloc(void)
|
||||
void uiprivInitAlloc(void)
|
||||
{
|
||||
allocations = [NSMutableArray new];
|
||||
delegates = [NSMutableArray new];
|
||||
uiprivDelegates = [NSMutableArray new];
|
||||
}
|
||||
|
||||
#define UINT8(p) ((uint8_t *) (p))
|
||||
|
@ -20,12 +20,12 @@ void initAlloc(void)
|
|||
#define CCHAR(p) ((const char **) (p))
|
||||
#define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t))
|
||||
|
||||
void uninitAlloc(void)
|
||||
void uiprivUninitAlloc(void)
|
||||
{
|
||||
NSMutableString *str;
|
||||
NSValue *v;
|
||||
|
||||
[delegates release];
|
||||
[uiprivDelegates release];
|
||||
if ([allocations count] == 0) {
|
||||
[allocations release];
|
||||
return;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct uiArea {
|
|||
NSView *view; // either sv or area depending on whether it is scrolling
|
||||
NSScrollView *sv;
|
||||
areaView *area;
|
||||
struct scrollViewData *d;
|
||||
uiprivScrollViewData *d;
|
||||
uiAreaHandler *ah;
|
||||
BOOL scrolling;
|
||||
NSEvent *dragevent;
|
||||
|
@ -57,7 +57,7 @@ struct uiArea {
|
|||
|
||||
c = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
|
||||
// see draw.m under text for why we need the height
|
||||
dp.Context = newContext(c, [self bounds].size.height);
|
||||
dp.Context = uiprivDrawNewContext(c, [self bounds].size.height);
|
||||
|
||||
dp.AreaWidth = 0;
|
||||
dp.AreaHeight = 0;
|
||||
|
@ -74,7 +74,7 @@ struct uiArea {
|
|||
// no need to save or restore the graphics state to reset transformations; Cocoa creates a brand-new context each time
|
||||
(*(a->ah->Draw))(a->ah, a, &dp);
|
||||
|
||||
freeContext(dp.Context);
|
||||
uiprivDrawFreeContext(dp.Context);
|
||||
}
|
||||
|
||||
- (BOOL)isFlipped
|
||||
|
@ -264,7 +264,7 @@ mouseEvent(otherMouseUp)
|
|||
|
||||
ke.Up = up;
|
||||
|
||||
if (!fromKeycode([e keyCode], &ke))
|
||||
if (!uiprivFromKeycode([e keyCode], &ke))
|
||||
return 0;
|
||||
return [self sendKeyEvent:&ke];
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ mouseEvent(otherMouseUp)
|
|||
|
||||
// Mac OS X sends this event on both key up and key down.
|
||||
// Fortunately -[e keyCode] IS valid here, so we can simply map from key code to Modifiers, get the value of [e modifierFlags], and check if the respective bit is set or not — that will give us the up/down state
|
||||
if (!keycodeModifier([e keyCode], &whichmod))
|
||||
if (!uiprivKeycodeModifier([e keyCode], &whichmod))
|
||||
return 0;
|
||||
ke.Modifier = whichmod;
|
||||
ke.Modifiers = [self parseModifiers:e];
|
||||
|
@ -350,7 +350,7 @@ static void uiAreaDestroy(uiControl *c)
|
|||
uiArea *a = uiArea(c);
|
||||
|
||||
if (a->scrolling)
|
||||
scrollViewFreeData(a->sv, a->d);
|
||||
uiprivScrollViewFreeData(a->sv, a->d);
|
||||
[a->area release];
|
||||
if (a->scrolling)
|
||||
[a->sv release];
|
||||
|
@ -361,7 +361,7 @@ static void uiAreaDestroy(uiControl *c)
|
|||
// by default, NSApplication eats some key events
|
||||
// this prevents that from happening with uiArea
|
||||
// see http://stackoverflow.com/questions/24099063/how-do-i-detect-keyup-in-my-nsview-with-the-command-key-held and http://lists.apple.com/archives/cocoa-dev/2003/Oct/msg00442.html
|
||||
int sendAreaEvents(NSEvent *e)
|
||||
int uiprivSendAreaEvents(NSEvent *e)
|
||||
{
|
||||
NSEventType type;
|
||||
id focused;
|
||||
|
@ -409,26 +409,26 @@ void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height)
|
|||
|
||||
void uiAreaBeginUserWindowMove(uiArea *a)
|
||||
{
|
||||
libuiNSWindow *w;
|
||||
uiprivNSWindow *w;
|
||||
|
||||
w = (libuiNSWindow *) [a->area window];
|
||||
w = (uiprivNSWindow *) [a->area window];
|
||||
if (w == nil)
|
||||
return; // TODO
|
||||
if (a->dragevent == nil)
|
||||
return; // TODO
|
||||
[w libui_doMove:a->dragevent];
|
||||
[w uiprivDoMove:a->dragevent];
|
||||
}
|
||||
|
||||
void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge)
|
||||
{
|
||||
libuiNSWindow *w;
|
||||
uiprivNSWindow *w;
|
||||
|
||||
w = (libuiNSWindow *) [a->area window];
|
||||
w = (uiprivNSWindow *) [a->area window];
|
||||
if (w == nil)
|
||||
return; // TODO
|
||||
if (a->dragevent == nil)
|
||||
return; // TODO
|
||||
[w libui_doResize:a->dragevent on:edge];
|
||||
[w uiprivDoResize:a->dragevent on:edge];
|
||||
}
|
||||
|
||||
uiArea *uiNewArea(uiAreaHandler *ah)
|
||||
|
@ -450,7 +450,7 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
|||
uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
||||
{
|
||||
uiArea *a;
|
||||
struct scrollViewCreateParams p;
|
||||
uiprivScrollViewCreateParams p;
|
||||
|
||||
uiDarwinNewControl(uiArea, a);
|
||||
|
||||
|
@ -460,14 +460,14 @@ uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
|||
a->area = [[areaView alloc] initWithFrame:NSMakeRect(0, 0, width, height)
|
||||
area:a];
|
||||
|
||||
memset(&p, 0, sizeof (struct scrollViewCreateParams));
|
||||
memset(&p, 0, sizeof (uiprivScrollViewCreateParams));
|
||||
p.DocumentView = a->area;
|
||||
p.BackgroundColor = [NSColor controlColor];
|
||||
p.DrawsBackground = 1;
|
||||
p.Bordered = NO;
|
||||
p.HScroll = YES;
|
||||
p.VScroll = YES;
|
||||
a->sv = mkScrollView(&p, &(a->d));
|
||||
a->sv = uiprivMkScrollView(&p, &(a->d));
|
||||
|
||||
a->view = a->sv;
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ static const struct {
|
|||
{ 0xFFFF, 0 },
|
||||
};
|
||||
|
||||
BOOL fromKeycode(unsigned short keycode, uiAreaKeyEvent *ke)
|
||||
BOOL uiprivFromKeycode(unsigned short keycode, uiAreaKeyEvent *ke)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -146,7 +146,7 @@ BOOL fromKeycode(unsigned short keycode, uiAreaKeyEvent *ke)
|
|||
return NO;
|
||||
}
|
||||
|
||||
BOOL keycodeModifier(unsigned short keycode, uiModifiers *mod)
|
||||
BOOL uiprivKeycodeModifier(unsigned short keycode, uiModifiers *mod)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -296,14 +296,14 @@ static void addBackgroundAttribute(struct foreachParams *p, size_t start, size_t
|
|||
uiprivDrawTextBackgroundParams *dtb;
|
||||
|
||||
// TODO make sure this works properly with line paragraph spacings (after figuring out what that means, of course)
|
||||
if (FUTURE_kCTBackgroundColorAttributeName != NULL) {
|
||||
if (uiprivFUTURE_kCTBackgroundColorAttributeName != NULL) {
|
||||
CGColorRef color;
|
||||
CFRange range;
|
||||
|
||||
color = mkcolor(r, g, b, a);
|
||||
range.location = start;
|
||||
range.length = end - start;
|
||||
CFAttributedStringSetAttribute(p->mas, range, *FUTURE_kCTBackgroundColorAttributeName, color);
|
||||
CFAttributedStringSetAttribute(p->mas, range, *uiprivFUTURE_kCTBackgroundColorAttributeName, color);
|
||||
CFRelease(color);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// 15 august 2015
|
||||
#import "uipriv_darwin.h"
|
||||
|
||||
NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc)
|
||||
NSLayoutConstraint *uiprivMkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc)
|
||||
{
|
||||
NSLayoutConstraint *constraint;
|
||||
|
||||
|
@ -12,7 +12,7 @@ NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRela
|
|||
attribute:attr2
|
||||
multiplier:multiplier
|
||||
constant:c];
|
||||
FUTURE_NSLayoutConstraint_setIdentifier(constraint, desc);
|
||||
uiprivFUTURE_NSLayoutConstraint_setIdentifier(constraint, desc);
|
||||
return constraint;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ CGFloat uiDarwinPaddingAmount(void *reserved)
|
|||
// this is needed for NSSplitView to work properly; see http://stackoverflow.com/questions/34574478/how-can-i-set-the-position-of-a-nssplitview-nowadays-setpositionofdivideratind (stal in irc.freenode.net/#macdev came up with the exact combination)
|
||||
// turns out it also works on NSTabView and NSBox too, possibly others!
|
||||
// and for bonus points, it even seems to fix unsatisfiable-constraint-autoresizing-mask issues with NSTabView and NSBox too!!! this is nuts
|
||||
void jiggleViewLayout(NSView *view)
|
||||
void uiprivJiggleViewLayout(NSView *view)
|
||||
{
|
||||
[view setNeedsLayout:YES];
|
||||
[view layoutSubtreeIfNeeded];
|
||||
|
@ -42,13 +42,13 @@ static CGFloat margins(int margined)
|
|||
return uiDarwinMarginAmount(NULL);
|
||||
}
|
||||
|
||||
void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc)
|
||||
void uiprivSingleChildConstraintsEstablish(uiprivSingleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc)
|
||||
{
|
||||
CGFloat margin;
|
||||
|
||||
margin = margins(margined);
|
||||
|
||||
c->leadingConstraint = mkConstraint(contentView, NSLayoutAttributeLeading,
|
||||
c->leadingConstraint = uiprivMkConstraint(contentView, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
childView, NSLayoutAttributeLeading,
|
||||
1, -margin,
|
||||
|
@ -56,7 +56,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
|||
[contentView addConstraint:c->leadingConstraint];
|
||||
[c->leadingConstraint retain];
|
||||
|
||||
c->topConstraint = mkConstraint(contentView, NSLayoutAttributeTop,
|
||||
c->topConstraint = uiprivMkConstraint(contentView, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
childView, NSLayoutAttributeTop,
|
||||
1, -margin,
|
||||
|
@ -64,7 +64,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
|||
[contentView addConstraint:c->topConstraint];
|
||||
[c->topConstraint retain];
|
||||
|
||||
c->trailingConstraintGreater = mkConstraint(contentView, NSLayoutAttributeTrailing,
|
||||
c->trailingConstraintGreater = uiprivMkConstraint(contentView, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationGreaterThanOrEqual,
|
||||
childView, NSLayoutAttributeTrailing,
|
||||
1, margin,
|
||||
|
@ -74,7 +74,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
|||
[contentView addConstraint:c->trailingConstraintGreater];
|
||||
[c->trailingConstraintGreater retain];
|
||||
|
||||
c->trailingConstraintEqual = mkConstraint(contentView, NSLayoutAttributeTrailing,
|
||||
c->trailingConstraintEqual = uiprivMkConstraint(contentView, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
childView, NSLayoutAttributeTrailing,
|
||||
1, margin,
|
||||
|
@ -84,7 +84,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
|||
[contentView addConstraint:c->trailingConstraintEqual];
|
||||
[c->trailingConstraintEqual retain];
|
||||
|
||||
c->bottomConstraintGreater = mkConstraint(contentView, NSLayoutAttributeBottom,
|
||||
c->bottomConstraintGreater = uiprivMkConstraint(contentView, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationGreaterThanOrEqual,
|
||||
childView, NSLayoutAttributeBottom,
|
||||
1, margin,
|
||||
|
@ -94,7 +94,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
|||
[contentView addConstraint:c->bottomConstraintGreater];
|
||||
[c->bottomConstraintGreater retain];
|
||||
|
||||
c->bottomConstraintEqual = mkConstraint(contentView, NSLayoutAttributeBottom,
|
||||
c->bottomConstraintEqual = uiprivMkConstraint(contentView, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
childView, NSLayoutAttributeBottom,
|
||||
1, margin,
|
||||
|
@ -105,7 +105,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
|||
[c->bottomConstraintEqual retain];
|
||||
}
|
||||
|
||||
void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv)
|
||||
void uiprivSingleChildConstraintsRemove(uiprivSingleChildConstraints *c, NSView *cv)
|
||||
{
|
||||
if (c->leadingConstraint != nil) {
|
||||
[cv removeConstraint:c->leadingConstraint];
|
||||
|
@ -139,7 +139,7 @@ void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv)
|
|||
}
|
||||
}
|
||||
|
||||
void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int margined)
|
||||
void uiprivSingleChildConstraintsSetMargined(uiprivSingleChildConstraints *c, int margined)
|
||||
{
|
||||
CGFloat margin;
|
||||
|
||||
|
|
14
darwin/box.m
14
darwin/box.m
|
@ -167,7 +167,7 @@ struct uiBox {
|
|||
if (!uiControlVisible(bc.c))
|
||||
continue;
|
||||
if (prev == nil) { // first view
|
||||
self->first = mkConstraint(self, self->primaryStart,
|
||||
self->first = uiprivMkConstraint(self, self->primaryStart,
|
||||
NSLayoutRelationEqual,
|
||||
[bc view], self->primaryStart,
|
||||
1, 0,
|
||||
|
@ -178,7 +178,7 @@ struct uiBox {
|
|||
continue;
|
||||
}
|
||||
// not the first; link it
|
||||
c = mkConstraint(prev, self->primaryEnd,
|
||||
c = uiprivMkConstraint(prev, self->primaryEnd,
|
||||
NSLayoutRelationEqual,
|
||||
[bc view], self->primaryStart,
|
||||
1, -padding,
|
||||
|
@ -189,7 +189,7 @@ struct uiBox {
|
|||
}
|
||||
if (prev == nil) // no control visible; act as if no controls
|
||||
return;
|
||||
self->last = mkConstraint(prev, self->primaryEnd,
|
||||
self->last = uiprivMkConstraint(prev, self->primaryEnd,
|
||||
NSLayoutRelationEqual,
|
||||
self, self->primaryEnd,
|
||||
1, 0,
|
||||
|
@ -204,14 +204,14 @@ struct uiBox {
|
|||
for (bc in self->children) {
|
||||
if (!uiControlVisible(bc.c))
|
||||
continue;
|
||||
c = mkConstraint(self, self->secondaryStart,
|
||||
c = uiprivMkConstraint(self, self->secondaryStart,
|
||||
NSLayoutRelationEqual,
|
||||
[bc view], self->secondaryStart,
|
||||
1, 0,
|
||||
@"uiBox secondary start constraint");
|
||||
[self addConstraint:c];
|
||||
[self->otherConstraints addObject:c];
|
||||
c = mkConstraint([bc view], self->secondaryEnd,
|
||||
c = uiprivMkConstraint([bc view], self->secondaryEnd,
|
||||
NSLayoutRelationLessThanOrEqual,
|
||||
self, self->secondaryEnd,
|
||||
1, 0,
|
||||
|
@ -220,7 +220,7 @@ struct uiBox {
|
|||
[c setPriority:NSLayoutPriorityDefaultLow];
|
||||
[self addConstraint:c];
|
||||
[self->otherConstraints addObject:c];
|
||||
c = mkConstraint([bc view], self->secondaryEnd,
|
||||
c = uiprivMkConstraint([bc view], self->secondaryEnd,
|
||||
NSLayoutRelationEqual,
|
||||
self, self->secondaryEnd,
|
||||
1, 0,
|
||||
|
@ -244,7 +244,7 @@ struct uiBox {
|
|||
prev = [bc view];
|
||||
continue;
|
||||
}
|
||||
c = mkConstraint(prev, self->primarySize,
|
||||
c = uiprivMkConstraint(prev, self->primarySize,
|
||||
NSLayoutRelationEqual,
|
||||
[bc view], self->primarySize,
|
||||
1, 0,
|
||||
|
|
|
@ -9,7 +9,7 @@ struct uiButton {
|
|||
};
|
||||
|
||||
@interface buttonDelegateClass : NSObject {
|
||||
struct mapTable *buttons;
|
||||
uiprivMap *buttons;
|
||||
}
|
||||
- (IBAction)onClicked:(id)sender;
|
||||
- (void)registerButton:(uiButton *)b;
|
||||
|
@ -22,13 +22,13 @@ struct uiButton {
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
self->buttons = newMap();
|
||||
self->buttons = uiprivNewMap();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapDestroy(self->buttons);
|
||||
uiprivMapDestroy(self->buttons);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ struct uiButton {
|
|||
{
|
||||
uiButton *b;
|
||||
|
||||
b = (uiButton *) mapGet(self->buttons, sender);
|
||||
b = (uiButton *) uiprivMapGet(self->buttons, sender);
|
||||
(*(b->onClicked))(b, b->onClickedData);
|
||||
}
|
||||
|
||||
- (void)registerButton:(uiButton *)b
|
||||
{
|
||||
mapSet(self->buttons, b->button, b);
|
||||
uiprivMapSet(self->buttons, b->button, b);
|
||||
[b->button setTarget:self];
|
||||
[b->button setAction:@selector(onClicked:)];
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ struct uiButton {
|
|||
- (void)unregisterButton:(uiButton *)b
|
||||
{
|
||||
[b->button setTarget:nil];
|
||||
mapDelete(self->buttons, b->button);
|
||||
uiprivMapDelete(self->buttons, b->button);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -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];
|
||||
|
@ -104,7 +104,7 @@ uiButton *uiNewButton(const char *text)
|
|||
|
||||
if (buttonDelegate == nil) {
|
||||
buttonDelegate = [[buttonDelegateClass new] autorelease];
|
||||
[delegates addObject:buttonDelegate];
|
||||
[uiprivDelegates addObject:buttonDelegate];
|
||||
}
|
||||
[buttonDelegate registerButton:b];
|
||||
uiButtonOnClicked(b, defaultOnClicked, NULL);
|
||||
|
|
|
@ -9,7 +9,7 @@ struct uiCheckbox {
|
|||
};
|
||||
|
||||
@interface checkboxDelegateClass : NSObject {
|
||||
struct mapTable *buttons;
|
||||
uiprivMap *buttons;
|
||||
}
|
||||
- (IBAction)onToggled:(id)sender;
|
||||
- (void)registerCheckbox:(uiCheckbox *)c;
|
||||
|
@ -22,13 +22,13 @@ struct uiCheckbox {
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
self->buttons = newMap();
|
||||
self->buttons = uiprivNewMap();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapDestroy(self->buttons);
|
||||
uiprivMapDestroy(self->buttons);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -36,13 +36,13 @@ struct uiCheckbox {
|
|||
{
|
||||
uiCheckbox *c;
|
||||
|
||||
c = (uiCheckbox *) mapGet(self->buttons, sender);
|
||||
c = (uiCheckbox *) uiprivMapGet(self->buttons, sender);
|
||||
(*(c->onToggled))(c, c->onToggledData);
|
||||
}
|
||||
|
||||
- (void)registerCheckbox:(uiCheckbox *)c
|
||||
{
|
||||
mapSet(self->buttons, c->button, c);
|
||||
uiprivMapSet(self->buttons, c->button, c);
|
||||
[c->button setTarget:self];
|
||||
[c->button setAction:@selector(onToggled:)];
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ struct uiCheckbox {
|
|||
- (void)unregisterCheckbox:(uiCheckbox *)c
|
||||
{
|
||||
[c->button setTarget:nil];
|
||||
mapDelete(self->buttons, c->button);
|
||||
uiprivMapDelete(self->buttons, c->button);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -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];
|
||||
|
@ -120,7 +120,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
|||
|
||||
if (checkboxDelegate == nil) {
|
||||
checkboxDelegate = [[checkboxDelegateClass new] autorelease];
|
||||
[delegates addObject:checkboxDelegate];
|
||||
[uiprivDelegates addObject:checkboxDelegate];
|
||||
}
|
||||
[checkboxDelegate registerCheckbox:c];
|
||||
uiCheckboxOnToggled(c, defaultOnToggled, NULL);
|
||||
|
|
|
@ -117,7 +117,7 @@ uiDarwinControlAllDefaults(uiColorButton, button)
|
|||
|
||||
// we do not want color change events to be sent to any controls other than the color buttons
|
||||
// see main.m for more details
|
||||
BOOL colorButtonInhibitSendAction(SEL sel, id from, id to)
|
||||
BOOL uiprivColorButtonInhibitSendAction(SEL sel, id from, id to)
|
||||
{
|
||||
if (sel != @selector(changeColor:))
|
||||
return NO;
|
||||
|
|
|
@ -14,7 +14,7 @@ struct uiCombobox {
|
|||
};
|
||||
|
||||
@interface comboboxDelegateClass : NSObject {
|
||||
struct mapTable *comboboxes;
|
||||
uiprivMap *comboboxes;
|
||||
}
|
||||
- (IBAction)onSelected:(id)sender;
|
||||
- (void)registerCombobox:(uiCombobox *)c;
|
||||
|
@ -27,13 +27,13 @@ struct uiCombobox {
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
self->comboboxes = newMap();
|
||||
self->comboboxes = uiprivNewMap();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapDestroy(self->comboboxes);
|
||||
uiprivMapDestroy(self->comboboxes);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -41,13 +41,13 @@ struct uiCombobox {
|
|||
{
|
||||
uiCombobox *c;
|
||||
|
||||
c = uiCombobox(mapGet(self->comboboxes, sender));
|
||||
c = uiCombobox(uiprivMapGet(self->comboboxes, sender));
|
||||
(*(c->onSelected))(c, c->onSelectedData);
|
||||
}
|
||||
|
||||
- (void)registerCombobox:(uiCombobox *)c
|
||||
{
|
||||
mapSet(self->comboboxes, c->pb, c);
|
||||
uiprivMapSet(self->comboboxes, c->pb, c);
|
||||
[c->pb setTarget:self];
|
||||
[c->pb setAction:@selector(onSelected:)];
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ struct uiCombobox {
|
|||
- (void)unregisterCombobox:(uiCombobox *)c
|
||||
{
|
||||
[c->pb setTarget:nil];
|
||||
mapDelete(self->comboboxes, c->pb);
|
||||
uiprivMapDelete(self->comboboxes, c->pb);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -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)
|
||||
|
@ -136,7 +136,7 @@ uiCombobox *uiNewCombobox(void)
|
|||
|
||||
if (comboboxDelegate == nil) {
|
||||
comboboxDelegate = [[comboboxDelegateClass new] autorelease];
|
||||
[delegates addObject:comboboxDelegate];
|
||||
[uiprivDelegates addObject:comboboxDelegate];
|
||||
}
|
||||
[comboboxDelegate registerCombobox:c];
|
||||
uiComboboxOnSelected(c, defaultOnSelected, NULL);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// 6 january 2017
|
||||
|
||||
// TODO why do we still have this file; should we just split draw.m or not
|
||||
|
||||
struct uiDrawContext {
|
||||
CGContextRef c;
|
||||
CGFloat height; // needed for text; see below
|
||||
|
|
|
@ -104,7 +104,7 @@ void uiDrawPathEnd(uiDrawPath *p)
|
|||
p->ended = TRUE;
|
||||
}
|
||||
|
||||
uiDrawContext *newContext(CGContextRef ctxt, CGFloat height)
|
||||
uiDrawContext *uiprivDrawNewContext(CGContextRef ctxt, CGFloat height)
|
||||
{
|
||||
uiDrawContext *c;
|
||||
|
||||
|
@ -114,7 +114,7 @@ uiDrawContext *newContext(CGContextRef ctxt, CGFloat height)
|
|||
return c;
|
||||
}
|
||||
|
||||
void freeContext(uiDrawContext *c)
|
||||
void uiprivDrawFreeContext(uiDrawContext *c)
|
||||
{
|
||||
uiprivFree(c);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ struct uiEditableCombobox {
|
|||
};
|
||||
|
||||
@interface editableComboboxDelegateClass : NSObject<NSComboBoxDelegate> {
|
||||
struct mapTable *comboboxes;
|
||||
uiprivMap *comboboxes;
|
||||
}
|
||||
- (void)controlTextDidChange:(NSNotification *)note;
|
||||
- (void)comboBoxSelectionDidChange:(NSNotification *)note;
|
||||
|
@ -48,13 +48,13 @@ struct uiEditableCombobox {
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
self->comboboxes = newMap();
|
||||
self->comboboxes = uiprivNewMap();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapDestroy(self->comboboxes);
|
||||
uiprivMapDestroy(self->comboboxes);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,8 @@ struct uiEditableCombobox {
|
|||
{
|
||||
uiEditableCombobox *c;
|
||||
|
||||
c = uiEditableCombobox(mapGet(self->comboboxes, [note object]));
|
||||
// TODO normalize the cast styles in these calls
|
||||
c = uiEditableCombobox(uiprivMapGet(self->comboboxes, [note object]));
|
||||
(*(c->onChanged))(c, c->onChangedData);
|
||||
}
|
||||
|
||||
|
@ -79,14 +80,14 @@ struct uiEditableCombobox {
|
|||
|
||||
- (void)registerCombobox:(uiEditableCombobox *)c
|
||||
{
|
||||
mapSet(self->comboboxes, c->cb, c);
|
||||
uiprivMapSet(self->comboboxes, c->cb, c);
|
||||
[c->cb setDelegate:self];
|
||||
}
|
||||
|
||||
- (void)unregisterCombobox:(uiEditableCombobox *)c
|
||||
{
|
||||
[c->cb setDelegate:nil];
|
||||
mapDelete(self->comboboxes, c->cb);
|
||||
uiprivMapDelete(self->comboboxes, c->cb);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -106,7 +107,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 +119,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
|
||||
|
@ -176,7 +177,7 @@ uiEditableCombobox *uiNewEditableCombobox(void)
|
|||
|
||||
if (comboboxDelegate == nil) {
|
||||
comboboxDelegate = [[editableComboboxDelegateClass new] autorelease];
|
||||
[delegates addObject:comboboxDelegate];
|
||||
[uiprivDelegates addObject:comboboxDelegate];
|
||||
}
|
||||
[comboboxDelegate registerCombobox:c];
|
||||
uiEditableComboboxOnChanged(c, defaultOnChanged, NULL);
|
||||
|
|
|
@ -67,7 +67,7 @@ static BOOL isSearchField(NSTextField *tf)
|
|||
}
|
||||
|
||||
@interface entryDelegateClass : NSObject<NSTextFieldDelegate> {
|
||||
struct mapTable *entries;
|
||||
uiprivMap *entries;
|
||||
}
|
||||
- (void)controlTextDidChange:(NSNotification *)note;
|
||||
- (IBAction)onSearch:(id)sender;
|
||||
|
@ -81,13 +81,13 @@ static BOOL isSearchField(NSTextField *tf)
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
self->entries = newMap();
|
||||
self->entries = uiprivNewMap();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapDestroy(self->entries);
|
||||
uiprivMapDestroy(self->entries);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -100,13 +100,13 @@ static BOOL isSearchField(NSTextField *tf)
|
|||
{
|
||||
uiEntry *e;
|
||||
|
||||
e = (uiEntry *) mapGet(self->entries, sender);
|
||||
e = (uiEntry *) uiprivMapGet(self->entries, sender);
|
||||
(*(e->onChanged))(e, e->onChangedData);
|
||||
}
|
||||
|
||||
- (void)registerEntry:(uiEntry *)e
|
||||
{
|
||||
mapSet(self->entries, e->textfield, e);
|
||||
uiprivMapSet(self->entries, e->textfield, e);
|
||||
if (isSearchField(e->textfield)) {
|
||||
[e->textfield setTarget:self];
|
||||
[e->textfield setAction:@selector(onSearch:)];
|
||||
|
@ -120,7 +120,7 @@ static BOOL isSearchField(NSTextField *tf)
|
|||
[e->textfield setTarget:nil];
|
||||
else
|
||||
[e->textfield setDelegate:nil];
|
||||
mapDelete(self->entries, e->textfield);
|
||||
uiprivMapDelete(self->entries, e->textfield);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ static void defaultOnChanged(uiEntry *e, void *data)
|
|||
}
|
||||
|
||||
// these are based on interface builder defaults; my comments in the old code weren't very good so I don't really know what talked about what, sorry :/
|
||||
void finishNewTextField(NSTextField *t, BOOL isEntry)
|
||||
void uiprivFinishNewTextField(NSTextField *t, BOOL isEntry)
|
||||
{
|
||||
uiDarwinSetControlFont(t, NSRegularControlSize);
|
||||
|
||||
|
@ -197,11 +197,11 @@ static NSTextField *realNewEditableTextField(Class class)
|
|||
|
||||
tf = [[class alloc] initWithFrame:NSZeroRect];
|
||||
[tf setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
|
||||
finishNewTextField(tf, YES);
|
||||
uiprivFinishNewTextField(tf, YES);
|
||||
return tf;
|
||||
}
|
||||
|
||||
NSTextField *newEditableTextField(void)
|
||||
NSTextField *uiprivNewEditableTextField(void)
|
||||
{
|
||||
return realNewEditableTextField([libui_intrinsicWidthNSTextField class]);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ static uiEntry *finishNewEntry(Class class)
|
|||
|
||||
if (entryDelegate == nil) {
|
||||
entryDelegate = [[entryDelegateClass new] autorelease];
|
||||
[delegates addObject:entryDelegate];
|
||||
[uiprivDelegates addObject:entryDelegate];
|
||||
}
|
||||
[entryDelegate registerEntry:e];
|
||||
uiEntryOnChanged(e, defaultOnChanged, NULL);
|
||||
|
|
|
@ -246,7 +246,7 @@
|
|||
FONTNAME(preferredSubFamilyName,
|
||||
self->didPreferredSubFamilyName,
|
||||
self->preferredSubFamilyName,
|
||||
UNDOC_kCTFontPreferredSubFamilyNameKey)
|
||||
uiprivUNDOC_kCTFontPreferredSubFamilyNameKey)
|
||||
FONTNAME(subFamilyName,
|
||||
self->didSubFamilyName,
|
||||
self->subFamilyName,
|
||||
|
@ -258,7 +258,7 @@ FONTNAME(fullName,
|
|||
FONTNAME(preferredFamilyName,
|
||||
self->didPreferredFamilyName,
|
||||
self->preferredFamilyName,
|
||||
UNDOC_kCTFontPreferredFamilyNameKey)
|
||||
uiprivUNDOC_kCTFontPreferredFamilyNameKey)
|
||||
FONTNAME(familyName,
|
||||
self->didFamilyName,
|
||||
self->familyName,
|
||||
|
|
|
@ -66,25 +66,25 @@ struct uiForm {
|
|||
[self.label setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationVertical];
|
||||
[self addSubview:self.label];
|
||||
|
||||
self.leading = mkConstraint(self.label, NSLayoutAttributeLeading,
|
||||
self.leading = uiprivMkConstraint(self.label, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationGreaterThanOrEqual,
|
||||
self, NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
@"uiForm label leading");
|
||||
[self addConstraint:self.leading];
|
||||
self.top = mkConstraint(self.label, NSLayoutAttributeTop,
|
||||
self.top = uiprivMkConstraint(self.label, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeTop,
|
||||
1, 0,
|
||||
@"uiForm label top");
|
||||
[self addConstraint:self.top];
|
||||
self.trailing = mkConstraint(self.label, NSLayoutAttributeTrailing,
|
||||
self.trailing = uiprivMkConstraint(self.label, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeTrailing,
|
||||
1, 0,
|
||||
@"uiForm label trailing");
|
||||
[self addConstraint:self.trailing];
|
||||
self.bottom = mkConstraint(self.label, NSLayoutAttributeBottom,
|
||||
self.bottom = uiprivMkConstraint(self.label, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
|
@ -224,7 +224,7 @@ struct uiForm {
|
|||
if (!uiControlVisible(fc.c))
|
||||
continue;
|
||||
if (prev == nil) { // first view
|
||||
self->first = mkConstraint(self, NSLayoutAttributeTop,
|
||||
self->first = uiprivMkConstraint(self, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
[fc view], NSLayoutAttributeTop,
|
||||
1, 0,
|
||||
|
@ -236,7 +236,7 @@ struct uiForm {
|
|||
continue;
|
||||
}
|
||||
// not the first; link it
|
||||
c = mkConstraint(prev, NSLayoutAttributeBottom,
|
||||
c = uiprivMkConstraint(prev, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
[fc view], NSLayoutAttributeTop,
|
||||
1, -padding,
|
||||
|
@ -244,14 +244,14 @@ struct uiForm {
|
|||
[self addConstraint:c];
|
||||
[self->inBetweens addObject:c];
|
||||
// and make the same width
|
||||
c = mkConstraint(prev, NSLayoutAttributeWidth,
|
||||
c = uiprivMkConstraint(prev, NSLayoutAttributeWidth,
|
||||
NSLayoutRelationEqual,
|
||||
[fc view], NSLayoutAttributeWidth,
|
||||
1, 0,
|
||||
@"uiForm control width constraint");
|
||||
[self addConstraint:c];
|
||||
[self->widths addObject:c];
|
||||
c = mkConstraint(prevlabel, NSLayoutAttributeWidth,
|
||||
c = uiprivMkConstraint(prevlabel, NSLayoutAttributeWidth,
|
||||
NSLayoutRelationEqual,
|
||||
fc, NSLayoutAttributeWidth,
|
||||
1, 0,
|
||||
|
@ -263,7 +263,7 @@ struct uiForm {
|
|||
}
|
||||
if (prev == nil) // all hidden; act as if nothing there
|
||||
return;
|
||||
self->last = mkConstraint(prev, NSLayoutAttributeBottom,
|
||||
self->last = uiprivMkConstraint(prev, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
|
@ -275,7 +275,7 @@ struct uiForm {
|
|||
for (fc in self->children) {
|
||||
if (!uiControlVisible(fc.c))
|
||||
continue;
|
||||
c = mkConstraint(self, NSLayoutAttributeLeading,
|
||||
c = uiprivMkConstraint(self, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
fc, NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
|
@ -284,7 +284,7 @@ struct uiForm {
|
|||
[self->leadings addObject:c];
|
||||
// coerce the control to be as wide as possible
|
||||
// see http://stackoverflow.com/questions/37710892/in-auto-layout-i-set-up-labels-that-shouldnt-grow-horizontally-and-controls-th
|
||||
c = mkConstraint(self, NSLayoutAttributeLeading,
|
||||
c = uiprivMkConstraint(self, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
[fc view], NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
|
@ -292,14 +292,14 @@ struct uiForm {
|
|||
[c setPriority:NSLayoutPriorityDefaultHigh];
|
||||
[self addConstraint:c];
|
||||
[self->leadings addObject:c];
|
||||
c = mkConstraint(fc, NSLayoutAttributeTrailing,
|
||||
c = uiprivMkConstraint(fc, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
[fc view], NSLayoutAttributeLeading,
|
||||
1, -padding,
|
||||
@"uiForm middle constraint");
|
||||
[self addConstraint:c];
|
||||
[self->middles addObject:c];
|
||||
c = mkConstraint([fc view], NSLayoutAttributeTrailing,
|
||||
c = uiprivMkConstraint([fc view], NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeTrailing,
|
||||
1, 0,
|
||||
|
@ -307,7 +307,7 @@ struct uiForm {
|
|||
[self addConstraint:c];
|
||||
[self->trailings addObject:c];
|
||||
// TODO
|
||||
c = mkConstraint(fc, NSLayoutAttributeBottom,
|
||||
c = uiprivMkConstraint(fc, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationLessThanOrEqual,
|
||||
self, NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
|
@ -327,7 +327,7 @@ struct uiForm {
|
|||
prev = [fc view];
|
||||
continue;
|
||||
}
|
||||
c = mkConstraint([fc view], NSLayoutAttributeHeight,
|
||||
c = uiprivMkConstraint([fc view], NSLayoutAttributeHeight,
|
||||
NSLayoutRelationEqual,
|
||||
prev, NSLayoutAttributeHeight,
|
||||
1, 0,
|
||||
|
@ -347,7 +347,7 @@ struct uiForm {
|
|||
NSLayoutAttribute attribute;
|
||||
int oldnStretchy;
|
||||
|
||||
fc = [[formChild alloc] initWithLabel:newLabel(label)];
|
||||
fc = [[formChild alloc] initWithLabel:uiprivNewLabel(label)];
|
||||
fc.c = c;
|
||||
fc.stretchy = stretchy;
|
||||
fc.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(fc.c), NSLayoutConstraintOrientationHorizontal);
|
||||
|
@ -376,7 +376,7 @@ struct uiForm {
|
|||
attribute = NSLayoutAttributeBaseline;
|
||||
if ([[fc view] isKindOfClass:[NSScrollView class]])
|
||||
attribute = NSLayoutAttributeTop;
|
||||
fc.baseline = mkConstraint(fc.label, attribute,
|
||||
fc.baseline = uiprivMkConstraint(fc.label, attribute,
|
||||
NSLayoutRelationEqual,
|
||||
[fc view], attribute,
|
||||
1, 0,
|
||||
|
@ -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)
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
// note: for constants, dlsym() returns the address of the constant itself, as if we had done &constantName
|
||||
|
||||
// added in OS X 10.10; we need 10.8
|
||||
CFStringRef *FUTURE_kCTFontOpenTypeFeatureTag = NULL;
|
||||
CFStringRef *FUTURE_kCTFontOpenTypeFeatureValue = NULL;
|
||||
CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureTag = NULL;
|
||||
CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureValue = NULL;
|
||||
|
||||
// added in OS X 10.12; we need 10.8
|
||||
CFStringRef *FUTURE_kCTBackgroundColorAttributeName = NULL;
|
||||
CFStringRef *uiprivFUTURE_kCTBackgroundColorAttributeName = NULL;
|
||||
|
||||
// note that we treat any error as "the symbols aren't there" (and don't care if dlclose() failed)
|
||||
void loadFutures(void)
|
||||
void uiprivLoadFutures(void)
|
||||
{
|
||||
void *handle;
|
||||
|
||||
|
@ -21,9 +21,9 @@ void loadFutures(void)
|
|||
if (handle == NULL)
|
||||
return;
|
||||
#define GET(var, fn) *((void **) (&var)) = dlsym(handle, #fn)
|
||||
GET(FUTURE_kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureTag);
|
||||
GET(FUTURE_kCTFontOpenTypeFeatureValue, kCTFontOpenTypeFeatureValue);
|
||||
GET(FUTURE_kCTBackgroundColorAttributeName, kCTBackgroundColorAttributeName);
|
||||
GET(uiprivFUTURE_kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureTag);
|
||||
GET(uiprivFUTURE_kCTFontOpenTypeFeatureValue, kCTFontOpenTypeFeatureValue);
|
||||
GET(uiprivFUTURE_kCTBackgroundColorAttributeName, kCTBackgroundColorAttributeName);
|
||||
dlclose(handle);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ void loadFutures(void)
|
|||
// keep them in one place for convenience
|
||||
|
||||
// apparently only added in 10.9; we need 10.8
|
||||
void FUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSString *identifier)
|
||||
void uiprivFUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSString *identifier)
|
||||
{
|
||||
id cid = (id) constraint;
|
||||
|
||||
|
@ -41,7 +41,7 @@ void FUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSS
|
|||
|
||||
// added in 10.11; we need 10.8
|
||||
// return whether this was done because we recreate its effects if not (see winmoveresize.m)
|
||||
BOOL FUTURE_NSWindow_performWindowDragWithEvent(NSWindow *w, NSEvent *initialEvent)
|
||||
BOOL uiprivFUTURE_NSWindow_performWindowDragWithEvent(NSWindow *w, NSEvent *initialEvent)
|
||||
{
|
||||
id cw = (id) w;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ struct uiGrid {
|
|||
uiDarwinControlSyncEnableState(uiDarwinControl(self.c), uiControlEnabledToUser(uiControl(g)));
|
||||
|
||||
if (self.halign == uiAlignStart || self.halign == uiAlignFill) {
|
||||
self.leadingc = mkConstraint(self, NSLayoutAttributeLeading,
|
||||
self.leadingc = uiprivMkConstraint(self, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
[self view], NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
|
@ -80,7 +80,7 @@ struct uiGrid {
|
|||
[self addConstraint:self.leadingc];
|
||||
}
|
||||
if (self.halign == uiAlignCenter) {
|
||||
self.xcenterc = mkConstraint(self, NSLayoutAttributeCenterX,
|
||||
self.xcenterc = uiprivMkConstraint(self, NSLayoutAttributeCenterX,
|
||||
NSLayoutRelationEqual,
|
||||
[self view], NSLayoutAttributeCenterX,
|
||||
1, 0,
|
||||
|
@ -88,7 +88,7 @@ struct uiGrid {
|
|||
[self addConstraint:self.xcenterc];
|
||||
}
|
||||
if (self.halign == uiAlignEnd || self.halign == uiAlignFill) {
|
||||
self.trailingc = mkConstraint(self, NSLayoutAttributeTrailing,
|
||||
self.trailingc = uiprivMkConstraint(self, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
[self view], NSLayoutAttributeTrailing,
|
||||
1, 0,
|
||||
|
@ -97,7 +97,7 @@ struct uiGrid {
|
|||
}
|
||||
|
||||
if (self.valign == uiAlignStart || self.valign == uiAlignFill) {
|
||||
self.topc = mkConstraint(self, NSLayoutAttributeTop,
|
||||
self.topc = uiprivMkConstraint(self, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
[self view], NSLayoutAttributeTop,
|
||||
1, 0,
|
||||
|
@ -105,7 +105,7 @@ struct uiGrid {
|
|||
[self addConstraint:self.topc];
|
||||
}
|
||||
if (self.valign == uiAlignCenter) {
|
||||
self.ycenterc = mkConstraint(self, NSLayoutAttributeCenterY,
|
||||
self.ycenterc = uiprivMkConstraint(self, NSLayoutAttributeCenterY,
|
||||
NSLayoutRelationEqual,
|
||||
[self view], NSLayoutAttributeCenterY,
|
||||
1, 0,
|
||||
|
@ -113,7 +113,7 @@ struct uiGrid {
|
|||
[self addConstraint:self.ycenterc];
|
||||
}
|
||||
if (self.valign == uiAlignEnd || self.valign == uiAlignFill) {
|
||||
self.bottomc = mkConstraint(self, NSLayoutAttributeBottom,
|
||||
self.bottomc = uiprivMkConstraint(self, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
[self view], NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
|
@ -403,14 +403,14 @@ struct uiGrid {
|
|||
// now establish all the edge constraints
|
||||
// leading and trailing edges
|
||||
for (y = 0; y < ycount; y++) {
|
||||
c = mkConstraint(self, NSLayoutAttributeLeading,
|
||||
c = uiprivMkConstraint(self, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
gv[y][0], NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
@"uiGrid leading edge constraint");
|
||||
[self addConstraint:c];
|
||||
[self->edges addObject:c];
|
||||
c = mkConstraint(self, NSLayoutAttributeTrailing,
|
||||
c = uiprivMkConstraint(self, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
gv[y][xcount - 1], NSLayoutAttributeTrailing,
|
||||
1, 0,
|
||||
|
@ -420,14 +420,14 @@ struct uiGrid {
|
|||
}
|
||||
// top and bottom edges
|
||||
for (x = 0; x < xcount; x++) {
|
||||
c = mkConstraint(self, NSLayoutAttributeTop,
|
||||
c = uiprivMkConstraint(self, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
gv[0][x], NSLayoutAttributeTop,
|
||||
1, 0,
|
||||
@"uiGrid top edge constraint");
|
||||
[self addConstraint:c];
|
||||
[self->edges addObject:c];
|
||||
c = mkConstraint(self, NSLayoutAttributeBottom,
|
||||
c = uiprivMkConstraint(self, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
gv[ycount - 1][x], NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
|
@ -446,7 +446,7 @@ struct uiGrid {
|
|||
for (y++; y < ycount; y++) {
|
||||
if (gspan[y][x])
|
||||
continue;
|
||||
c = mkConstraint(gv[firsty][x], NSLayoutAttributeLeading,
|
||||
c = uiprivMkConstraint(gv[firsty][x], NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
gv[y][x], NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
|
@ -463,7 +463,7 @@ struct uiGrid {
|
|||
for (x++; x < xcount; x++) {
|
||||
if (gspan[y][x])
|
||||
continue;
|
||||
c = mkConstraint(gv[y][firstx], NSLayoutAttributeTop,
|
||||
c = uiprivMkConstraint(gv[y][firstx], NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
gv[y][x], NSLayoutAttributeTop,
|
||||
1, 0,
|
||||
|
@ -477,7 +477,7 @@ struct uiGrid {
|
|||
for (y = 0; y < ycount; y++)
|
||||
for (x = 1; x < xcount; x++)
|
||||
if (gv[y][x - 1] != gv[y][x]) {
|
||||
c = mkConstraint(gv[y][x - 1], NSLayoutAttributeTrailing,
|
||||
c = uiprivMkConstraint(gv[y][x - 1], NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
gv[y][x], NSLayoutAttributeLeading,
|
||||
1, -padding,
|
||||
|
@ -488,7 +488,7 @@ struct uiGrid {
|
|||
for (x = 0; x < xcount; x++)
|
||||
for (y = 1; y < ycount; y++)
|
||||
if (gv[y - 1][x] != gv[y][x]) {
|
||||
c = mkConstraint(gv[y - 1][x], NSLayoutAttributeBottom,
|
||||
c = uiprivMkConstraint(gv[y - 1][x], NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
gv[y][x], NSLayoutAttributeTop,
|
||||
1, -padding,
|
||||
|
|
|
@ -8,7 +8,7 @@ struct uiGroup {
|
|||
NSLayoutPriority oldHorzHuggingPri;
|
||||
NSLayoutPriority oldVertHuggingPri;
|
||||
int margined;
|
||||
struct singleChildConstraints constraints;
|
||||
uiprivSingleChildConstraints constraints;
|
||||
NSLayoutPriority horzHuggingPri;
|
||||
NSLayoutPriority vertHuggingPri;
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ struct uiGroup {
|
|||
static void removeConstraints(uiGroup *g)
|
||||
{
|
||||
// set to contentView instead of to the box itself, otherwise we get clipping underneath the label
|
||||
singleChildConstraintsRemove(&(g->constraints), [g->box contentView]);
|
||||
uiprivSingleChildConstraintsRemove(&(g->constraints), [g->box contentView]);
|
||||
}
|
||||
|
||||
static void uiGroupDestroy(uiControl *c)
|
||||
|
@ -64,14 +64,14 @@ static void groupRelayout(uiGroup *g)
|
|||
if (g->child == NULL)
|
||||
return;
|
||||
childView = (NSView *) uiControlHandle(g->child);
|
||||
singleChildConstraintsEstablish(&(g->constraints),
|
||||
uiprivSingleChildConstraintsEstablish(&(g->constraints),
|
||||
[g->box contentView], childView,
|
||||
uiDarwinControlHugsTrailingEdge(uiDarwinControl(g->child)),
|
||||
uiDarwinControlHugsBottom(uiDarwinControl(g->child)),
|
||||
g->margined,
|
||||
@"uiGroup");
|
||||
// needed for some very rare drawing errors...
|
||||
jiggleViewLayout(g->box);
|
||||
uiprivJiggleViewLayout(g->box);
|
||||
}
|
||||
|
||||
// TODO rename these since I'm starting to get confused by what they mean by hugging
|
||||
|
@ -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)
|
||||
|
@ -168,7 +168,7 @@ int uiGroupMargined(uiGroup *g)
|
|||
void uiGroupSetMargined(uiGroup *g, int margined)
|
||||
{
|
||||
g->margined = margined;
|
||||
singleChildConstraintsSetMargined(&(g->constraints), g->margined);
|
||||
uiprivSingleChildConstraintsSetMargined(&(g->constraints), g->margined);
|
||||
}
|
||||
|
||||
uiGroup *uiNewGroup(const char *title)
|
||||
|
@ -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];
|
||||
|
|
|
@ -76,7 +76,7 @@ void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, in
|
|||
[i->swizzled addObject:[NSValue valueWithPointer:swizzled]];
|
||||
}
|
||||
|
||||
NSImage *imageImage(uiImage *i)
|
||||
NSImage *uiprivImageNSImage(uiImage *i)
|
||||
{
|
||||
return i->i;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ 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)
|
||||
NSTextField *uiprivNewLabel(NSString *str)
|
||||
{
|
||||
NSTextField *tf;
|
||||
|
||||
|
@ -27,7 +27,7 @@ NSTextField *newLabel(NSString *str)
|
|||
[tf setEditable:NO];
|
||||
[tf setSelectable:NO];
|
||||
[tf setDrawsBackground:NO];
|
||||
finishNewTextField(tf, NO);
|
||||
uiprivFinishNewTextField(tf, NO);
|
||||
return tf;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ uiLabel *uiNewLabel(const char *text)
|
|||
|
||||
uiDarwinNewControl(uiLabel, l);
|
||||
|
||||
l->textfield = newLabel(toNSString(text));
|
||||
l->textfield = uiprivNewLabel(uiprivToNSString(text));
|
||||
|
||||
return l;
|
||||
}
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
|
||||
static BOOL canQuit = NO;
|
||||
static NSAutoreleasePool *globalPool;
|
||||
static applicationClass *app;
|
||||
static appDelegate *delegate;
|
||||
static uiprivApplicationClass *app;
|
||||
static uiprivAppDelegate *delegate;
|
||||
|
||||
static BOOL (^isRunning)(void);
|
||||
static BOOL stepsIsRunning;
|
||||
|
||||
@implementation applicationClass
|
||||
@implementation uiprivApplicationClass
|
||||
|
||||
- (void)sendEvent:(NSEvent *)e
|
||||
{
|
||||
if (sendAreaEvents(e) != 0)
|
||||
if (uiprivSendAreaEvents(e) != 0)
|
||||
return;
|
||||
[super sendEvent:e];
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ static BOOL stepsIsRunning;
|
|||
// it turns out NSFontManager also sends changeFont: through this; let's inhibit that here too (see fontbutton.m)
|
||||
- (BOOL)sendAction:(SEL)sel to:(id)to from:(id)from
|
||||
{
|
||||
if (colorButtonInhibitSendAction(sel, from, to))
|
||||
if (uiprivColorButtonInhibitSendAction(sel, from, to))
|
||||
return NO;
|
||||
if (uiprivFontButtonInhibitSendAction(sel, from, to))
|
||||
return NO;
|
||||
|
@ -59,7 +59,7 @@ static BOOL stepsIsRunning;
|
|||
if (!canQuit)
|
||||
uiprivImplBug("call to [NSApp terminate:] when not ready to terminate; definitely contact andlabs");
|
||||
|
||||
[realNSApp() stop:realNSApp()];
|
||||
[uiprivNSApp() stop:uiprivNSApp()];
|
||||
// stop: won't register until another event has passed; let's synthesize one
|
||||
e = [NSEvent otherEventWithType:NSApplicationDefined
|
||||
location:NSZeroPoint
|
||||
|
@ -70,7 +70,7 @@ static BOOL stepsIsRunning;
|
|||
subtype:0
|
||||
data1:0
|
||||
data2:0];
|
||||
[realNSApp() postEvent:e atStart:NO]; // let pending events take priority (this is what PostQuitMessage() on Windows does so we have to do it here too for parity; thanks to mikeash in irc.freenode.net/#macdev for confirming that this parameter should indeed be NO)
|
||||
[uiprivNSApp() postEvent:e atStart:NO]; // let pending events take priority (this is what PostQuitMessage() on Windows does so we have to do it here too for parity; thanks to mikeash in irc.freenode.net/#macdev for confirming that this parameter should indeed be NO)
|
||||
|
||||
// and in case uiMainSteps() was called
|
||||
stepsIsRunning = NO;
|
||||
|
@ -78,7 +78,7 @@ static BOOL stepsIsRunning;
|
|||
|
||||
@end
|
||||
|
||||
@implementation appDelegate
|
||||
@implementation uiprivAppDelegate
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
|
@ -112,20 +112,20 @@ const char *uiInit(uiInitOptions *o)
|
|||
{
|
||||
@autoreleasepool {
|
||||
uiprivOptions = *o;
|
||||
app = [[applicationClass sharedApplication] retain];
|
||||
app = [[uiprivApplicationClass sharedApplication] retain];
|
||||
// don't check for a NO return; something (launch services?) causes running from application bundles to always return NO when asking to change activation policy, even if the change is to the same activation policy!
|
||||
// see https://github.com/andlabs/ui/issues/6
|
||||
[realNSApp() setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
delegate = [appDelegate new];
|
||||
[realNSApp() setDelegate:delegate];
|
||||
[uiprivNSApp() setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
delegate = [uiprivAppDelegate new];
|
||||
[uiprivNSApp() setDelegate:delegate];
|
||||
|
||||
initAlloc();
|
||||
loadFutures();
|
||||
loadUndocumented();
|
||||
uiprivInitAlloc();
|
||||
uiprivLoadFutures();
|
||||
uiprivLoadUndocumented();
|
||||
|
||||
// always do this so we always have an application menu
|
||||
appDelegate().menuManager = [[menuManager new] autorelease];
|
||||
[realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]];
|
||||
uiprivAppDelegate().menuManager = [[uiprivMenuManager new] autorelease];
|
||||
[uiprivNSApp() setMainMenu:[uiprivAppDelegate().menuManager makeMenubar]];
|
||||
|
||||
uiprivSetupFontPanel();
|
||||
|
||||
|
@ -146,9 +146,9 @@ void uiUninit(void)
|
|||
@autoreleasepool {
|
||||
uiprivUninitUnderlineColors();
|
||||
[delegate release];
|
||||
[realNSApp() setDelegate:nil];
|
||||
[uiprivNSApp() setDelegate:nil];
|
||||
[app release];
|
||||
uninitAlloc();
|
||||
uiprivUninitAlloc();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,15 +159,15 @@ void uiFreeInitError(const char *err)
|
|||
void uiMain(void)
|
||||
{
|
||||
isRunning = ^{
|
||||
return [realNSApp() isRunning];
|
||||
return [uiprivNSApp() isRunning];
|
||||
};
|
||||
[realNSApp() run];
|
||||
[uiprivNSApp() run];
|
||||
}
|
||||
|
||||
void uiMainSteps(void)
|
||||
{
|
||||
// SDL does this and it seems to be necessary for the menubar to work (see #182)
|
||||
[realNSApp() finishLaunching];
|
||||
[uiprivNSApp() finishLaunching];
|
||||
isRunning = ^{
|
||||
return stepsIsRunning;
|
||||
};
|
||||
|
@ -176,7 +176,7 @@ void uiMainSteps(void)
|
|||
|
||||
int uiMainStep(int wait)
|
||||
{
|
||||
struct nextEventArgs nea;
|
||||
uiprivNextEventArgs nea;
|
||||
|
||||
nea.mask = NSAnyEventMask;
|
||||
|
||||
|
@ -189,7 +189,7 @@ int uiMainStep(int wait)
|
|||
nea.mode = NSDefaultRunLoopMode;
|
||||
nea.dequeue = YES;
|
||||
|
||||
return mainStep(&nea, ^(NSEvent *e) {
|
||||
return uiprivMainStep(&nea, ^(NSEvent *e) {
|
||||
return NO;
|
||||
});
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ int uiMainStep(int wait)
|
|||
// see also:
|
||||
// - http://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html
|
||||
// - https://github.com/gnustep/gui/blob/master/Source/NSApplication.m
|
||||
int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
||||
int uiprivMainStep(uiprivNextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
||||
{
|
||||
NSDate *expire;
|
||||
NSEvent *e;
|
||||
|
@ -207,7 +207,7 @@ int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
|||
if (!isRunning())
|
||||
return 0;
|
||||
|
||||
e = [realNSApp() nextEventMatchingMask:nea->mask
|
||||
e = [uiprivNSApp() nextEventMatchingMask:nea->mask
|
||||
untilDate:nea->duration
|
||||
inMode:nea->mode
|
||||
dequeue:nea->dequeue];
|
||||
|
@ -216,13 +216,13 @@ int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
|||
|
||||
type = [e type];
|
||||
if (!interceptEvent(e))
|
||||
[realNSApp() sendEvent:e];
|
||||
[realNSApp() updateWindows];
|
||||
[uiprivNSApp() sendEvent:e];
|
||||
[uiprivNSApp() updateWindows];
|
||||
|
||||
// GNUstep does this
|
||||
// it also updates the Services menu but there doesn't seem to be a public API for that so
|
||||
if (type != NSPeriodic && type != NSMouseMoved)
|
||||
[[realNSApp() mainMenu] update];
|
||||
[[uiprivNSApp() mainMenu] update];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
|||
void uiQuit(void)
|
||||
{
|
||||
canQuit = YES;
|
||||
[realNSApp() terminate:realNSApp()];
|
||||
[uiprivNSApp() terminate:uiprivNSApp()];
|
||||
}
|
||||
|
||||
// thanks to mikeash in irc.freenode.net/#macdev for suggesting the use of Grand Central Dispatch for this
|
||||
|
|
32
darwin/map.m
32
darwin/map.m
|
@ -4,22 +4,22 @@
|
|||
// unfortunately NSMutableDictionary copies its keys, meaning we can't use it for pointers
|
||||
// hence, this file
|
||||
// we could expose a NSMapTable directly, but let's treat all pointers as opaque and hide the implementation, just to be safe and prevent even more rewrites later
|
||||
struct mapTable {
|
||||
struct uiprivMap {
|
||||
NSMapTable *m;
|
||||
};
|
||||
|
||||
struct mapTable *newMap(void)
|
||||
uiprivMap *uiprivNewMap(void)
|
||||
{
|
||||
struct mapTable *m;
|
||||
uiprivMap *m;
|
||||
|
||||
m = uiprivNew(struct mapTable);
|
||||
m = uiprivNew(uiprivMap);
|
||||
m->m = [[NSMapTable alloc] initWithKeyOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||
valueOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||
capacity:0];
|
||||
return m;
|
||||
}
|
||||
|
||||
void mapDestroy(struct mapTable *m)
|
||||
void uiprivMapDestroy(uiprivMap *m)
|
||||
{
|
||||
if ([m->m count] != 0)
|
||||
uiprivImplBug("attempt to destroy map with items inside");
|
||||
|
@ -27,33 +27,35 @@ void mapDestroy(struct mapTable *m)
|
|||
uiprivFree(m);
|
||||
}
|
||||
|
||||
void *mapGet(struct mapTable *m, void *key)
|
||||
void *uiprivMapGet(uiprivMap *m, void *key)
|
||||
{
|
||||
return NSMapGet(m->m, key);
|
||||
}
|
||||
|
||||
void mapSet(struct mapTable *m, void *key, void *value)
|
||||
void uiprivMapSet(uiprivMap *m, void *key, void *value)
|
||||
{
|
||||
NSMapInsert(m->m, key, value);
|
||||
}
|
||||
|
||||
void mapDelete(struct mapTable *m, void *key)
|
||||
void uiprivMapDelete(uiprivMap *m, void *key)
|
||||
{
|
||||
NSMapRemove(m->m, key);
|
||||
}
|
||||
|
||||
void mapWalk(struct mapTable *m, void (*f)(void *key, void *value))
|
||||
void uiprivMapWalk(uiprivMap *m, void (*f)(void *key, void *value))
|
||||
{
|
||||
NSMapEnumerator e = NSEnumerateMapTable(m->m);
|
||||
void *k = NULL;
|
||||
void *v = NULL;
|
||||
while (NSNextMapEnumeratorPair(&e, &k, &v)) {
|
||||
NSMapEnumerator e;
|
||||
void *k, *v;
|
||||
|
||||
e = NSEnumerateMapTable(m->m);
|
||||
k = NULL;
|
||||
v = NULL;
|
||||
while (NSNextMapEnumeratorPair(&e, &k, &v))
|
||||
f(k, v);
|
||||
}
|
||||
NSEndMapTableEnumeration(&e);
|
||||
}
|
||||
|
||||
void mapReset(struct mapTable *m)
|
||||
void uiprivMapReset(uiprivMap *m)
|
||||
{
|
||||
NSResetMapTable(m->m);
|
||||
}
|
||||
|
|
|
@ -31,17 +31,17 @@ static void mapItemReleaser(void *key, void *value)
|
|||
{
|
||||
uiMenuItem *item;
|
||||
|
||||
item = (uiMenuItem *)value;
|
||||
item = (uiMenuItem *) value;
|
||||
[item->item release];
|
||||
}
|
||||
|
||||
@implementation menuManager
|
||||
@implementation uiprivMenuManager
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self->items = newMap();
|
||||
self->items = uiprivNewMap();
|
||||
self->hasQuit = NO;
|
||||
self->hasPreferences = NO;
|
||||
self->hasAbout = NO;
|
||||
|
@ -51,10 +51,10 @@ static void mapItemReleaser(void *key, void *value)
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapWalk(self->items, mapItemReleaser);
|
||||
mapReset(self->items);
|
||||
mapDestroy(self->items);
|
||||
uninitMenus();
|
||||
uiprivMapWalk(self->items, mapItemReleaser);
|
||||
uiprivMapReset(self->items);
|
||||
uiprivMapDestroy(self->items);
|
||||
uiprivUninitMenus();
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -62,11 +62,11 @@ static void mapItemReleaser(void *key, void *value)
|
|||
{
|
||||
uiMenuItem *item;
|
||||
|
||||
item = (uiMenuItem *) mapGet(self->items, sender);
|
||||
item = (uiMenuItem *) uiprivMapGet(self->items, sender);
|
||||
if (item->type == typeCheckbox)
|
||||
uiMenuItemSetChecked(item, !uiMenuItemChecked(item));
|
||||
// use the key window as the source of the menu event; it's the active window
|
||||
(*(item->onClicked))(item, windowFromNSWindow([realNSApp() keyWindow]), item->onClickedData);
|
||||
(*(item->onClicked))(item, uiprivWindowFromNSWindow([uiprivNSApp() keyWindow]), item->onClickedData);
|
||||
}
|
||||
|
||||
- (IBAction)onQuitClicked:(id)sender
|
||||
|
@ -94,7 +94,7 @@ static void mapItemReleaser(void *key, void *value)
|
|||
self->hasAbout = YES;
|
||||
break;
|
||||
}
|
||||
mapSet(self->items, item, smi);
|
||||
uiprivMapSet(self->items, item, smi);
|
||||
}
|
||||
|
||||
// on OS X there are two ways to handle menu items being enabled or disabled: automatically and manually
|
||||
|
@ -112,7 +112,7 @@ static void mapItemReleaser(void *key, void *value)
|
|||
if (item == self.aboutItem && !self->hasAbout)
|
||||
return NO;
|
||||
// then poll the item's enabled/disabled state
|
||||
smi = (uiMenuItem *) mapGet(self->items, item);
|
||||
smi = (uiMenuItem *) uiprivMapGet(self->items, item);
|
||||
return !smi->disabled;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ static void mapItemReleaser(void *key, void *value)
|
|||
item = [[[NSMenuItem alloc] initWithTitle:@"Services" action:NULL keyEquivalent:@""] autorelease];
|
||||
servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
|
||||
[item setSubmenu:servicesMenu];
|
||||
[realNSApp() setServicesMenu:servicesMenu];
|
||||
[uiprivNSApp() setServicesMenu:servicesMenu];
|
||||
[appMenu addItem:item];
|
||||
|
||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
@ -246,26 +246,26 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
|||
item->type = type;
|
||||
switch (item->type) {
|
||||
case typeQuit:
|
||||
item->item = [appDelegate().menuManager.quitItem retain];
|
||||
item->item = [uiprivAppDelegate().menuManager.quitItem retain];
|
||||
break;
|
||||
case typePreferences:
|
||||
item->item = [appDelegate().menuManager.preferencesItem retain];
|
||||
item->item = [uiprivAppDelegate().menuManager.preferencesItem retain];
|
||||
break;
|
||||
case typeAbout:
|
||||
item->item = [appDelegate().menuManager.aboutItem retain];
|
||||
item->item = [uiprivAppDelegate().menuManager.aboutItem retain];
|
||||
break;
|
||||
case typeSeparator:
|
||||
item->item = [[NSMenuItem separatorItem] retain];
|
||||
[m->menu addItem:item->item];
|
||||
break;
|
||||
default:
|
||||
item->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:@selector(onClicked:) keyEquivalent:@""];
|
||||
[item->item setTarget:appDelegate().menuManager];
|
||||
item->item = [[NSMenuItem alloc] initWithTitle:uiprivToNSString(name) action:@selector(onClicked:) keyEquivalent:@""];
|
||||
[item->item setTarget:uiprivAppDelegate().menuManager];
|
||||
[m->menu addItem:item->item];
|
||||
break;
|
||||
}
|
||||
|
||||
[appDelegate().menuManager register:item->item to:item];
|
||||
[uiprivAppDelegate().menuManager register:item->item to:item];
|
||||
item->onClicked = defaultOnClicked;
|
||||
|
||||
[m->items addObject:[NSValue valueWithPointer:item]];
|
||||
|
@ -321,15 +321,15 @@ 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];
|
||||
|
||||
[[realNSApp() mainMenu] addItem:m->item];
|
||||
[[uiprivNSApp() mainMenu] addItem:m->item];
|
||||
|
||||
[menus addObject:[NSValue valueWithPointer:m]];
|
||||
|
||||
|
@ -338,12 +338,12 @@ uiMenu *uiNewMenu(const char *name)
|
|||
} // @autoreleasepool
|
||||
}
|
||||
|
||||
void finalizeMenus(void)
|
||||
void uiprivFinalizeMenus(void)
|
||||
{
|
||||
menusFinalized = YES;
|
||||
}
|
||||
|
||||
void uninitMenus(void)
|
||||
void uiprivUninitMenus(void)
|
||||
{
|
||||
if (menus == NULL)
|
||||
return;
|
||||
|
|
|
@ -14,7 +14,7 @@ struct uiMultilineEntry {
|
|||
uiDarwinControl c;
|
||||
NSScrollView *sv;
|
||||
intrinsicSizeTextView *tv;
|
||||
struct scrollViewData *d;
|
||||
uiprivScrollViewData *d;
|
||||
void (*onChanged)(uiMultilineEntry *, void *);
|
||||
void *onChangedData;
|
||||
BOOL changing;
|
||||
|
@ -59,7 +59,7 @@ static void uiMultilineEntryDestroy(uiControl *c)
|
|||
{
|
||||
uiMultilineEntry *e = uiMultilineEntry(c);
|
||||
|
||||
scrollViewFreeData(e->sv, e->d);
|
||||
uiprivScrollViewFreeData(e->sv, e->d);
|
||||
[e->tv release];
|
||||
[e->sv release];
|
||||
uiFreeControl(uiControl(e));
|
||||
|
@ -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;
|
||||
|
@ -120,7 +120,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
|||
{
|
||||
uiMultilineEntry *e;
|
||||
NSFont *font;
|
||||
struct scrollViewCreateParams p;
|
||||
uiprivScrollViewCreateParams p;
|
||||
|
||||
uiDarwinNewControl(uiMultilineEntry, e);
|
||||
|
||||
|
@ -182,7 +182,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
|||
[[e->tv layoutManager] setAllowsNonContiguousLayout:YES];
|
||||
|
||||
// now just to be safe; this will do some of the above but whatever
|
||||
disableAutocorrect(e->tv);
|
||||
uiprivDisableAutocorrect(e->tv);
|
||||
|
||||
// see https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TextUILayer/Tasks/TextInScrollView.html
|
||||
// notice we don't use the Auto Layout code; see scrollview.m for more details
|
||||
|
@ -207,7 +207,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
|||
// let's just set it to the standard control font anyway, just to be safe
|
||||
[e->tv setFont:font];
|
||||
|
||||
memset(&p, 0, sizeof (struct scrollViewCreateParams));
|
||||
memset(&p, 0, sizeof (uiprivScrollViewCreateParams));
|
||||
p.DocumentView = e->tv;
|
||||
// this is what Interface Builder sets it to
|
||||
p.BackgroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
|
||||
|
@ -215,7 +215,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
|||
p.Bordered = YES;
|
||||
p.HScroll = hscroll;
|
||||
p.VScroll = YES;
|
||||
e->sv = mkScrollView(&p, &(e->d));
|
||||
e->sv = uiprivMkScrollView(&p, &(e->d));
|
||||
|
||||
uiMultilineEntryOnChanged(e, defaultOnChanged, NULL);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static uiForEach otfArrayForEachOT(const uiOpenTypeFeatures *otf, char a, char b
|
|||
|
||||
p.array = (CFMutableArrayRef) data;
|
||||
|
||||
p.tagKey = *FUTURE_kCTFontOpenTypeFeatureTag;
|
||||
p.tagKey = *uiprivFUTURE_kCTFontOpenTypeFeatureTag;
|
||||
p.tagIsNumber = NO;
|
||||
tagcstr[0] = a;
|
||||
tagcstr[1] = b;
|
||||
|
@ -87,7 +87,7 @@ static uiForEach otfArrayForEachOT(const uiOpenTypeFeatures *otf, char a, char b
|
|||
}
|
||||
p.tagValue = tagstr;
|
||||
|
||||
p.valueKey = *FUTURE_kCTFontOpenTypeFeatureValue;
|
||||
p.valueKey = *uiprivFUTURE_kCTFontOpenTypeFeatureValue;
|
||||
p.valueType = kCFNumberSInt32Type;
|
||||
p.valueValue = (const SInt32 *) (&value);
|
||||
addCTFeatureEntry(&p);
|
||||
|
@ -106,7 +106,7 @@ CFArrayRef uiprivOpenTypeFeaturesToCTFeatures(const uiOpenTypeFeatures *otf)
|
|||
// TODO
|
||||
}
|
||||
f = otfArrayForEachAAT;
|
||||
if (FUTURE_kCTFontOpenTypeFeatureTag != NULL && FUTURE_kCTFontOpenTypeFeatureValue != NULL)
|
||||
if (uiprivFUTURE_kCTFontOpenTypeFeatureTag != NULL && uiprivFUTURE_kCTFontOpenTypeFeatureValue != NULL)
|
||||
f = otfArrayForEachOT;
|
||||
uiOpenTypeFeaturesForEach(otf, f, array);
|
||||
return array;
|
||||
|
|
|
@ -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];
|
||||
|
@ -102,14 +102,14 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
|||
[r->view addSubview:b];
|
||||
|
||||
// pin horizontally to the edges of the superview
|
||||
constraint = mkConstraint(b, NSLayoutAttributeLeading,
|
||||
constraint = uiprivMkConstraint(b, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
r->view, NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
@"uiRadioButtons button leading constraint");
|
||||
[r->view addConstraint:constraint];
|
||||
[r->constraints addObject:constraint];
|
||||
constraint = mkConstraint(b, NSLayoutAttributeTrailing,
|
||||
constraint = uiprivMkConstraint(b, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
r->view, NSLayoutAttributeTrailing,
|
||||
1, 0,
|
||||
|
@ -120,14 +120,14 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
|||
// if this is the first view, pin it to the top
|
||||
// otherwise pin to the bottom of the last
|
||||
if ([r->buttons count] == 1)
|
||||
constraint = mkConstraint(b, NSLayoutAttributeTop,
|
||||
constraint = uiprivMkConstraint(b, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
r->view, NSLayoutAttributeTop,
|
||||
1, 0,
|
||||
@"uiRadioButtons first button top constraint");
|
||||
else {
|
||||
b2 = buttonAt(r, [r->buttons count] - 2);
|
||||
constraint = mkConstraint(b, NSLayoutAttributeTop,
|
||||
constraint = uiprivMkConstraint(b, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
b2, NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
|
@ -144,7 +144,7 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
|||
}
|
||||
|
||||
// and make the new bottom constraint
|
||||
r->lastv = mkConstraint(b, NSLayoutAttributeBottom,
|
||||
r->lastv = uiprivMkConstraint(b, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
r->view, NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
// see http://stackoverflow.com/questions/37979445/how-do-i-properly-set-up-a-scrolling-nstableview-using-auto-layout-what-ive-tr for why we don't use auto layout
|
||||
// TODO do the same with uiGroup and uiTab?
|
||||
|
||||
struct scrollViewData {
|
||||
struct uiprivScrollViewData {
|
||||
BOOL hscroll;
|
||||
BOOL vscroll;
|
||||
};
|
||||
|
||||
NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewData **dout)
|
||||
NSScrollView *uiprivMkScrollView(uiprivScrollViewCreateParams *p, uiprivScrollViewData **dout)
|
||||
{
|
||||
NSScrollView *sv;
|
||||
NSBorderType border;
|
||||
struct scrollViewData *d;
|
||||
uiprivScrollViewData *d;
|
||||
|
||||
sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
|
||||
if (p->BackgroundColor != nil)
|
||||
|
@ -39,15 +39,15 @@ NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewDa
|
|||
[sv setAllowsMagnification:NO];
|
||||
|
||||
[sv setDocumentView:p->DocumentView];
|
||||
d = uiprivNew(struct scrollViewData);
|
||||
scrollViewSetScrolling(sv, d, p->HScroll, p->VScroll);
|
||||
d = uiprivNew(uiprivScrollViewData);
|
||||
uiprivScrollViewSetScrolling(sv, d, p->HScroll, p->VScroll);
|
||||
|
||||
*dout = d;
|
||||
return sv;
|
||||
}
|
||||
|
||||
// based on http://blog.bjhomer.com/2014/08/nsscrollview-and-autolayout.html because (as pointed out there) Apple's official guide is really only for iOS
|
||||
void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hscroll, BOOL vscroll)
|
||||
void uiprivScrollViewSetScrolling(NSScrollView *sv, uiprivScrollViewData *d, BOOL hscroll, BOOL vscroll)
|
||||
{
|
||||
d->hscroll = hscroll;
|
||||
[sv setHasHorizontalScroller:d->hscroll];
|
||||
|
@ -55,7 +55,7 @@ void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hsc
|
|||
[sv setHasVerticalScroller:d->vscroll];
|
||||
}
|
||||
|
||||
void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d)
|
||||
void uiprivScrollViewFreeData(NSScrollView *sv, uiprivScrollViewData *d)
|
||||
{
|
||||
uiprivFree(d);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ struct uiSlider {
|
|||
};
|
||||
|
||||
@interface sliderDelegateClass : NSObject {
|
||||
struct mapTable *sliders;
|
||||
uiprivMap *sliders;
|
||||
}
|
||||
- (IBAction)onChanged:(id)sender;
|
||||
- (void)registerSlider:(uiSlider *)b;
|
||||
|
@ -42,13 +42,13 @@ struct uiSlider {
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
self->sliders = newMap();
|
||||
self->sliders = uiprivNewMap();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapDestroy(self->sliders);
|
||||
uiprivMapDestroy(self->sliders);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -56,13 +56,13 @@ struct uiSlider {
|
|||
{
|
||||
uiSlider *s;
|
||||
|
||||
s = (uiSlider *) mapGet(self->sliders, sender);
|
||||
s = (uiSlider *) uiprivMapGet(self->sliders, sender);
|
||||
(*(s->onChanged))(s, s->onChangedData);
|
||||
}
|
||||
|
||||
- (void)registerSlider:(uiSlider *)s
|
||||
{
|
||||
mapSet(self->sliders, s->slider, s);
|
||||
uiprivMapSet(self->sliders, s->slider, s);
|
||||
[s->slider setTarget:self];
|
||||
[s->slider setAction:@selector(onChanged:)];
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ struct uiSlider {
|
|||
- (void)unregisterSlider:(uiSlider *)s
|
||||
{
|
||||
[s->slider setTarget:nil];
|
||||
mapDelete(self->sliders, s->slider);
|
||||
uiprivMapDelete(self->sliders, s->slider);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -138,7 +138,7 @@ uiSlider *uiNewSlider(int min, int max)
|
|||
|
||||
if (sliderDelegate == nil) {
|
||||
sliderDelegate = [[sliderDelegateClass new] autorelease];
|
||||
[delegates addObject:sliderDelegate];
|
||||
[uiprivDelegates addObject:sliderDelegate];
|
||||
}
|
||||
[sliderDelegate registerSlider:s];
|
||||
uiSliderOnChanged(s, defaultOnChanged, NULL);
|
||||
|
|
|
@ -46,7 +46,7 @@ static CGFloat stepperYDelta(void)
|
|||
{
|
||||
self = [super initWithFrame:r];
|
||||
if (self) {
|
||||
self->tf = newEditableTextField();
|
||||
self->tf = uiprivNewEditableTextField();
|
||||
[self->tf setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
|
||||
self->formatter = [NSNumberFormatter new];
|
||||
|
@ -70,37 +70,37 @@ static CGFloat stepperYDelta(void)
|
|||
[self addSubview:self->tf];
|
||||
[self addSubview:self->stepper];
|
||||
|
||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeLeading,
|
||||
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeLeading,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeLeading,
|
||||
1, 0,
|
||||
@"uiSpinbox left edge")];
|
||||
[self addConstraint:mkConstraint(self->stepper, NSLayoutAttributeTrailing,
|
||||
[self addConstraint:uiprivMkConstraint(self->stepper, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeTrailing,
|
||||
1, 0,
|
||||
@"uiSpinbox right edge")];
|
||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeTop,
|
||||
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeTop,
|
||||
1, 0,
|
||||
@"uiSpinbox top edge text field")];
|
||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeBottom,
|
||||
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeBottom,
|
||||
1, 0,
|
||||
@"uiSpinbox bottom edge text field")];
|
||||
[self addConstraint:mkConstraint(self->stepper, NSLayoutAttributeTop,
|
||||
[self addConstraint:uiprivMkConstraint(self->stepper, NSLayoutAttributeTop,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeTop,
|
||||
1, stepperYDelta(),
|
||||
@"uiSpinbox top edge stepper")];
|
||||
[self addConstraint:mkConstraint(self->stepper, NSLayoutAttributeBottom,
|
||||
[self addConstraint:uiprivMkConstraint(self->stepper, NSLayoutAttributeBottom,
|
||||
NSLayoutRelationEqual,
|
||||
self, NSLayoutAttributeBottom,
|
||||
1, stepperYDelta(),
|
||||
@"uiSpinbox bottom edge stepper")];
|
||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeTrailing,
|
||||
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeTrailing,
|
||||
NSLayoutRelationEqual,
|
||||
self->stepper, NSLayoutAttributeLeading,
|
||||
1, -3, // arbitrary amount; good enough visually (and it seems to match NSDatePicker too, at least on 10.11, which is even better)
|
||||
|
|
|
@ -24,9 +24,9 @@ static char *runSavePanel(NSWindow *parent, NSSavePanel *s)
|
|||
char *filename;
|
||||
|
||||
[s beginSheetModalForWindow:parent completionHandler:^(NSInteger result) {
|
||||
[realNSApp() stopModalWithCode:result];
|
||||
[uiprivNSApp() stopModalWithCode:result];
|
||||
}];
|
||||
if ([realNSApp() runModalForWindow:s] != NSFileHandlingPanelOKButton)
|
||||
if ([uiprivNSApp() runModalForWindow:s] != NSFileHandlingPanelOKButton)
|
||||
return NULL;
|
||||
filename = uiDarwinNSStringToText([[s URL] path]);
|
||||
return filename;
|
||||
|
@ -84,12 +84,12 @@ char *uiSaveFile(uiWindow *parent)
|
|||
modalDelegate:self
|
||||
didEndSelector:@selector(panelEnded:result:data:)
|
||||
contextInfo:NULL];
|
||||
return [realNSApp() runModalForWindow:[self->panel window]];
|
||||
return [uiprivNSApp() runModalForWindow:[self->panel window]];
|
||||
}
|
||||
|
||||
- (void)panelEnded:(NSAlert *)panel result:(NSInteger)result data:(void *)data
|
||||
{
|
||||
[realNSApp() stopModalWithCode:result];
|
||||
[uiprivNSApp() stopModalWithCode:result];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -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];
|
||||
|
|
12
darwin/tab.m
12
darwin/tab.m
|
@ -4,7 +4,7 @@
|
|||
// TODO need to jiggle on tab change too (second page disabled tab label initially ambiguous)
|
||||
|
||||
@interface tabPage : NSObject {
|
||||
struct singleChildConstraints constraints;
|
||||
uiprivSingleChildConstraints constraints;
|
||||
int margined;
|
||||
NSView *view; // the NSTabViewItem view itself
|
||||
NSObject *pageID;
|
||||
|
@ -58,7 +58,7 @@ struct uiTab {
|
|||
[self removeChildConstraints];
|
||||
if (self.c == NULL)
|
||||
return;
|
||||
singleChildConstraintsEstablish(&(self->constraints),
|
||||
uiprivSingleChildConstraintsEstablish(&(self->constraints),
|
||||
self->view, [self childView],
|
||||
uiDarwinControlHugsTrailingEdge(uiDarwinControl(self.c)),
|
||||
uiDarwinControlHugsBottom(uiDarwinControl(self.c)),
|
||||
|
@ -68,7 +68,7 @@ struct uiTab {
|
|||
|
||||
- (void)removeChildConstraints
|
||||
{
|
||||
singleChildConstraintsRemove(&(self->constraints), self->view);
|
||||
uiprivSingleChildConstraintsRemove(&(self->constraints), self->view);
|
||||
}
|
||||
|
||||
- (int)isMargined
|
||||
|
@ -79,7 +79,7 @@ struct uiTab {
|
|||
- (void)setMargined:(int)m
|
||||
{
|
||||
self->margined = m;
|
||||
singleChildConstraintsSetMargined(&(self->constraints), self->margined);
|
||||
uiprivSingleChildConstraintsSetMargined(&(self->constraints), self->margined);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -136,7 +136,7 @@ static void tabRelayout(uiTab *t)
|
|||
for (page in t->pages)
|
||||
[page establishChildConstraints];
|
||||
// and this gets rid of some weird issues with regards to box alignment
|
||||
jiggleViewLayout(t->tabview);
|
||||
uiprivJiggleViewLayout(t->tabview);
|
||||
}
|
||||
|
||||
BOOL uiTabHugsTrailingEdge(uiDarwinControl *c)
|
||||
|
@ -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];
|
||||
|
||||
|
|
|
@ -3,27 +3,41 @@
|
|||
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_8
|
||||
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_8
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <dlfcn.h> // see future.m
|
||||
#import <dlfcn.h> // see future.m
|
||||
#import "../ui.h"
|
||||
#import "../ui_darwin.h"
|
||||
#import "../common/uipriv.h"
|
||||
|
||||
// TODO should we rename the uiprivMk things or not
|
||||
// TODO what about renaming class wrapper functions that return the underlying class (like uiprivNewLabel())
|
||||
|
||||
#if __has_feature(objc_arc)
|
||||
#error Sorry, libui cannot be compiled with ARC.
|
||||
#endif
|
||||
|
||||
#define toNSString(str) [NSString stringWithUTF8String:(str)]
|
||||
#define fromNSString(str) [(str) UTF8String]
|
||||
#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;
|
||||
|
||||
// map.m
|
||||
typedef struct uiprivMap uiprivMap;
|
||||
extern uiprivMap *uiprivNewMap(void);
|
||||
extern void uiprivMapDestroy(uiprivMap *m);
|
||||
extern void *uiprivMapGet(uiprivMap *m, void *key);
|
||||
extern void uiprivMapSet(uiprivMap *m, void *key, void *value);
|
||||
extern void uiprivMapDelete(uiprivMap *m, void *key);
|
||||
extern void uiprivMapWalk(uiprivMap *m, void (*f)(void *key, void *value));
|
||||
extern void uiprivMapReset(uiprivMap *m);
|
||||
|
||||
// menu.m
|
||||
@interface menuManager : NSObject {
|
||||
struct mapTable *items;
|
||||
@interface uiprivMenuManager : NSObject {
|
||||
uiprivMap *items;
|
||||
BOOL hasQuit;
|
||||
BOOL hasPreferences;
|
||||
BOOL hasAbout;
|
||||
|
@ -35,50 +49,52 @@
|
|||
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
||||
- (NSMenu *)makeMenubar;
|
||||
@end
|
||||
extern void finalizeMenus(void);
|
||||
extern void uninitMenus(void);
|
||||
extern void uiprivFinalizeMenus(void);
|
||||
extern void uiprivUninitMenus(void);
|
||||
|
||||
// main.m
|
||||
@interface applicationClass : NSApplication
|
||||
@interface uiprivApplicationClass : NSApplication
|
||||
@end
|
||||
// this is needed because NSApp is of type id, confusing clang
|
||||
#define realNSApp() ((applicationClass *) NSApp)
|
||||
@interface appDelegate : NSObject <NSApplicationDelegate>
|
||||
@property (strong) menuManager *menuManager;
|
||||
#define uiprivNSApp() ((uiprivApplicationClass *) NSApp)
|
||||
@interface uiprivAppDelegate : NSObject<NSApplicationDelegate>
|
||||
@property (strong) uiprivMenuManager *menuManager;
|
||||
@end
|
||||
#define appDelegate() ((appDelegate *) [realNSApp() delegate])
|
||||
struct nextEventArgs {
|
||||
#define uiprivAppDelegate() ((uiprivAppDelegate *) [uiprivNSApp() delegate])
|
||||
typedef struct uiprivNextEventArgs uiprivNextEventArgs;
|
||||
struct uiprivNextEventArgs {
|
||||
NSEventMask mask;
|
||||
NSDate *duration;
|
||||
// LONGTERM no NSRunLoopMode?
|
||||
NSString *mode;
|
||||
BOOL dequeue;
|
||||
};
|
||||
extern int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *));
|
||||
extern int uiprivMainStep(uiprivNextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *));
|
||||
|
||||
// util.m
|
||||
extern void disableAutocorrect(NSTextView *);
|
||||
extern void uiprivDisableAutocorrect(NSTextView *);
|
||||
|
||||
// entry.m
|
||||
extern void finishNewTextField(NSTextField *, BOOL);
|
||||
extern NSTextField *newEditableTextField(void);
|
||||
extern void uiprivFinishNewTextField(NSTextField *, BOOL);
|
||||
extern NSTextField *uiprivNewEditableTextField(void);
|
||||
|
||||
// window.m
|
||||
@interface libuiNSWindow : NSWindow
|
||||
- (void)libui_doMove:(NSEvent *)initialEvent;
|
||||
- (void)libui_doResize:(NSEvent *)initialEvent on:(uiWindowResizeEdge)edge;
|
||||
@interface uiprivNSWindow : NSWindow
|
||||
- (void)uiprivDoMove:(NSEvent *)initialEvent;
|
||||
- (void)uiprivDoResize:(NSEvent *)initialEvent on:(uiWindowResizeEdge)edge;
|
||||
@end
|
||||
extern uiWindow *windowFromNSWindow(NSWindow *);
|
||||
extern uiWindow *uiprivWindowFromNSWindow(NSWindow *);
|
||||
|
||||
// alloc.m
|
||||
extern NSMutableArray *delegates;
|
||||
extern void initAlloc(void);
|
||||
extern void uninitAlloc(void);
|
||||
extern NSMutableArray *uiprivDelegates;
|
||||
extern void uiprivInitAlloc(void);
|
||||
extern void uiprivUninitAlloc(void);
|
||||
|
||||
// autolayout.m
|
||||
extern NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc);
|
||||
extern void jiggleViewLayout(NSView *view);
|
||||
struct singleChildConstraints {
|
||||
extern NSLayoutConstraint *uiprivMkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc);
|
||||
extern void uiprivJiggleViewLayout(NSView *view);
|
||||
typedef struct uiprivSingleChildConstraints uiprivSingleChildConstraints;
|
||||
struct uiprivSingleChildConstraints {
|
||||
NSLayoutConstraint *leadingConstraint;
|
||||
NSLayoutConstraint *topConstraint;
|
||||
NSLayoutConstraint *trailingConstraintGreater;
|
||||
|
@ -86,29 +102,20 @@ struct singleChildConstraints {
|
|||
NSLayoutConstraint *bottomConstraintGreater;
|
||||
NSLayoutConstraint *bottomConstraintEqual;
|
||||
};
|
||||
extern void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc);
|
||||
extern void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv);
|
||||
extern void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int margined);
|
||||
|
||||
// map.m
|
||||
extern struct mapTable *newMap(void);
|
||||
extern void mapDestroy(struct mapTable *m);
|
||||
extern void *mapGet(struct mapTable *m, void *key);
|
||||
extern void mapSet(struct mapTable *m, void *key, void *value);
|
||||
extern void mapDelete(struct mapTable *m, void *key);
|
||||
extern void mapWalk(struct mapTable *m, void (*f)(void *key, void *value));
|
||||
extern void mapReset(struct mapTable *m);
|
||||
extern void uiprivSingleChildConstraintsEstablish(uiprivSingleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc);
|
||||
extern void uiprivSingleChildConstraintsRemove(uiprivSingleChildConstraints *c, NSView *cv);
|
||||
extern void uiprivSingleChildConstraintsSetMargined(uiprivSingleChildConstraints *c, int margined);
|
||||
|
||||
// area.m
|
||||
extern int sendAreaEvents(NSEvent *);
|
||||
extern int uiprivSendAreaEvents(NSEvent *);
|
||||
|
||||
// areaevents.m
|
||||
extern BOOL fromKeycode(unsigned short keycode, uiAreaKeyEvent *ke);
|
||||
extern BOOL keycodeModifier(unsigned short keycode, uiModifiers *mod);
|
||||
extern BOOL uiprivFromKeycode(unsigned short keycode, uiAreaKeyEvent *ke);
|
||||
extern BOOL uiprivKeycodeModifier(unsigned short keycode, uiModifiers *mod);
|
||||
|
||||
// draw.m
|
||||
extern uiDrawContext *newContext(CGContextRef, CGFloat);
|
||||
extern void freeContext(uiDrawContext *);
|
||||
extern uiDrawContext *uiprivDrawNewContext(CGContextRef, CGFloat);
|
||||
extern void uiprivDrawFreeContext(uiDrawContext *);
|
||||
|
||||
// fontbutton.m
|
||||
extern BOOL uiprivFontButtonInhibitSendAction(SEL sel, id from, id to);
|
||||
|
@ -116,10 +123,12 @@ extern BOOL uiprivFontButtonOverrideTargetForAction(SEL sel, id from, id to, id
|
|||
extern void uiprivSetupFontPanel(void);
|
||||
|
||||
// colorbutton.m
|
||||
extern BOOL colorButtonInhibitSendAction(SEL sel, id from, id to);
|
||||
extern BOOL uiprivColorButtonInhibitSendAction(SEL sel, id from, id to);
|
||||
|
||||
// scrollview.m
|
||||
struct scrollViewCreateParams {
|
||||
typedef struct uiprivScrollViewCreateParams uiprivScrollViewCreateParams;
|
||||
struct uiprivScrollViewCreateParams {
|
||||
// TODO MAYBE fix these identifiers
|
||||
NSView *DocumentView;
|
||||
NSColor *BackgroundColor;
|
||||
BOOL DrawsBackground;
|
||||
|
@ -127,30 +136,30 @@ struct scrollViewCreateParams {
|
|||
BOOL HScroll;
|
||||
BOOL VScroll;
|
||||
};
|
||||
struct scrollViewData;
|
||||
extern NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewData **dout);
|
||||
extern void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hscroll, BOOL vscroll);
|
||||
extern void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d);
|
||||
typedef struct uiprivScrollViewData uiprivScrollViewData;
|
||||
extern NSScrollView *uiprivMkScrollView(uiprivScrollViewCreateParams *p, uiprivScrollViewData **dout);
|
||||
extern void uiprivScrollViewSetScrolling(NSScrollView *sv, uiprivScrollViewData *d, BOOL hscroll, BOOL vscroll);
|
||||
extern void uiprivScrollViewFreeData(NSScrollView *sv, uiprivScrollViewData *d);
|
||||
|
||||
// label.m
|
||||
extern NSTextField *newLabel(NSString *str);
|
||||
extern NSTextField *uiprivNewLabel(NSString *str);
|
||||
|
||||
// image.m
|
||||
extern NSImage *imageImage(uiImage *);
|
||||
extern NSImage *uiprivImageNSImage(uiImage *);
|
||||
|
||||
// winmoveresize.m
|
||||
extern void doManualMove(NSWindow *w, NSEvent *initialEvent);
|
||||
extern void doManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge);
|
||||
extern void uiprivDoManualMove(NSWindow *w, NSEvent *initialEvent);
|
||||
extern void uiprivDoManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge);
|
||||
|
||||
// future.m
|
||||
extern CFStringRef *FUTURE_kCTFontOpenTypeFeatureTag;
|
||||
extern CFStringRef *FUTURE_kCTFontOpenTypeFeatureValue;
|
||||
extern CFStringRef *FUTURE_kCTBackgroundColorAttributeName;
|
||||
extern void loadFutures(void);
|
||||
extern void FUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSString *identifier);
|
||||
extern BOOL FUTURE_NSWindow_performWindowDragWithEvent(NSWindow *w, NSEvent *initialEvent);
|
||||
extern CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureTag;
|
||||
extern CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureValue;
|
||||
extern CFStringRef *uiprivFUTURE_kCTBackgroundColorAttributeName;
|
||||
extern void uiprivLoadFutures(void);
|
||||
extern void uiprivFUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSString *identifier);
|
||||
extern BOOL uiprivFUTURE_NSWindow_performWindowDragWithEvent(NSWindow *w, NSEvent *initialEvent);
|
||||
|
||||
// undocumented.m
|
||||
extern CFStringRef UNDOC_kCTFontPreferredSubFamilyNameKey;
|
||||
extern CFStringRef UNDOC_kCTFontPreferredFamilyNameKey;
|
||||
extern void loadUndocumented(void);
|
||||
extern CFStringRef uiprivUNDOC_kCTFontPreferredSubFamilyNameKey;
|
||||
extern CFStringRef uiprivUNDOC_kCTFontPreferredFamilyNameKey;
|
||||
extern void uiprivLoadUndocumented(void);
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
// we also provide default values just in case
|
||||
|
||||
// these values come from 10.12.6
|
||||
CFStringRef UNDOC_kCTFontPreferredSubFamilyNameKey = CFSTR("CTFontPreferredSubFamilyName");
|
||||
CFStringRef UNDOC_kCTFontPreferredFamilyNameKey = CFSTR("CTFontPreferredFamilyName");
|
||||
CFStringRef uiprivUNDOC_kCTFontPreferredSubFamilyNameKey = CFSTR("CTFontPreferredSubFamilyName");
|
||||
CFStringRef uiprivUNDOC_kCTFontPreferredFamilyNameKey = CFSTR("CTFontPreferredFamilyName");
|
||||
|
||||
// note that we treat any error as "the symbols aren't there" (and don't care if dlclose() failed)
|
||||
void loadUndocumented(void)
|
||||
void uiprivLoadUndocumented(void)
|
||||
{
|
||||
void *handle;
|
||||
CFStringRef *str;
|
||||
|
@ -23,9 +23,9 @@ void loadUndocumented(void)
|
|||
GET(str, kCTFontPreferredSubFamilyNameKey);
|
||||
NSLog(@"get %p", str);
|
||||
if (str != NULL)
|
||||
UNDOC_kCTFontPreferredSubFamilyNameKey = *str;
|
||||
uiprivUNDOC_kCTFontPreferredSubFamilyNameKey = *str;
|
||||
GET(str, kCTFontPreferredFamilyNameKey);
|
||||
if (str != NULL)
|
||||
UNDOC_kCTFontPreferredFamilyNameKey = *str;
|
||||
uiprivUNDOC_kCTFontPreferredFamilyNameKey = *str;
|
||||
dlclose(handle);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#import "uipriv_darwin.h"
|
||||
|
||||
// LONGTERM do we really want to do this? make it an option?
|
||||
void disableAutocorrect(NSTextView *tv)
|
||||
// TODO figure out why we removed this from window.m
|
||||
void uiprivDisableAutocorrect(NSTextView *tv)
|
||||
{
|
||||
[tv setEnabledTextCheckingTypes:0];
|
||||
[tv setAutomaticDashSubstitutionEnabled:NO];
|
||||
|
|
|
@ -10,7 +10,7 @@ struct uiWindow {
|
|||
int margined;
|
||||
int (*onClosing)(uiWindow *, void *);
|
||||
void *onClosingData;
|
||||
struct singleChildConstraints constraints;
|
||||
uiprivSingleChildConstraints constraints;
|
||||
void (*onContentSizeChanged)(uiWindow *, void *);
|
||||
void *onContentSizeChangedData;
|
||||
BOOL suppressSizeChanged;
|
||||
|
@ -18,22 +18,22 @@ struct uiWindow {
|
|||
int borderless;
|
||||
};
|
||||
|
||||
@implementation libuiNSWindow
|
||||
@implementation uiprivNSWindow
|
||||
|
||||
- (void)libui_doMove:(NSEvent *)initialEvent
|
||||
- (void)uiprivDoMove:(NSEvent *)initialEvent
|
||||
{
|
||||
doManualMove(self, initialEvent);
|
||||
uiprivDoManualMove(self, initialEvent);
|
||||
}
|
||||
|
||||
- (void)libui_doResize:(NSEvent *)initialEvent on:(uiWindowResizeEdge)edge
|
||||
- (void)uiprivDoResize:(NSEvent *)initialEvent on:(uiWindowResizeEdge)edge
|
||||
{
|
||||
doManualResize(self, initialEvent, edge);
|
||||
uiprivDoManualResize(self, initialEvent, edge);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
|
||||
struct mapTable *windows;
|
||||
uiprivMap *windows;
|
||||
}
|
||||
- (BOOL)windowShouldClose:(id)sender;
|
||||
- (void)windowDidResize:(NSNotification *)note;
|
||||
|
@ -50,13 +50,13 @@ struct uiWindow {
|
|||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
self->windows = newMap();
|
||||
self->windows = uiprivNewMap();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
mapDestroy(self->windows);
|
||||
uiprivMapDestroy(self->windows);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -100,21 +100,21 @@ struct uiWindow {
|
|||
|
||||
- (void)registerWindow:(uiWindow *)w
|
||||
{
|
||||
mapSet(self->windows, w->window, w);
|
||||
uiprivMapSet(self->windows, w->window, w);
|
||||
[w->window setDelegate:self];
|
||||
}
|
||||
|
||||
- (void)unregisterWindow:(uiWindow *)w
|
||||
{
|
||||
[w->window setDelegate:nil];
|
||||
mapDelete(self->windows, w->window);
|
||||
uiprivMapDelete(self->windows, w->window);
|
||||
}
|
||||
|
||||
- (uiWindow *)lookupWindow:(NSWindow *)w
|
||||
{
|
||||
uiWindow *v;
|
||||
|
||||
v = uiWindow(mapGet(self->windows, w));
|
||||
v = uiWindow(uiprivMapGet(self->windows, w));
|
||||
// this CAN (and IS ALLOWED TO) return NULL, just in case we're called with some OS X-provided window as the key window
|
||||
return v;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static void removeConstraints(uiWindow *w)
|
|||
NSView *cv;
|
||||
|
||||
cv = [w->window contentView];
|
||||
singleChildConstraintsRemove(&(w->constraints), cv);
|
||||
uiprivSingleChildConstraintsRemove(&(w->constraints), cv);
|
||||
}
|
||||
|
||||
static void uiWindowDestroy(uiControl *c)
|
||||
|
@ -215,7 +215,7 @@ static void windowRelayout(uiWindow *w)
|
|||
return;
|
||||
childView = (NSView *) uiControlHandle(w->child);
|
||||
contentView = [w->window contentView];
|
||||
singleChildConstraintsEstablish(&(w->constraints),
|
||||
uiprivSingleChildConstraintsEstablish(&(w->constraints),
|
||||
contentView, childView,
|
||||
uiDarwinControlHugsTrailingEdge(uiDarwinControl(w->child)),
|
||||
uiDarwinControlHugsBottom(uiDarwinControl(w->child)),
|
||||
|
@ -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)
|
||||
|
@ -354,7 +354,7 @@ int uiWindowMargined(uiWindow *w)
|
|||
void uiWindowSetMargined(uiWindow *w, int margined)
|
||||
{
|
||||
w->margined = margined;
|
||||
singleChildConstraintsSetMargined(&(w->constraints), w->margined);
|
||||
uiprivSingleChildConstraintsSetMargined(&(w->constraints), w->margined);
|
||||
}
|
||||
|
||||
static int defaultOnClosing(uiWindow *w, void *data)
|
||||
|
@ -371,15 +371,15 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
{
|
||||
uiWindow *w;
|
||||
|
||||
finalizeMenus();
|
||||
uiprivFinalizeMenus();
|
||||
|
||||
uiDarwinNewControl(uiWindow, w);
|
||||
|
||||
w->window = [[libuiNSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
|
||||
w->window = [[uiprivNSWindow alloc] initWithContentRect:NSMakeRect(0, 0, (CGFloat) width, (CGFloat) height)
|
||||
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
|
||||
|
@ -387,7 +387,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
|
||||
if (windowDelegate == nil) {
|
||||
windowDelegate = [[windowDelegateClass new] autorelease];
|
||||
[delegates addObject:windowDelegate];
|
||||
[uiprivDelegates addObject:windowDelegate];
|
||||
}
|
||||
[windowDelegate registerWindow:w];
|
||||
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
||||
|
@ -397,7 +397,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
|||
}
|
||||
|
||||
// utility function for menus
|
||||
uiWindow *windowFromNSWindow(NSWindow *w)
|
||||
uiWindow *uiprivWindowFromNSWindow(NSWindow *w)
|
||||
{
|
||||
if (w == nil)
|
||||
return NULL;
|
||||
|
|
|
@ -43,16 +43,16 @@ void onMoveDrag(struct onMoveDragParams *p, NSEvent *e)
|
|||
[p->w setFrameOrigin:frame.origin];
|
||||
}
|
||||
|
||||
void doManualMove(NSWindow *w, NSEvent *initialEvent)
|
||||
void uiprivDoManualMove(NSWindow *w, NSEvent *initialEvent)
|
||||
{
|
||||
__block struct onMoveDragParams mdp;
|
||||
struct nextEventArgs nea;
|
||||
uiprivNextEventArgs nea;
|
||||
BOOL (^handleEvent)(NSEvent *e);
|
||||
__block BOOL done;
|
||||
|
||||
// 10.11 gives us a method to handle this for us
|
||||
// use it if available; this lets us use the real OS dragging code, which means we can take advantage of OS features like Spaces
|
||||
if (FUTURE_NSWindow_performWindowDragWithEvent(w, initialEvent))
|
||||
if (uiprivFUTURE_NSWindow_performWindowDragWithEvent(w, initialEvent))
|
||||
return;
|
||||
|
||||
mdp.w = w;
|
||||
|
@ -72,7 +72,7 @@ void doManualMove(NSWindow *w, NSEvent *initialEvent)
|
|||
return YES; // do not send
|
||||
};
|
||||
done = NO;
|
||||
while (mainStep(&nea, handleEvent))
|
||||
while (uiprivMainStep(&nea, handleEvent))
|
||||
if (done)
|
||||
break;
|
||||
}
|
||||
|
@ -90,14 +90,14 @@ static void minMaxAutoLayoutSizes(NSWindow *w, NSSize *min, NSSize *max)
|
|||
|
||||
// minimum: encourage the window to be as small as possible
|
||||
contentView = [w contentView];
|
||||
cw = mkConstraint(contentView, NSLayoutAttributeWidth,
|
||||
cw = uiprivMkConstraint(contentView, NSLayoutAttributeWidth,
|
||||
NSLayoutRelationEqual,
|
||||
nil, NSLayoutAttributeNotAnAttribute,
|
||||
0, 0,
|
||||
@"window minimum width finding constraint");
|
||||
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
||||
[contentView addConstraint:cw];
|
||||
ch = mkConstraint(contentView, NSLayoutAttributeHeight,
|
||||
ch = uiprivMkConstraint(contentView, NSLayoutAttributeHeight,
|
||||
NSLayoutRelationEqual,
|
||||
nil, NSLayoutAttributeNotAnAttribute,
|
||||
0, 0,
|
||||
|
@ -110,14 +110,14 @@ static void minMaxAutoLayoutSizes(NSWindow *w, NSSize *min, NSSize *max)
|
|||
|
||||
// maximum: encourage the window to be as large as possible
|
||||
contentView = [w contentView];
|
||||
cw = mkConstraint(contentView, NSLayoutAttributeWidth,
|
||||
cw = uiprivMkConstraint(contentView, NSLayoutAttributeWidth,
|
||||
NSLayoutRelationEqual,
|
||||
nil, NSLayoutAttributeNotAnAttribute,
|
||||
0, CGFLOAT_MAX,
|
||||
@"window maximum width finding constraint");
|
||||
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
||||
[contentView addConstraint:cw];
|
||||
ch = mkConstraint(contentView, NSLayoutAttributeHeight,
|
||||
ch = uiprivMkConstraint(contentView, NSLayoutAttributeHeight,
|
||||
NSLayoutRelationEqual,
|
||||
nil, NSLayoutAttributeNotAnAttribute,
|
||||
0, CGFLOAT_MAX,
|
||||
|
@ -220,10 +220,10 @@ static void onResizeDrag(struct onResizeDragParams *p, NSEvent *e)
|
|||
}
|
||||
|
||||
// TODO do our events get fired with this? *should* they?
|
||||
void doManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge)
|
||||
void uiprivDoManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge)
|
||||
{
|
||||
__block struct onResizeDragParams rdp;
|
||||
struct nextEventArgs nea;
|
||||
uiprivNextEventArgs nea;
|
||||
BOOL (^handleEvent)(NSEvent *e);
|
||||
__block BOOL done;
|
||||
|
||||
|
@ -247,7 +247,7 @@ void doManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge)
|
|||
return YES; // do not send
|
||||
};
|
||||
done = NO;
|
||||
while (mainStep(&nea, handleEvent))
|
||||
while (uiprivMainStep(&nea, handleEvent))
|
||||
if (done)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
TODO clean this up
|
||||
|
||||
TODO note that you -fvisibility=hidden means nothing in static libraries, hence this (confirmed on OS X)
|
||||
|
||||
In general, all names that begin with "ui" and are followed by a capital letter and all names htat begin with "uipriv" and are followed by a capita lletter are reserved by libui. This applies even in C++, where name mangling may affect the actual names in the object file.
|
||||
|
||||
# Reserved names; for users
|
||||
|
||||
All reserved names in libui are defined by a prefix followed by any uppercase letter in ASCII. The bullet lists before list those prefixes.
|
||||
|
||||
Global-scope identifiers of any form (variables, constant names, functions, structure names, union names, C++ class names, enum type names, enum value names, C++ namespace names, GObject class and interface struct names, and Objective-C class and protocol name identifiers) and macro names:
|
||||
|
||||
- `ui`
|
||||
- `uipriv`
|
||||
|
||||
GObject and Objective-C class, interface, and protocol name strings, in the form they take in their respective runtime memory (e.g. when passed to `g_type_from_name()` and `NSClassFromString()`, respectively):
|
||||
|
||||
- `uipriv`
|
||||
|
||||
Objective-C method names:
|
||||
|
||||
- `initWithUipriv`
|
||||
- `initWithFrame:uipriv` (TODO probably worth removing)
|
||||
- `uipriv`
|
||||
- `isUipriv` (for compatibility with KVO and `@property` statements)
|
||||
- `setUipriv` (for compatibility with KVO and `@property` statements)
|
||||
|
||||
Objective-C ivar names:
|
||||
|
||||
- `uipriv`
|
||||
- `_uipriv` (for compatibility with KVO and `@property` statements)
|
||||
|
||||
Objective-C property names:
|
||||
|
||||
- `uipriv`
|
||||
|
||||
TODO GObject macros (in libui's source code), properties, and signals
|
||||
|
||||
# Developer notes
|
||||
|
||||
TODO
|
Loading…
Reference in New Issue