comparison mac/dw.m @ 1924:c47a04d83b90

Added dw_mle_set_auto_complete() to enable MLE auto completion on supported platforms. Currently only Mac is supported, but may add Windows support soon.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 20 Apr 2017 09:57:15 +0000
parents a2a8145f3148
children 0448507827e6
comparison
equal deleted inserted replaced
1923:ad3a32fd7008 1924:c47a04d83b90
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 BUILDING_FOR_SNOW_LEOPARD 24 #define BUILDING_FOR_SNOW_LEOPARD
25 #endif
26
27 /* Create a define to let us know to include Snow Leopard 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))
29 #define BUILDING_FOR_LION
25 #endif 30 #endif
26 31
27 /* Macros to protect access to thread unsafe classes */ 32 /* Macros to protect access to thread unsafe classes */
28 #define DW_MUTEX_LOCK { \ 33 #define DW_MUTEX_LOCK { \
29 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \ 34 if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \
1860 -(void)doubleClicked:(id)sender; 1865 -(void)doubleClicked:(id)sender;
1861 -(void)keyUp:(NSEvent *)theEvent; 1866 -(void)keyUp:(NSEvent *)theEvent;
1862 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn; 1867 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn;
1863 -(void)selectionChanged:(id)sender; 1868 -(void)selectionChanged:(id)sender;
1864 -(NSMenu *)menuForEvent:(NSEvent *)event; 1869 -(NSMenu *)menuForEvent:(NSEvent *)event;
1870 #ifdef BUILDING_FOR_LION1
1871 -(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row;
1872 #endif
1865 @end 1873 @end
1866 1874
1867 @implementation DWContainer 1875 @implementation DWContainer
1868 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable 1876 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable
1869 { 1877 {
1903 } 1911 }
1904 } 1912 }
1905 } 1913 }
1906 return nil; 1914 return nil;
1907 } 1915 }
1916 #ifdef BUILDING_FOR_LION1
1917 -(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
1918 {
1919 ItemCellView *result = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
1920 Item *item = [self.items objectAtIndex:row];
1921 result.imageView.image = item.itemIcon;
1922 result.textField.stringValue = item.itemDisplayName;
1923 result.detailTextField.stringValue = item.itemKind;
1924 return result;
1925 }
1926 #endif
1908 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; } 1927 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; }
1909 -(void *)userdata { return userdata; } 1928 -(void *)userdata { return userdata; }
1910 -(void)setUserdata:(void *)input { userdata = input; } 1929 -(void)setUserdata:(void *)input { userdata = input; }
1911 -(void)setFilesystem:(int)input { filesystem = input; } 1930 -(void)setFilesystem:(int)input { filesystem = input; }
1912 -(int)filesystem { return filesystem; } 1931 -(int)filesystem { return filesystem; }
5611 [[mle textContainer] setWidthTracksTextView:NO]; 5630 [[mle textContainer] setWidthTracksTextView:NO];
5612 [[mle textContainer] setContainerSize:[mle maxSize]]; 5631 [[mle textContainer] setContainerSize:[mle maxSize]];
5613 [mle setHorizontallyResizable:YES]; 5632 [mle setHorizontallyResizable:YES];
5614 [sv setHasHorizontalScroller:YES]; 5633 [sv setHasHorizontalScroller:YES];
5615 } 5634 }
5635 }
5636
5637 /*
5638 * Sets the word auto complete state of an MLE box.
5639 * Parameters:
5640 * handle: Handle to the MLE.
5641 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
5642 */
5643 void API dw_mle_set_auto_complete(HWND handle, int state)
5644 {
5645 DWMLE *mle = handle;
5646 [mle setAutomaticQuoteSubstitutionEnabled:(state & DW_MLE_COMPLETE_QUOTE ? YES : NO)];
5647 [mle setAutomaticDashSubstitutionEnabled:(state & DW_MLE_COMPLETE_DASH ? YES : NO)];
5648 [mle setAutomaticTextReplacementEnabled:(state & DW_MLE_COMPLETE_TEXT ? YES : NO)];
5616 } 5649 }
5617 5650
5618 /* 5651 /*
5619 * Sets the current cursor position of an MLE box. 5652 * Sets the current cursor position of an MLE box.
5620 * Parameters: 5653 * Parameters: