2015-08-16 21:46:18 -05:00
|
|
|
// 6 january 2015
|
2016-05-28 12:06:16 -05:00
|
|
|
#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
|
2015-08-16 21:46:18 -05:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import "../ui.h"
|
|
|
|
#import "../ui_darwin.h"
|
2015-10-16 17:31:14 -05:00
|
|
|
#import "../common/uipriv.h"
|
2015-08-16 21:46:18 -05:00
|
|
|
|
2016-01-02 08:22:24 -06:00
|
|
|
#if __has_feature(objc_arc)
|
|
|
|
#error Sorry, libui cannot be compiled with ARC.
|
|
|
|
#endif
|
|
|
|
|
2015-08-16 21:46:18 -05:00
|
|
|
#define toNSString(str) [NSString stringWithUTF8String:(str)]
|
|
|
|
#define fromNSString(str) [(str) UTF8String]
|
|
|
|
|
2016-05-30 07:06:25 -05:00
|
|
|
#ifndef NSAppKitVersionNumber10_9
|
|
|
|
#define NSAppKitVersionNumber10_9 1265
|
|
|
|
#endif
|
|
|
|
|
2016-12-01 12:26:59 -06:00
|
|
|
/*TODO remove this*/typedef struct uiImage uiImage;
|
2016-12-01 10:32:14 -06:00
|
|
|
|
2015-08-16 21:46:18 -05:00
|
|
|
// menu.m
|
|
|
|
@interface menuManager : NSObject {
|
2016-01-07 13:41:20 -06:00
|
|
|
struct mapTable *items;
|
2015-08-16 21:46:18 -05:00
|
|
|
BOOL hasQuit;
|
|
|
|
BOOL hasPreferences;
|
|
|
|
BOOL hasAbout;
|
|
|
|
}
|
|
|
|
@property (strong) NSMenuItem *quitItem;
|
|
|
|
@property (strong) NSMenuItem *preferencesItem;
|
|
|
|
@property (strong) NSMenuItem *aboutItem;
|
|
|
|
// NSMenuValidation is only informal
|
|
|
|
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
|
|
|
- (NSMenu *)makeMenubar;
|
|
|
|
@end
|
|
|
|
extern void finalizeMenus(void);
|
|
|
|
extern void uninitMenus(void);
|
|
|
|
|
2016-10-27 22:32:33 -05:00
|
|
|
// main.m
|
2015-08-16 21:46:18 -05:00
|
|
|
@interface applicationClass : NSApplication
|
|
|
|
@end
|
|
|
|
// this is needed because NSApp is of type id, confusing clang
|
|
|
|
#define realNSApp() ((applicationClass *) NSApp)
|
|
|
|
@interface appDelegate : NSObject <NSApplicationDelegate>
|
|
|
|
@property (strong) menuManager *menuManager;
|
|
|
|
@end
|
|
|
|
#define appDelegate() ((appDelegate *) [realNSApp() delegate])
|
2016-10-31 13:33:11 -05:00
|
|
|
struct nextEventArgs {
|
|
|
|
NSEventMask mask;
|
|
|
|
NSDate *duration;
|
|
|
|
// LONGTERM no NSRunLoopMode?
|
|
|
|
NSString *mode;
|
|
|
|
BOOL dequeue;
|
|
|
|
};
|
|
|
|
extern int mainStep(struct nextEventArgs *nea, BOOL (^interceptEvent)(NSEvent *));
|
2015-08-16 21:46:18 -05:00
|
|
|
|
|
|
|
// util.m
|
|
|
|
extern void disableAutocorrect(NSTextView *);
|
|
|
|
|
|
|
|
// entry.m
|
2015-08-16 22:44:23 -05:00
|
|
|
extern void finishNewTextField(NSTextField *, BOOL);
|
2015-08-21 19:14:50 -05:00
|
|
|
extern NSTextField *newEditableTextField(void);
|
2015-08-16 21:46:18 -05:00
|
|
|
|
|
|
|
// window.m
|
2016-10-26 00:15:01 -05:00
|
|
|
@interface libuiNSWindow : NSWindow
|
|
|
|
- (void)libui_doMove:(NSEvent *)initialEvent;
|
|
|
|
- (void)libui_doResize:(NSEvent *)initialEvent on:(uiWindowResizeEdge)edge;
|
|
|
|
@end
|
2015-08-16 21:46:18 -05:00
|
|
|
extern uiWindow *windowFromNSWindow(NSWindow *);
|
|
|
|
|
|
|
|
// alloc.m
|
2015-08-17 11:57:45 -05:00
|
|
|
extern NSMutableArray *delegates;
|
2015-08-16 21:46:18 -05:00
|
|
|
extern void initAlloc(void);
|
|
|
|
extern void uninitAlloc(void);
|
|
|
|
|
2015-08-16 22:08:00 -05:00
|
|
|
// autolayout.m
|
2016-04-30 16:14:14 -05:00
|
|
|
extern NSLayoutConstraint *mkConstraint(id view1, NSLayoutAttribute attr1, NSLayoutRelation relation, id view2, NSLayoutAttribute attr2, CGFloat multiplier, CGFloat c, NSString *desc);
|
2016-05-12 19:18:22 -05:00
|
|
|
extern void jiggleViewLayout(NSView *view);
|
2016-05-11 17:06:29 -05:00
|
|
|
struct singleChildConstraints {
|
|
|
|
NSLayoutConstraint *leadingConstraint;
|
|
|
|
NSLayoutConstraint *topConstraint;
|
2016-05-13 12:08:00 -05:00
|
|
|
NSLayoutConstraint *trailingConstraintGreater;
|
|
|
|
NSLayoutConstraint *trailingConstraintEqual;
|
|
|
|
NSLayoutConstraint *bottomConstraintGreater;
|
|
|
|
NSLayoutConstraint *bottomConstraintEqual;
|
2016-05-11 17:06:29 -05:00
|
|
|
};
|
|
|
|
extern void singleChildConstraintsEstablish(struct singleChildConstraints *c, NSView *contentView, NSView *childView, BOOL hugsTrailing, BOOL hugsBottom, int margined, NSString *desc);
|
|
|
|
extern void singleChildConstraintsRemove(struct singleChildConstraints *c, NSView *cv);
|
|
|
|
extern void singleChildConstraintsSetMargined(struct singleChildConstraints *c, int margined);
|
2015-08-16 21:46:18 -05:00
|
|
|
|
2015-08-17 00:03:53 -05:00
|
|
|
// map.m
|
2016-01-07 13:41:20 -06:00
|
|
|
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);
|
2016-05-23 23:41:52 -05:00
|
|
|
extern void mapWalk(struct mapTable *m, void (*f)(void *key, void *value));
|
|
|
|
extern void mapReset(struct mapTable *m);
|
2015-10-09 11:33:45 -05:00
|
|
|
|
|
|
|
// area.m
|
|
|
|
extern int sendAreaEvents(NSEvent *);
|
|
|
|
|
|
|
|
// areaevents.m
|
|
|
|
extern BOOL fromKeycode(unsigned short keycode, uiAreaKeyEvent *ke);
|
|
|
|
extern BOOL keycodeModifier(unsigned short keycode, uiModifiers *mod);
|
|
|
|
|
|
|
|
// draw.m
|
2016-01-08 12:51:39 -06:00
|
|
|
extern uiDrawContext *newContext(CGContextRef, CGFloat);
|
2015-10-09 11:33:45 -05:00
|
|
|
extern void freeContext(uiDrawContext *);
|
2016-01-12 00:12:35 -06:00
|
|
|
|
2016-04-14 13:01:33 -05:00
|
|
|
// fontbutton.m
|
|
|
|
extern BOOL fontButtonInhibitSendAction(SEL sel, id from, id to);
|
|
|
|
extern BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override);
|
2016-05-15 18:56:01 -05:00
|
|
|
extern void setupFontPanel(void);
|
2016-05-15 19:51:33 -05:00
|
|
|
|
|
|
|
// colorbutton.m
|
|
|
|
extern BOOL colorButtonInhibitSendAction(SEL sel, id from, id to);
|
2016-05-27 22:42:05 -05:00
|
|
|
|
|
|
|
// scrollview.m
|
|
|
|
struct scrollViewCreateParams {
|
|
|
|
NSView *DocumentView;
|
|
|
|
NSColor *BackgroundColor;
|
|
|
|
BOOL DrawsBackground;
|
|
|
|
BOOL Bordered;
|
|
|
|
BOOL HScroll;
|
|
|
|
BOOL VScroll;
|
|
|
|
};
|
2016-05-27 22:56:44 -05:00
|
|
|
struct scrollViewData;
|
2016-05-27 22:42:05 -05:00
|
|
|
extern NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewData **dout);
|
|
|
|
extern void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hscroll, BOOL vscroll);
|
|
|
|
extern void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d);
|
2016-06-07 10:29:49 -05:00
|
|
|
|
2016-06-25 18:18:25 -05:00
|
|
|
// label.m
|
2016-06-07 10:29:49 -05:00
|
|
|
extern NSTextField *newLabel(NSString *str);
|
2016-06-25 18:18:25 -05:00
|
|
|
|
|
|
|
// image.m
|
|
|
|
extern NSImage *imageImage(uiImage *);
|
2016-11-01 10:58:01 -05:00
|
|
|
|
|
|
|
// winmoveresize.m
|
2016-11-02 08:29:44 -05:00
|
|
|
extern void doManualMove(NSWindow *w, NSEvent *initialEvent);
|
2016-11-01 10:58:01 -05:00
|
|
|
extern void doManualResize(NSWindow *w, NSEvent *initialEvent, uiWindowResizeEdge edge);
|
2017-01-03 22:59:23 -06:00
|
|
|
|
|
|
|
// fontmatch.m
|
2017-01-24 16:12:17 -06:00
|
|
|
extern CTFontDescriptorRef fontdescToCTFontDescriptor(uiDrawFontDescriptor *fd);
|
2017-02-24 11:12:03 -06:00
|
|
|
extern CTFontDescriptorRef fontdescAppendFeatures(CTFontDescriptorRef desc, const uint16_t *types, const uint16_t *selectors, size_t n);
|
2017-02-10 23:53:52 -06:00
|
|
|
extern void fontdescFromCTFontDescriptor(CTFontDescriptorRef ctdesc, uiDrawFontDescriptor *uidesc);
|
2017-02-12 00:05:27 -06:00
|
|
|
|
|
|
|
// attrstr.m
|
2017-02-14 13:57:56 -06:00
|
|
|
extern void initUnderlineColors(void);
|
|
|
|
extern void uninitUnderlineColors(void);
|
2017-02-13 01:10:39 -06:00
|
|
|
typedef void (^backgroundBlock)(uiDrawContext *c, uiDrawTextLayout *layout, double x, double y);
|
|
|
|
extern CFAttributedStringRef attrstrToCoreFoundation(uiDrawTextLayoutParams *p, NSArray **backgroundBlocks);
|
2017-02-15 22:10:23 -06:00
|
|
|
|
|
|
|
// aat.m
|
|
|
|
typedef void (*specToAATEnumFunc)(uint16_t type, uint16_t selector, void *data);
|
|
|
|
extern int specToAAT(uiAttributeSpec *spec, specToAATEnumFunc f, void *data);
|