Mercurial > dwindows
comparison mac/dw.m @ 719:d5e49ef8f541
Updated the #if for Snow Leopard/Leopard builds to handle them not being defined properly.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 13 Mar 2011 07:40:53 +0000 |
parents | 002f33d4439d |
children | 357b59e57a31 |
comparison
equal
deleted
inserted
replaced
718:002f33d4439d | 719:d5e49ef8f541 |
---|---|
14 #include <sys/socket.h> | 14 #include <sys/socket.h> |
15 #include <sys/un.h> | 15 #include <sys/un.h> |
16 #include <sys/mman.h> | 16 #include <sys/mman.h> |
17 #include <sys/time.h> | 17 #include <sys/time.h> |
18 #include <sys/stat.h> | 18 #include <sys/stat.h> |
19 | |
20 /* Create a define to let us know to include Snow Leopard specific features */ | |
21 #if defined(MAC_OS_X_VERSION_10_6) && ((defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6) || !defined(MAC_OS_X_VERSION_MIN_REQUIRED)) | |
22 #define BUILDING_FOR_SNOW_LEOPARD | |
23 #endif | |
19 | 24 |
20 /* Macros to protect access to thread unsafe classes */ | 25 /* Macros to protect access to thread unsafe classes */ |
21 #define DW_MUTEX_LOCK { \ | 26 #define DW_MUTEX_LOCK { \ |
22 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \ | 27 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \ |
23 dw_mutex_lock(DWThreadMutex); \ | 28 dw_mutex_lock(DWThreadMutex); \ |
388 * going to work. -Brian | 393 * going to work. -Brian |
389 */ | 394 */ |
390 | 395 |
391 /* Subclass for a box type */ | 396 /* Subclass for a box type */ |
392 @interface DWBox : NSView | 397 @interface DWBox : NSView |
393 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 398 #ifdef BUILDING_FOR_SNOW_LEOPARD |
394 <NSWindowDelegate> | 399 <NSWindowDelegate> |
395 #endif | 400 #endif |
396 { | 401 { |
397 Box *box; | 402 Box *box; |
398 void *userdata; | 403 void *userdata; |
575 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } | 580 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
576 @end | 581 @end |
577 | 582 |
578 /* Subclass for a Notebook control type */ | 583 /* Subclass for a Notebook control type */ |
579 @interface DWNotebook : NSTabView | 584 @interface DWNotebook : NSTabView |
580 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 585 #ifdef BUILDING_FOR_SNOW_LEOPARD |
581 <NSTabViewDelegate> | 586 <NSTabViewDelegate> |
582 #endif | 587 #endif |
583 { | 588 { |
584 void *userdata; | 589 void *userdata; |
585 int pageid; | 590 int pageid; |
650 -(void)setDialog:(DWDialog *)input { dialog = input; } | 655 -(void)setDialog:(DWDialog *)input { dialog = input; } |
651 @end | 656 @end |
652 | 657 |
653 /* Subclass for a splitbar type */ | 658 /* Subclass for a splitbar type */ |
654 @interface DWSplitBar : NSSplitView | 659 @interface DWSplitBar : NSSplitView |
655 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 660 #ifdef BUILDING_FOR_SNOW_LEOPARD |
656 <NSSplitViewDelegate> | 661 <NSSplitViewDelegate> |
657 #endif | 662 #endif |
658 { | 663 { |
659 void *userdata; | 664 void *userdata; |
660 float percent; | 665 float percent; |
828 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } | 833 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
829 @end | 834 @end |
830 | 835 |
831 /* Subclass for a Container/List type */ | 836 /* Subclass for a Container/List type */ |
832 @interface DWContainer : NSTableView | 837 @interface DWContainer : NSTableView |
833 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 838 #ifdef BUILDING_FOR_SNOW_LEOPARD |
834 <NSTableViewDataSource> | 839 <NSTableViewDataSource> |
835 #endif | 840 #endif |
836 { | 841 { |
837 void *userdata; | 842 void *userdata; |
838 NSMutableArray *tvcols; | 843 NSMutableArray *tvcols; |
1062 } | 1067 } |
1063 } | 1068 } |
1064 | 1069 |
1065 /* Subclass for a Tree type */ | 1070 /* Subclass for a Tree type */ |
1066 @interface DWTree : NSOutlineView | 1071 @interface DWTree : NSOutlineView |
1067 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 1072 #ifdef BUILDING_FOR_SNOW_LEOPARD |
1068 <NSOutlineViewDataSource> | 1073 <NSOutlineViewDataSource> |
1069 #endif | 1074 #endif |
1070 { | 1075 { |
1071 void *userdata; | 1076 void *userdata; |
1072 NSTableColumn *imagecol; | 1077 NSTableColumn *imagecol; |
1241 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } | 1246 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } |
1242 @end | 1247 @end |
1243 | 1248 |
1244 /* Subclass for a Combobox type */ | 1249 /* Subclass for a Combobox type */ |
1245 @interface DWComboBox : NSComboBox | 1250 @interface DWComboBox : NSComboBox |
1246 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 1251 #ifdef BUILDING_FOR_SNOW_LEOPARD |
1247 <NSComboBoxDelegate> | 1252 <NSComboBoxDelegate> |
1248 #endif | 1253 #endif |
1249 { | 1254 { |
1250 void *userdata; | 1255 void *userdata; |
1251 } | 1256 } |
1297 } | 1302 } |
1298 @end | 1303 @end |
1299 | 1304 |
1300 /* Subclass for a Spinbutton type */ | 1305 /* Subclass for a Spinbutton type */ |
1301 @interface DWSpinButton : NSView | 1306 @interface DWSpinButton : NSView |
1302 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 1307 #ifdef BUILDING_FOR_SNOW_LEOPARD |
1303 <NSTextFieldDelegate> | 1308 <NSTextFieldDelegate> |
1304 #endif | 1309 #endif |
1305 { | 1310 { |
1306 void *userdata; | 1311 void *userdata; |
1307 NSTextField *textfield; | 1312 NSTextField *textfield; |
1796 NSMenu *_generate_main_menu() | 1801 NSMenu *_generate_main_menu() |
1797 { | 1802 { |
1798 NSString *applicationName = nil; | 1803 NSString *applicationName = nil; |
1799 | 1804 |
1800 /* This only works on 10.6 so we have a backup method */ | 1805 /* This only works on 10.6 so we have a backup method */ |
1801 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 1806 #ifdef BUILDING_FOR_SNOW_LEOPARD |
1802 applicationName = [[NSRunningApplication currentApplication] localizedName]; | 1807 applicationName = [[NSRunningApplication currentApplication] localizedName]; |
1803 #endif | 1808 #endif |
1804 if(applicationName == nil) | 1809 if(applicationName == nil) |
1805 { | 1810 { |
1806 applicationName = [[NSProcessInfo processInfo] processName]; | 1811 applicationName = [[NSProcessInfo processInfo] processName]; |
2137 */ | 2142 */ |
2138 void dw_clipboard_set_text( char *str, int len) | 2143 void dw_clipboard_set_text( char *str, int len) |
2139 { | 2144 { |
2140 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; | 2145 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; |
2141 | 2146 |
2142 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 2147 #ifdef BUILDING_FOR_SNOW_LEOPARD |
2143 [pasteboard clearContents]; | 2148 [pasteboard clearContents]; |
2144 #endif | 2149 #endif |
2145 | 2150 |
2146 [pasteboard setString:[ NSString stringWithUTF8String:str ] forType:NSStringPboardType]; | 2151 [pasteboard setString:[ NSString stringWithUTF8String:str ] forType:NSStringPboardType]; |
2147 } | 2152 } |
5462 DWView *view = [[DWView alloc] init]; | 5467 DWView *view = [[DWView alloc] init]; |
5463 | 5468 |
5464 [window setContentView:view]; | 5469 [window setContentView:view]; |
5465 [window setDelegate:view]; | 5470 [window setDelegate:view]; |
5466 [window makeKeyAndOrderFront:nil]; | 5471 [window makeKeyAndOrderFront:nil]; |
5467 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 5472 #ifdef BUILDING_FOR_SNOW_LEOPARD |
5468 [window setAllowsConcurrentViewDrawing:NO]; | 5473 [window setAllowsConcurrentViewDrawing:NO]; |
5469 #endif | 5474 #endif |
5470 [view release]; | 5475 [view release]; |
5471 | 5476 |
5472 /* If it isn't a toplevel window... */ | 5477 /* If it isn't a toplevel window... */ |
5619 { | 5624 { |
5620 id object = handle; | 5625 id object = handle; |
5621 | 5626 |
5622 if([object isMemberOfClass:[NSWindow class]]) | 5627 if([object isMemberOfClass:[NSWindow class]]) |
5623 { | 5628 { |
5624 #if MAC_OS_X_VERSION_10_6 > MAC_OS_X_VERSION_MAX_ALLOWED | 5629 #ifdef BUILDING_FOR_SNOW_LEOPARD |
5625 NSWindow *window = object; | 5630 NSWindow *window = object; |
5626 int currentstyle = (int)[window styleMask]; | 5631 int currentstyle = (int)[window styleMask]; |
5627 int tmp; | 5632 int tmp; |
5628 | 5633 |
5629 tmp = currentstyle | (int)mask; | 5634 tmp = currentstyle | (int)mask; |