diff options
Diffstat (limited to 'cocoa')
-rw-r--r-- | cocoa/PlatCocoa.mm | 16 | ||||
-rw-r--r-- | cocoa/ScintillaTest/AppController.mm | 43 |
2 files changed, 55 insertions, 4 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 9b4455237..ce112f853 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1383,7 +1383,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; } @@ -1464,7 +1467,10 @@ public: class ListBoxImpl; @interface AutoCompletionDataSource : -NSObject <NSTableViewDataSource> +NSObject +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 +<NSTableViewDataSource> +#endif { ListBoxImpl* box; } @@ -1841,7 +1847,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); @@ -1878,7 +1887,6 @@ NSImage* ListBoxImpl::ImageForRow(NSInteger row) if (it != images.end()) { NSImage* img = it->second; - [img retain]; return img; } else diff --git a/cocoa/ScintillaTest/AppController.mm b/cocoa/ScintillaTest/AppController.mm index fbcdad9a8..294704f02 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 |