changeset 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 ad3a32fd7008
children 0448507827e6
files dw.h mac/dw.m
diffstat 2 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Wed Oct 12 00:12:12 2016 +0000
+++ b/dw.h	Thu Apr 20 09:57:15 2017 +0000
@@ -1406,6 +1406,11 @@
 #define DW_DRAW_FULL       (1 << 1)
 #define DW_DRAW_NOAA       (1 << 2)
 
+/* MLE Completion flags */
+#define DW_MLE_COMPLETE_TEXT      1
+#define DW_MLE_COMPLETE_DASH      (1 << 1)
+#define DW_MLE_COMPLETE_QUOTE     (1 << 2)
+
 /* Macro for casting resource IDs to HICN */
 #define DW_RESOURCE(a) (a < 65536 ? (HICN)a : (HICN)0)
 
@@ -1606,6 +1611,7 @@
 void API dw_mle_set_visible(HWND handle, int line);
 void API dw_mle_set_editable(HWND handle, int state);
 void API dw_mle_set_word_wrap(HWND handle, int state);
+void API dw_mle_set_auto_complete(HWND handle, int state);
 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags);
 void API dw_spinbutton_set_pos(HWND handle, long position);
 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower);
--- 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.