diff 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
line wrap: on
line diff
--- a/mac/dw.m	Wed Oct 12 00:12:12 2016 +0000
+++ b/mac/dw.m	Thu Apr 20 09:57:15 2017 +0000
@@ -24,6 +24,11 @@
 #define BUILDING_FOR_SNOW_LEOPARD
 #endif
 
+/* Create a define to let us know to include Snow Leopard specific features */
+#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))
+#define BUILDING_FOR_LION
+#endif
+
 /* Macros to protect access to thread unsafe classes */
 #define  DW_MUTEX_LOCK { \
     if(DWThread != (DWTID)-1 && pthread_self() != DWThread && pthread_self() != _dw_mutex_locked) { \
@@ -1862,6 +1867,9 @@
 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn;
 -(void)selectionChanged:(id)sender;
 -(NSMenu *)menuForEvent:(NSEvent *)event;
+#ifdef BUILDING_FOR_LION1
+-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row;
+#endif
 @end
 
 @implementation DWContainer
@@ -1905,6 +1913,17 @@
     }
     return nil;
 }
+#ifdef BUILDING_FOR_LION1
+-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
+{
+    ItemCellView *result = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self];
+    Item *item = [self.items objectAtIndex:row];
+    result.imageView.image = item.itemIcon;
+    result.textField.stringValue = item.itemDisplayName;
+    result.detailTextField.stringValue = item.itemKind;
+    return result;
+}
+#endif
 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; }
 -(void *)userdata { return userdata; }
 -(void)setUserdata:(void *)input { userdata = input; }
@@ -5616,6 +5635,20 @@
 }
 
 /*
+ * Sets the word auto complete state of an MLE box.
+ * Parameters:
+ *          handle: Handle to the MLE.
+ *          state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
+ */
+void API dw_mle_set_auto_complete(HWND handle, int state)
+{
+    DWMLE *mle = handle;
+    [mle setAutomaticQuoteSubstitutionEnabled:(state & DW_MLE_COMPLETE_QUOTE ? YES : NO)];
+    [mle setAutomaticDashSubstitutionEnabled:(state & DW_MLE_COMPLETE_DASH ? YES : NO)];
+    [mle setAutomaticTextReplacementEnabled:(state & DW_MLE_COMPLETE_TEXT ? YES : NO)];
+}
+
+/*
  * Sets the current cursor position of an MLE box.
  * Parameters:
  *          handle: Handle to the MLE to be positioned.