From fafcffad2b74f045990f025fba5ce25d7db91812 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 20 Aug 2011 09:51:57 +1000 Subject: Include autocompletion list test. --- cocoa/ScintillaTest/AppController.mm | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'cocoa') diff --git a/cocoa/ScintillaTest/AppController.mm b/cocoa/ScintillaTest/AppController.mm index 4c8801a33..24941ffe2 100644 --- a/cocoa/ScintillaTest/AppController.mm +++ b/cocoa/ScintillaTest/AppController.mm @@ -211,6 +211,47 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL. //-------------------------------------------------------------------------------------------------- +/* XPM */ +static const char * box_xpm[] = { + "12 12 2 1", + " c None", + ". c #800000", + " .........", + " . . ..", + " . . . .", + "......... .", + ". . . .", + ". . . ..", + ". . .. .", + "......... .", + ". . . .", + ". . . . ", + ". . .. ", + "......... "}; + + +- (void) showAutocompletion +{ + const char *words = "Babylon-5?1 Battlestar-Galactica Millenium-Falcon?2 Moya?2 Serenity Voyager"; + [mEditor setGeneralProperty: SCI_AUTOCSETIGNORECASE parameter: 1 value:0]; + [mEditor setGeneralProperty: SCI_REGISTERIMAGE parameter: 1 value:(sptr_t)box_xpm]; + const int imSize = 12; + [mEditor setGeneralProperty: SCI_RGBAIMAGESETWIDTH parameter: imSize value:0]; + [mEditor setGeneralProperty: SCI_RGBAIMAGESETHEIGHT parameter: imSize value:0]; + char image[imSize * imSize * 4]; + for (size_t y = 0; y < imSize; y++) { + for (size_t x = 0; x < imSize; x++) { + char *p = image + (y * imSize + x) * 4; + p[0] = 0xFF; + p[1] = 0xA0; + p[2] = 0; + p[3] = x * 23; + } + } + [mEditor setGeneralProperty: SCI_REGISTERRGBAIMAGE parameter: 2 value:(sptr_t)image]; + [mEditor setGeneralProperty: SCI_AUTOCSHOW parameter: 0 value:(sptr_t)words]; +} + - (IBAction) searchText: (id) sender { NSSearchField* searchField = (NSSearchField*) sender; @@ -219,6 +260,8 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL. wholeWord: NO scrollTo: YES wrap: YES]; + if ([[searchField stringValue] isEqualToString: @"XX"]) + [self showAutocompletion]; } @end -- cgit v1.2.3 From 502fe6953ebc27dde3622ea9fa8313364c412217 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 20 Aug 2011 10:00:50 +1000 Subject: Replace call available only on 10.6 with sequence that works on 10.5. --- cocoa/PlatCocoa.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 75803e33b..e2e2915f5 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1378,7 +1378,10 @@ static NSImage* ImageFromXPM(XPM* pxpm) img = [NSImage alloc]; [img autorelease]; CGImageRef imageRef = surfaceIXPM->GetImage(); - [img initWithCGImage:imageRef size:NSZeroSize]; + [img initWithSize:NSZeroSize]; + NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; + [img addRepresentation: bitmapRep]; + [bitmapRep release]; CGImageRelease(imageRef); delete surfaceXPM; } @@ -1836,7 +1839,10 @@ void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsig [img autorelease]; CGImageRef imageRef = ImageFromRGBA(width, height, pixelsImage, false); NSSize sz = {width, height}; - [img initWithCGImage:imageRef size:sz]; + [img initWithSize: sz]; + NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef]; + [img addRepresentation: bitmapRep]; + [bitmapRep release]; CGImageRelease(imageRef); [img retain]; ImageMap::iterator it=images.find(type); -- cgit v1.2.3 From 29eb86f8dc7d6b95c364135443bf71e0c77dfc6a Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 20 Aug 2011 10:21:43 +1000 Subject: Specify that AutoCompletionDataSource implements NSTableViewDataSource protocol only when building for later than 10.5 so SDK has to know about that protocol. --- cocoa/PlatCocoa.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index e2e2915f5..22eadec0f 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1462,7 +1462,10 @@ public: class ListBoxImpl; @interface AutoCompletionDataSource : -NSObject +NSObject +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 + +#endif { ListBoxImpl* box; } -- cgit v1.2.3 From 4d5260e36e1353b0d317e4538ca252fa430e14c2 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 20 Aug 2011 10:24:06 +1000 Subject: Fix memory leak with images in autocompletion list. --- cocoa/PlatCocoa.mm | 1 - 1 file changed, 1 deletion(-) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 22eadec0f..fd66f671f 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1882,7 +1882,6 @@ NSImage* ListBoxImpl::ImageForRow(NSInteger row) if (it != images.end()) { NSImage* img = it->second; - [img retain]; return img; } else -- cgit v1.2.3