]> git.saurik.com Git - wxWidgets.git/commitdiff
preparing for completions support
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 13 Apr 2011 09:22:17 +0000 (09:22 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 13 Apr 2011 09:22:17 +0000 (09:22 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/srchctrl.mm
src/osx/cocoa/textctrl.mm

index c9b722d727ecfe248468a5534d045b33f8f0c60c..e665167688ed04deecc7c221eb190d7b9159e91e 100644 (file)
         impl->controlTextDidChange();
 }
 
+- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words
+ forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int*)index
+{
+    NSMutableArray* matches = NULL;
+    NSString*       partialString;
+    
+    partialString = [[textView string] substringWithRange:charRange];
+    matches       = [NSMutableArray array];
+    
+    wxTextWidgetImpl* impl = (wxTextWidgetImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+    wxArrayString completions;
+    
+    // adapt to whatever strategy we have for getting the strings
+    // impl->GetTextEntry()->GetCompletions(wxCFStringRef::AsString(partialString), completions);
+    
+    for (size_t i = 0; i < completions.GetCount(); ++i )
+        [matches addObject: wxCFStringRef(completions[i]).AsNSString()];
+    
+    // [matches sortUsingSelector:@selector(compare:)];
+    
+    
+    return matches;
+}
+
 @end
 
 // ============================================================================
index 738482a841d4209f8c388fb9a1d2d3d684049f77..364c3993b2040ea7e1c45e98a4c986fa7a1f84be 100644 (file)
@@ -289,6 +289,29 @@ protected :
         impl->controlTextDidChange();
 }
 
+- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words
+ forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int*)index
+{
+    NSMutableArray* matches = NULL;
+    NSString*       partialString;
+    
+    partialString = [[textView string] substringWithRange:charRange];
+    matches       = [NSMutableArray array];
+    
+    wxTextWidgetImpl* impl = (wxTextWidgetImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+    wxArrayString completions;
+    
+    // adapt to whatever strategy we have for getting the strings
+    // impl->GetTextEntry()->GetCompletions(wxCFStringRef::AsString(partialString), completions);
+    
+    for (size_t i = 0; i < completions.GetCount(); ++i )
+        [matches addObject: wxCFStringRef(completions[i]).AsNSString()];
+
+    // [matches sortUsingSelector:@selector(compare:)];
+    
+    return matches;
+}
+
 - (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector
 {
     wxUnusedVar(textView);