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(_LIBUI_INCLUDEDIRS _LIBUI_INCLUDEDIRS PARENT_SCOPE)
|
||||||
|
|
||||||
set(_LIBUINAME libui 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)
|
macro(_handle_static)
|
||||||
set_target_properties(${_LIBUINAME} PROPERTIES
|
# do nothing
|
||||||
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)
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
set(_LIBUI_LIBS
|
set(_LIBUI_LIBS
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
static NSMutableArray *allocations;
|
static NSMutableArray *allocations;
|
||||||
NSMutableArray *delegates;
|
NSMutableArray *uiprivDelegates;
|
||||||
|
|
||||||
void initAlloc(void)
|
void uiprivInitAlloc(void)
|
||||||
{
|
{
|
||||||
allocations = [NSMutableArray new];
|
allocations = [NSMutableArray new];
|
||||||
delegates = [NSMutableArray new];
|
uiprivDelegates = [NSMutableArray new];
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UINT8(p) ((uint8_t *) (p))
|
#define UINT8(p) ((uint8_t *) (p))
|
||||||
|
@ -20,12 +20,12 @@ void initAlloc(void)
|
||||||
#define CCHAR(p) ((const char **) (p))
|
#define CCHAR(p) ((const char **) (p))
|
||||||
#define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t))
|
#define TYPE(p) CCHAR(UINT8(p) + sizeof (size_t))
|
||||||
|
|
||||||
void uninitAlloc(void)
|
void uiprivUninitAlloc(void)
|
||||||
{
|
{
|
||||||
NSMutableString *str;
|
NSMutableString *str;
|
||||||
NSValue *v;
|
NSValue *v;
|
||||||
|
|
||||||
[delegates release];
|
[uiprivDelegates release];
|
||||||
if ([allocations count] == 0) {
|
if ([allocations count] == 0) {
|
||||||
[allocations release];
|
[allocations release];
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct uiArea {
|
||||||
NSView *view; // either sv or area depending on whether it is scrolling
|
NSView *view; // either sv or area depending on whether it is scrolling
|
||||||
NSScrollView *sv;
|
NSScrollView *sv;
|
||||||
areaView *area;
|
areaView *area;
|
||||||
struct scrollViewData *d;
|
uiprivScrollViewData *d;
|
||||||
uiAreaHandler *ah;
|
uiAreaHandler *ah;
|
||||||
BOOL scrolling;
|
BOOL scrolling;
|
||||||
NSEvent *dragevent;
|
NSEvent *dragevent;
|
||||||
|
@ -57,7 +57,7 @@ struct uiArea {
|
||||||
|
|
||||||
c = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
|
c = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
|
||||||
// see draw.m under text for why we need the height
|
// 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.AreaWidth = 0;
|
||||||
dp.AreaHeight = 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
|
// 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);
|
(*(a->ah->Draw))(a->ah, a, &dp);
|
||||||
|
|
||||||
freeContext(dp.Context);
|
uiprivDrawFreeContext(dp.Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isFlipped
|
- (BOOL)isFlipped
|
||||||
|
@ -264,7 +264,7 @@ mouseEvent(otherMouseUp)
|
||||||
|
|
||||||
ke.Up = up;
|
ke.Up = up;
|
||||||
|
|
||||||
if (!fromKeycode([e keyCode], &ke))
|
if (!uiprivFromKeycode([e keyCode], &ke))
|
||||||
return 0;
|
return 0;
|
||||||
return [self sendKeyEvent:&ke];
|
return [self sendKeyEvent:&ke];
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ mouseEvent(otherMouseUp)
|
||||||
|
|
||||||
// Mac OS X sends this event on both key up and key down.
|
// 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
|
// 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;
|
return 0;
|
||||||
ke.Modifier = whichmod;
|
ke.Modifier = whichmod;
|
||||||
ke.Modifiers = [self parseModifiers:e];
|
ke.Modifiers = [self parseModifiers:e];
|
||||||
|
@ -350,7 +350,7 @@ static void uiAreaDestroy(uiControl *c)
|
||||||
uiArea *a = uiArea(c);
|
uiArea *a = uiArea(c);
|
||||||
|
|
||||||
if (a->scrolling)
|
if (a->scrolling)
|
||||||
scrollViewFreeData(a->sv, a->d);
|
uiprivScrollViewFreeData(a->sv, a->d);
|
||||||
[a->area release];
|
[a->area release];
|
||||||
if (a->scrolling)
|
if (a->scrolling)
|
||||||
[a->sv release];
|
[a->sv release];
|
||||||
|
@ -361,7 +361,7 @@ static void uiAreaDestroy(uiControl *c)
|
||||||
// by default, NSApplication eats some key events
|
// by default, NSApplication eats some key events
|
||||||
// this prevents that from happening with uiArea
|
// 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
|
// 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;
|
NSEventType type;
|
||||||
id focused;
|
id focused;
|
||||||
|
@ -409,26 +409,26 @@ void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height)
|
||||||
|
|
||||||
void uiAreaBeginUserWindowMove(uiArea *a)
|
void uiAreaBeginUserWindowMove(uiArea *a)
|
||||||
{
|
{
|
||||||
libuiNSWindow *w;
|
uiprivNSWindow *w;
|
||||||
|
|
||||||
w = (libuiNSWindow *) [a->area window];
|
w = (uiprivNSWindow *) [a->area window];
|
||||||
if (w == nil)
|
if (w == nil)
|
||||||
return; // TODO
|
return; // TODO
|
||||||
if (a->dragevent == nil)
|
if (a->dragevent == nil)
|
||||||
return; // TODO
|
return; // TODO
|
||||||
[w libui_doMove:a->dragevent];
|
[w uiprivDoMove:a->dragevent];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge)
|
void uiAreaBeginUserWindowResize(uiArea *a, uiWindowResizeEdge edge)
|
||||||
{
|
{
|
||||||
libuiNSWindow *w;
|
uiprivNSWindow *w;
|
||||||
|
|
||||||
w = (libuiNSWindow *) [a->area window];
|
w = (uiprivNSWindow *) [a->area window];
|
||||||
if (w == nil)
|
if (w == nil)
|
||||||
return; // TODO
|
return; // TODO
|
||||||
if (a->dragevent == nil)
|
if (a->dragevent == nil)
|
||||||
return; // TODO
|
return; // TODO
|
||||||
[w libui_doResize:a->dragevent on:edge];
|
[w uiprivDoResize:a->dragevent on:edge];
|
||||||
}
|
}
|
||||||
|
|
||||||
uiArea *uiNewArea(uiAreaHandler *ah)
|
uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
|
@ -450,7 +450,7 @@ uiArea *uiNewArea(uiAreaHandler *ah)
|
||||||
uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
uiArea *uiNewScrollingArea(uiAreaHandler *ah, int width, int height)
|
||||||
{
|
{
|
||||||
uiArea *a;
|
uiArea *a;
|
||||||
struct scrollViewCreateParams p;
|
uiprivScrollViewCreateParams p;
|
||||||
|
|
||||||
uiDarwinNewControl(uiArea, a);
|
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)
|
a->area = [[areaView alloc] initWithFrame:NSMakeRect(0, 0, width, height)
|
||||||
area:a];
|
area:a];
|
||||||
|
|
||||||
memset(&p, 0, sizeof (struct scrollViewCreateParams));
|
memset(&p, 0, sizeof (uiprivScrollViewCreateParams));
|
||||||
p.DocumentView = a->area;
|
p.DocumentView = a->area;
|
||||||
p.BackgroundColor = [NSColor controlColor];
|
p.BackgroundColor = [NSColor controlColor];
|
||||||
p.DrawsBackground = 1;
|
p.DrawsBackground = 1;
|
||||||
p.Bordered = NO;
|
p.Bordered = NO;
|
||||||
p.HScroll = YES;
|
p.HScroll = YES;
|
||||||
p.VScroll = YES;
|
p.VScroll = YES;
|
||||||
a->sv = mkScrollView(&p, &(a->d));
|
a->sv = uiprivMkScrollView(&p, &(a->d));
|
||||||
|
|
||||||
a->view = a->sv;
|
a->view = a->sv;
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ static const struct {
|
||||||
{ 0xFFFF, 0 },
|
{ 0xFFFF, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOL fromKeycode(unsigned short keycode, uiAreaKeyEvent *ke)
|
BOOL uiprivFromKeycode(unsigned short keycode, uiAreaKeyEvent *ke)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ BOOL fromKeycode(unsigned short keycode, uiAreaKeyEvent *ke)
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL keycodeModifier(unsigned short keycode, uiModifiers *mod)
|
BOOL uiprivKeycodeModifier(unsigned short keycode, uiModifiers *mod)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -296,14 +296,14 @@ static void addBackgroundAttribute(struct foreachParams *p, size_t start, size_t
|
||||||
uiprivDrawTextBackgroundParams *dtb;
|
uiprivDrawTextBackgroundParams *dtb;
|
||||||
|
|
||||||
// TODO make sure this works properly with line paragraph spacings (after figuring out what that means, of course)
|
// 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;
|
CGColorRef color;
|
||||||
CFRange range;
|
CFRange range;
|
||||||
|
|
||||||
color = mkcolor(r, g, b, a);
|
color = mkcolor(r, g, b, a);
|
||||||
range.location = start;
|
range.location = start;
|
||||||
range.length = end - start;
|
range.length = end - start;
|
||||||
CFAttributedStringSetAttribute(p->mas, range, *FUTURE_kCTBackgroundColorAttributeName, color);
|
CFAttributedStringSetAttribute(p->mas, range, *uiprivFUTURE_kCTBackgroundColorAttributeName, color);
|
||||||
CFRelease(color);
|
CFRelease(color);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// 15 august 2015
|
// 15 august 2015
|
||||||
#import "uipriv_darwin.h"
|
#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;
|
NSLayoutConstraint *constraint;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRela
|
||||||
attribute:attr2
|
attribute:attr2
|
||||||
multiplier:multiplier
|
multiplier:multiplier
|
||||||
constant:c];
|
constant:c];
|
||||||
FUTURE_NSLayoutConstraint_setIdentifier(constraint, desc);
|
uiprivFUTURE_NSLayoutConstraint_setIdentifier(constraint, desc);
|
||||||
return constraint;
|
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)
|
// 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!
|
// 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
|
// 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 setNeedsLayout:YES];
|
||||||
[view layoutSubtreeIfNeeded];
|
[view layoutSubtreeIfNeeded];
|
||||||
|
@ -42,13 +42,13 @@ static CGFloat margins(int margined)
|
||||||
return uiDarwinMarginAmount(NULL);
|
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;
|
CGFloat margin;
|
||||||
|
|
||||||
margin = margins(margined);
|
margin = margins(margined);
|
||||||
|
|
||||||
c->leadingConstraint = mkConstraint(contentView, NSLayoutAttributeLeading,
|
c->leadingConstraint = uiprivMkConstraint(contentView, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
childView, NSLayoutAttributeLeading,
|
childView, NSLayoutAttributeLeading,
|
||||||
1, -margin,
|
1, -margin,
|
||||||
|
@ -56,7 +56,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
||||||
[contentView addConstraint:c->leadingConstraint];
|
[contentView addConstraint:c->leadingConstraint];
|
||||||
[c->leadingConstraint retain];
|
[c->leadingConstraint retain];
|
||||||
|
|
||||||
c->topConstraint = mkConstraint(contentView, NSLayoutAttributeTop,
|
c->topConstraint = uiprivMkConstraint(contentView, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
childView, NSLayoutAttributeTop,
|
childView, NSLayoutAttributeTop,
|
||||||
1, -margin,
|
1, -margin,
|
||||||
|
@ -64,7 +64,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
||||||
[contentView addConstraint:c->topConstraint];
|
[contentView addConstraint:c->topConstraint];
|
||||||
[c->topConstraint retain];
|
[c->topConstraint retain];
|
||||||
|
|
||||||
c->trailingConstraintGreater = mkConstraint(contentView, NSLayoutAttributeTrailing,
|
c->trailingConstraintGreater = uiprivMkConstraint(contentView, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationGreaterThanOrEqual,
|
NSLayoutRelationGreaterThanOrEqual,
|
||||||
childView, NSLayoutAttributeTrailing,
|
childView, NSLayoutAttributeTrailing,
|
||||||
1, margin,
|
1, margin,
|
||||||
|
@ -74,7 +74,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
||||||
[contentView addConstraint:c->trailingConstraintGreater];
|
[contentView addConstraint:c->trailingConstraintGreater];
|
||||||
[c->trailingConstraintGreater retain];
|
[c->trailingConstraintGreater retain];
|
||||||
|
|
||||||
c->trailingConstraintEqual = mkConstraint(contentView, NSLayoutAttributeTrailing,
|
c->trailingConstraintEqual = uiprivMkConstraint(contentView, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
childView, NSLayoutAttributeTrailing,
|
childView, NSLayoutAttributeTrailing,
|
||||||
1, margin,
|
1, margin,
|
||||||
|
@ -84,7 +84,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
||||||
[contentView addConstraint:c->trailingConstraintEqual];
|
[contentView addConstraint:c->trailingConstraintEqual];
|
||||||
[c->trailingConstraintEqual retain];
|
[c->trailingConstraintEqual retain];
|
||||||
|
|
||||||
c->bottomConstraintGreater = mkConstraint(contentView, NSLayoutAttributeBottom,
|
c->bottomConstraintGreater = uiprivMkConstraint(contentView, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationGreaterThanOrEqual,
|
NSLayoutRelationGreaterThanOrEqual,
|
||||||
childView, NSLayoutAttributeBottom,
|
childView, NSLayoutAttributeBottom,
|
||||||
1, margin,
|
1, margin,
|
||||||
|
@ -94,7 +94,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
||||||
[contentView addConstraint:c->bottomConstraintGreater];
|
[contentView addConstraint:c->bottomConstraintGreater];
|
||||||
[c->bottomConstraintGreater retain];
|
[c->bottomConstraintGreater retain];
|
||||||
|
|
||||||
c->bottomConstraintEqual = mkConstraint(contentView, NSLayoutAttributeBottom,
|
c->bottomConstraintEqual = uiprivMkConstraint(contentView, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
childView, NSLayoutAttributeBottom,
|
childView, NSLayoutAttributeBottom,
|
||||||
1, margin,
|
1, margin,
|
||||||
|
@ -105,7 +105,7 @@ void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *c
|
||||||
[c->bottomConstraintEqual retain];
|
[c->bottomConstraintEqual retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv)
|
void uiprivSingleChildConstraintsRemove(uiprivSingleChildConstraints *c, NSView *cv)
|
||||||
{
|
{
|
||||||
if (c->leadingConstraint != nil) {
|
if (c->leadingConstraint != nil) {
|
||||||
[cv removeConstraint:c->leadingConstraint];
|
[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;
|
CGFloat margin;
|
||||||
|
|
||||||
|
|
14
darwin/box.m
14
darwin/box.m
|
@ -167,7 +167,7 @@ struct uiBox {
|
||||||
if (!uiControlVisible(bc.c))
|
if (!uiControlVisible(bc.c))
|
||||||
continue;
|
continue;
|
||||||
if (prev == nil) { // first view
|
if (prev == nil) { // first view
|
||||||
self->first = mkConstraint(self, self->primaryStart,
|
self->first = uiprivMkConstraint(self, self->primaryStart,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[bc view], self->primaryStart,
|
[bc view], self->primaryStart,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -178,7 +178,7 @@ struct uiBox {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// not the first; link it
|
// not the first; link it
|
||||||
c = mkConstraint(prev, self->primaryEnd,
|
c = uiprivMkConstraint(prev, self->primaryEnd,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[bc view], self->primaryStart,
|
[bc view], self->primaryStart,
|
||||||
1, -padding,
|
1, -padding,
|
||||||
|
@ -189,7 +189,7 @@ struct uiBox {
|
||||||
}
|
}
|
||||||
if (prev == nil) // no control visible; act as if no controls
|
if (prev == nil) // no control visible; act as if no controls
|
||||||
return;
|
return;
|
||||||
self->last = mkConstraint(prev, self->primaryEnd,
|
self->last = uiprivMkConstraint(prev, self->primaryEnd,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, self->primaryEnd,
|
self, self->primaryEnd,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -204,14 +204,14 @@ struct uiBox {
|
||||||
for (bc in self->children) {
|
for (bc in self->children) {
|
||||||
if (!uiControlVisible(bc.c))
|
if (!uiControlVisible(bc.c))
|
||||||
continue;
|
continue;
|
||||||
c = mkConstraint(self, self->secondaryStart,
|
c = uiprivMkConstraint(self, self->secondaryStart,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[bc view], self->secondaryStart,
|
[bc view], self->secondaryStart,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiBox secondary start constraint");
|
@"uiBox secondary start constraint");
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->otherConstraints addObject:c];
|
[self->otherConstraints addObject:c];
|
||||||
c = mkConstraint([bc view], self->secondaryEnd,
|
c = uiprivMkConstraint([bc view], self->secondaryEnd,
|
||||||
NSLayoutRelationLessThanOrEqual,
|
NSLayoutRelationLessThanOrEqual,
|
||||||
self, self->secondaryEnd,
|
self, self->secondaryEnd,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -220,7 +220,7 @@ struct uiBox {
|
||||||
[c setPriority:NSLayoutPriorityDefaultLow];
|
[c setPriority:NSLayoutPriorityDefaultLow];
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->otherConstraints addObject:c];
|
[self->otherConstraints addObject:c];
|
||||||
c = mkConstraint([bc view], self->secondaryEnd,
|
c = uiprivMkConstraint([bc view], self->secondaryEnd,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, self->secondaryEnd,
|
self, self->secondaryEnd,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -244,7 +244,7 @@ struct uiBox {
|
||||||
prev = [bc view];
|
prev = [bc view];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
c = mkConstraint(prev, self->primarySize,
|
c = uiprivMkConstraint(prev, self->primarySize,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[bc view], self->primarySize,
|
[bc view], self->primarySize,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct uiButton {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface buttonDelegateClass : NSObject {
|
@interface buttonDelegateClass : NSObject {
|
||||||
struct mapTable *buttons;
|
uiprivMap *buttons;
|
||||||
}
|
}
|
||||||
- (IBAction)onClicked:(id)sender;
|
- (IBAction)onClicked:(id)sender;
|
||||||
- (void)registerButton:(uiButton *)b;
|
- (void)registerButton:(uiButton *)b;
|
||||||
|
@ -22,13 +22,13 @@ struct uiButton {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->buttons = newMap();
|
self->buttons = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->buttons);
|
uiprivMapDestroy(self->buttons);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ struct uiButton {
|
||||||
{
|
{
|
||||||
uiButton *b;
|
uiButton *b;
|
||||||
|
|
||||||
b = (uiButton *) mapGet(self->buttons, sender);
|
b = (uiButton *) uiprivMapGet(self->buttons, sender);
|
||||||
(*(b->onClicked))(b, b->onClickedData);
|
(*(b->onClicked))(b, b->onClickedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerButton:(uiButton *)b
|
- (void)registerButton:(uiButton *)b
|
||||||
{
|
{
|
||||||
mapSet(self->buttons, b->button, b);
|
uiprivMapSet(self->buttons, b->button, b);
|
||||||
[b->button setTarget:self];
|
[b->button setTarget:self];
|
||||||
[b->button setAction:@selector(onClicked:)];
|
[b->button setAction:@selector(onClicked:)];
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ struct uiButton {
|
||||||
- (void)unregisterButton:(uiButton *)b
|
- (void)unregisterButton:(uiButton *)b
|
||||||
{
|
{
|
||||||
[b->button setTarget:nil];
|
[b->button setTarget:nil];
|
||||||
mapDelete(self->buttons, b->button);
|
uiprivMapDelete(self->buttons, b->button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -75,7 +75,7 @@ char *uiButtonText(uiButton *b)
|
||||||
|
|
||||||
void uiButtonSetText(uiButton *b, const char *text)
|
void uiButtonSetText(uiButton *b, const char *text)
|
||||||
{
|
{
|
||||||
[b->button setTitle:toNSString(text)];
|
[b->button setTitle:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data)
|
void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data)
|
||||||
|
@ -96,7 +96,7 @@ uiButton *uiNewButton(const char *text)
|
||||||
uiDarwinNewControl(uiButton, b);
|
uiDarwinNewControl(uiButton, b);
|
||||||
|
|
||||||
b->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
b->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
||||||
[b->button setTitle:toNSString(text)];
|
[b->button setTitle:uiprivToNSString(text)];
|
||||||
[b->button setButtonType:NSMomentaryPushInButton];
|
[b->button setButtonType:NSMomentaryPushInButton];
|
||||||
[b->button setBordered:YES];
|
[b->button setBordered:YES];
|
||||||
[b->button setBezelStyle:NSRoundedBezelStyle];
|
[b->button setBezelStyle:NSRoundedBezelStyle];
|
||||||
|
@ -104,7 +104,7 @@ uiButton *uiNewButton(const char *text)
|
||||||
|
|
||||||
if (buttonDelegate == nil) {
|
if (buttonDelegate == nil) {
|
||||||
buttonDelegate = [[buttonDelegateClass new] autorelease];
|
buttonDelegate = [[buttonDelegateClass new] autorelease];
|
||||||
[delegates addObject:buttonDelegate];
|
[uiprivDelegates addObject:buttonDelegate];
|
||||||
}
|
}
|
||||||
[buttonDelegate registerButton:b];
|
[buttonDelegate registerButton:b];
|
||||||
uiButtonOnClicked(b, defaultOnClicked, NULL);
|
uiButtonOnClicked(b, defaultOnClicked, NULL);
|
||||||
|
|
|
@ -9,7 +9,7 @@ struct uiCheckbox {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface checkboxDelegateClass : NSObject {
|
@interface checkboxDelegateClass : NSObject {
|
||||||
struct mapTable *buttons;
|
uiprivMap *buttons;
|
||||||
}
|
}
|
||||||
- (IBAction)onToggled:(id)sender;
|
- (IBAction)onToggled:(id)sender;
|
||||||
- (void)registerCheckbox:(uiCheckbox *)c;
|
- (void)registerCheckbox:(uiCheckbox *)c;
|
||||||
|
@ -22,13 +22,13 @@ struct uiCheckbox {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->buttons = newMap();
|
self->buttons = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->buttons);
|
uiprivMapDestroy(self->buttons);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,13 @@ struct uiCheckbox {
|
||||||
{
|
{
|
||||||
uiCheckbox *c;
|
uiCheckbox *c;
|
||||||
|
|
||||||
c = (uiCheckbox *) mapGet(self->buttons, sender);
|
c = (uiCheckbox *) uiprivMapGet(self->buttons, sender);
|
||||||
(*(c->onToggled))(c, c->onToggledData);
|
(*(c->onToggled))(c, c->onToggledData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerCheckbox:(uiCheckbox *)c
|
- (void)registerCheckbox:(uiCheckbox *)c
|
||||||
{
|
{
|
||||||
mapSet(self->buttons, c->button, c);
|
uiprivMapSet(self->buttons, c->button, c);
|
||||||
[c->button setTarget:self];
|
[c->button setTarget:self];
|
||||||
[c->button setAction:@selector(onToggled:)];
|
[c->button setAction:@selector(onToggled:)];
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ struct uiCheckbox {
|
||||||
- (void)unregisterCheckbox:(uiCheckbox *)c
|
- (void)unregisterCheckbox:(uiCheckbox *)c
|
||||||
{
|
{
|
||||||
[c->button setTarget:nil];
|
[c->button setTarget:nil];
|
||||||
mapDelete(self->buttons, c->button);
|
uiprivMapDelete(self->buttons, c->button);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -75,7 +75,7 @@ char *uiCheckboxText(uiCheckbox *c)
|
||||||
|
|
||||||
void uiCheckboxSetText(uiCheckbox *c, const char *text)
|
void uiCheckboxSetText(uiCheckbox *c, const char *text)
|
||||||
{
|
{
|
||||||
[c->button setTitle:toNSString(text)];
|
[c->button setTitle:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *, void *), void *data)
|
void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *, void *), void *data)
|
||||||
|
@ -111,7 +111,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
||||||
uiDarwinNewControl(uiCheckbox, c);
|
uiDarwinNewControl(uiCheckbox, c);
|
||||||
|
|
||||||
c->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
c->button = [[NSButton alloc] initWithFrame:NSZeroRect];
|
||||||
[c->button setTitle:toNSString(text)];
|
[c->button setTitle:uiprivToNSString(text)];
|
||||||
[c->button setButtonType:NSSwitchButton];
|
[c->button setButtonType:NSSwitchButton];
|
||||||
// doesn't seem to have an associated bezel style
|
// doesn't seem to have an associated bezel style
|
||||||
[c->button setBordered:NO];
|
[c->button setBordered:NO];
|
||||||
|
@ -120,7 +120,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
|
||||||
|
|
||||||
if (checkboxDelegate == nil) {
|
if (checkboxDelegate == nil) {
|
||||||
checkboxDelegate = [[checkboxDelegateClass new] autorelease];
|
checkboxDelegate = [[checkboxDelegateClass new] autorelease];
|
||||||
[delegates addObject:checkboxDelegate];
|
[uiprivDelegates addObject:checkboxDelegate];
|
||||||
}
|
}
|
||||||
[checkboxDelegate registerCheckbox:c];
|
[checkboxDelegate registerCheckbox:c];
|
||||||
uiCheckboxOnToggled(c, defaultOnToggled, NULL);
|
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
|
// we do not want color change events to be sent to any controls other than the color buttons
|
||||||
// see main.m for more details
|
// 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:))
|
if (sel != @selector(changeColor:))
|
||||||
return NO;
|
return NO;
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct uiCombobox {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface comboboxDelegateClass : NSObject {
|
@interface comboboxDelegateClass : NSObject {
|
||||||
struct mapTable *comboboxes;
|
uiprivMap *comboboxes;
|
||||||
}
|
}
|
||||||
- (IBAction)onSelected:(id)sender;
|
- (IBAction)onSelected:(id)sender;
|
||||||
- (void)registerCombobox:(uiCombobox *)c;
|
- (void)registerCombobox:(uiCombobox *)c;
|
||||||
|
@ -27,13 +27,13 @@ struct uiCombobox {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->comboboxes = newMap();
|
self->comboboxes = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->comboboxes);
|
uiprivMapDestroy(self->comboboxes);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@ struct uiCombobox {
|
||||||
{
|
{
|
||||||
uiCombobox *c;
|
uiCombobox *c;
|
||||||
|
|
||||||
c = uiCombobox(mapGet(self->comboboxes, sender));
|
c = uiCombobox(uiprivMapGet(self->comboboxes, sender));
|
||||||
(*(c->onSelected))(c, c->onSelectedData);
|
(*(c->onSelected))(c, c->onSelectedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerCombobox:(uiCombobox *)c
|
- (void)registerCombobox:(uiCombobox *)c
|
||||||
{
|
{
|
||||||
mapSet(self->comboboxes, c->pb, c);
|
uiprivMapSet(self->comboboxes, c->pb, c);
|
||||||
[c->pb setTarget:self];
|
[c->pb setTarget:self];
|
||||||
[c->pb setAction:@selector(onSelected:)];
|
[c->pb setAction:@selector(onSelected:)];
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ struct uiCombobox {
|
||||||
- (void)unregisterCombobox:(uiCombobox *)c
|
- (void)unregisterCombobox:(uiCombobox *)c
|
||||||
{
|
{
|
||||||
[c->pb setTarget:nil];
|
[c->pb setTarget:nil];
|
||||||
mapDelete(self->comboboxes, c->pb);
|
uiprivMapDelete(self->comboboxes, c->pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -78,7 +78,7 @@ static void uiComboboxDestroy(uiControl *cc)
|
||||||
|
|
||||||
void uiComboboxAppend(uiCombobox *c, const char *text)
|
void uiComboboxAppend(uiCombobox *c, const char *text)
|
||||||
{
|
{
|
||||||
[c->pbac addObject:toNSString(text)];
|
[c->pbac addObject:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
int uiComboboxSelected(uiCombobox *c)
|
int uiComboboxSelected(uiCombobox *c)
|
||||||
|
@ -136,7 +136,7 @@ uiCombobox *uiNewCombobox(void)
|
||||||
|
|
||||||
if (comboboxDelegate == nil) {
|
if (comboboxDelegate == nil) {
|
||||||
comboboxDelegate = [[comboboxDelegateClass new] autorelease];
|
comboboxDelegate = [[comboboxDelegateClass new] autorelease];
|
||||||
[delegates addObject:comboboxDelegate];
|
[uiprivDelegates addObject:comboboxDelegate];
|
||||||
}
|
}
|
||||||
[comboboxDelegate registerCombobox:c];
|
[comboboxDelegate registerCombobox:c];
|
||||||
uiComboboxOnSelected(c, defaultOnSelected, NULL);
|
uiComboboxOnSelected(c, defaultOnSelected, NULL);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// 6 january 2017
|
// 6 january 2017
|
||||||
|
|
||||||
|
// TODO why do we still have this file; should we just split draw.m or not
|
||||||
|
|
||||||
struct uiDrawContext {
|
struct uiDrawContext {
|
||||||
CGContextRef c;
|
CGContextRef c;
|
||||||
CGFloat height; // needed for text; see below
|
CGFloat height; // needed for text; see below
|
||||||
|
|
|
@ -104,7 +104,7 @@ void uiDrawPathEnd(uiDrawPath *p)
|
||||||
p->ended = TRUE;
|
p->ended = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
uiDrawContext *newContext(CGContextRef ctxt, CGFloat height)
|
uiDrawContext *uiprivDrawNewContext(CGContextRef ctxt, CGFloat height)
|
||||||
{
|
{
|
||||||
uiDrawContext *c;
|
uiDrawContext *c;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ uiDrawContext *newContext(CGContextRef ctxt, CGFloat height)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeContext(uiDrawContext *c)
|
void uiprivDrawFreeContext(uiDrawContext *c)
|
||||||
{
|
{
|
||||||
uiprivFree(c);
|
uiprivFree(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct uiEditableCombobox {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface editableComboboxDelegateClass : NSObject<NSComboBoxDelegate> {
|
@interface editableComboboxDelegateClass : NSObject<NSComboBoxDelegate> {
|
||||||
struct mapTable *comboboxes;
|
uiprivMap *comboboxes;
|
||||||
}
|
}
|
||||||
- (void)controlTextDidChange:(NSNotification *)note;
|
- (void)controlTextDidChange:(NSNotification *)note;
|
||||||
- (void)comboBoxSelectionDidChange:(NSNotification *)note;
|
- (void)comboBoxSelectionDidChange:(NSNotification *)note;
|
||||||
|
@ -48,13 +48,13 @@ struct uiEditableCombobox {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->comboboxes = newMap();
|
self->comboboxes = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->comboboxes);
|
uiprivMapDestroy(self->comboboxes);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ struct uiEditableCombobox {
|
||||||
{
|
{
|
||||||
uiEditableCombobox *c;
|
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);
|
(*(c->onChanged))(c, c->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,14 +80,14 @@ struct uiEditableCombobox {
|
||||||
|
|
||||||
- (void)registerCombobox:(uiEditableCombobox *)c
|
- (void)registerCombobox:(uiEditableCombobox *)c
|
||||||
{
|
{
|
||||||
mapSet(self->comboboxes, c->cb, c);
|
uiprivMapSet(self->comboboxes, c->cb, c);
|
||||||
[c->cb setDelegate:self];
|
[c->cb setDelegate:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unregisterCombobox:(uiEditableCombobox *)c
|
- (void)unregisterCombobox:(uiEditableCombobox *)c
|
||||||
{
|
{
|
||||||
[c->cb setDelegate:nil];
|
[c->cb setDelegate:nil];
|
||||||
mapDelete(self->comboboxes, c->cb);
|
uiprivMapDelete(self->comboboxes, c->cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -106,7 +107,7 @@ static void uiEditableComboboxDestroy(uiControl *cc)
|
||||||
|
|
||||||
void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text)
|
void uiEditableComboboxAppend(uiEditableCombobox *c, const char *text)
|
||||||
{
|
{
|
||||||
[c->cb addItemWithObjectValue:toNSString(text)];
|
[c->cb addItemWithObjectValue:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
char *uiEditableComboboxText(uiEditableCombobox *c)
|
char *uiEditableComboboxText(uiEditableCombobox *c)
|
||||||
|
@ -118,7 +119,7 @@ void uiEditableComboboxSetText(uiEditableCombobox *c, const char *text)
|
||||||
{
|
{
|
||||||
NSString *t;
|
NSString *t;
|
||||||
|
|
||||||
t = toNSString(text);
|
t = uiprivToNSString(text);
|
||||||
[c->cb setStringValue:t];
|
[c->cb setStringValue:t];
|
||||||
// yes, let's imitate the behavior that caused uiEditableCombobox to be separate in the first place!
|
// yes, let's imitate the behavior that caused uiEditableCombobox to be separate in the first place!
|
||||||
// just to avoid confusion when users see an option in the list in the text field but not selected in the list
|
// just to avoid confusion when users see an option in the list in the text field but not selected in the list
|
||||||
|
@ -176,7 +177,7 @@ uiEditableCombobox *uiNewEditableCombobox(void)
|
||||||
|
|
||||||
if (comboboxDelegate == nil) {
|
if (comboboxDelegate == nil) {
|
||||||
comboboxDelegate = [[editableComboboxDelegateClass new] autorelease];
|
comboboxDelegate = [[editableComboboxDelegateClass new] autorelease];
|
||||||
[delegates addObject:comboboxDelegate];
|
[uiprivDelegates addObject:comboboxDelegate];
|
||||||
}
|
}
|
||||||
[comboboxDelegate registerCombobox:c];
|
[comboboxDelegate registerCombobox:c];
|
||||||
uiEditableComboboxOnChanged(c, defaultOnChanged, NULL);
|
uiEditableComboboxOnChanged(c, defaultOnChanged, NULL);
|
||||||
|
|
|
@ -67,7 +67,7 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface entryDelegateClass : NSObject<NSTextFieldDelegate> {
|
@interface entryDelegateClass : NSObject<NSTextFieldDelegate> {
|
||||||
struct mapTable *entries;
|
uiprivMap *entries;
|
||||||
}
|
}
|
||||||
- (void)controlTextDidChange:(NSNotification *)note;
|
- (void)controlTextDidChange:(NSNotification *)note;
|
||||||
- (IBAction)onSearch:(id)sender;
|
- (IBAction)onSearch:(id)sender;
|
||||||
|
@ -81,13 +81,13 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->entries = newMap();
|
self->entries = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->entries);
|
uiprivMapDestroy(self->entries);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,13 +100,13 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
{
|
{
|
||||||
uiEntry *e;
|
uiEntry *e;
|
||||||
|
|
||||||
e = (uiEntry *) mapGet(self->entries, sender);
|
e = (uiEntry *) uiprivMapGet(self->entries, sender);
|
||||||
(*(e->onChanged))(e, e->onChangedData);
|
(*(e->onChanged))(e, e->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerEntry:(uiEntry *)e
|
- (void)registerEntry:(uiEntry *)e
|
||||||
{
|
{
|
||||||
mapSet(self->entries, e->textfield, e);
|
uiprivMapSet(self->entries, e->textfield, e);
|
||||||
if (isSearchField(e->textfield)) {
|
if (isSearchField(e->textfield)) {
|
||||||
[e->textfield setTarget:self];
|
[e->textfield setTarget:self];
|
||||||
[e->textfield setAction:@selector(onSearch:)];
|
[e->textfield setAction:@selector(onSearch:)];
|
||||||
|
@ -120,7 +120,7 @@ static BOOL isSearchField(NSTextField *tf)
|
||||||
[e->textfield setTarget:nil];
|
[e->textfield setTarget:nil];
|
||||||
else
|
else
|
||||||
[e->textfield setDelegate:nil];
|
[e->textfield setDelegate:nil];
|
||||||
mapDelete(self->entries, e->textfield);
|
uiprivMapDelete(self->entries, e->textfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -145,7 +145,7 @@ char *uiEntryText(uiEntry *e)
|
||||||
|
|
||||||
void uiEntrySetText(uiEntry *e, const char *text)
|
void uiEntrySetText(uiEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
[e->textfield setStringValue:toNSString(text)];
|
[e->textfield setStringValue:uiprivToNSString(text)];
|
||||||
// don't queue the control for resize; entry sizes are independent of their contents
|
// don't queue the control for resize; entry sizes are independent of their contents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 :/
|
// 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);
|
uiDarwinSetControlFont(t, NSRegularControlSize);
|
||||||
|
|
||||||
|
@ -197,11 +197,11 @@ static NSTextField *realNewEditableTextField(Class class)
|
||||||
|
|
||||||
tf = [[class alloc] initWithFrame:NSZeroRect];
|
tf = [[class alloc] initWithFrame:NSZeroRect];
|
||||||
[tf setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
|
[tf setSelectable:YES]; // otherwise the setting is masked by the editable default of YES
|
||||||
finishNewTextField(tf, YES);
|
uiprivFinishNewTextField(tf, YES);
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSTextField *newEditableTextField(void)
|
NSTextField *uiprivNewEditableTextField(void)
|
||||||
{
|
{
|
||||||
return realNewEditableTextField([libui_intrinsicWidthNSTextField class]);
|
return realNewEditableTextField([libui_intrinsicWidthNSTextField class]);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ static uiEntry *finishNewEntry(Class class)
|
||||||
|
|
||||||
if (entryDelegate == nil) {
|
if (entryDelegate == nil) {
|
||||||
entryDelegate = [[entryDelegateClass new] autorelease];
|
entryDelegate = [[entryDelegateClass new] autorelease];
|
||||||
[delegates addObject:entryDelegate];
|
[uiprivDelegates addObject:entryDelegate];
|
||||||
}
|
}
|
||||||
[entryDelegate registerEntry:e];
|
[entryDelegate registerEntry:e];
|
||||||
uiEntryOnChanged(e, defaultOnChanged, NULL);
|
uiEntryOnChanged(e, defaultOnChanged, NULL);
|
||||||
|
|
|
@ -246,7 +246,7 @@
|
||||||
FONTNAME(preferredSubFamilyName,
|
FONTNAME(preferredSubFamilyName,
|
||||||
self->didPreferredSubFamilyName,
|
self->didPreferredSubFamilyName,
|
||||||
self->preferredSubFamilyName,
|
self->preferredSubFamilyName,
|
||||||
UNDOC_kCTFontPreferredSubFamilyNameKey)
|
uiprivUNDOC_kCTFontPreferredSubFamilyNameKey)
|
||||||
FONTNAME(subFamilyName,
|
FONTNAME(subFamilyName,
|
||||||
self->didSubFamilyName,
|
self->didSubFamilyName,
|
||||||
self->subFamilyName,
|
self->subFamilyName,
|
||||||
|
@ -258,7 +258,7 @@ FONTNAME(fullName,
|
||||||
FONTNAME(preferredFamilyName,
|
FONTNAME(preferredFamilyName,
|
||||||
self->didPreferredFamilyName,
|
self->didPreferredFamilyName,
|
||||||
self->preferredFamilyName,
|
self->preferredFamilyName,
|
||||||
UNDOC_kCTFontPreferredFamilyNameKey)
|
uiprivUNDOC_kCTFontPreferredFamilyNameKey)
|
||||||
FONTNAME(familyName,
|
FONTNAME(familyName,
|
||||||
self->didFamilyName,
|
self->didFamilyName,
|
||||||
self->familyName,
|
self->familyName,
|
||||||
|
|
|
@ -66,25 +66,25 @@ struct uiForm {
|
||||||
[self.label setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationVertical];
|
[self.label setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationVertical];
|
||||||
[self addSubview:self.label];
|
[self addSubview:self.label];
|
||||||
|
|
||||||
self.leading = mkConstraint(self.label, NSLayoutAttributeLeading,
|
self.leading = uiprivMkConstraint(self.label, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationGreaterThanOrEqual,
|
NSLayoutRelationGreaterThanOrEqual,
|
||||||
self, NSLayoutAttributeLeading,
|
self, NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiForm label leading");
|
@"uiForm label leading");
|
||||||
[self addConstraint:self.leading];
|
[self addConstraint:self.leading];
|
||||||
self.top = mkConstraint(self.label, NSLayoutAttributeTop,
|
self.top = uiprivMkConstraint(self.label, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeTop,
|
self, NSLayoutAttributeTop,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiForm label top");
|
@"uiForm label top");
|
||||||
[self addConstraint:self.top];
|
[self addConstraint:self.top];
|
||||||
self.trailing = mkConstraint(self.label, NSLayoutAttributeTrailing,
|
self.trailing = uiprivMkConstraint(self.label, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeTrailing,
|
self, NSLayoutAttributeTrailing,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiForm label trailing");
|
@"uiForm label trailing");
|
||||||
[self addConstraint:self.trailing];
|
[self addConstraint:self.trailing];
|
||||||
self.bottom = mkConstraint(self.label, NSLayoutAttributeBottom,
|
self.bottom = uiprivMkConstraint(self.label, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeBottom,
|
self, NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -224,7 +224,7 @@ struct uiForm {
|
||||||
if (!uiControlVisible(fc.c))
|
if (!uiControlVisible(fc.c))
|
||||||
continue;
|
continue;
|
||||||
if (prev == nil) { // first view
|
if (prev == nil) { // first view
|
||||||
self->first = mkConstraint(self, NSLayoutAttributeTop,
|
self->first = uiprivMkConstraint(self, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[fc view], NSLayoutAttributeTop,
|
[fc view], NSLayoutAttributeTop,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -236,7 +236,7 @@ struct uiForm {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// not the first; link it
|
// not the first; link it
|
||||||
c = mkConstraint(prev, NSLayoutAttributeBottom,
|
c = uiprivMkConstraint(prev, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[fc view], NSLayoutAttributeTop,
|
[fc view], NSLayoutAttributeTop,
|
||||||
1, -padding,
|
1, -padding,
|
||||||
|
@ -244,14 +244,14 @@ struct uiForm {
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->inBetweens addObject:c];
|
[self->inBetweens addObject:c];
|
||||||
// and make the same width
|
// and make the same width
|
||||||
c = mkConstraint(prev, NSLayoutAttributeWidth,
|
c = uiprivMkConstraint(prev, NSLayoutAttributeWidth,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[fc view], NSLayoutAttributeWidth,
|
[fc view], NSLayoutAttributeWidth,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiForm control width constraint");
|
@"uiForm control width constraint");
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->widths addObject:c];
|
[self->widths addObject:c];
|
||||||
c = mkConstraint(prevlabel, NSLayoutAttributeWidth,
|
c = uiprivMkConstraint(prevlabel, NSLayoutAttributeWidth,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
fc, NSLayoutAttributeWidth,
|
fc, NSLayoutAttributeWidth,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -263,7 +263,7 @@ struct uiForm {
|
||||||
}
|
}
|
||||||
if (prev == nil) // all hidden; act as if nothing there
|
if (prev == nil) // all hidden; act as if nothing there
|
||||||
return;
|
return;
|
||||||
self->last = mkConstraint(prev, NSLayoutAttributeBottom,
|
self->last = uiprivMkConstraint(prev, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeBottom,
|
self, NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -275,7 +275,7 @@ struct uiForm {
|
||||||
for (fc in self->children) {
|
for (fc in self->children) {
|
||||||
if (!uiControlVisible(fc.c))
|
if (!uiControlVisible(fc.c))
|
||||||
continue;
|
continue;
|
||||||
c = mkConstraint(self, NSLayoutAttributeLeading,
|
c = uiprivMkConstraint(self, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
fc, NSLayoutAttributeLeading,
|
fc, NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -284,7 +284,7 @@ struct uiForm {
|
||||||
[self->leadings addObject:c];
|
[self->leadings addObject:c];
|
||||||
// coerce the control to be as wide as possible
|
// 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
|
// 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,
|
NSLayoutRelationEqual,
|
||||||
[fc view], NSLayoutAttributeLeading,
|
[fc view], NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -292,14 +292,14 @@ struct uiForm {
|
||||||
[c setPriority:NSLayoutPriorityDefaultHigh];
|
[c setPriority:NSLayoutPriorityDefaultHigh];
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->leadings addObject:c];
|
[self->leadings addObject:c];
|
||||||
c = mkConstraint(fc, NSLayoutAttributeTrailing,
|
c = uiprivMkConstraint(fc, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[fc view], NSLayoutAttributeLeading,
|
[fc view], NSLayoutAttributeLeading,
|
||||||
1, -padding,
|
1, -padding,
|
||||||
@"uiForm middle constraint");
|
@"uiForm middle constraint");
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->middles addObject:c];
|
[self->middles addObject:c];
|
||||||
c = mkConstraint([fc view], NSLayoutAttributeTrailing,
|
c = uiprivMkConstraint([fc view], NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeTrailing,
|
self, NSLayoutAttributeTrailing,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -307,7 +307,7 @@ struct uiForm {
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->trailings addObject:c];
|
[self->trailings addObject:c];
|
||||||
// TODO
|
// TODO
|
||||||
c = mkConstraint(fc, NSLayoutAttributeBottom,
|
c = uiprivMkConstraint(fc, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationLessThanOrEqual,
|
NSLayoutRelationLessThanOrEqual,
|
||||||
self, NSLayoutAttributeBottom,
|
self, NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -327,7 +327,7 @@ struct uiForm {
|
||||||
prev = [fc view];
|
prev = [fc view];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
c = mkConstraint([fc view], NSLayoutAttributeHeight,
|
c = uiprivMkConstraint([fc view], NSLayoutAttributeHeight,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
prev, NSLayoutAttributeHeight,
|
prev, NSLayoutAttributeHeight,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -347,7 +347,7 @@ struct uiForm {
|
||||||
NSLayoutAttribute attribute;
|
NSLayoutAttribute attribute;
|
||||||
int oldnStretchy;
|
int oldnStretchy;
|
||||||
|
|
||||||
fc = [[formChild alloc] initWithLabel:newLabel(label)];
|
fc = [[formChild alloc] initWithLabel:uiprivNewLabel(label)];
|
||||||
fc.c = c;
|
fc.c = c;
|
||||||
fc.stretchy = stretchy;
|
fc.stretchy = stretchy;
|
||||||
fc.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(fc.c), NSLayoutConstraintOrientationHorizontal);
|
fc.oldHorzHuggingPri = uiDarwinControlHuggingPriority(uiDarwinControl(fc.c), NSLayoutConstraintOrientationHorizontal);
|
||||||
|
@ -376,7 +376,7 @@ struct uiForm {
|
||||||
attribute = NSLayoutAttributeBaseline;
|
attribute = NSLayoutAttributeBaseline;
|
||||||
if ([[fc view] isKindOfClass:[NSScrollView class]])
|
if ([[fc view] isKindOfClass:[NSScrollView class]])
|
||||||
attribute = NSLayoutAttributeTop;
|
attribute = NSLayoutAttributeTop;
|
||||||
fc.baseline = mkConstraint(fc.label, attribute,
|
fc.baseline = uiprivMkConstraint(fc.label, attribute,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[fc view], attribute,
|
[fc view], attribute,
|
||||||
1, 0,
|
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
|
// or at leat allow this and implicitly turn it into a spacer
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
uiprivUserBug("You cannot add NULL to a uiForm.");
|
uiprivUserBug("You cannot add NULL to a uiForm.");
|
||||||
[f->view append:toNSString(label) c:c stretchy:stretchy];
|
[f->view append:uiprivToNSString(label) c:c stretchy:stretchy];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiFormDelete(uiForm *f, int n)
|
void uiFormDelete(uiForm *f, int n)
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
// note: for constants, dlsym() returns the address of the constant itself, as if we had done &constantName
|
// 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
|
// added in OS X 10.10; we need 10.8
|
||||||
CFStringRef *FUTURE_kCTFontOpenTypeFeatureTag = NULL;
|
CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureTag = NULL;
|
||||||
CFStringRef *FUTURE_kCTFontOpenTypeFeatureValue = NULL;
|
CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureValue = NULL;
|
||||||
|
|
||||||
// added in OS X 10.12; we need 10.8
|
// 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)
|
// 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;
|
void *handle;
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ void loadFutures(void)
|
||||||
if (handle == NULL)
|
if (handle == NULL)
|
||||||
return;
|
return;
|
||||||
#define GET(var, fn) *((void **) (&var)) = dlsym(handle, #fn)
|
#define GET(var, fn) *((void **) (&var)) = dlsym(handle, #fn)
|
||||||
GET(FUTURE_kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureTag);
|
GET(uiprivFUTURE_kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureTag);
|
||||||
GET(FUTURE_kCTFontOpenTypeFeatureValue, kCTFontOpenTypeFeatureValue);
|
GET(uiprivFUTURE_kCTFontOpenTypeFeatureValue, kCTFontOpenTypeFeatureValue);
|
||||||
GET(FUTURE_kCTBackgroundColorAttributeName, kCTBackgroundColorAttributeName);
|
GET(uiprivFUTURE_kCTBackgroundColorAttributeName, kCTBackgroundColorAttributeName);
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void loadFutures(void)
|
||||||
// keep them in one place for convenience
|
// keep them in one place for convenience
|
||||||
|
|
||||||
// apparently only added in 10.9; we need 10.8
|
// 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;
|
id cid = (id) constraint;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ void FUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSS
|
||||||
|
|
||||||
// added in 10.11; we need 10.8
|
// added in 10.11; we need 10.8
|
||||||
// return whether this was done because we recreate its effects if not (see winmoveresize.m)
|
// 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;
|
id cw = (id) w;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct uiGrid {
|
||||||
uiDarwinControlSyncEnableState(uiDarwinControl(self.c), uiControlEnabledToUser(uiControl(g)));
|
uiDarwinControlSyncEnableState(uiDarwinControl(self.c), uiControlEnabledToUser(uiControl(g)));
|
||||||
|
|
||||||
if (self.halign == uiAlignStart || self.halign == uiAlignFill) {
|
if (self.halign == uiAlignStart || self.halign == uiAlignFill) {
|
||||||
self.leadingc = mkConstraint(self, NSLayoutAttributeLeading,
|
self.leadingc = uiprivMkConstraint(self, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[self view], NSLayoutAttributeLeading,
|
[self view], NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -80,7 +80,7 @@ struct uiGrid {
|
||||||
[self addConstraint:self.leadingc];
|
[self addConstraint:self.leadingc];
|
||||||
}
|
}
|
||||||
if (self.halign == uiAlignCenter) {
|
if (self.halign == uiAlignCenter) {
|
||||||
self.xcenterc = mkConstraint(self, NSLayoutAttributeCenterX,
|
self.xcenterc = uiprivMkConstraint(self, NSLayoutAttributeCenterX,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[self view], NSLayoutAttributeCenterX,
|
[self view], NSLayoutAttributeCenterX,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -88,7 +88,7 @@ struct uiGrid {
|
||||||
[self addConstraint:self.xcenterc];
|
[self addConstraint:self.xcenterc];
|
||||||
}
|
}
|
||||||
if (self.halign == uiAlignEnd || self.halign == uiAlignFill) {
|
if (self.halign == uiAlignEnd || self.halign == uiAlignFill) {
|
||||||
self.trailingc = mkConstraint(self, NSLayoutAttributeTrailing,
|
self.trailingc = uiprivMkConstraint(self, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[self view], NSLayoutAttributeTrailing,
|
[self view], NSLayoutAttributeTrailing,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -97,7 +97,7 @@ struct uiGrid {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.valign == uiAlignStart || self.valign == uiAlignFill) {
|
if (self.valign == uiAlignStart || self.valign == uiAlignFill) {
|
||||||
self.topc = mkConstraint(self, NSLayoutAttributeTop,
|
self.topc = uiprivMkConstraint(self, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[self view], NSLayoutAttributeTop,
|
[self view], NSLayoutAttributeTop,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -105,7 +105,7 @@ struct uiGrid {
|
||||||
[self addConstraint:self.topc];
|
[self addConstraint:self.topc];
|
||||||
}
|
}
|
||||||
if (self.valign == uiAlignCenter) {
|
if (self.valign == uiAlignCenter) {
|
||||||
self.ycenterc = mkConstraint(self, NSLayoutAttributeCenterY,
|
self.ycenterc = uiprivMkConstraint(self, NSLayoutAttributeCenterY,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[self view], NSLayoutAttributeCenterY,
|
[self view], NSLayoutAttributeCenterY,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -113,7 +113,7 @@ struct uiGrid {
|
||||||
[self addConstraint:self.ycenterc];
|
[self addConstraint:self.ycenterc];
|
||||||
}
|
}
|
||||||
if (self.valign == uiAlignEnd || self.valign == uiAlignFill) {
|
if (self.valign == uiAlignEnd || self.valign == uiAlignFill) {
|
||||||
self.bottomc = mkConstraint(self, NSLayoutAttributeBottom,
|
self.bottomc = uiprivMkConstraint(self, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
[self view], NSLayoutAttributeBottom,
|
[self view], NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -403,14 +403,14 @@ struct uiGrid {
|
||||||
// now establish all the edge constraints
|
// now establish all the edge constraints
|
||||||
// leading and trailing edges
|
// leading and trailing edges
|
||||||
for (y = 0; y < ycount; y++) {
|
for (y = 0; y < ycount; y++) {
|
||||||
c = mkConstraint(self, NSLayoutAttributeLeading,
|
c = uiprivMkConstraint(self, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[y][0], NSLayoutAttributeLeading,
|
gv[y][0], NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiGrid leading edge constraint");
|
@"uiGrid leading edge constraint");
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->edges addObject:c];
|
[self->edges addObject:c];
|
||||||
c = mkConstraint(self, NSLayoutAttributeTrailing,
|
c = uiprivMkConstraint(self, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[y][xcount - 1], NSLayoutAttributeTrailing,
|
gv[y][xcount - 1], NSLayoutAttributeTrailing,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -420,14 +420,14 @@ struct uiGrid {
|
||||||
}
|
}
|
||||||
// top and bottom edges
|
// top and bottom edges
|
||||||
for (x = 0; x < xcount; x++) {
|
for (x = 0; x < xcount; x++) {
|
||||||
c = mkConstraint(self, NSLayoutAttributeTop,
|
c = uiprivMkConstraint(self, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[0][x], NSLayoutAttributeTop,
|
gv[0][x], NSLayoutAttributeTop,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiGrid top edge constraint");
|
@"uiGrid top edge constraint");
|
||||||
[self addConstraint:c];
|
[self addConstraint:c];
|
||||||
[self->edges addObject:c];
|
[self->edges addObject:c];
|
||||||
c = mkConstraint(self, NSLayoutAttributeBottom,
|
c = uiprivMkConstraint(self, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[ycount - 1][x], NSLayoutAttributeBottom,
|
gv[ycount - 1][x], NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -446,7 +446,7 @@ struct uiGrid {
|
||||||
for (y++; y < ycount; y++) {
|
for (y++; y < ycount; y++) {
|
||||||
if (gspan[y][x])
|
if (gspan[y][x])
|
||||||
continue;
|
continue;
|
||||||
c = mkConstraint(gv[firsty][x], NSLayoutAttributeLeading,
|
c = uiprivMkConstraint(gv[firsty][x], NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[y][x], NSLayoutAttributeLeading,
|
gv[y][x], NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -463,7 +463,7 @@ struct uiGrid {
|
||||||
for (x++; x < xcount; x++) {
|
for (x++; x < xcount; x++) {
|
||||||
if (gspan[y][x])
|
if (gspan[y][x])
|
||||||
continue;
|
continue;
|
||||||
c = mkConstraint(gv[y][firstx], NSLayoutAttributeTop,
|
c = uiprivMkConstraint(gv[y][firstx], NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[y][x], NSLayoutAttributeTop,
|
gv[y][x], NSLayoutAttributeTop,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -477,7 +477,7 @@ struct uiGrid {
|
||||||
for (y = 0; y < ycount; y++)
|
for (y = 0; y < ycount; y++)
|
||||||
for (x = 1; x < xcount; x++)
|
for (x = 1; x < xcount; x++)
|
||||||
if (gv[y][x - 1] != gv[y][x]) {
|
if (gv[y][x - 1] != gv[y][x]) {
|
||||||
c = mkConstraint(gv[y][x - 1], NSLayoutAttributeTrailing,
|
c = uiprivMkConstraint(gv[y][x - 1], NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[y][x], NSLayoutAttributeLeading,
|
gv[y][x], NSLayoutAttributeLeading,
|
||||||
1, -padding,
|
1, -padding,
|
||||||
|
@ -488,7 +488,7 @@ struct uiGrid {
|
||||||
for (x = 0; x < xcount; x++)
|
for (x = 0; x < xcount; x++)
|
||||||
for (y = 1; y < ycount; y++)
|
for (y = 1; y < ycount; y++)
|
||||||
if (gv[y - 1][x] != gv[y][x]) {
|
if (gv[y - 1][x] != gv[y][x]) {
|
||||||
c = mkConstraint(gv[y - 1][x], NSLayoutAttributeBottom,
|
c = uiprivMkConstraint(gv[y - 1][x], NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
gv[y][x], NSLayoutAttributeTop,
|
gv[y][x], NSLayoutAttributeTop,
|
||||||
1, -padding,
|
1, -padding,
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct uiGroup {
|
||||||
NSLayoutPriority oldHorzHuggingPri;
|
NSLayoutPriority oldHorzHuggingPri;
|
||||||
NSLayoutPriority oldVertHuggingPri;
|
NSLayoutPriority oldVertHuggingPri;
|
||||||
int margined;
|
int margined;
|
||||||
struct singleChildConstraints constraints;
|
uiprivSingleChildConstraints constraints;
|
||||||
NSLayoutPriority horzHuggingPri;
|
NSLayoutPriority horzHuggingPri;
|
||||||
NSLayoutPriority vertHuggingPri;
|
NSLayoutPriority vertHuggingPri;
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,7 @@ struct uiGroup {
|
||||||
static void removeConstraints(uiGroup *g)
|
static void removeConstraints(uiGroup *g)
|
||||||
{
|
{
|
||||||
// set to contentView instead of to the box itself, otherwise we get clipping underneath the label
|
// 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)
|
static void uiGroupDestroy(uiControl *c)
|
||||||
|
@ -64,14 +64,14 @@ static void groupRelayout(uiGroup *g)
|
||||||
if (g->child == NULL)
|
if (g->child == NULL)
|
||||||
return;
|
return;
|
||||||
childView = (NSView *) uiControlHandle(g->child);
|
childView = (NSView *) uiControlHandle(g->child);
|
||||||
singleChildConstraintsEstablish(&(g->constraints),
|
uiprivSingleChildConstraintsEstablish(&(g->constraints),
|
||||||
[g->box contentView], childView,
|
[g->box contentView], childView,
|
||||||
uiDarwinControlHugsTrailingEdge(uiDarwinControl(g->child)),
|
uiDarwinControlHugsTrailingEdge(uiDarwinControl(g->child)),
|
||||||
uiDarwinControlHugsBottom(uiDarwinControl(g->child)),
|
uiDarwinControlHugsBottom(uiDarwinControl(g->child)),
|
||||||
g->margined,
|
g->margined,
|
||||||
@"uiGroup");
|
@"uiGroup");
|
||||||
// needed for some very rare drawing errors...
|
// 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
|
// 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)
|
void uiGroupSetTitle(uiGroup *g, const char *title)
|
||||||
{
|
{
|
||||||
[g->box setTitle:toNSString(title)];
|
[g->box setTitle:uiprivToNSString(title)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiGroupSetChild(uiGroup *g, uiControl *child)
|
void uiGroupSetChild(uiGroup *g, uiControl *child)
|
||||||
|
@ -168,7 +168,7 @@ int uiGroupMargined(uiGroup *g)
|
||||||
void uiGroupSetMargined(uiGroup *g, int margined)
|
void uiGroupSetMargined(uiGroup *g, int margined)
|
||||||
{
|
{
|
||||||
g->margined = margined;
|
g->margined = margined;
|
||||||
singleChildConstraintsSetMargined(&(g->constraints), g->margined);
|
uiprivSingleChildConstraintsSetMargined(&(g->constraints), g->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiGroup *uiNewGroup(const char *title)
|
uiGroup *uiNewGroup(const char *title)
|
||||||
|
@ -178,7 +178,7 @@ uiGroup *uiNewGroup(const char *title)
|
||||||
uiDarwinNewControl(uiGroup, g);
|
uiDarwinNewControl(uiGroup, g);
|
||||||
|
|
||||||
g->box = [[NSBox alloc] initWithFrame:NSZeroRect];
|
g->box = [[NSBox alloc] initWithFrame:NSZeroRect];
|
||||||
[g->box setTitle:toNSString(title)];
|
[g->box setTitle:uiprivToNSString(title)];
|
||||||
[g->box setBoxType:NSBoxPrimary];
|
[g->box setBoxType:NSBoxPrimary];
|
||||||
[g->box setBorderType:NSLineBorder];
|
[g->box setBorderType:NSLineBorder];
|
||||||
[g->box setTransparent:NO];
|
[g->box setTransparent:NO];
|
||||||
|
|
|
@ -76,7 +76,7 @@ void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, in
|
||||||
[i->swizzled addObject:[NSValue valueWithPointer:swizzled]];
|
[i->swizzled addObject:[NSValue valueWithPointer:swizzled]];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSImage *imageImage(uiImage *i)
|
NSImage *uiprivImageNSImage(uiImage *i)
|
||||||
{
|
{
|
||||||
return i->i;
|
return i->i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,10 @@ char *uiLabelText(uiLabel *l)
|
||||||
|
|
||||||
void uiLabelSetText(uiLabel *l, const char *text)
|
void uiLabelSetText(uiLabel *l, const char *text)
|
||||||
{
|
{
|
||||||
[l->textfield setStringValue:toNSString(text)];
|
[l->textfield setStringValue:uiprivToNSString(text)];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSTextField *newLabel(NSString *str)
|
NSTextField *uiprivNewLabel(NSString *str)
|
||||||
{
|
{
|
||||||
NSTextField *tf;
|
NSTextField *tf;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ NSTextField *newLabel(NSString *str)
|
||||||
[tf setEditable:NO];
|
[tf setEditable:NO];
|
||||||
[tf setSelectable:NO];
|
[tf setSelectable:NO];
|
||||||
[tf setDrawsBackground:NO];
|
[tf setDrawsBackground:NO];
|
||||||
finishNewTextField(tf, NO);
|
uiprivFinishNewTextField(tf, NO);
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ uiLabel *uiNewLabel(const char *text)
|
||||||
|
|
||||||
uiDarwinNewControl(uiLabel, l);
|
uiDarwinNewControl(uiLabel, l);
|
||||||
|
|
||||||
l->textfield = newLabel(toNSString(text));
|
l->textfield = uiprivNewLabel(uiprivToNSString(text));
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
|
|
||||||
static BOOL canQuit = NO;
|
static BOOL canQuit = NO;
|
||||||
static NSAutoreleasePool *globalPool;
|
static NSAutoreleasePool *globalPool;
|
||||||
static applicationClass *app;
|
static uiprivApplicationClass *app;
|
||||||
static appDelegate *delegate;
|
static uiprivAppDelegate *delegate;
|
||||||
|
|
||||||
static BOOL (^isRunning)(void);
|
static BOOL (^isRunning)(void);
|
||||||
static BOOL stepsIsRunning;
|
static BOOL stepsIsRunning;
|
||||||
|
|
||||||
@implementation applicationClass
|
@implementation uiprivApplicationClass
|
||||||
|
|
||||||
- (void)sendEvent:(NSEvent *)e
|
- (void)sendEvent:(NSEvent *)e
|
||||||
{
|
{
|
||||||
if (sendAreaEvents(e) != 0)
|
if (uiprivSendAreaEvents(e) != 0)
|
||||||
return;
|
return;
|
||||||
[super sendEvent:e];
|
[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)
|
// 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
|
- (BOOL)sendAction:(SEL)sel to:(id)to from:(id)from
|
||||||
{
|
{
|
||||||
if (colorButtonInhibitSendAction(sel, from, to))
|
if (uiprivColorButtonInhibitSendAction(sel, from, to))
|
||||||
return NO;
|
return NO;
|
||||||
if (uiprivFontButtonInhibitSendAction(sel, from, to))
|
if (uiprivFontButtonInhibitSendAction(sel, from, to))
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -59,7 +59,7 @@ static BOOL stepsIsRunning;
|
||||||
if (!canQuit)
|
if (!canQuit)
|
||||||
uiprivImplBug("call to [NSApp terminate:] when not ready to terminate; definitely contact andlabs");
|
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
|
// stop: won't register until another event has passed; let's synthesize one
|
||||||
e = [NSEvent otherEventWithType:NSApplicationDefined
|
e = [NSEvent otherEventWithType:NSApplicationDefined
|
||||||
location:NSZeroPoint
|
location:NSZeroPoint
|
||||||
|
@ -70,7 +70,7 @@ static BOOL stepsIsRunning;
|
||||||
subtype:0
|
subtype:0
|
||||||
data1:0
|
data1:0
|
||||||
data2: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
|
// and in case uiMainSteps() was called
|
||||||
stepsIsRunning = NO;
|
stepsIsRunning = NO;
|
||||||
|
@ -78,7 +78,7 @@ static BOOL stepsIsRunning;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation appDelegate
|
@implementation uiprivAppDelegate
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
@ -112,20 +112,20 @@ const char *uiInit(uiInitOptions *o)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
uiprivOptions = *o;
|
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!
|
// 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
|
// see https://github.com/andlabs/ui/issues/6
|
||||||
[realNSApp() setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[uiprivNSApp() setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
delegate = [appDelegate new];
|
delegate = [uiprivAppDelegate new];
|
||||||
[realNSApp() setDelegate:delegate];
|
[uiprivNSApp() setDelegate:delegate];
|
||||||
|
|
||||||
initAlloc();
|
uiprivInitAlloc();
|
||||||
loadFutures();
|
uiprivLoadFutures();
|
||||||
loadUndocumented();
|
uiprivLoadUndocumented();
|
||||||
|
|
||||||
// always do this so we always have an application menu
|
// always do this so we always have an application menu
|
||||||
appDelegate().menuManager = [[menuManager new] autorelease];
|
uiprivAppDelegate().menuManager = [[uiprivMenuManager new] autorelease];
|
||||||
[realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]];
|
[uiprivNSApp() setMainMenu:[uiprivAppDelegate().menuManager makeMenubar]];
|
||||||
|
|
||||||
uiprivSetupFontPanel();
|
uiprivSetupFontPanel();
|
||||||
|
|
||||||
|
@ -146,9 +146,9 @@ void uiUninit(void)
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
uiprivUninitUnderlineColors();
|
uiprivUninitUnderlineColors();
|
||||||
[delegate release];
|
[delegate release];
|
||||||
[realNSApp() setDelegate:nil];
|
[uiprivNSApp() setDelegate:nil];
|
||||||
[app release];
|
[app release];
|
||||||
uninitAlloc();
|
uiprivUninitAlloc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,15 +159,15 @@ void uiFreeInitError(const char *err)
|
||||||
void uiMain(void)
|
void uiMain(void)
|
||||||
{
|
{
|
||||||
isRunning = ^{
|
isRunning = ^{
|
||||||
return [realNSApp() isRunning];
|
return [uiprivNSApp() isRunning];
|
||||||
};
|
};
|
||||||
[realNSApp() run];
|
[uiprivNSApp() run];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiMainSteps(void)
|
void uiMainSteps(void)
|
||||||
{
|
{
|
||||||
// SDL does this and it seems to be necessary for the menubar to work (see #182)
|
// SDL does this and it seems to be necessary for the menubar to work (see #182)
|
||||||
[realNSApp() finishLaunching];
|
[uiprivNSApp() finishLaunching];
|
||||||
isRunning = ^{
|
isRunning = ^{
|
||||||
return stepsIsRunning;
|
return stepsIsRunning;
|
||||||
};
|
};
|
||||||
|
@ -176,7 +176,7 @@ void uiMainSteps(void)
|
||||||
|
|
||||||
int uiMainStep(int wait)
|
int uiMainStep(int wait)
|
||||||
{
|
{
|
||||||
struct nextEventArgs nea;
|
uiprivNextEventArgs nea;
|
||||||
|
|
||||||
nea.mask = NSAnyEventMask;
|
nea.mask = NSAnyEventMask;
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ int uiMainStep(int wait)
|
||||||
nea.mode = NSDefaultRunLoopMode;
|
nea.mode = NSDefaultRunLoopMode;
|
||||||
nea.dequeue = YES;
|
nea.dequeue = YES;
|
||||||
|
|
||||||
return mainStep(&nea, ^(NSEvent *e) {
|
return uiprivMainStep(&nea, ^(NSEvent *e) {
|
||||||
return NO;
|
return NO;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ int uiMainStep(int wait)
|
||||||
// see also:
|
// see also:
|
||||||
// - http://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html
|
// - http://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html
|
||||||
// - https://github.com/gnustep/gui/blob/master/Source/NSApplication.m
|
// - 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;
|
NSDate *expire;
|
||||||
NSEvent *e;
|
NSEvent *e;
|
||||||
|
@ -207,7 +207,7 @@ int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
||||||
if (!isRunning())
|
if (!isRunning())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
e = [realNSApp() nextEventMatchingMask:nea->mask
|
e = [uiprivNSApp() nextEventMatchingMask:nea->mask
|
||||||
untilDate:nea->duration
|
untilDate:nea->duration
|
||||||
inMode:nea->mode
|
inMode:nea->mode
|
||||||
dequeue:nea->dequeue];
|
dequeue:nea->dequeue];
|
||||||
|
@ -216,13 +216,13 @@ int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
||||||
|
|
||||||
type = [e type];
|
type = [e type];
|
||||||
if (!interceptEvent(e))
|
if (!interceptEvent(e))
|
||||||
[realNSApp() sendEvent:e];
|
[uiprivNSApp() sendEvent:e];
|
||||||
[realNSApp() updateWindows];
|
[uiprivNSApp() updateWindows];
|
||||||
|
|
||||||
// GNUstep does this
|
// GNUstep does this
|
||||||
// it also updates the Services menu but there doesn't seem to be a public API for that so
|
// it also updates the Services menu but there doesn't seem to be a public API for that so
|
||||||
if (type != NSPeriodic && type != NSMouseMoved)
|
if (type != NSPeriodic && type != NSMouseMoved)
|
||||||
[[realNSApp() mainMenu] update];
|
[[uiprivNSApp() mainMenu] update];
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *e))
|
||||||
void uiQuit(void)
|
void uiQuit(void)
|
||||||
{
|
{
|
||||||
canQuit = YES;
|
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
|
// 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
|
// unfortunately NSMutableDictionary copies its keys, meaning we can't use it for pointers
|
||||||
// hence, this file
|
// 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
|
// 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;
|
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)
|
m->m = [[NSMapTable alloc] initWithKeyOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||||
valueOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
valueOptions:(NSPointerFunctionsOpaqueMemory | NSPointerFunctionsOpaquePersonality)
|
||||||
capacity:0];
|
capacity:0];
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapDestroy(struct mapTable *m)
|
void uiprivMapDestroy(uiprivMap *m)
|
||||||
{
|
{
|
||||||
if ([m->m count] != 0)
|
if ([m->m count] != 0)
|
||||||
uiprivImplBug("attempt to destroy map with items inside");
|
uiprivImplBug("attempt to destroy map with items inside");
|
||||||
|
@ -27,33 +27,35 @@ void mapDestroy(struct mapTable *m)
|
||||||
uiprivFree(m);
|
uiprivFree(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mapGet(struct mapTable *m, void *key)
|
void *uiprivMapGet(uiprivMap *m, void *key)
|
||||||
{
|
{
|
||||||
return NSMapGet(m->m, 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);
|
NSMapInsert(m->m, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapDelete(struct mapTable *m, void *key)
|
void uiprivMapDelete(uiprivMap *m, void *key)
|
||||||
{
|
{
|
||||||
NSMapRemove(m->m, 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);
|
NSMapEnumerator e;
|
||||||
void *k = NULL;
|
void *k, *v;
|
||||||
void *v = NULL;
|
|
||||||
while (NSNextMapEnumeratorPair(&e, &k, &v)) {
|
e = NSEnumerateMapTable(m->m);
|
||||||
|
k = NULL;
|
||||||
|
v = NULL;
|
||||||
|
while (NSNextMapEnumeratorPair(&e, &k, &v))
|
||||||
f(k, v);
|
f(k, v);
|
||||||
}
|
|
||||||
NSEndMapTableEnumeration(&e);
|
NSEndMapTableEnumeration(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapReset(struct mapTable *m)
|
void uiprivMapReset(uiprivMap *m)
|
||||||
{
|
{
|
||||||
NSResetMapTable(m->m);
|
NSResetMapTable(m->m);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,17 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
{
|
{
|
||||||
uiMenuItem *item;
|
uiMenuItem *item;
|
||||||
|
|
||||||
item = (uiMenuItem *)value;
|
item = (uiMenuItem *) value;
|
||||||
[item->item release];
|
[item->item release];
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation menuManager
|
@implementation uiprivMenuManager
|
||||||
|
|
||||||
- (id)init
|
- (id)init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
self->items = newMap();
|
self->items = uiprivNewMap();
|
||||||
self->hasQuit = NO;
|
self->hasQuit = NO;
|
||||||
self->hasPreferences = NO;
|
self->hasPreferences = NO;
|
||||||
self->hasAbout = NO;
|
self->hasAbout = NO;
|
||||||
|
@ -51,10 +51,10 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapWalk(self->items, mapItemReleaser);
|
uiprivMapWalk(self->items, mapItemReleaser);
|
||||||
mapReset(self->items);
|
uiprivMapReset(self->items);
|
||||||
mapDestroy(self->items);
|
uiprivMapDestroy(self->items);
|
||||||
uninitMenus();
|
uiprivUninitMenus();
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,11 +62,11 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
{
|
{
|
||||||
uiMenuItem *item;
|
uiMenuItem *item;
|
||||||
|
|
||||||
item = (uiMenuItem *) mapGet(self->items, sender);
|
item = (uiMenuItem *) uiprivMapGet(self->items, sender);
|
||||||
if (item->type == typeCheckbox)
|
if (item->type == typeCheckbox)
|
||||||
uiMenuItemSetChecked(item, !uiMenuItemChecked(item));
|
uiMenuItemSetChecked(item, !uiMenuItemChecked(item));
|
||||||
// use the key window as the source of the menu event; it's the active window
|
// 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
|
- (IBAction)onQuitClicked:(id)sender
|
||||||
|
@ -94,7 +94,7 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
self->hasAbout = YES;
|
self->hasAbout = YES;
|
||||||
break;
|
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
|
// 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)
|
if (item == self.aboutItem && !self->hasAbout)
|
||||||
return NO;
|
return NO;
|
||||||
// then poll the item's enabled/disabled state
|
// then poll the item's enabled/disabled state
|
||||||
smi = (uiMenuItem *) mapGet(self->items, item);
|
smi = (uiMenuItem *) uiprivMapGet(self->items, item);
|
||||||
return !smi->disabled;
|
return !smi->disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ static void mapItemReleaser(void *key, void *value)
|
||||||
item = [[[NSMenuItem alloc] initWithTitle:@"Services" action:NULL keyEquivalent:@""] autorelease];
|
item = [[[NSMenuItem alloc] initWithTitle:@"Services" action:NULL keyEquivalent:@""] autorelease];
|
||||||
servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
|
servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
|
||||||
[item setSubmenu:servicesMenu];
|
[item setSubmenu:servicesMenu];
|
||||||
[realNSApp() setServicesMenu:servicesMenu];
|
[uiprivNSApp() setServicesMenu:servicesMenu];
|
||||||
[appMenu addItem:item];
|
[appMenu addItem:item];
|
||||||
|
|
||||||
[appMenu addItem:[NSMenuItem separatorItem]];
|
[appMenu addItem:[NSMenuItem separatorItem]];
|
||||||
|
@ -246,26 +246,26 @@ static uiMenuItem *newItem(uiMenu *m, int type, const char *name)
|
||||||
item->type = type;
|
item->type = type;
|
||||||
switch (item->type) {
|
switch (item->type) {
|
||||||
case typeQuit:
|
case typeQuit:
|
||||||
item->item = [appDelegate().menuManager.quitItem retain];
|
item->item = [uiprivAppDelegate().menuManager.quitItem retain];
|
||||||
break;
|
break;
|
||||||
case typePreferences:
|
case typePreferences:
|
||||||
item->item = [appDelegate().menuManager.preferencesItem retain];
|
item->item = [uiprivAppDelegate().menuManager.preferencesItem retain];
|
||||||
break;
|
break;
|
||||||
case typeAbout:
|
case typeAbout:
|
||||||
item->item = [appDelegate().menuManager.aboutItem retain];
|
item->item = [uiprivAppDelegate().menuManager.aboutItem retain];
|
||||||
break;
|
break;
|
||||||
case typeSeparator:
|
case typeSeparator:
|
||||||
item->item = [[NSMenuItem separatorItem] retain];
|
item->item = [[NSMenuItem separatorItem] retain];
|
||||||
[m->menu addItem:item->item];
|
[m->menu addItem:item->item];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:@selector(onClicked:) keyEquivalent:@""];
|
item->item = [[NSMenuItem alloc] initWithTitle:uiprivToNSString(name) action:@selector(onClicked:) keyEquivalent:@""];
|
||||||
[item->item setTarget:appDelegate().menuManager];
|
[item->item setTarget:uiprivAppDelegate().menuManager];
|
||||||
[m->menu addItem:item->item];
|
[m->menu addItem:item->item];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
[appDelegate().menuManager register:item->item to:item];
|
[uiprivAppDelegate().menuManager register:item->item to:item];
|
||||||
item->onClicked = defaultOnClicked;
|
item->onClicked = defaultOnClicked;
|
||||||
|
|
||||||
[m->items addObject:[NSValue valueWithPointer:item]];
|
[m->items addObject:[NSValue valueWithPointer:item]];
|
||||||
|
@ -321,15 +321,15 @@ uiMenu *uiNewMenu(const char *name)
|
||||||
|
|
||||||
m = uiprivNew(uiMenu);
|
m = uiprivNew(uiMenu);
|
||||||
|
|
||||||
m->menu = [[NSMenu alloc] initWithTitle:toNSString(name)];
|
m->menu = [[NSMenu alloc] initWithTitle:uiprivToNSString(name)];
|
||||||
// use automatic menu item enabling for all menus for consistency's sake
|
// use automatic menu item enabling for all menus for consistency's sake
|
||||||
|
|
||||||
m->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:NULL keyEquivalent:@""];
|
m->item = [[NSMenuItem alloc] initWithTitle:uiprivToNSString(name) action:NULL keyEquivalent:@""];
|
||||||
[m->item setSubmenu:m->menu];
|
[m->item setSubmenu:m->menu];
|
||||||
|
|
||||||
m->items = [NSMutableArray new];
|
m->items = [NSMutableArray new];
|
||||||
|
|
||||||
[[realNSApp() mainMenu] addItem:m->item];
|
[[uiprivNSApp() mainMenu] addItem:m->item];
|
||||||
|
|
||||||
[menus addObject:[NSValue valueWithPointer:m]];
|
[menus addObject:[NSValue valueWithPointer:m]];
|
||||||
|
|
||||||
|
@ -338,12 +338,12 @@ uiMenu *uiNewMenu(const char *name)
|
||||||
} // @autoreleasepool
|
} // @autoreleasepool
|
||||||
}
|
}
|
||||||
|
|
||||||
void finalizeMenus(void)
|
void uiprivFinalizeMenus(void)
|
||||||
{
|
{
|
||||||
menusFinalized = YES;
|
menusFinalized = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitMenus(void)
|
void uiprivUninitMenus(void)
|
||||||
{
|
{
|
||||||
if (menus == NULL)
|
if (menus == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct uiMultilineEntry {
|
||||||
uiDarwinControl c;
|
uiDarwinControl c;
|
||||||
NSScrollView *sv;
|
NSScrollView *sv;
|
||||||
intrinsicSizeTextView *tv;
|
intrinsicSizeTextView *tv;
|
||||||
struct scrollViewData *d;
|
uiprivScrollViewData *d;
|
||||||
void (*onChanged)(uiMultilineEntry *, void *);
|
void (*onChanged)(uiMultilineEntry *, void *);
|
||||||
void *onChangedData;
|
void *onChangedData;
|
||||||
BOOL changing;
|
BOOL changing;
|
||||||
|
@ -59,7 +59,7 @@ static void uiMultilineEntryDestroy(uiControl *c)
|
||||||
{
|
{
|
||||||
uiMultilineEntry *e = uiMultilineEntry(c);
|
uiMultilineEntry *e = uiMultilineEntry(c);
|
||||||
|
|
||||||
scrollViewFreeData(e->sv, e->d);
|
uiprivScrollViewFreeData(e->sv, e->d);
|
||||||
[e->tv release];
|
[e->tv release];
|
||||||
[e->sv release];
|
[e->sv release];
|
||||||
uiFreeControl(uiControl(e));
|
uiFreeControl(uiControl(e));
|
||||||
|
@ -78,7 +78,7 @@ char *uiMultilineEntryText(uiMultilineEntry *e)
|
||||||
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
[[e->tv textStorage] replaceCharactersInRange:NSMakeRange(0, [[e->tv string] length])
|
[[e->tv textStorage] replaceCharactersInRange:NSMakeRange(0, [[e->tv string] length])
|
||||||
withString:toNSString(text)];
|
withString:uiprivToNSString(text)];
|
||||||
// must be called explicitly according to the documentation of shouldChangeTextInRange:replacementString:
|
// must be called explicitly according to the documentation of shouldChangeTextInRange:replacementString:
|
||||||
e->changing = YES;
|
e->changing = YES;
|
||||||
[e->tv didChangeText];
|
[e->tv didChangeText];
|
||||||
|
@ -89,7 +89,7 @@ void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text)
|
||||||
void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)
|
void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text)
|
||||||
{
|
{
|
||||||
[[e->tv textStorage] replaceCharactersInRange:NSMakeRange([[e->tv string] length], 0)
|
[[e->tv textStorage] replaceCharactersInRange:NSMakeRange([[e->tv string] length], 0)
|
||||||
withString:toNSString(text)];
|
withString:uiprivToNSString(text)];
|
||||||
e->changing = YES;
|
e->changing = YES;
|
||||||
[e->tv didChangeText];
|
[e->tv didChangeText];
|
||||||
e->changing = NO;
|
e->changing = NO;
|
||||||
|
@ -120,7 +120,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
||||||
{
|
{
|
||||||
uiMultilineEntry *e;
|
uiMultilineEntry *e;
|
||||||
NSFont *font;
|
NSFont *font;
|
||||||
struct scrollViewCreateParams p;
|
uiprivScrollViewCreateParams p;
|
||||||
|
|
||||||
uiDarwinNewControl(uiMultilineEntry, e);
|
uiDarwinNewControl(uiMultilineEntry, e);
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
||||||
[[e->tv layoutManager] setAllowsNonContiguousLayout:YES];
|
[[e->tv layoutManager] setAllowsNonContiguousLayout:YES];
|
||||||
|
|
||||||
// now just to be safe; this will do some of the above but whatever
|
// 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
|
// 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
|
// 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
|
// let's just set it to the standard control font anyway, just to be safe
|
||||||
[e->tv setFont:font];
|
[e->tv setFont:font];
|
||||||
|
|
||||||
memset(&p, 0, sizeof (struct scrollViewCreateParams));
|
memset(&p, 0, sizeof (uiprivScrollViewCreateParams));
|
||||||
p.DocumentView = e->tv;
|
p.DocumentView = e->tv;
|
||||||
// this is what Interface Builder sets it to
|
// this is what Interface Builder sets it to
|
||||||
p.BackgroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
|
p.BackgroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
|
||||||
|
@ -215,7 +215,7 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
||||||
p.Bordered = YES;
|
p.Bordered = YES;
|
||||||
p.HScroll = hscroll;
|
p.HScroll = hscroll;
|
||||||
p.VScroll = YES;
|
p.VScroll = YES;
|
||||||
e->sv = mkScrollView(&p, &(e->d));
|
e->sv = uiprivMkScrollView(&p, &(e->d));
|
||||||
|
|
||||||
uiMultilineEntryOnChanged(e, defaultOnChanged, NULL);
|
uiMultilineEntryOnChanged(e, defaultOnChanged, NULL);
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ static uiForEach otfArrayForEachOT(const uiOpenTypeFeatures *otf, char a, char b
|
||||||
|
|
||||||
p.array = (CFMutableArrayRef) data;
|
p.array = (CFMutableArrayRef) data;
|
||||||
|
|
||||||
p.tagKey = *FUTURE_kCTFontOpenTypeFeatureTag;
|
p.tagKey = *uiprivFUTURE_kCTFontOpenTypeFeatureTag;
|
||||||
p.tagIsNumber = NO;
|
p.tagIsNumber = NO;
|
||||||
tagcstr[0] = a;
|
tagcstr[0] = a;
|
||||||
tagcstr[1] = b;
|
tagcstr[1] = b;
|
||||||
|
@ -87,7 +87,7 @@ static uiForEach otfArrayForEachOT(const uiOpenTypeFeatures *otf, char a, char b
|
||||||
}
|
}
|
||||||
p.tagValue = tagstr;
|
p.tagValue = tagstr;
|
||||||
|
|
||||||
p.valueKey = *FUTURE_kCTFontOpenTypeFeatureValue;
|
p.valueKey = *uiprivFUTURE_kCTFontOpenTypeFeatureValue;
|
||||||
p.valueType = kCFNumberSInt32Type;
|
p.valueType = kCFNumberSInt32Type;
|
||||||
p.valueValue = (const SInt32 *) (&value);
|
p.valueValue = (const SInt32 *) (&value);
|
||||||
addCTFeatureEntry(&p);
|
addCTFeatureEntry(&p);
|
||||||
|
@ -106,7 +106,7 @@ CFArrayRef uiprivOpenTypeFeaturesToCTFeatures(const uiOpenTypeFeatures *otf)
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
f = otfArrayForEachAAT;
|
f = otfArrayForEachAAT;
|
||||||
if (FUTURE_kCTFontOpenTypeFeatureTag != NULL && FUTURE_kCTFontOpenTypeFeatureValue != NULL)
|
if (uiprivFUTURE_kCTFontOpenTypeFeatureTag != NULL && uiprivFUTURE_kCTFontOpenTypeFeatureValue != NULL)
|
||||||
f = otfArrayForEachOT;
|
f = otfArrayForEachOT;
|
||||||
uiOpenTypeFeaturesForEach(otf, f, array);
|
uiOpenTypeFeaturesForEach(otf, f, array);
|
||||||
return array;
|
return array;
|
||||||
|
|
|
@ -87,7 +87,7 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
||||||
NSLayoutConstraint *constraint;
|
NSLayoutConstraint *constraint;
|
||||||
|
|
||||||
b = [[NSButton alloc] initWithFrame:NSZeroRect];
|
b = [[NSButton alloc] initWithFrame:NSZeroRect];
|
||||||
[b setTitle:toNSString(text)];
|
[b setTitle:uiprivToNSString(text)];
|
||||||
[b setButtonType:NSRadioButton];
|
[b setButtonType:NSRadioButton];
|
||||||
// doesn't seem to have an associated bezel style
|
// doesn't seem to have an associated bezel style
|
||||||
[b setBordered:NO];
|
[b setBordered:NO];
|
||||||
|
@ -102,14 +102,14 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
||||||
[r->view addSubview:b];
|
[r->view addSubview:b];
|
||||||
|
|
||||||
// pin horizontally to the edges of the superview
|
// pin horizontally to the edges of the superview
|
||||||
constraint = mkConstraint(b, NSLayoutAttributeLeading,
|
constraint = uiprivMkConstraint(b, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
r->view, NSLayoutAttributeLeading,
|
r->view, NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiRadioButtons button leading constraint");
|
@"uiRadioButtons button leading constraint");
|
||||||
[r->view addConstraint:constraint];
|
[r->view addConstraint:constraint];
|
||||||
[r->constraints addObject:constraint];
|
[r->constraints addObject:constraint];
|
||||||
constraint = mkConstraint(b, NSLayoutAttributeTrailing,
|
constraint = uiprivMkConstraint(b, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
r->view, NSLayoutAttributeTrailing,
|
r->view, NSLayoutAttributeTrailing,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -120,14 +120,14 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
||||||
// if this is the first view, pin it to the top
|
// if this is the first view, pin it to the top
|
||||||
// otherwise pin to the bottom of the last
|
// otherwise pin to the bottom of the last
|
||||||
if ([r->buttons count] == 1)
|
if ([r->buttons count] == 1)
|
||||||
constraint = mkConstraint(b, NSLayoutAttributeTop,
|
constraint = uiprivMkConstraint(b, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
r->view, NSLayoutAttributeTop,
|
r->view, NSLayoutAttributeTop,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiRadioButtons first button top constraint");
|
@"uiRadioButtons first button top constraint");
|
||||||
else {
|
else {
|
||||||
b2 = buttonAt(r, [r->buttons count] - 2);
|
b2 = buttonAt(r, [r->buttons count] - 2);
|
||||||
constraint = mkConstraint(b, NSLayoutAttributeTop,
|
constraint = uiprivMkConstraint(b, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
b2, NSLayoutAttributeBottom,
|
b2, NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
|
@ -144,7 +144,7 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// and make the new bottom constraint
|
// and make the new bottom constraint
|
||||||
r->lastv = mkConstraint(b, NSLayoutAttributeBottom,
|
r->lastv = uiprivMkConstraint(b, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
r->view, NSLayoutAttributeBottom,
|
r->view, NSLayoutAttributeBottom,
|
||||||
1, 0,
|
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
|
// 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?
|
// TODO do the same with uiGroup and uiTab?
|
||||||
|
|
||||||
struct scrollViewData {
|
struct uiprivScrollViewData {
|
||||||
BOOL hscroll;
|
BOOL hscroll;
|
||||||
BOOL vscroll;
|
BOOL vscroll;
|
||||||
};
|
};
|
||||||
|
|
||||||
NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewData **dout)
|
NSScrollView *uiprivMkScrollView(uiprivScrollViewCreateParams *p, uiprivScrollViewData **dout)
|
||||||
{
|
{
|
||||||
NSScrollView *sv;
|
NSScrollView *sv;
|
||||||
NSBorderType border;
|
NSBorderType border;
|
||||||
struct scrollViewData *d;
|
uiprivScrollViewData *d;
|
||||||
|
|
||||||
sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
|
sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
|
||||||
if (p->BackgroundColor != nil)
|
if (p->BackgroundColor != nil)
|
||||||
|
@ -39,15 +39,15 @@ NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewDa
|
||||||
[sv setAllowsMagnification:NO];
|
[sv setAllowsMagnification:NO];
|
||||||
|
|
||||||
[sv setDocumentView:p->DocumentView];
|
[sv setDocumentView:p->DocumentView];
|
||||||
d = uiprivNew(struct scrollViewData);
|
d = uiprivNew(uiprivScrollViewData);
|
||||||
scrollViewSetScrolling(sv, d, p->HScroll, p->VScroll);
|
uiprivScrollViewSetScrolling(sv, d, p->HScroll, p->VScroll);
|
||||||
|
|
||||||
*dout = d;
|
*dout = d;
|
||||||
return sv;
|
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
|
// 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;
|
d->hscroll = hscroll;
|
||||||
[sv setHasHorizontalScroller:d->hscroll];
|
[sv setHasHorizontalScroller:d->hscroll];
|
||||||
|
@ -55,7 +55,7 @@ void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hsc
|
||||||
[sv setHasVerticalScroller:d->vscroll];
|
[sv setHasVerticalScroller:d->vscroll];
|
||||||
}
|
}
|
||||||
|
|
||||||
void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d)
|
void uiprivScrollViewFreeData(NSScrollView *sv, uiprivScrollViewData *d)
|
||||||
{
|
{
|
||||||
uiprivFree(d);
|
uiprivFree(d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct uiSlider {
|
||||||
};
|
};
|
||||||
|
|
||||||
@interface sliderDelegateClass : NSObject {
|
@interface sliderDelegateClass : NSObject {
|
||||||
struct mapTable *sliders;
|
uiprivMap *sliders;
|
||||||
}
|
}
|
||||||
- (IBAction)onChanged:(id)sender;
|
- (IBAction)onChanged:(id)sender;
|
||||||
- (void)registerSlider:(uiSlider *)b;
|
- (void)registerSlider:(uiSlider *)b;
|
||||||
|
@ -42,13 +42,13 @@ struct uiSlider {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->sliders = newMap();
|
self->sliders = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->sliders);
|
uiprivMapDestroy(self->sliders);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,13 +56,13 @@ struct uiSlider {
|
||||||
{
|
{
|
||||||
uiSlider *s;
|
uiSlider *s;
|
||||||
|
|
||||||
s = (uiSlider *) mapGet(self->sliders, sender);
|
s = (uiSlider *) uiprivMapGet(self->sliders, sender);
|
||||||
(*(s->onChanged))(s, s->onChangedData);
|
(*(s->onChanged))(s, s->onChangedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)registerSlider:(uiSlider *)s
|
- (void)registerSlider:(uiSlider *)s
|
||||||
{
|
{
|
||||||
mapSet(self->sliders, s->slider, s);
|
uiprivMapSet(self->sliders, s->slider, s);
|
||||||
[s->slider setTarget:self];
|
[s->slider setTarget:self];
|
||||||
[s->slider setAction:@selector(onChanged:)];
|
[s->slider setAction:@selector(onChanged:)];
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ struct uiSlider {
|
||||||
- (void)unregisterSlider:(uiSlider *)s
|
- (void)unregisterSlider:(uiSlider *)s
|
||||||
{
|
{
|
||||||
[s->slider setTarget:nil];
|
[s->slider setTarget:nil];
|
||||||
mapDelete(self->sliders, s->slider);
|
uiprivMapDelete(self->sliders, s->slider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -138,7 +138,7 @@ uiSlider *uiNewSlider(int min, int max)
|
||||||
|
|
||||||
if (sliderDelegate == nil) {
|
if (sliderDelegate == nil) {
|
||||||
sliderDelegate = [[sliderDelegateClass new] autorelease];
|
sliderDelegate = [[sliderDelegateClass new] autorelease];
|
||||||
[delegates addObject:sliderDelegate];
|
[uiprivDelegates addObject:sliderDelegate];
|
||||||
}
|
}
|
||||||
[sliderDelegate registerSlider:s];
|
[sliderDelegate registerSlider:s];
|
||||||
uiSliderOnChanged(s, defaultOnChanged, NULL);
|
uiSliderOnChanged(s, defaultOnChanged, NULL);
|
||||||
|
|
|
@ -46,7 +46,7 @@ static CGFloat stepperYDelta(void)
|
||||||
{
|
{
|
||||||
self = [super initWithFrame:r];
|
self = [super initWithFrame:r];
|
||||||
if (self) {
|
if (self) {
|
||||||
self->tf = newEditableTextField();
|
self->tf = uiprivNewEditableTextField();
|
||||||
[self->tf setTranslatesAutoresizingMaskIntoConstraints:NO];
|
[self->tf setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||||
|
|
||||||
self->formatter = [NSNumberFormatter new];
|
self->formatter = [NSNumberFormatter new];
|
||||||
|
@ -70,37 +70,37 @@ static CGFloat stepperYDelta(void)
|
||||||
[self addSubview:self->tf];
|
[self addSubview:self->tf];
|
||||||
[self addSubview:self->stepper];
|
[self addSubview:self->stepper];
|
||||||
|
|
||||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeLeading,
|
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeLeading,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeLeading,
|
self, NSLayoutAttributeLeading,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiSpinbox left edge")];
|
@"uiSpinbox left edge")];
|
||||||
[self addConstraint:mkConstraint(self->stepper, NSLayoutAttributeTrailing,
|
[self addConstraint:uiprivMkConstraint(self->stepper, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeTrailing,
|
self, NSLayoutAttributeTrailing,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiSpinbox right edge")];
|
@"uiSpinbox right edge")];
|
||||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeTop,
|
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeTop,
|
self, NSLayoutAttributeTop,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiSpinbox top edge text field")];
|
@"uiSpinbox top edge text field")];
|
||||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeBottom,
|
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeBottom,
|
self, NSLayoutAttributeBottom,
|
||||||
1, 0,
|
1, 0,
|
||||||
@"uiSpinbox bottom edge text field")];
|
@"uiSpinbox bottom edge text field")];
|
||||||
[self addConstraint:mkConstraint(self->stepper, NSLayoutAttributeTop,
|
[self addConstraint:uiprivMkConstraint(self->stepper, NSLayoutAttributeTop,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeTop,
|
self, NSLayoutAttributeTop,
|
||||||
1, stepperYDelta(),
|
1, stepperYDelta(),
|
||||||
@"uiSpinbox top edge stepper")];
|
@"uiSpinbox top edge stepper")];
|
||||||
[self addConstraint:mkConstraint(self->stepper, NSLayoutAttributeBottom,
|
[self addConstraint:uiprivMkConstraint(self->stepper, NSLayoutAttributeBottom,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self, NSLayoutAttributeBottom,
|
self, NSLayoutAttributeBottom,
|
||||||
1, stepperYDelta(),
|
1, stepperYDelta(),
|
||||||
@"uiSpinbox bottom edge stepper")];
|
@"uiSpinbox bottom edge stepper")];
|
||||||
[self addConstraint:mkConstraint(self->tf, NSLayoutAttributeTrailing,
|
[self addConstraint:uiprivMkConstraint(self->tf, NSLayoutAttributeTrailing,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
self->stepper, NSLayoutAttributeLeading,
|
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)
|
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;
|
char *filename;
|
||||||
|
|
||||||
[s beginSheetModalForWindow:parent completionHandler:^(NSInteger result) {
|
[s beginSheetModalForWindow:parent completionHandler:^(NSInteger result) {
|
||||||
[realNSApp() stopModalWithCode:result];
|
[uiprivNSApp() stopModalWithCode:result];
|
||||||
}];
|
}];
|
||||||
if ([realNSApp() runModalForWindow:s] != NSFileHandlingPanelOKButton)
|
if ([uiprivNSApp() runModalForWindow:s] != NSFileHandlingPanelOKButton)
|
||||||
return NULL;
|
return NULL;
|
||||||
filename = uiDarwinNSStringToText([[s URL] path]);
|
filename = uiDarwinNSStringToText([[s URL] path]);
|
||||||
return filename;
|
return filename;
|
||||||
|
@ -84,12 +84,12 @@ char *uiSaveFile(uiWindow *parent)
|
||||||
modalDelegate:self
|
modalDelegate:self
|
||||||
didEndSelector:@selector(panelEnded:result:data:)
|
didEndSelector:@selector(panelEnded:result:data:)
|
||||||
contextInfo:NULL];
|
contextInfo:NULL];
|
||||||
return [realNSApp() runModalForWindow:[self->panel window]];
|
return [uiprivNSApp() runModalForWindow:[self->panel window]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)panelEnded:(NSAlert *)panel result:(NSInteger)result data:(void *)data
|
- (void)panelEnded:(NSAlert *)panel result:(NSInteger)result data:(void *)data
|
||||||
{
|
{
|
||||||
[realNSApp() stopModalWithCode:result];
|
[uiprivNSApp() stopModalWithCode:result];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -103,8 +103,8 @@ static void msgbox(NSWindow *parent, const char *title, const char *description,
|
||||||
[a setAlertStyle:style];
|
[a setAlertStyle:style];
|
||||||
[a setShowsHelp:NO];
|
[a setShowsHelp:NO];
|
||||||
[a setShowsSuppressionButton:NO];
|
[a setShowsSuppressionButton:NO];
|
||||||
[a setMessageText:toNSString(title)];
|
[a setMessageText:uiprivToNSString(title)];
|
||||||
[a setInformativeText:toNSString(description)];
|
[a setInformativeText:uiprivToNSString(description)];
|
||||||
[a addButtonWithTitle:@"OK"];
|
[a addButtonWithTitle:@"OK"];
|
||||||
cm = [[libuiCodeModalAlertPanel alloc] initWithPanel:a parent:parent];
|
cm = [[libuiCodeModalAlertPanel alloc] initWithPanel:a parent:parent];
|
||||||
[cm run];
|
[cm run];
|
||||||
|
|
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)
|
// TODO need to jiggle on tab change too (second page disabled tab label initially ambiguous)
|
||||||
|
|
||||||
@interface tabPage : NSObject {
|
@interface tabPage : NSObject {
|
||||||
struct singleChildConstraints constraints;
|
uiprivSingleChildConstraints constraints;
|
||||||
int margined;
|
int margined;
|
||||||
NSView *view; // the NSTabViewItem view itself
|
NSView *view; // the NSTabViewItem view itself
|
||||||
NSObject *pageID;
|
NSObject *pageID;
|
||||||
|
@ -58,7 +58,7 @@ struct uiTab {
|
||||||
[self removeChildConstraints];
|
[self removeChildConstraints];
|
||||||
if (self.c == NULL)
|
if (self.c == NULL)
|
||||||
return;
|
return;
|
||||||
singleChildConstraintsEstablish(&(self->constraints),
|
uiprivSingleChildConstraintsEstablish(&(self->constraints),
|
||||||
self->view, [self childView],
|
self->view, [self childView],
|
||||||
uiDarwinControlHugsTrailingEdge(uiDarwinControl(self.c)),
|
uiDarwinControlHugsTrailingEdge(uiDarwinControl(self.c)),
|
||||||
uiDarwinControlHugsBottom(uiDarwinControl(self.c)),
|
uiDarwinControlHugsBottom(uiDarwinControl(self.c)),
|
||||||
|
@ -68,7 +68,7 @@ struct uiTab {
|
||||||
|
|
||||||
- (void)removeChildConstraints
|
- (void)removeChildConstraints
|
||||||
{
|
{
|
||||||
singleChildConstraintsRemove(&(self->constraints), self->view);
|
uiprivSingleChildConstraintsRemove(&(self->constraints), self->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)isMargined
|
- (int)isMargined
|
||||||
|
@ -79,7 +79,7 @@ struct uiTab {
|
||||||
- (void)setMargined:(int)m
|
- (void)setMargined:(int)m
|
||||||
{
|
{
|
||||||
self->margined = m;
|
self->margined = m;
|
||||||
singleChildConstraintsSetMargined(&(self->constraints), self->margined);
|
uiprivSingleChildConstraintsSetMargined(&(self->constraints), self->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -136,7 +136,7 @@ static void tabRelayout(uiTab *t)
|
||||||
for (page in t->pages)
|
for (page in t->pages)
|
||||||
[page establishChildConstraints];
|
[page establishChildConstraints];
|
||||||
// and this gets rid of some weird issues with regards to box alignment
|
// and this gets rid of some weird issues with regards to box alignment
|
||||||
jiggleViewLayout(t->tabview);
|
uiprivJiggleViewLayout(t->tabview);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL uiTabHugsTrailingEdge(uiDarwinControl *c)
|
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];
|
[t->pages insertObject:page atIndex:n];
|
||||||
|
|
||||||
i = [[[NSTabViewItem alloc] initWithIdentifier:pageID] autorelease];
|
i = [[[NSTabViewItem alloc] initWithIdentifier:pageID] autorelease];
|
||||||
[i setLabel:toNSString(name)];
|
[i setLabel:uiprivToNSString(name)];
|
||||||
[i setView:view];
|
[i setView:view];
|
||||||
[t->tabview insertTabViewItem:i atIndex:n];
|
[t->tabview insertTabViewItem:i atIndex:n];
|
||||||
|
|
||||||
|
|
|
@ -3,27 +3,41 @@
|
||||||
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_8
|
#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
|
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_8
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#include <dlfcn.h> // see future.m
|
#import <dlfcn.h> // see future.m
|
||||||
#import "../ui.h"
|
#import "../ui.h"
|
||||||
#import "../ui_darwin.h"
|
#import "../ui_darwin.h"
|
||||||
#import "../common/uipriv.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)
|
#if __has_feature(objc_arc)
|
||||||
#error Sorry, libui cannot be compiled with ARC.
|
#error Sorry, libui cannot be compiled with ARC.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define toNSString(str) [NSString stringWithUTF8String:(str)]
|
#define uiprivToNSString(str) [NSString stringWithUTF8String:(str)]
|
||||||
#define fromNSString(str) [(str) UTF8String]
|
#define uiprivFromNSString(str) [(str) UTF8String]
|
||||||
|
|
||||||
|
// TODO find a better place for this
|
||||||
#ifndef NSAppKitVersionNumber10_9
|
#ifndef NSAppKitVersionNumber10_9
|
||||||
#define NSAppKitVersionNumber10_9 1265
|
#define NSAppKitVersionNumber10_9 1265
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*TODO remove this*/typedef struct uiImage uiImage;
|
/*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
|
// menu.m
|
||||||
@interface menuManager : NSObject {
|
@interface uiprivMenuManager : NSObject {
|
||||||
struct mapTable *items;
|
uiprivMap *items;
|
||||||
BOOL hasQuit;
|
BOOL hasQuit;
|
||||||
BOOL hasPreferences;
|
BOOL hasPreferences;
|
||||||
BOOL hasAbout;
|
BOOL hasAbout;
|
||||||
|
@ -35,50 +49,52 @@
|
||||||
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
||||||
- (NSMenu *)makeMenubar;
|
- (NSMenu *)makeMenubar;
|
||||||
@end
|
@end
|
||||||
extern void finalizeMenus(void);
|
extern void uiprivFinalizeMenus(void);
|
||||||
extern void uninitMenus(void);
|
extern void uiprivUninitMenus(void);
|
||||||
|
|
||||||
// main.m
|
// main.m
|
||||||
@interface applicationClass : NSApplication
|
@interface uiprivApplicationClass : NSApplication
|
||||||
@end
|
@end
|
||||||
// this is needed because NSApp is of type id, confusing clang
|
// this is needed because NSApp is of type id, confusing clang
|
||||||
#define realNSApp() ((applicationClass *) NSApp)
|
#define uiprivNSApp() ((uiprivApplicationClass *) NSApp)
|
||||||
@interface appDelegate : NSObject <NSApplicationDelegate>
|
@interface uiprivAppDelegate : NSObject<NSApplicationDelegate>
|
||||||
@property (strong) menuManager *menuManager;
|
@property (strong) uiprivMenuManager *menuManager;
|
||||||
@end
|
@end
|
||||||
#define appDelegate() ((appDelegate *) [realNSApp() delegate])
|
#define uiprivAppDelegate() ((uiprivAppDelegate *) [uiprivNSApp() delegate])
|
||||||
struct nextEventArgs {
|
typedef struct uiprivNextEventArgs uiprivNextEventArgs;
|
||||||
|
struct uiprivNextEventArgs {
|
||||||
NSEventMask mask;
|
NSEventMask mask;
|
||||||
NSDate *duration;
|
NSDate *duration;
|
||||||
// LONGTERM no NSRunLoopMode?
|
// LONGTERM no NSRunLoopMode?
|
||||||
NSString *mode;
|
NSString *mode;
|
||||||
BOOL dequeue;
|
BOOL dequeue;
|
||||||
};
|
};
|
||||||
extern int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *));
|
extern int uiprivMainStep(uiprivNextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *));
|
||||||
|
|
||||||
// util.m
|
// util.m
|
||||||
extern void disableAutocorrect(NSTextView *);
|
extern void uiprivDisableAutocorrect(NSTextView *);
|
||||||
|
|
||||||
// entry.m
|
// entry.m
|
||||||
extern void finishNewTextField(NSTextField *, BOOL);
|
extern void uiprivFinishNewTextField(NSTextField *, BOOL);
|
||||||
extern NSTextField *newEditableTextField(void);
|
extern NSTextField *uiprivNewEditableTextField(void);
|
||||||
|
|
||||||
// window.m
|
// window.m
|
||||||
@interface libuiNSWindow : NSWindow
|
@interface uiprivNSWindow : NSWindow
|
||||||
- (void)libui_doMove:(NSEvent *)initialEvent;
|
- (void)uiprivDoMove:(NSEvent *)initialEvent;
|
||||||
- (void)libui_doResize:(NSEvent *)initialEvent on:(uiWindowResizeEdge)edge;
|
- (void)uiprivDoResize:(NSEvent *)initialEvent on:(uiWindowResizeEdge)edge;
|
||||||
@end
|
@end
|
||||||
extern uiWindow *windowFromNSWindow(NSWindow *);
|
extern uiWindow *uiprivWindowFromNSWindow(NSWindow *);
|
||||||
|
|
||||||
// alloc.m
|
// alloc.m
|
||||||
extern NSMutableArray *delegates;
|
extern NSMutableArray *uiprivDelegates;
|
||||||
extern void initAlloc(void);
|
extern void uiprivInitAlloc(void);
|
||||||
extern void uninitAlloc(void);
|
extern void uiprivUninitAlloc(void);
|
||||||
|
|
||||||
// autolayout.m
|
// autolayout.m
|
||||||
extern NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc);
|
extern NSLayoutConstraint *uiprivMkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc);
|
||||||
extern void jiggleViewLayout(NSView *view);
|
extern void uiprivJiggleViewLayout(NSView *view);
|
||||||
struct singleChildConstraints {
|
typedef struct uiprivSingleChildConstraints uiprivSingleChildConstraints;
|
||||||
|
struct uiprivSingleChildConstraints {
|
||||||
NSLayoutConstraint *leadingConstraint;
|
NSLayoutConstraint *leadingConstraint;
|
||||||
NSLayoutConstraint *topConstraint;
|
NSLayoutConstraint *topConstraint;
|
||||||
NSLayoutConstraint *trailingConstraintGreater;
|
NSLayoutConstraint *trailingConstraintGreater;
|
||||||
|
@ -86,29 +102,20 @@ struct singleChildConstraints {
|
||||||
NSLayoutConstraint *bottomConstraintGreater;
|
NSLayoutConstraint *bottomConstraintGreater;
|
||||||
NSLayoutConstraint *bottomConstraintEqual;
|
NSLayoutConstraint *bottomConstraintEqual;
|
||||||
};
|
};
|
||||||
extern void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc);
|
extern void uiprivSingleChildConstraintsEstablish(uiprivSingleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc);
|
||||||
extern void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv);
|
extern void uiprivSingleChildConstraintsRemove(uiprivSingleChildConstraints *c, NSView *cv);
|
||||||
extern void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int margined);
|
extern void uiprivSingleChildConstraintsSetMargined(uiprivSingleChildConstraints *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);
|
|
||||||
|
|
||||||
// area.m
|
// area.m
|
||||||
extern int sendAreaEvents(NSEvent *);
|
extern int uiprivSendAreaEvents(NSEvent *);
|
||||||
|
|
||||||
// areaevents.m
|
// areaevents.m
|
||||||
extern BOOL fromKeycode(unsigned short keycode, uiAreaKeyEvent *ke);
|
extern BOOL uiprivFromKeycode(unsigned short keycode, uiAreaKeyEvent *ke);
|
||||||
extern BOOL keycodeModifier(unsigned short keycode, uiModifiers *mod);
|
extern BOOL uiprivKeycodeModifier(unsigned short keycode, uiModifiers *mod);
|
||||||
|
|
||||||
// draw.m
|
// draw.m
|
||||||
extern uiDrawContext *newContext(CGContextRef, CGFloat);
|
extern uiDrawContext *uiprivDrawNewContext(CGContextRef, CGFloat);
|
||||||
extern void freeContext(uiDrawContext *);
|
extern void uiprivDrawFreeContext(uiDrawContext *);
|
||||||
|
|
||||||
// fontbutton.m
|
// fontbutton.m
|
||||||
extern BOOL uiprivFontButtonInhibitSendAction(SEL sel, id from, id to);
|
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);
|
extern void uiprivSetupFontPanel(void);
|
||||||
|
|
||||||
// colorbutton.m
|
// colorbutton.m
|
||||||
extern BOOL colorButtonInhibitSendAction(SEL sel, id from, id to);
|
extern BOOL uiprivColorButtonInhibitSendAction(SEL sel, id from, id to);
|
||||||
|
|
||||||
// scrollview.m
|
// scrollview.m
|
||||||
struct scrollViewCreateParams {
|
typedef struct uiprivScrollViewCreateParams uiprivScrollViewCreateParams;
|
||||||
|
struct uiprivScrollViewCreateParams {
|
||||||
|
// TODO MAYBE fix these identifiers
|
||||||
NSView *DocumentView;
|
NSView *DocumentView;
|
||||||
NSColor *BackgroundColor;
|
NSColor *BackgroundColor;
|
||||||
BOOL DrawsBackground;
|
BOOL DrawsBackground;
|
||||||
|
@ -127,30 +136,30 @@ struct scrollViewCreateParams {
|
||||||
BOOL HScroll;
|
BOOL HScroll;
|
||||||
BOOL VScroll;
|
BOOL VScroll;
|
||||||
};
|
};
|
||||||
struct scrollViewData;
|
typedef struct uiprivScrollViewData uiprivScrollViewData;
|
||||||
extern NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewData **dout);
|
extern NSScrollView *uiprivMkScrollView(uiprivScrollViewCreateParams *p, uiprivScrollViewData **dout);
|
||||||
extern void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hscroll, BOOL vscroll);
|
extern void uiprivScrollViewSetScrolling(NSScrollView *sv, uiprivScrollViewData *d, BOOL hscroll, BOOL vscroll);
|
||||||
extern void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d);
|
extern void uiprivScrollViewFreeData(NSScrollView *sv, uiprivScrollViewData *d);
|
||||||
|
|
||||||
// label.m
|
// label.m
|
||||||
extern NSTextField *newLabel(NSString *str);
|
extern NSTextField *uiprivNewLabel(NSString *str);
|
||||||
|
|
||||||
// image.m
|
// image.m
|
||||||
extern NSImage *imageImage(uiImage *);
|
extern NSImage *uiprivImageNSImage(uiImage *);
|
||||||
|
|
||||||
// winmoveresize.m
|
// winmoveresize.m
|
||||||
extern void doManualMove(NSWindow *w, NSEvent *initialEvent);
|
extern void uiprivDoManualMove(NSWindow *w, NSEvent *initialEvent);
|
||||||
extern void doManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge);
|
extern void uiprivDoManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge);
|
||||||
|
|
||||||
// future.m
|
// future.m
|
||||||
extern CFStringRef *FUTURE_kCTFontOpenTypeFeatureTag;
|
extern CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureTag;
|
||||||
extern CFStringRef *FUTURE_kCTFontOpenTypeFeatureValue;
|
extern CFStringRef *uiprivFUTURE_kCTFontOpenTypeFeatureValue;
|
||||||
extern CFStringRef *FUTURE_kCTBackgroundColorAttributeName;
|
extern CFStringRef *uiprivFUTURE_kCTBackgroundColorAttributeName;
|
||||||
extern void loadFutures(void);
|
extern void uiprivLoadFutures(void);
|
||||||
extern void FUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSString *identifier);
|
extern void uiprivFUTURE_NSLayoutConstraint_setIdentifier(NSLayoutConstraint *constraint, NSString *identifier);
|
||||||
extern BOOL FUTURE_NSWindow_performWindowDragWithEvent(NSWindow *w, NSEvent *initialEvent);
|
extern BOOL uiprivFUTURE_NSWindow_performWindowDragWithEvent(NSWindow *w, NSEvent *initialEvent);
|
||||||
|
|
||||||
// undocumented.m
|
// undocumented.m
|
||||||
extern CFStringRef UNDOC_kCTFontPreferredSubFamilyNameKey;
|
extern CFStringRef uiprivUNDOC_kCTFontPreferredSubFamilyNameKey;
|
||||||
extern CFStringRef UNDOC_kCTFontPreferredFamilyNameKey;
|
extern CFStringRef uiprivUNDOC_kCTFontPreferredFamilyNameKey;
|
||||||
extern void loadUndocumented(void);
|
extern void uiprivLoadUndocumented(void);
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
// we also provide default values just in case
|
// we also provide default values just in case
|
||||||
|
|
||||||
// these values come from 10.12.6
|
// these values come from 10.12.6
|
||||||
CFStringRef UNDOC_kCTFontPreferredSubFamilyNameKey = CFSTR("CTFontPreferredSubFamilyName");
|
CFStringRef uiprivUNDOC_kCTFontPreferredSubFamilyNameKey = CFSTR("CTFontPreferredSubFamilyName");
|
||||||
CFStringRef UNDOC_kCTFontPreferredFamilyNameKey = CFSTR("CTFontPreferredFamilyName");
|
CFStringRef uiprivUNDOC_kCTFontPreferredFamilyNameKey = CFSTR("CTFontPreferredFamilyName");
|
||||||
|
|
||||||
// note that we treat any error as "the symbols aren't there" (and don't care if dlclose() failed)
|
// 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;
|
void *handle;
|
||||||
CFStringRef *str;
|
CFStringRef *str;
|
||||||
|
@ -23,9 +23,9 @@ void loadUndocumented(void)
|
||||||
GET(str, kCTFontPreferredSubFamilyNameKey);
|
GET(str, kCTFontPreferredSubFamilyNameKey);
|
||||||
NSLog(@"get %p", str);
|
NSLog(@"get %p", str);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
UNDOC_kCTFontPreferredSubFamilyNameKey = *str;
|
uiprivUNDOC_kCTFontPreferredSubFamilyNameKey = *str;
|
||||||
GET(str, kCTFontPreferredFamilyNameKey);
|
GET(str, kCTFontPreferredFamilyNameKey);
|
||||||
if (str != NULL)
|
if (str != NULL)
|
||||||
UNDOC_kCTFontPreferredFamilyNameKey = *str;
|
uiprivUNDOC_kCTFontPreferredFamilyNameKey = *str;
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
|
||||||
// LONGTERM do we really want to do this? make it an option?
|
// 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 setEnabledTextCheckingTypes:0];
|
||||||
[tv setAutomaticDashSubstitutionEnabled:NO];
|
[tv setAutomaticDashSubstitutionEnabled:NO];
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct uiWindow {
|
||||||
int margined;
|
int margined;
|
||||||
int (*onClosing)(uiWindow *, void *);
|
int (*onClosing)(uiWindow *, void *);
|
||||||
void *onClosingData;
|
void *onClosingData;
|
||||||
struct singleChildConstraints constraints;
|
uiprivSingleChildConstraints constraints;
|
||||||
void (*onContentSizeChanged)(uiWindow *, void *);
|
void (*onContentSizeChanged)(uiWindow *, void *);
|
||||||
void *onContentSizeChangedData;
|
void *onContentSizeChangedData;
|
||||||
BOOL suppressSizeChanged;
|
BOOL suppressSizeChanged;
|
||||||
|
@ -18,22 +18,22 @@ struct uiWindow {
|
||||||
int borderless;
|
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
|
@end
|
||||||
|
|
||||||
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
|
@interface windowDelegateClass : NSObject<NSWindowDelegate> {
|
||||||
struct mapTable *windows;
|
uiprivMap *windows;
|
||||||
}
|
}
|
||||||
- (BOOL)windowShouldClose:(id)sender;
|
- (BOOL)windowShouldClose:(id)sender;
|
||||||
- (void)windowDidResize:(NSNotification *)note;
|
- (void)windowDidResize:(NSNotification *)note;
|
||||||
|
@ -50,13 +50,13 @@ struct uiWindow {
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
self->windows = newMap();
|
self->windows = uiprivNewMap();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
mapDestroy(self->windows);
|
uiprivMapDestroy(self->windows);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,21 +100,21 @@ struct uiWindow {
|
||||||
|
|
||||||
- (void)registerWindow:(uiWindow *)w
|
- (void)registerWindow:(uiWindow *)w
|
||||||
{
|
{
|
||||||
mapSet(self->windows, w->window, w);
|
uiprivMapSet(self->windows, w->window, w);
|
||||||
[w->window setDelegate:self];
|
[w->window setDelegate:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unregisterWindow:(uiWindow *)w
|
- (void)unregisterWindow:(uiWindow *)w
|
||||||
{
|
{
|
||||||
[w->window setDelegate:nil];
|
[w->window setDelegate:nil];
|
||||||
mapDelete(self->windows, w->window);
|
uiprivMapDelete(self->windows, w->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (uiWindow *)lookupWindow:(NSWindow *)w
|
- (uiWindow *)lookupWindow:(NSWindow *)w
|
||||||
{
|
{
|
||||||
uiWindow *v;
|
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
|
// 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;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ static void removeConstraints(uiWindow *w)
|
||||||
NSView *cv;
|
NSView *cv;
|
||||||
|
|
||||||
cv = [w->window contentView];
|
cv = [w->window contentView];
|
||||||
singleChildConstraintsRemove(&(w->constraints), cv);
|
uiprivSingleChildConstraintsRemove(&(w->constraints), cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uiWindowDestroy(uiControl *c)
|
static void uiWindowDestroy(uiControl *c)
|
||||||
|
@ -215,7 +215,7 @@ static void windowRelayout(uiWindow *w)
|
||||||
return;
|
return;
|
||||||
childView = (NSView *) uiControlHandle(w->child);
|
childView = (NSView *) uiControlHandle(w->child);
|
||||||
contentView = [w->window contentView];
|
contentView = [w->window contentView];
|
||||||
singleChildConstraintsEstablish(&(w->constraints),
|
uiprivSingleChildConstraintsEstablish(&(w->constraints),
|
||||||
contentView, childView,
|
contentView, childView,
|
||||||
uiDarwinControlHugsTrailingEdge(uiDarwinControl(w->child)),
|
uiDarwinControlHugsTrailingEdge(uiDarwinControl(w->child)),
|
||||||
uiDarwinControlHugsBottom(uiDarwinControl(w->child)),
|
uiDarwinControlHugsBottom(uiDarwinControl(w->child)),
|
||||||
|
@ -252,7 +252,7 @@ char *uiWindowTitle(uiWindow *w)
|
||||||
|
|
||||||
void uiWindowSetTitle(uiWindow *w, const char *title)
|
void uiWindowSetTitle(uiWindow *w, const char *title)
|
||||||
{
|
{
|
||||||
[w->window setTitle:toNSString(title)];
|
[w->window setTitle:uiprivToNSString(title)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiWindowContentSize(uiWindow *w, int *width, int *height)
|
void uiWindowContentSize(uiWindow *w, int *width, int *height)
|
||||||
|
@ -354,7 +354,7 @@ int uiWindowMargined(uiWindow *w)
|
||||||
void uiWindowSetMargined(uiWindow *w, int margined)
|
void uiWindowSetMargined(uiWindow *w, int margined)
|
||||||
{
|
{
|
||||||
w->margined = margined;
|
w->margined = margined;
|
||||||
singleChildConstraintsSetMargined(&(w->constraints), w->margined);
|
uiprivSingleChildConstraintsSetMargined(&(w->constraints), w->margined);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int defaultOnClosing(uiWindow *w, void *data)
|
static int defaultOnClosing(uiWindow *w, void *data)
|
||||||
|
@ -371,15 +371,15 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
{
|
{
|
||||||
uiWindow *w;
|
uiWindow *w;
|
||||||
|
|
||||||
finalizeMenus();
|
uiprivFinalizeMenus();
|
||||||
|
|
||||||
uiDarwinNewControl(uiWindow, w);
|
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
|
styleMask:defaultStyleMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:YES];
|
defer:YES];
|
||||||
[w->window setTitle:toNSString(title)];
|
[w->window setTitle:uiprivToNSString(title)];
|
||||||
|
|
||||||
// do NOT release when closed
|
// do NOT release when closed
|
||||||
// we manually do this in uiWindowDestroy() above
|
// we manually do this in uiWindowDestroy() above
|
||||||
|
@ -387,7 +387,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
|
|
||||||
if (windowDelegate == nil) {
|
if (windowDelegate == nil) {
|
||||||
windowDelegate = [[windowDelegateClass new] autorelease];
|
windowDelegate = [[windowDelegateClass new] autorelease];
|
||||||
[delegates addObject:windowDelegate];
|
[uiprivDelegates addObject:windowDelegate];
|
||||||
}
|
}
|
||||||
[windowDelegate registerWindow:w];
|
[windowDelegate registerWindow:w];
|
||||||
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
uiWindowOnClosing(w, defaultOnClosing, NULL);
|
||||||
|
@ -397,7 +397,7 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility function for menus
|
// utility function for menus
|
||||||
uiWindow *windowFromNSWindow(NSWindow *w)
|
uiWindow *uiprivWindowFromNSWindow(NSWindow *w)
|
||||||
{
|
{
|
||||||
if (w == nil)
|
if (w == nil)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -43,16 +43,16 @@ void onMoveDrag(struct onMoveDragParams *p, NSEvent *e)
|
||||||
[p->w setFrameOrigin:frame.origin];
|
[p->w setFrameOrigin:frame.origin];
|
||||||
}
|
}
|
||||||
|
|
||||||
void doManualMove(NSWindow *w, NSEvent *initialEvent)
|
void uiprivDoManualMove(NSWindow *w, NSEvent *initialEvent)
|
||||||
{
|
{
|
||||||
__block struct onMoveDragParams mdp;
|
__block struct onMoveDragParams mdp;
|
||||||
struct nextEventArgs nea;
|
uiprivNextEventArgs nea;
|
||||||
BOOL (^handleEvent)(NSEvent *e);
|
BOOL (^handleEvent)(NSEvent *e);
|
||||||
__block BOOL done;
|
__block BOOL done;
|
||||||
|
|
||||||
// 10.11 gives us a method to handle this for us
|
// 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
|
// 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;
|
return;
|
||||||
|
|
||||||
mdp.w = w;
|
mdp.w = w;
|
||||||
|
@ -72,7 +72,7 @@ void doManualMove(NSWindow *w, NSEvent *initialEvent)
|
||||||
return YES; // do not send
|
return YES; // do not send
|
||||||
};
|
};
|
||||||
done = NO;
|
done = NO;
|
||||||
while (mainStep(&nea, handleEvent))
|
while (uiprivMainStep(&nea, handleEvent))
|
||||||
if (done)
|
if (done)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -90,14 +90,14 @@ static void minMaxAutoLayoutSizes(NSWindow *w, NSSize *min, NSSize *max)
|
||||||
|
|
||||||
// minimum: encourage the window to be as small as possible
|
// minimum: encourage the window to be as small as possible
|
||||||
contentView = [w contentView];
|
contentView = [w contentView];
|
||||||
cw = mkConstraint(contentView, NSLayoutAttributeWidth,
|
cw = uiprivMkConstraint(contentView, NSLayoutAttributeWidth,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
nil, NSLayoutAttributeNotAnAttribute,
|
nil, NSLayoutAttributeNotAnAttribute,
|
||||||
0, 0,
|
0, 0,
|
||||||
@"window minimum width finding constraint");
|
@"window minimum width finding constraint");
|
||||||
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
||||||
[contentView addConstraint:cw];
|
[contentView addConstraint:cw];
|
||||||
ch = mkConstraint(contentView, NSLayoutAttributeHeight,
|
ch = uiprivMkConstraint(contentView, NSLayoutAttributeHeight,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
nil, NSLayoutAttributeNotAnAttribute,
|
nil, NSLayoutAttributeNotAnAttribute,
|
||||||
0, 0,
|
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
|
// maximum: encourage the window to be as large as possible
|
||||||
contentView = [w contentView];
|
contentView = [w contentView];
|
||||||
cw = mkConstraint(contentView, NSLayoutAttributeWidth,
|
cw = uiprivMkConstraint(contentView, NSLayoutAttributeWidth,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
nil, NSLayoutAttributeNotAnAttribute,
|
nil, NSLayoutAttributeNotAnAttribute,
|
||||||
0, CGFLOAT_MAX,
|
0, CGFLOAT_MAX,
|
||||||
@"window maximum width finding constraint");
|
@"window maximum width finding constraint");
|
||||||
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
||||||
[contentView addConstraint:cw];
|
[contentView addConstraint:cw];
|
||||||
ch = mkConstraint(contentView, NSLayoutAttributeHeight,
|
ch = uiprivMkConstraint(contentView, NSLayoutAttributeHeight,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
nil, NSLayoutAttributeNotAnAttribute,
|
nil, NSLayoutAttributeNotAnAttribute,
|
||||||
0, CGFLOAT_MAX,
|
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?
|
// 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;
|
__block struct onResizeDragParams rdp;
|
||||||
struct nextEventArgs nea;
|
uiprivNextEventArgs nea;
|
||||||
BOOL (^handleEvent)(NSEvent *e);
|
BOOL (^handleEvent)(NSEvent *e);
|
||||||
__block BOOL done;
|
__block BOOL done;
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ void doManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge)
|
||||||
return YES; // do not send
|
return YES; // do not send
|
||||||
};
|
};
|
||||||
done = NO;
|
done = NO;
|
||||||
while (mainStep(&nea, handleEvent))
|
while (uiprivMainStep(&nea, handleEvent))
|
||||||
if (done)
|
if (done)
|
||||||
break;
|
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