comparison mac/dw.m @ 2293:af6beae5228c

Mac: Fix building on Leopard 10.5.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 07 Feb 2021 10:07:02 +0000
parents 3361ce6070ce
children 19242334712f
comparison
equal deleted inserted replaced
2292:fa19fce045aa 2293:af6beae5228c
19 #include <sys/stat.h> 19 #include <sys/stat.h>
20 #include <math.h> 20 #include <math.h>
21 21
22 /* Create a define to let us know to include Snow Leopard specific features */ 22 /* Create a define to let us know to include Snow Leopard specific features */
23 #if defined(MAC_OS_X_VERSION_10_6) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED)) 23 #if defined(MAC_OS_X_VERSION_10_6) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED))
24 #define DWPasteboardTypeString NSPasteboardTypeString
24 #define BUILDING_FOR_SNOW_LEOPARD 25 #define BUILDING_FOR_SNOW_LEOPARD
26 #else
27 #define DWPasteboardTypeString NSStringPboardType
25 #endif 28 #endif
26 29
27 /* Create a define to let us know to include Lion specific features */ 30 /* Create a define to let us know to include Lion specific features */
28 #if defined(MAC_OS_X_VERSION_10_7) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED)) 31 #if defined(MAC_OS_X_VERSION_10_7) && ((defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) || !defined(MAC_OS_X_VERSION_MAX_ALLOWED))
29 #define BUILDING_FOR_LION 32 #define BUILDING_FOR_LION
4543 * be converted to text. 4546 * be converted to text.
4544 */ 4547 */
4545 char *dw_clipboard_get_text() 4548 char *dw_clipboard_get_text()
4546 { 4549 {
4547 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; 4550 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
4548 NSString *str = [pasteboard stringForType:NSPasteboardTypeString]; 4551 NSString *str = [pasteboard stringForType:DWPasteboardTypeString];
4549 if(str != nil) 4552 if(str != nil)
4550 { 4553 {
4551 return strdup([ str UTF8String ]); 4554 return strdup([ str UTF8String ]);
4552 } 4555 }
4553 return NULL; 4556 return NULL;
4567 { 4570 {
4568 DWIMP icc = (DWIMP)[pasteboard methodForSelector:scc]; 4571 DWIMP icc = (DWIMP)[pasteboard methodForSelector:scc];
4569 icc(pasteboard, scc); 4572 icc(pasteboard, scc);
4570 } 4573 }
4571 4574
4572 [pasteboard setString:[ NSString stringWithUTF8String:str ] forType:NSPasteboardTypeString]; 4575 [pasteboard setString:[ NSString stringWithUTF8String:str ] forType:DWPasteboardTypeString];
4573 } 4576 }
4574 4577
4575 4578
4576 /* 4579 /*
4577 * Allocates and initializes a dialog struct. 4580 * Allocates and initializes a dialog struct.
6316 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; 6319 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
6317 [scrollview setDocumentView:mle]; 6320 [scrollview setDocumentView:mle];
6318 [mle setVerticallyResizable:YES]; 6321 [mle setVerticallyResizable:YES];
6319 [mle setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; 6322 [mle setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
6320 [mle setScrollview:scrollview]; 6323 [mle setScrollview:scrollview];
6324 #ifdef BUILDING_FOR_SNOW_LEOPARD
6321 [mle setAutomaticQuoteSubstitutionEnabled:NO]; 6325 [mle setAutomaticQuoteSubstitutionEnabled:NO];
6322 [mle setAutomaticDashSubstitutionEnabled:NO]; 6326 [mle setAutomaticDashSubstitutionEnabled:NO];
6323 [mle setAutomaticTextReplacementEnabled:NO]; 6327 [mle setAutomaticTextReplacementEnabled:NO];
6328 #endif
6324 /* [mle setTag:cid]; Why doesn't this work? */ 6329 /* [mle setTag:cid]; Why doesn't this work? */
6325 [mle autorelease]; 6330 [mle autorelease];
6326 return mle; 6331 return mle;
6327 } 6332 }
6328 6333
6344 NSTextStorage *ts = [mle textStorage]; 6349 NSTextStorage *ts = [mle textStorage];
6345 NSString *nstr = [NSString stringWithUTF8String:buffer]; 6350 NSString *nstr = [NSString stringWithUTF8String:buffer];
6346 NSColor *fgcolor = [ts foregroundColor]; 6351 NSColor *fgcolor = [ts foregroundColor];
6347 NSFont *font = [ts font]; 6352 NSFont *font = [ts font];
6348 NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; 6353 NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
6349 [attributes setObject:(fgcolor ? fgcolor : NSColor.textColor) forKey:NSForegroundColorAttributeName]; 6354 [attributes setObject:(fgcolor ? fgcolor : [NSColor textColor]) forKey:NSForegroundColorAttributeName];
6350 if(font) 6355 if(font)
6351 [attributes setObject:font forKey:NSFontAttributeName]; 6356 [attributes setObject:font forKey:NSFontAttributeName];
6352 NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes]; 6357 NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes];
6353 NSUInteger length = [ts length]; 6358 NSUInteger length = [ts length];
6354 if(startpoint < 0) 6359 if(startpoint < 0)
6542 * handle: Handle to the MLE. 6547 * handle: Handle to the MLE.
6543 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE 6548 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
6544 */ 6549 */
6545 void API dw_mle_set_auto_complete(HWND handle, int state) 6550 void API dw_mle_set_auto_complete(HWND handle, int state)
6546 { 6551 {
6552 #ifdef BUILDING_FOR_SNOW_LEOPARD
6547 DWMLE *mle = handle; 6553 DWMLE *mle = handle;
6548 [mle setAutomaticQuoteSubstitutionEnabled:(state & DW_MLE_COMPLETE_QUOTE ? YES : NO)]; 6554 [mle setAutomaticQuoteSubstitutionEnabled:(state & DW_MLE_COMPLETE_QUOTE ? YES : NO)];
6549 [mle setAutomaticDashSubstitutionEnabled:(state & DW_MLE_COMPLETE_DASH ? YES : NO)]; 6555 [mle setAutomaticDashSubstitutionEnabled:(state & DW_MLE_COMPLETE_DASH ? YES : NO)];
6550 [mle setAutomaticTextReplacementEnabled:(state & DW_MLE_COMPLETE_TEXT ? YES : NO)]; 6556 [mle setAutomaticTextReplacementEnabled:(state & DW_MLE_COMPLETE_TEXT ? YES : NO)];
6557 #endif
6551 } 6558 }
6552 6559
6553 /* 6560 /*
6554 * Sets the current cursor position of an MLE box. 6561 * Sets the current cursor position of an MLE box.
6555 * Parameters: 6562 * Parameters:
7442 } 7449 }
7443 if(icon) 7450 if(icon)
7444 { 7451 {
7445 [array replaceObjectAtIndex:0 withObject:icon]; 7452 [array replaceObjectAtIndex:0 withObject:icon];
7446 } 7453 }
7454 #ifdef BUILDING_FOR_SNOW_LEOPARD
7447 NSInteger row = [tree rowForItem:item]; 7455 NSInteger row = [tree rowForItem:item];
7448 [tree reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:row] 7456 [tree reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:row]
7449 columnIndexes:[NSIndexSet indexSetWithIndex:0]]; 7457 columnIndexes:[NSIndexSet indexSetWithIndex:0]];
7458 #else
7459 [tree reloadData];
7460 #endif
7450 DW_LOCAL_POOL_OUT; 7461 DW_LOCAL_POOL_OUT;
7451 DW_FUNCTION_RETURN_NOTHING; 7462 DW_FUNCTION_RETURN_NOTHING;
7452 } 7463 }
7453 7464
7454 /* 7465 /*