diff --git ipe/Makefile ipe/Makefile
index 06e07ed..6ab7658 100644
|
|
ifdef IPEUI_COCOA |
51 | 51 | nib = $(RESOURCEDIR)/mainmenu.nib |
52 | 52 | |
53 | 53 | $(nib): mainmenu.xib |
| 54 | $(INSTALL_DIR) $(RESOURCEDIR) |
54 | 55 | ibtool --compile $(nib) mainmenu.xib |
55 | 56 | |
56 | 57 | else |
diff --git ipe/appui_cocoa.cpp ipe/appui_cocoa.cpp
index a26f7b8..6f7ecad 100644
|
|
static NSImage *loadIcon(String action) |
339 | 339 | return t; |
340 | 340 | } |
341 | 341 | |
342 | | - (NSArray<NSString *> *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar |
| 342 | - (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar |
343 | 343 | { |
344 | 344 | return @[ @"copy", @"cut", @"paste", @"delete", @"undo", @"redo", |
345 | 345 | @"zoom_in", @"zoom_out", @"fit_objects", @"fit_page", |
… |
… |
static NSImage *loadIcon(String action) |
357 | 357 | ]; |
358 | 358 | } |
359 | 359 | |
360 | | - (NSArray<NSString *> *) toolbarDefaultItemIdentifiers:(NSToolbar *) toolbar |
| 360 | - (NSArray *) toolbarDefaultItemIdentifiers:(NSToolbar *) toolbar |
361 | 361 | { |
362 | 362 | return @[ @"mode_select", @"mode_translate", @"mode_rotate", |
363 | 363 | @"mode_stretch", @"mode_pan", @"mode_shredder", |
… |
… |
AppUi::AppUi(lua_State *L0, int model) |
585 | 585 | iLayerBox = [[NSBox alloc] initWithFrame:subRect]; |
586 | 586 | iLayerBox.title = @"Layers"; |
587 | 587 | |
588 | | NSRect layerFrame = iLayerBox.contentView.frame; |
| 588 | NSRect layerFrame = [iLayerBox.contentView frame]; |
589 | 589 | iLayerView = [[IpeLayerView alloc] initWithFrame:layerFrame]; |
590 | 590 | iLayerView.delegate = iDelegate; |
591 | 591 | iLayerView.toolTip = @"Layers of this page"; |
… |
… |
void AppUi::setCheckMark(String name, String value) |
921 | 921 | NSString *prefix = I2N(name); |
922 | 922 | for (NSString *action in iActions) { |
923 | 923 | if ([action hasPrefix:prefix]) |
924 | | iActions[action].state = NO; |
| 924 | ((IpeAction *)iActions[action]).state = NO; |
925 | 925 | } |
926 | | iActions[I2N(name + value)].state = YES; |
| 926 | ((IpeAction *)iActions[I2N(name + value)]).state = YES; |
927 | 927 | } |
928 | 928 | |
929 | 929 | void AppUi::setLayers(const Page *page, int view) |
… |
… |
void AppUi::setNumbers(String vno, bool vm, String pno, bool pm) |
955 | 955 | BOOL AppUi::validateMenuItem(NSMenuItem *item, NSString *name) |
956 | 956 | { |
957 | 957 | if ([name isEqualToString:@"snapbar"]) { |
958 | | item.title = iSnapBar.hidden ? @"Show Snap Toolbar" : |
| 958 | item.title = [iSnapBar isHidden] ? @"Show Snap Toolbar" : |
959 | 959 | @"Hide Snap Toolbar"; |
960 | 960 | return YES; |
961 | 961 | } |
962 | 962 | IpeAction *s = findAction(name); |
963 | 963 | if (s) { |
964 | 964 | if ([name isEqualToString:@"toggle_notes"]) |
965 | | s.state = (iNotesPanel && iNotesPanel.visible); |
| 965 | s.state = (iNotesPanel && [iNotesPanel isVisible]); |
966 | 966 | else if ([name isEqualToString:@"toggle_bookmarks"]) |
967 | | s.state = (iBookmarksPanel && iBookmarksPanel.visible); |
| 967 | s.state = (iBookmarksPanel && [iBookmarksPanel isVisible]); |
968 | 968 | [item setState:(s.state ? NSOnState : NSOffState)]; |
969 | 969 | return actionsEnabled() || s.alwaysOn; |
970 | 970 | } |
… |
… |
void AppUi::fillDynamicSubmenu(NSMenuItem *item) |
1024 | 1024 | |
1025 | 1025 | void AppUi::toggleSnapbarShown() |
1026 | 1026 | { |
1027 | | iSnapBar.hidden = !iSnapBar.hidden; |
1028 | | if (iSnapBar.hidden) { |
| 1027 | iSnapBar.hidden = ![iSnapBar isHidden]; |
| 1028 | if ([iSnapBar isHidden]) { |
1029 | 1029 | activateConstraint(iViewToSnapBar, NO); |
1030 | 1030 | activateConstraint(iViewToTop, YES); |
1031 | 1031 | } else { |
diff --git ipe/appui_cocoa.h ipe/appui_cocoa.h
index 4305b86..fa25320 100644
|
|
private: |
112 | 112 | virtual void setButtonColor(int sel, Color color) override; |
113 | 113 | |
114 | 114 | private: |
115 | | NSMutableDictionary <NSString *, IpeAction *> *iActions; |
| 115 | NSMutableDictionary *iActions; // <NSString *, IpeAction *> |
116 | 116 | bool iActionsEnabled; |
117 | 117 | bool iInUiUpdate; |
118 | 118 | NSWindow *iWindow; |
diff --git ipe/controls_cocoa.cpp ipe/controls_cocoa.cpp
index d6d079c..1d1c582 100644
|
|
extern CGContextRef ipeGetCGContext(); |
229 | 229 | |
230 | 230 | @implementation IpeLayerView { |
231 | 231 | NSTableView *iTV; |
232 | | NSMutableArray <IpeLayerItem *> *iLayers; |
| 232 | NSMutableArray *iLayers; // <IpeLayerItem *> |
233 | 233 | } |
234 | 234 | |
235 | 235 | - (instancetype) initWithFrame:(NSRect) rect |
… |
… |
extern CGContextRef ipeGetCGContext(); |
283 | 283 | - (void) ipeLayerToggled:(id) sender |
284 | 284 | { |
285 | 285 | int row = [sender tag]; |
286 | | if (iLayers[row].checked) |
287 | | [self.delegate layerAction:@"selectoff" forLayer:iLayers[row].name]; |
| 286 | if (((IpeLayerItem *)iLayers[row]).checked) |
| 287 | [self.delegate layerAction:@"selectoff" forLayer:((IpeLayerItem *)iLayers[row]).name]; |
288 | 288 | else |
289 | | [self.delegate layerAction:@"selecton" forLayer:iLayers[row].name]; |
| 289 | [self.delegate layerAction:@"selecton" forLayer:((IpeLayerItem *)iLayers[row]).name]; |
290 | 290 | } |
291 | 291 | |
292 | 292 | - (void) ipeLayerClicked:(int) row |
293 | 293 | { |
294 | | [self.delegate layerAction:@"active" forLayer:iLayers[row].name]; |
| 294 | [self.delegate layerAction:@"active" forLayer:((IpeLayerItem *)iLayers[row]).name]; |
295 | 295 | } |
296 | 296 | |
297 | 297 | - (void) ipeLayerMenuAt:(NSPoint) p forRow:(int) row |
298 | 298 | { |
299 | | [self.delegate layerMenuAt:p forLayer:iLayers[row].name]; |
| 299 | [self.delegate layerMenuAt:p forLayer:((IpeLayerItem *)iLayers[row]).name]; |
300 | 300 | } |
301 | 301 | |
302 | 302 | - (NSInteger) numberOfRowsInTableView:(NSTableView *) tv |
… |
… |
objectValueForTableColumn:(NSTableColumn *) col |
309 | 309 | row:(NSInteger)row |
310 | 310 | { |
311 | 311 | if ([[col identifier] isEqualToString:@"checks"]) |
312 | | return [NSNumber numberWithBool:iLayers[row].checked]; |
| 312 | return [NSNumber numberWithBool:((IpeLayerItem *)iLayers[row]).checked]; |
313 | 313 | else |
314 | | return iLayers[row].name; |
| 314 | return ((IpeLayerItem *)iLayers[row]).name; |
315 | 315 | } |
316 | 316 | |
317 | 317 | - (NSView *) tableView:(NSTableView *) tv |
… |
… |
objectValueForTableColumn:(NSTableColumn *) col |
328 | 328 | [result setAction:@selector(ipeLayerToggled:)]; |
329 | 329 | [result setTarget:self]; |
330 | 330 | [result setTag:row]; |
331 | | [result setState:iLayers[row].checked]; |
| 331 | [result setState:((IpeLayerItem *)iLayers[row]).checked]; |
332 | 332 | return result; |
333 | 333 | } else { |
334 | 334 | IpeLayerField *result = [tv makeViewWithIdentifier:@"LayerName" owner:self]; |
… |
… |
objectValueForTableColumn:(NSTableColumn *) col |
349 | 349 | |
350 | 350 | @implementation IpeBookmarksView { |
351 | 351 | NSTableView *iTV; |
352 | | NSMutableArray <NSString *> *iBookmarks; |
| 352 | NSMutableArray *iBookmarks; // <NSString *> |
353 | 353 | } |
354 | 354 | |
355 | 355 | - (instancetype) initWithFrame:(NSRect) rect |
diff --git ipe/main_cocoa.cpp ipe/main_cocoa.cpp
index 132eaaa..4e00495 100644
|
|
static void setup_globals(lua_State *L) |
72 | 72 | IPELIB_VERSION % 100); |
73 | 73 | lua_setfield(L, -2, "version"); |
74 | 74 | |
75 | | NSArray <NSString *> *args = [[NSProcessInfo processInfo] arguments]; |
| 75 | NSArray *args = [[NSProcessInfo processInfo] arguments]; |
76 | 76 | int argc = [args count]; |
77 | 77 | lua_createtable(L, 0, argc - 1); |
78 | 78 | for (int i = 1; i < argc; ++i) { |
diff --git ipe/pagesorter_cocoa.cpp ipe/pagesorter_cocoa.cpp
index 3cb7500..4cbe980 100644
|
|
extern NSSize thumbnail_size; // in ipeselector_cocoa.cpp |
131 | 131 | @interface IpePageSorterDelegate : NSObject <NSWindowDelegate, |
132 | 132 | NSCollectionViewDelegate> |
133 | 133 | |
134 | | @property NSMutableArray <IpeSelectorItem *> *pages; |
| 134 | @property NSMutableArray *pages; // <IpeSelectorItem *> |
135 | 135 | @property (assign) NSCollectionView *cv; |
136 | 136 | |
137 | 137 | - (void) ipeAccept; |
… |
… |
int AppUi::pageSorter(lua_State *L, Document *doc, |
249 | 249 | } |
250 | 250 | |
251 | 251 | NSScrollView *scroll = |
252 | | [[NSScrollView alloc] initWithFrame:panel.contentView.frame]; |
| 252 | [[NSScrollView alloc] initWithFrame:[panel.contentView frame]]; |
253 | 253 | scroll.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable; |
254 | 254 | scroll.hasVerticalScroller = YES; |
255 | 255 | |
… |
… |
int AppUi::pageSorter(lua_State *L, Document *doc, |
326 | 326 | int n = [delegate.pages count]; |
327 | 327 | lua_createtable(L, n, 0); |
328 | 328 | for (int i = 1; i <= n; ++i) { |
329 | | lua_pushinteger(L, delegate.pages[i-1].index + 1); |
| 329 | lua_pushinteger(L, ((IpeSelectorItem *)delegate.pages[i-1]).index + 1); |
330 | 330 | lua_rawseti(L, -2, i); |
331 | 331 | } |
332 | 332 | return 1; |
diff --git ipecanvas/ipecanvas_cocoa.cpp ipecanvas/ipecanvas_cocoa.cpp
index 2af4ca7..966a12b 100644
|
|
static CGContextRef gc_graphics_port() |
45 | 45 | |
46 | 46 | static CGContextRef gc_cgcontext() |
47 | 47 | { |
| 48 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
48 | 49 | return [[NSGraphicsContext currentContext] CGContext]; |
| 50 | #else |
| 51 | return nil; |
| 52 | #endif |
49 | 53 | } |
50 | 54 | |
51 | 55 | CGContextRef ipeGetCGContext() |
52 | 56 | { |
| 57 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
53 | 58 | if ([NSGraphicsContext instancesRespondToSelector:@selector(CGContext)]) |
54 | | return gc_cgcontext(); |
55 | | else |
56 | | return gc_graphics_port(); |
| 59 | return [[NSGraphicsContext currentContext] CGContext]; |
| 60 | #endif |
| 61 | return (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; |
57 | 62 | } |
58 | 63 | |
59 | 64 | // -------------------------------------------------------------------- |
… |
… |
Canvas::Canvas(IpeCanvasView *view) |
63 | 68 | iView = view; |
64 | 69 | iLayer = NULL; |
65 | 70 | |
| 71 | iGCGetter = gc_graphics_port; |
| 72 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
66 | 73 | if ([NSGraphicsContext instancesRespondToSelector:@selector(CGContext)]) |
67 | 74 | iGCGetter = gc_cgcontext; |
68 | | else |
69 | | iGCGetter = gc_graphics_port; |
| 75 | #endif |
70 | 76 | } |
71 | 77 | |
72 | 78 | Canvas::~Canvas() |
diff --git ipecanvas/ipeselector_cocoa.cpp ipecanvas/ipeselector_cocoa.cpp
index 9a5129b..7b2891d 100644
|
|
int CanvasBase::selectPageOrView(Document *doc, int page, int startIndex, |
241 | 241 | } |
242 | 242 | |
243 | 243 | NSScrollView *scroll = |
244 | | [[NSScrollView alloc] initWithFrame:panel.contentView.frame]; |
| 244 | [[NSScrollView alloc] initWithFrame:[panel.contentView frame]]; |
245 | 245 | scroll.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable; |
246 | 246 | scroll.hasVerticalScroller = YES; |
247 | 247 | panel.contentView = scroll; |
diff --git ipeui/ipeui_cocoa.cpp ipeui/ipeui_cocoa.cpp
index 4ac1035..7918ca6 100644
|
|
inline NSString *C2N(const char *s) {return [NSString stringWithUTF8String:s];} |
52 | 52 | |
53 | 53 | CGContextRef ipeGetCGContext() |
54 | 54 | { |
| 55 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
55 | 56 | if ([NSGraphicsContext instancesRespondToSelector:@selector(CGContext)]) |
56 | 57 | return [[NSGraphicsContext currentContext] CGContext]; |
57 | | else |
58 | | return (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; |
| 58 | #endif |
| 59 | return (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; |
59 | 60 | } |
60 | 61 | |
61 | 62 | // -------------------------------------------------------------------- |
… |
… |
void addToLayout(NSView *view, NSView *subview) |
83 | 84 | |
84 | 85 | id layoutGuide(NSView *owner) |
85 | 86 | { |
| 87 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 |
86 | 88 | if ([owner respondsToSelector:@selector(addLayoutGuide:)]) { |
87 | 89 | #pragma clang diagnostic push |
88 | 90 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
… |
… |
id layoutGuide(NSView *owner) |
90 | 92 | [owner addLayoutGuide:g]; |
91 | 93 | #pragma clang diagnostic pop |
92 | 94 | return g; |
93 | | } else { |
94 | | NSView *g = [[NSView alloc] initWithFrame:NSZeroRect]; |
95 | | addToLayout(owner, g); |
96 | | return g; |
97 | 95 | } |
| 96 | #endif |
| 97 | NSView *g = [[NSView alloc] initWithFrame:NSZeroRect]; |
| 98 | addToLayout(owner, g); |
| 99 | return g; |
98 | 100 | } |
99 | 101 | |
100 | 102 | static NSLayoutAttribute layoutAttribute(char ch) |
… |
… |
static NSView *owner(id a) |
138 | 140 | { |
139 | 141 | if ([a respondsToSelector:@selector(superview)]) |
140 | 142 | return [a superview]; |
| 143 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 |
141 | 144 | if ([a respondsToSelector:@selector(owningView)]) |
142 | 145 | return [a owningView]; // is a layout guide |
| 146 | #endif |
143 | 147 | return nil; |
144 | 148 | } |
145 | 149 | |
146 | 150 | void activateConstraint(NSLayoutConstraint *c, BOOL active) |
147 | 151 | { |
| 152 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 |
148 | 153 | if ([c respondsToSelector:@selector(setActive:)]) { |
149 | 154 | #pragma clang diagnostic push |
150 | 155 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
151 | 156 | c.active = active; |
| 157 | return; |
152 | 158 | #pragma clang diagnostic pop |
153 | | } else { |
154 | | // need to figure out lowest common ancestor |
155 | | id a = c.firstItem; |
156 | | id b = c.secondItem; |
157 | | NSView *lca = nil; |
158 | | NSView *ao = owner(a); |
159 | | NSView *bo = owner(b); |
160 | | if (b == nil) |
161 | | lca = a; |
162 | | else if (ao == b) |
163 | | lca = b; |
164 | | else if (bo == a) |
165 | | lca = a; |
166 | | else { |
167 | | assert(ao == bo); |
168 | | lca = ao; |
169 | | } |
170 | | if (active) |
171 | | [lca addConstraint:c]; |
172 | | else |
173 | | [lca removeConstraint:c]; |
174 | 159 | } |
| 160 | #endif |
| 161 | // need to figure out lowest common ancestor |
| 162 | id a = c.firstItem; |
| 163 | id b = c.secondItem; |
| 164 | NSView *lca = nil; |
| 165 | NSView *ao = owner(a); |
| 166 | NSView *bo = owner(b); |
| 167 | if (b == nil) |
| 168 | lca = a; |
| 169 | else if (ao == b) |
| 170 | lca = b; |
| 171 | else if (bo == a) |
| 172 | lca = a; |
| 173 | else { |
| 174 | assert(ao == bo); |
| 175 | lca = ao; |
| 176 | } |
| 177 | if (active) |
| 178 | [lca addConstraint:c]; |
| 179 | else |
| 180 | [lca removeConstraint:c]; |
175 | 181 | } |
176 | 182 | |
177 | 183 | NSLayoutConstraint *layout(id a, id b, const char *rel, double gap, |
… |
… |
private: |
253 | 259 | private: |
254 | 260 | NSPanel *iPanel; |
255 | 261 | IpeDialogDelegate *iDelegate; |
256 | | NSMutableArray <NSView *> *iViews; |
| 262 | NSMutableArray *iViews; // <NSView *> |
257 | 263 | }; |
258 | 264 | |
259 | 265 | // -------------------------------------------------------------------- |