diff options
Diffstat (limited to 'cocoa')
-rw-r--r-- | cocoa/InfoBar.h | 6 | ||||
-rw-r--r-- | cocoa/InfoBar.mm | 70 | ||||
-rw-r--r-- | cocoa/PlatCocoa.h | 6 | ||||
-rw-r--r-- | cocoa/PlatCocoa.mm | 170 | ||||
-rw-r--r-- | cocoa/QuartzTextLayout.h | 26 | ||||
-rw-r--r-- | cocoa/ScintillaCocoa.h | 14 | ||||
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 230 | ||||
-rw-r--r-- | cocoa/ScintillaView.h | 8 | ||||
-rw-r--r-- | cocoa/ScintillaView.mm | 92 |
9 files changed, 311 insertions, 311 deletions
diff --git a/cocoa/InfoBar.h b/cocoa/InfoBar.h index efde17944..1ce139530 100644 --- a/cocoa/InfoBar.h +++ b/cocoa/InfoBar.h @@ -28,15 +28,15 @@ @private NSImage* mBackground; IBDisplay mDisplayMask; - + float mScaleFactor; NSPopUpButton* mZoomPopup; - + int mCurrentCaretX; int mCurrentCaretY; NSTextField* mCaretPositionLabel; NSTextField* mStatusTextLabel; - + id <InfoBarCommunicator> mCallback; } diff --git a/cocoa/InfoBar.mm b/cocoa/InfoBar.mm index 45093911d..a4bc52731 100644 --- a/cocoa/InfoBar.mm +++ b/cocoa/InfoBar.mm @@ -22,7 +22,7 @@ { // Get the parent's idea of where we should draw NSRect newRect = [super drawingRectForBounds: theRect]; - + // When the text field is being edited or selected, we have to turn off the magic because it // screws up the configuration of the field editor. We sneak around this by intercepting // selectWithFrame and editWithFrame and sneaking a reduced, centered rect in at the last minute. @@ -30,26 +30,26 @@ { // Get our ideal size for current text NSSize textSize = [self cellSizeForBounds: theRect]; - + // Center that in the proposed rect - float heightDelta = newRect.size.height - textSize.height; + float heightDelta = newRect.size.height - textSize.height; if (heightDelta > 0) { newRect.size.height -= heightDelta; newRect.origin.y += ceil(heightDelta / 2); } } - + return newRect; } //-------------------------------------------------------------------------------------------------- -- (void) selectWithFrame: (NSRect) aRect inView: (NSView*) controlView editor: (NSText*) textObj +- (void) selectWithFrame: (NSRect) aRect inView: (NSView*) controlView editor: (NSText*) textObj delegate:(id) anObject start: (NSInteger) selStart length: (NSInteger) selLength { aRect = [self drawingRectForBounds: aRect]; - mIsEditingOrSelecting = YES; + mIsEditingOrSelecting = YES; [super selectWithFrame: aRect inView: controlView editor: textObj @@ -63,7 +63,7 @@ - (void) editWithFrame: (NSRect) aRect inView: (NSView*) controlView editor: (NSText*) textObj delegate: (id) anObject event: (NSEvent*) theEvent -{ +{ aRect = [self drawingRectForBounds: aRect]; mIsEditingOrSelecting = YES; [super editWithFrame: aRect @@ -86,7 +86,7 @@ if (self) { NSBundle* bundle = [NSBundle bundleForClass: [InfoBar class]]; - + NSString* path = [bundle pathForResource: @"info_bar_bg" ofType: @"tiff" inDirectory: nil]; mBackground = [[NSImage alloc] initWithContentsOfFile: path]; if (![mBackground isValid]) @@ -152,14 +152,14 @@ static float BarFontSize = 10.0; { // 1) The zoom popup. unsigned numberOfDefaultItems = sizeof(DefaultScaleMenuLabels) / sizeof(NSString *); - + // Create the popup button. mZoomPopup = [[NSPopUpButton allocWithZone:[self zone]] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown: NO]; - + // No border or background please. [[mZoomPopup cell] setBordered: NO]; [[mZoomPopup cell] setArrowPosition: NSPopUpArrowAtBottom]; - + // Fill it. for (unsigned count = 0; count < numberOfDefaultItems; count++) { @@ -169,28 +169,28 @@ static float BarFontSize = 10.0; [currentItem setRepresentedObject: [NSNumber numberWithFloat: DefaultScaleMenuFactors[count]]]; } [mZoomPopup selectItemAtIndex: DefaultScaleMenuSelectedItemIndex]; - + // Hook it up. [mZoomPopup setTarget: self]; [mZoomPopup setAction: @selector(zoomItemAction:)]; - + // Set a suitable font. [mZoomPopup setFont: [NSFont menuBarFontOfSize: BarFontSize]]; - + // Make sure the popup is big enough to fit the cells. [mZoomPopup sizeToFit]; - + // Don't let it become first responder [mZoomPopup setRefusesFirstResponder: YES]; - + // put it in the scrollview. [self addSubview: mZoomPopup]; [mZoomPopup release]; - + // 2) The caret position label. Class oldCellClass = [NSTextField cellClass]; [NSTextField setCellClass: [VerticallyCenteredTextFieldCell class]]; - + mCaretPositionLabel = [[NSTextField alloc] initWithFrame: NSMakeRect(0.0, 0.0, 50.0, 1.0)]; [mCaretPositionLabel setBezeled: NO]; [mCaretPositionLabel setBordered: NO]; @@ -205,7 +205,7 @@ static float BarFontSize = 10.0; [self addSubview: mCaretPositionLabel]; [mCaretPositionLabel release]; - + // 3) The status text. mStatusTextLabel = [[NSTextField alloc] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0)]; [mStatusTextLabel setBezeled: NO]; @@ -220,7 +220,7 @@ static float BarFontSize = 10.0; [self addSubview: mStatusTextLabel]; [mStatusTextLabel release]; - + // Restore original cell class so that everything else doesn't get broken [NSTextField setCellClass: oldCellClass]; } @@ -248,12 +248,12 @@ static float BarFontSize = 10.0; [mBackground drawAtPoint: target fromRect: NSZeroRect operation: NSCompositeCopy fraction: 1]; target.x += mBackground.size.width; } - + // Draw separator lines between items. NSRect verticalLineRect; float component = 190.0 / 255.0; NSColor* lineColor = [NSColor colorWithDeviceRed: component green: component blue: component alpha: 1]; - + if (mDisplayMask & IBShowZoom) { verticalLineRect = [mZoomPopup frame]; @@ -265,7 +265,7 @@ static float BarFontSize = 10.0; NSRectFill(verticalLineRect); } } - + if (mDisplayMask & IBShowCaretPosition) { verticalLineRect = [mCaretPositionLabel frame]; @@ -347,7 +347,7 @@ static float BarFontSize = 10.0; mDisplayMask = display; [self positionSubViews]; [self needsDisplay]; - } + } } //-------------------------------------------------------------------------------------------------- @@ -358,7 +358,7 @@ static float BarFontSize = 10.0; - (void) zoomItemAction: (id) sender { NSNumber* selectedFactorObject = [[sender selectedCell] representedObject]; - + if (selectedFactorObject == nil) { NSLog(@"Scale popup action: setting arbitrary zoom factors is not yet supported."); @@ -369,9 +369,9 @@ static float BarFontSize = 10.0; [self setScaleFactor: [selectedFactorObject floatValue] adjustPopup: NO]; } } - + //-------------------------------------------------------------------------------------------------- - + - (void) setScaleFactor: (float) newScaleFactor adjustPopup: (BOOL) flag { if (mScaleFactor != newScaleFactor) @@ -381,7 +381,7 @@ static float BarFontSize = 10.0; { unsigned count = 0; unsigned numberOfDefaultItems = sizeof(DefaultScaleMenuFactors) / sizeof(float); - + // We only work with some preset zoom values. If the given value does not correspond // to one then show no selection. while (count < numberOfDefaultItems && (fabs(newScaleFactor - DefaultScaleMenuFactors[count]) > 0.07)) @@ -391,7 +391,7 @@ static float BarFontSize = 10.0; else { [mZoomPopup selectItemAtIndex: count]; - + // Set scale factor to found preset value if it comes close. mScaleFactor = DefaultScaleMenuFactors[count]; } @@ -400,7 +400,7 @@ static float BarFontSize = 10.0; { // Internally set. Notify owner. [mCallback notify: IBNZoomChanged message: nil location: NSZeroPoint value: newScaleFactor]; - } + } } } @@ -414,12 +414,12 @@ static float BarFontSize = 10.0; // Make the position one-based. int newX = (int) position.x + 1; int newY = (int) position.y + 1; - + if (mCurrentCaretX != newX || mCurrentCaretY != newY) { mCurrentCaretX = newX; mCurrentCaretY = newY; - + [mCaretPositionLabel setStringValue: [NSString stringWithFormat: @"%d:%d", newX, newY]]; } } @@ -435,13 +435,13 @@ static float BarFontSize = 10.0; frame.size.width = 0; if (mDisplayMask & IBShowZoom) frame.size.width += [mZoomPopup frame].size.width; - + if (mDisplayMask & IBShowCaretPosition) frame.size.width += [mCaretPositionLabel frame].size.width; - + if (mDisplayMask & IBShowStatusText) frame.size.width += [mStatusTextLabel frame].size.width; - + [self setFrame: frame]; } diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index 58017706d..06b7a1f5b 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -50,7 +50,7 @@ private: QuartzTextLayout* textLayout; int codePage; int verticalDeviceResolution; - + /** If the surface is a bitmap context, contains a reference to the bitmap data. */ uint8_t* bitmapData; /** If the surface is a bitmap context, stores the dimensions of the bitmap. */ @@ -98,7 +98,7 @@ public: void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource); void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); - void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, + void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore); void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); @@ -117,7 +117,7 @@ public: void SetUnicodeMode(bool unicodeMode_); void SetDBCSMode(int codePage_); }; // SurfaceImpl class - + } // Scintilla namespace #endif diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 6bd5d676d..3d3417b82 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -178,7 +178,7 @@ void SurfaceImpl::Release() } bitmapData = NULL; gc = NULL; - + bitmapWidth = 0; bitmapHeight = 0; x = 0; @@ -202,7 +202,7 @@ void SurfaceImpl::Init(WindowID) // XXX Docs on QDBeginCGContext are light, a better way to do this would be good. // AFAIK we should not hold onto a context retrieved this way, thus the need for // acquire/release of the context. - + Release(); } @@ -221,19 +221,19 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID) void SurfaceImpl::InitPixMap(int width, int height, Surface* /* surface_ */, WindowID /* wid */) { Release(); - + // Create a new bitmap context, along with the RAM for the bitmap itself bitmapWidth = width; bitmapHeight = height; - + const int bitmapBytesPerRow = (width * BYTES_PER_PIXEL); const int bitmapByteCount = (bitmapBytesPerRow * height); - + // Create an RGB color space. CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); if (colorSpace == NULL) return; - + // Create the bitmap. bitmapData = new uint8_t[bitmapByteCount]; // create the context @@ -244,7 +244,7 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface* /* surface_ */, Win bitmapBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast); - + if (gc == NULL) { // the context couldn't be created for some reason, @@ -253,10 +253,10 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface* /* surface_ */, Win bitmapData = NULL; } textLayout->setContext (gc); - + // the context retains the color space, so we can release it CGColorSpaceRelease(colorSpace); - + if (gc != NULL && bitmapData != NULL) { // "Erase" to white. @@ -273,9 +273,9 @@ void SurfaceImpl::PenColour(ColourDesired fore) if (gc) { ColourDesired colour(fore.AsLong()); - + // Set the Stroke color to match - CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, + CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, colour.GetBlue() / 255.0, 1.0 ); } } @@ -287,9 +287,9 @@ void SurfaceImpl::FillColour(const ColourDesired& back) if (gc) { ColourDesired colour(back.AsLong()); - + // Set the Fill color to match - CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, + CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, colour.GetBlue() / 255.0, 1.0 ); } } @@ -301,17 +301,17 @@ CGImageRef SurfaceImpl::GetImage() // For now, assume that GetImage can only be called on PixMap surfaces. if (bitmapData == NULL) return NULL; - + CGContextFlush(gc); - + // Create an RGB color space. CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); if( colorSpace == NULL ) return NULL; - + const int bitmapBytesPerRow = ((int) bitmapWidth * BYTES_PER_PIXEL); const int bitmapByteCount = (bitmapBytesPerRow * (int) bitmapHeight); - + // Make a copy of the bitmap data for the image creation and divorce it // From the SurfaceImpl lifetime CFDataRef dataRef = CFDataCreate(kCFAllocatorDefault, bitmapData, bitmapByteCount); @@ -335,18 +335,18 @@ CGImageRef SurfaceImpl::GetImage() 0, kCGRenderingIntentDefault); } - + // The image retains the color space, so we can release it. CGColorSpaceRelease(colorSpace); colorSpace = NULL; - + // Done with the data provider. CGDataProviderRelease(dataProvider); dataProvider = NULL; - + // Done with the data provider. CFRelease(dataRef); - + return image; } @@ -386,7 +386,7 @@ void SurfaceImpl::MoveTo(int x_, int y_) void SurfaceImpl::LineTo(int x_, int y_) { CGContextBeginPath( gc ); - + // Because Quartz is based on floating point, lines are drawn with half their colour // on each side of the line. Integer coordinates specify the INTERSECTION of the pixel // division lines. If you specify exact pixel values, you get a line that @@ -406,23 +406,23 @@ void SurfaceImpl::Polygon(Scintilla::Point *pts, int npts, ColourDesired fore, { // Allocate memory for the array of points. std::vector<CGPoint> points(npts); - + for (int i = 0;i < npts;i++) { // Quartz floating point issues: plot the MIDDLE of the pixels points[i].x = pts[i].x + 0.5; points[i].y = pts[i].y + 0.5; } - + CGContextBeginPath(gc); - + // Set colours FillColour(back); PenColour(fore); - + // Draw the polygon CGContextAddLines(gc, points.data(), npts); - + // Explicitly close the path, so it is closed for stroking AND filling (implicit close = filling only) CGContextClosePath( gc ); CGContextDrawPath( gc, kCGPathFillStroke ); @@ -437,7 +437,7 @@ void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired CGContextBeginPath( gc ); FillColour(back); PenColour(fore); - + // Quartz integer -> float point conversion fun (see comment in SurfaceImpl::LineTo) // We subtract 1 from the Width() and Height() so that all our drawing is within the area defined // by the PRectangle. Otherwise, we draw one pixel too far to the right and bottom. @@ -480,7 +480,7 @@ void releaseImageRefCallback(CGImageRef pattern) void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { SurfaceImpl& patternSurface = static_cast<SurfaceImpl &>(surfacePattern); - + // For now, assume that copy can only be called on PixMap surfaces. Shows up black. CGImageRef image = patternSurface.GetImage(); if (image == NULL) @@ -488,11 +488,11 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) FillRectangle(rc, ColourDesired(0)); return; } - + const CGPatternCallbacks drawImageCallbacks = { 0, reinterpret_cast<CGPatternDrawPatternCallback>(drawImageRefCallback), reinterpret_cast<CGPatternReleaseInfoCallback>(releaseImageRefCallback) }; - + CGPatternRef pattern = CGPatternCreate(image, CGRectMake(0, 0, patternSurface.bitmapWidth, patternSurface.bitmapHeight), CGAffineTransformIdentity, @@ -507,10 +507,10 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) // Create a pattern color space CGColorSpaceRef colorSpace = CGColorSpaceCreatePattern( NULL ); if( colorSpace != NULL ) { - + CGContextSaveGState( gc ); CGContextSetFillColorSpace( gc, colorSpace ); - + // Unlike the documentation, you MUST pass in a "components" parameter: // For coloured patterns it is the alpha value. const CGFloat alpha = 1.0; @@ -533,12 +533,12 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi // which is a rectangle with rounded corners each having a radius of 4 pixels. // It would be almost as good just cutting off the corners with lines at // 45 degrees as is done on GTK+. - + // Create a rectangle with semicircles at the corners const int MAX_RADIUS = 4; int radius = Platform::Minimum( MAX_RADIUS, rc.Height()/2 ); radius = Platform::Minimum( radius, rc.Width()/2 ); - + // Points go clockwise, starting from just below the top left // Corners are kept together, so we can easily create arcs to connect them CGPoint corners[4][3] = @@ -564,7 +564,7 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi { rc.left, rc.bottom - radius - 1 }, }, }; - + // Align the points in the middle of the pixels for( int i = 0; i < 4; ++ i ) { @@ -574,20 +574,20 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi corners[i][j].y += 0.5; } } - + PenColour( fore ); FillColour( back ); - + // Move to the last point to begin the path CGContextBeginPath( gc ); CGContextMoveToPoint( gc, corners[3][2].x, corners[3][2].y ); - + for ( int i = 0; i < 4; ++ i ) { CGContextAddLineToPoint( gc, corners[i][0].x, corners[i][0].y ); CGContextAddArcToPoint( gc, corners[i][1].x, corners[i][1].y, corners[i][2].x, corners[i][2].y, radius ); } - + // Close the path to enclose it for stroking and for filling, then draw it CGContextClosePath( gc ); CGContextDrawPath( gc, kCGPathFillStroke ); @@ -616,7 +616,7 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz { rc.left, rc.bottom - cornerSize - 1 }, }, }; - + // Align the points in the middle of the pixels for( int i = 0; i < 4; ++ i ) { @@ -630,13 +630,13 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz // Move to the last point to begin the path CGContextBeginPath( gc ); CGContextMoveToPoint( gc, corners[3][1].x, corners[3][1].y ); - + for ( int i = 0; i < 4; ++ i ) { CGContextAddLineToPoint( gc, corners[i][0].x, corners[i][0].y ); CGContextAddLineToPoint( gc, corners[i][1].x, corners[i][1].y ); } - + // Close the path to enclose it for stroking and for filling, then draw it CGContextClosePath( gc ); CGContextDrawPath( gc, mode ); @@ -704,25 +704,25 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char if (colorSpace) { const int bitmapBytesPerRow = ((int) width * 4); const int bitmapByteCount = (bitmapBytesPerRow * (int) height); - + // Create a data provider. CGDataProviderRef dataProvider = 0; if (invert) { unsigned char *pixelsUpsideDown = new unsigned char[bitmapByteCount]; - + for (int y=0; y<height; y++) { int yInverse = height - y - 1; memcpy(pixelsUpsideDown + y * bitmapBytesPerRow, pixelsImage + yInverse * bitmapBytesPerRow, bitmapBytesPerRow); } - + dataProvider = CGDataProviderCreateWithData( NULL, pixelsUpsideDown, bitmapByteCount, ProviderReleaseData); } else { dataProvider = CGDataProviderCreateWithData( NULL, pixelsImage, bitmapByteCount, NULL); - + } if (dataProvider) { // Create the CGImage. @@ -740,7 +740,7 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char CGDataProviderRelease(dataProvider); } - + // The image retains the color space, so we can release it. CGColorSpaceRelease(colorSpace); } @@ -761,13 +761,13 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) // http://www.codeguru.com/gdi/ellipse.shtml // MAGICAL CONSTANT to map ellipse to beziers 2/3*(sqrt(2)-1) const double EToBConst = 0.2761423749154; - + CGSize offset = CGSizeMake((int)(rc.Width() * EToBConst), (int)(rc.Height() * EToBConst)); CGPoint centre = CGPointMake((rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2); - + // The control point array CGPoint cCtlPt[13]; - + // Assign values to all the control points cCtlPt[0].x = cCtlPt[1].x = @@ -782,7 +782,7 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) cCtlPt[8].x = centre.x + offset.width + 0.5; cCtlPt[3].x = cCtlPt[9].x = centre.x + 0.5; - + cCtlPt[2].y = cCtlPt[3].y = cCtlPt[4].y = rc.top + 0.5; @@ -796,18 +796,18 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) cCtlPt[0].y = cCtlPt[12].y = cCtlPt[6].y = centre.y + 0.5; - + FillColour(back); PenColour(fore); - + CGContextBeginPath( gc ); CGContextMoveToPoint( gc, cCtlPt[0].x, cCtlPt[0].y ); - + for ( int i = 1; i < 13; i += 3 ) { CGContextAddCurveToPoint( gc, cCtlPt[i].x, cCtlPt[i].y, cCtlPt[i+1].x, cCtlPt[i+1].y, cCtlPt[i+2].x, cCtlPt[i+2].y ); } - + // Close the path to enclose it for stroking and for filling, then draw it CGContextClosePath( gc ); CGContextDrawPath( gc, kCGPathFillStroke ); @@ -817,10 +817,10 @@ void SurfaceImpl::CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, { SurfaceImpl& source = static_cast<SurfaceImpl &>(surfaceSource); CGImageRef image = source.GetImage(); - + CGRect src = PRectangleToCGRect(srcRect); CGRect dst = PRectangleToCGRect(dstRect); - + /* source from QuickDrawToQuartz2D.pdf on developer.apple.com */ float w = (float) CGImageGetWidth(image); float h = (float) CGImageGetHeight(image); @@ -844,10 +844,10 @@ void SurfaceImpl::Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSou // Maybe we have to make the Surface two contexts: // a bitmap context which we do all the drawing on, and then a "real" context // which we copy the output to when we call "Synchronize". Ugh! Gross and slow! - + // For now, assume that copy can only be called on PixMap surfaces SurfaceImpl& source = static_cast<SurfaceImpl &>(surfaceSource); - + // Get the CGImageRef CGImageRef image = source.GetImage(); // If we could not get an image reference, fill the rectangle black @@ -856,19 +856,19 @@ void SurfaceImpl::Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSou FillRectangle( rc, ColourDesired( 0 ) ); return; } - + // Now draw the image on the surface - + // Some fancy clipping work is required here: draw only inside of rc CGContextSaveGState( gc ); CGContextClipToRect( gc, PRectangleToCGRect( rc ) ); - + //Platform::DebugPrintf(stderr, "Copy: CGContextDrawImage: (%d, %d) - (%d X %d)\n", rc.left - from.x, rc.top - from.y, source.bitmapWidth, source.bitmapHeight ); CGContextDrawImage( gc, CGRectMake( rc.left - from.x, rc.top - from.y, source.bitmapWidth, source.bitmapHeight ), image ); - + // Undo the clipping fun CGContextRestoreGState( gc ); - + // Done with the image CGImageRelease( image ); image = NULL; @@ -953,7 +953,7 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) } } -void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, +void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore) { CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); @@ -962,7 +962,7 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION yba QuartzTextStyle* style = reinterpret_cast<QuartzTextStyle*>(font_.GetID()); style->setCTStyleColor(color); - + CGColorRelease(color); textLayout->setText (reinterpret_cast<const UInt8*>(s), len, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); @@ -987,10 +987,10 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION { CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); textLayout->setText (reinterpret_cast<const UInt8*>(s), len, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); - + CTLineRef mLine = textLayout->getCTLine(); assert(mLine != NULL); - + if (unicodeMode) { // Map the widths given for UTF-16 characters back onto the UTF-8 input string CFIndex fit = textLayout->getStringLength(); @@ -1036,7 +1036,7 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { { CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); textLayout->setText (reinterpret_cast<const UInt8*>(s), len, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); - + return textLayout->MeasureStringWidth(); } return 1; @@ -1048,7 +1048,7 @@ XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) { { CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); textLayout->setText (reinterpret_cast<const UInt8*>(str), 1, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); - + return textLayout->MeasureStringWidth(); } else @@ -1062,7 +1062,7 @@ const char sizeString[] = "`~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890" XYPOSITION SurfaceImpl::Ascent(Font &font_) { if (!font_.GetID()) return 1; - + float ascent = reinterpret_cast<QuartzTextStyle*>( font_.GetID() )->getAscent(); return ascent + 0.5; @@ -1071,7 +1071,7 @@ XYPOSITION SurfaceImpl::Ascent(Font &font_) { XYPOSITION SurfaceImpl::Descent(Font &font_) { if (!font_.GetID()) return 1; - + float descent = reinterpret_cast<QuartzTextStyle*>( font_.GetID() )->getDescent(); return descent + 0.5; @@ -1084,7 +1084,7 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &) { XYPOSITION SurfaceImpl::ExternalLeading(Font &font_) { if (!font_.GetID()) return 1; - + float leading = reinterpret_cast<QuartzTextStyle*>( font_.GetID() )->getLeading(); return leading + 0.5; @@ -1097,13 +1097,13 @@ XYPOSITION SurfaceImpl::Height(Font &font_) { } XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { - + if (!font_.GetID()) return 1; - + const int sizeStringLength = (sizeof( sizeString ) / sizeof( sizeString[0] ) - 1); int width = WidthText( font_, sizeString, sizeStringLength ); - + return (int) ((width / (float) sizeStringLength) + 0.5); } @@ -1578,7 +1578,7 @@ private: NSTableColumn* colIcon; NSTableColumn* colText; AutoCompletionDataSource* ds; - + LinesData ld; CallBackAction doubleClickAction; void* doubleClickActionData; @@ -2009,7 +2009,7 @@ void Menu::Show(Point, Window &) ElapsedTime::ElapsedTime() { struct timeval curTime; gettimeofday( &curTime, NULL ); - + bigBit = curTime.tv_sec; littleBit = curTime.tv_usec; } @@ -2075,7 +2075,7 @@ int Platform::DefaultFontSize() */ unsigned int Platform::DoubleClickTime() { - float threshold = [[NSUserDefaults standardUserDefaults] floatForKey: + float threshold = [[NSUserDefaults standardUserDefaults] floatForKey: @"com.apple.mouse.doubleClickThreshold"]; if (threshold == 0) threshold = 0.5; @@ -2094,7 +2094,7 @@ bool Platform::MouseButtonBounce() /** * Helper method for the backend to reach through to the scintilla window. */ -long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) +long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) { return scintilla_send_message(w, msg, wParam, lParam); } @@ -2121,7 +2121,7 @@ bool Platform::IsDBCSLeadByte(int codePage, char ch) // Shift_jis return ((uch >= 0x81) && (uch <= 0x9F)) || ((uch >= 0xE0) && (uch <= 0xFC)); - // Lead bytes F0 to FC may be a Microsoft addition. + // Lead bytes F0 to FC may be a Microsoft addition. case 936: // GBK return (uch >= 0x81) && (uch <= 0xFE); @@ -2185,7 +2185,7 @@ void Platform::DebugPrintf(const char *format, ...) { const int BUF_SIZE = 2000; char buffer[BUF_SIZE]; - + va_list pArguments; va_start(pArguments, format); vsnprintf(buffer, BUF_SIZE, format, pArguments); @@ -2220,7 +2220,7 @@ void Platform::Assert(const char *c, const char *file, int line) sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line); strcat(buffer, "\r\n"); Platform::DebugDisplay(buffer); -#ifdef DEBUG +#ifdef DEBUG // Jump into debugger in assert on Mac (CL269835) ::Debugger(); #endif @@ -2241,7 +2241,7 @@ int Platform::Clamp(int val, int minVal, int maxVal) /** * Implements the platform specific part of library loading. - * + * * @param modulePath The path to the module to load. * @return A library instance or NULL if the module could not be found or another problem occurred. */ diff --git a/cocoa/QuartzTextLayout.h b/cocoa/QuartzTextLayout.h index c789ed10f..edf357682 100644 --- a/cocoa/QuartzTextLayout.h +++ b/cocoa/QuartzTextLayout.h @@ -39,7 +39,7 @@ public: { CFRelease(mLine); mLine = NULL; - } + } } inline void setText( const UInt8* buffer, size_t byteLength, CFStringEncoding encoding, const QuartzTextStyle& r ) @@ -47,19 +47,19 @@ public: CFStringRef str = CFStringCreateWithBytes( NULL, buffer, byteLength, encoding, false ); if (!str) return; - + stringLength = CFStringGetLength(str); CFMutableDictionaryRef stringAttribs = r.getCTStyle(); - + if (mString != NULL) CFRelease(mString); mString = ::CFAttributedStringCreate(NULL, str, stringAttribs); - + if (mLine != NULL) CFRelease(mLine); mLine = ::CTLineCreateWithAttributedString(mString); - + CFRelease( str ); } @@ -70,28 +70,28 @@ public: { if (mLine == NULL) return; - + ::CGContextSetTextMatrix(gc, CGAffineTransformMakeScale(1.0, -1.0)); - + // Set the text drawing position. ::CGContextSetTextPosition(gc, x, y); - + // And finally, draw! ::CTLineDraw(mLine, gc); } - + float MeasureStringWidth() - { + { if (mLine == NULL) return 0.0f; - + return ::CTLineGetTypographicBounds(mLine, NULL, NULL, NULL); } - + CTLineRef getCTLine() { return mLine; } - + CFIndex getStringLength() { return stringLength; } diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 358019b46..9098d2000 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -85,7 +85,7 @@ class ScintillaCocoa : public ScintillaBase private: TimerTarget* timerTarget; NSEvent* lastMouseEvent; - + id<ScintillaNotificationProtocol> delegate; SciNotifyFunc notifyProc; @@ -101,13 +101,13 @@ private: bool GetPasteboardData(NSPasteboard* board, SelectionText* selectedText); void SetPasteboardData(NSPasteboard* board, const SelectionText& selectedText); - + int scrollSpeed; int scrollTicks; NSTimer* tickTimer; NSTimer* idleTimer; CFRunLoopObserverRef observer; - + FindHighlightLayer *layerFindIndicator; protected: @@ -116,7 +116,7 @@ protected: Point ConvertPoint(NSPoint point); virtual void RedrawRect(PRectangle rc); virtual void Redraw(); - + virtual void Initialise(); virtual void Finalise(); virtual CaseFolder *CaseFolderForEncoding(); @@ -173,7 +173,7 @@ public: virtual void ClaimSelection(); NSPoint GetCaretPosition(); - + static sptr_t DirectFunction(ScintillaCocoa *sciThis, unsigned int iMessage, uptr_t wParam, sptr_t lParam); void TimerFired(NSTimer* timer); @@ -203,14 +203,14 @@ public: void DraggingExited(id <NSDraggingInfo> info); bool PerformDragOperation(id <NSDraggingInfo> info); void DragScroll(); - + // Promote some methods needed for NSResponder actions. virtual void SelectAll(); void DeleteBackward(); virtual void Cut(); virtual void Undo(); virtual void Redo(); - + virtual NSMenu* CreateContextMenu(NSEvent* event); void HandleCommand(NSInteger command); diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 53403e698..aaaf63c16 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2,7 +2,7 @@ /** * Scintilla source code edit control * ScintillaCocoa.mm - Cocoa subclass of ScintillaBase - * + * * Written by Mike Lischke <mlischke@sun.com> * * Loosely based on ScintillaMacOSX.cxx. @@ -195,7 +195,7 @@ static const KeyToCommand macMapDefault[] = self.anchorPoint = CGPointMake(0.5, 0.5); } return self; - + } const CGFloat paddingHighlightX = 4; @@ -204,23 +204,23 @@ const CGFloat paddingHighlightY = 2; -(void) drawInContext:(CGContextRef)context { if (!sFind || !sFont) return; - + CFStringRef str = CFStringRef(sFind); - + CFMutableDictionaryRef styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, - &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CGColorRef color = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 1.0); CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, color); CTFontRef fontRef = ::CTFontCreateWithName((CFStringRef)sFont, fontSize, NULL); CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef); - + CFAttributedStringRef attrString = ::CFAttributedStringCreate(NULL, str, styleDict); CTLineRef textLine = ::CTLineCreateWithAttributedString(attrString); // Indent from corner of bounds CGContextSetTextPosition(context, paddingHighlightX, 3 + paddingHighlightY); CTLineDraw(textLine, context); - + CFRelease(textLine); CFRelease(attrString); CFRelease(fontRef); @@ -258,7 +258,7 @@ const CGFloat paddingHighlightY = 2; } [self setNeedsDisplay]; [CATransaction commit]; - + if (bounce) { CABasicAnimation *animBounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; animBounce.duration = 0.15; @@ -266,26 +266,26 @@ const CGFloat paddingHighlightY = 2; animBounce.removedOnCompletion = NO; animBounce.fromValue = [NSNumber numberWithFloat: 1.0]; animBounce.toValue = [NSNumber numberWithFloat: 1.25]; - + if (self.retaining) { - + [self addAnimation: animBounce forKey:@"animateFound"]; - + } else { - + CABasicAnimation *animFade = [CABasicAnimation animationWithKeyPath:@"opacity"]; animFade.duration = 0.1; animFade.beginTime = 0.4; animFade.removedOnCompletion = NO; animFade.fromValue = [NSNumber numberWithFloat: 1.0]; animFade.toValue = [NSNumber numberWithFloat: 0.0]; - + CAAnimationGroup *group = [CAAnimationGroup animation]; [group setDuration:0.5]; group.removedOnCompletion = NO; group.fillMode = kCAFillModeForwards; [group setAnimations:[NSArray arrayWithObjects:animBounce, animFade, nil]]; - + [self addAnimation:group forKey:@"animateFound"]; } } @@ -314,9 +314,9 @@ const CGFloat paddingHighlightY = 2; // Get the default notification queue for the thread which created the instance (usually the // main thread). We need that later for idle event processing. - NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; + NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; notificationQueue = [[NSNotificationQueue alloc] initWithNotificationCenter: center]; - [center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: nil]; + [center addObserver: self selector: @selector(idleTriggered:) name: @"Idle" object: nil]; } return self; } @@ -354,11 +354,11 @@ const CGFloat paddingHighlightY = 2; // Post a new idle notification, which gets executed when the run loop is idle. // Since we are coalescing on name and sender there will always be only one actual notification // even for multiple requests. - NSNotification *notification = [NSNotification notificationWithName: @"Idle" object: self]; + NSNotification *notification = [NSNotification notificationWithName: @"Idle" object: self]; [notificationQueue enqueueNotification: notification postingStyle: NSPostWhenIdle coalesceMask: (NSNotificationCoalescingOnName | NSNotificationCoalescingOnSender) - forModes: nil]; + forModes: nil]; } //-------------------------------------------------------------------------------------------------- @@ -411,20 +411,20 @@ ScintillaCocoa::~ScintillaCocoa() /** * Core initialization of the control. Everything that needs to be set up happens here. */ -void ScintillaCocoa::Initialise() +void ScintillaCocoa::Initialise() { Scintilla_LinkLexers(); - + // Tell Scintilla not to buffer: Quartz buffers drawing for us. WndProc(SCI_SETBUFFEREDDRAW, 0, 0); - + // We are working with Unicode exclusively. WndProc(SCI_SETCODEPAGE, SC_CP_UTF8, 0); // Add Mac specific key bindings. - for (int i = 0; macMapDefault[i].key; i++) + for (int i = 0; macMapDefault[i].key; i++) kmap.AssignCmdKey(macMapDefault[i].key, macMapDefault[i].modifiers, macMapDefault[i].msg); - + } //-------------------------------------------------------------------------------------------------- @@ -507,7 +507,7 @@ static char *EncodedBytes(CFStringRef cfsRef, CFStringEncoding encoding) { CFIndex usedLen = 0; CFStringGetBytes(cfsRef, rangeAll, encoding, '?', false, NULL, 0, &usedLen); - + char *buffer = new char[usedLen+1]; CFStringGetBytes(cfsRef, rangeAll, encoding, '?', false, (UInt8 *)buffer,usedLen, NULL); @@ -533,12 +533,12 @@ public: return 1; } else { CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast<const UInt8 *>(mixed), + reinterpret_cast<const UInt8 *>(mixed), lenMixed, encoding, false); NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch locale:[NSLocale currentLocale]]; - + char *encoded = EncodedBytes((CFStringRef)sMapped, encoding); size_t lenMapped = strlen(encoded); @@ -572,20 +572,20 @@ CaseFolder *ScintillaCocoa::CaseFolderForEncoding() { char sCharacter[2] = "A"; sCharacter[0] = i; CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast<const UInt8 *>(sCharacter), + reinterpret_cast<const UInt8 *>(sCharacter), 1, encoding, false); if (!cfsVal) continue; - + NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch locale:[NSLocale currentLocale]]; - + char *encoded = EncodedBytes((CFStringRef)sMapped, encoding); - + if (strlen(encoded) == 1) { pcf->SetTranslation(sCharacter[0], encoded[0]); } - + delete []encoded; CFRelease(cfsVal); } @@ -607,10 +607,10 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping) { if ((s.size() == 0) || (caseMapping == cmSame)) return s; - + if (IsUnicodeMode()) { std::string retMapped(s.length() * maxExpansionCaseConversion, 0); - size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(), + size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(), (caseMapping == cmUpper) ? CaseConversionUpper : CaseConversionLower); retMapped.resize(lenMapped); return retMapped; @@ -619,7 +619,7 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping) CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); CFStringRef cfsVal = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast<const UInt8 *>(s.c_str()), + reinterpret_cast<const UInt8 *>(s.c_str()), s.length(), encoding, false); NSString *sMapped; @@ -716,7 +716,7 @@ PRectangle ScintillaCocoa::GetClientRectangle() /** * Converts the given point from base coordinates to local coordinates and at the same time into * a native Point structure. Base coordinates are used for the top window used in the view hierarchy. - * Returned value is in view coordinates. + * Returned value is in view coordinates. */ Scintilla::Point ScintillaCocoa::ConvertPoint(NSPoint point) { @@ -757,11 +757,11 @@ void ScintillaCocoa::Redraw() * * @param sciThis The target which is to be called. * @param iMessage A code that indicates which message was sent. - * @param wParam One of the two free parameters for the message. Traditionally a word sized parameter + * @param wParam One of the two free parameters for the message. Traditionally a word sized parameter * (hence the w prefix). * @param lParam The other of the two free parameters. A signed long. */ -sptr_t ScintillaCocoa::DirectFunction(ScintillaCocoa *sciThis, unsigned int iMessage, uptr_t wParam, +sptr_t ScintillaCocoa::DirectFunction(ScintillaCocoa *sciThis, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sciThis->WndProc(iMessage, wParam, lParam); @@ -796,34 +796,34 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar { case SCI_GETDIRECTFUNCTION: return reinterpret_cast<sptr_t>(DirectFunction); - + case SCI_GETDIRECTPOINTER: return reinterpret_cast<sptr_t>(this); - + case SCI_GRABFOCUS: [[ContentView() window] makeFirstResponder:ContentView()]; break; - + case SCI_SETBUFFEREDDRAW: // Buffered drawing not supported on Cocoa bufferedDraw = false; break; - + case SCI_FINDINDICATORSHOW: ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), YES); return 0; - + case SCI_FINDINDICATORFLASH: ShowFindIndicatorForRange(NSMakeRange(wParam, lParam-wParam), NO); return 0; - + case SCI_FINDINDICATORHIDE: HideFindIndicator(); return 0; - + default: sptr_t r = ScintillaBase::WndProc(iMessage, wParam, lParam); - + return r; } return 0l; @@ -832,7 +832,7 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar //-------------------------------------------------------------------------------------------------- /** - * In Windows lingo this is the handler which handles anything that wasn't handled in the normal + * In Windows lingo this is the handler which handles anything that wasn't handled in the normal * window proc which would usually send the message back to generic window proc that Windows uses. */ sptr_t ScintillaCocoa::DefWndProc(unsigned int, uptr_t, sptr_t) @@ -923,7 +923,7 @@ bool ScintillaCocoa::CanPaste() { if (!Editor::CanPaste()) return false; - + return GetPasteboardData([NSPasteboard generalPasteboard], NULL); } @@ -945,11 +945,11 @@ void ScintillaCocoa::Paste(bool forceRectangular) bool ok = GetPasteboardData([NSPasteboard generalPasteboard], &selectedText); if (forceRectangular) selectedText.rectangular = forceRectangular; - + if (!ok || selectedText.Empty()) // No data or no flavor we support. return; - + pdoc->BeginUndoAction(); ClearSelection(false); int length = selectedText.Length(); @@ -963,7 +963,7 @@ void ScintillaCocoa::Paste(bool forceRectangular) InsertPaste(selStart, selectedText.Data(), length); } pdoc->EndUndoAction(); - + Redraw(); EnsureCaretVisible(); } @@ -997,7 +997,7 @@ void ScintillaCocoa::CTPaint(void* gc, NSRect rc) { if (self) { sci = NULL; } - + return self; } @@ -1045,7 +1045,7 @@ void ScintillaCocoa::CallTipMouseDown(NSPoint pt) { void ScintillaCocoa::CreateCallTipWindow(PRectangle rc) { if (!ct.wCallTip.Created()) { NSRect ctRect = NSMakeRect(rc.top,rc.bottom, rc.Width(), rc.Height()); - NSWindow *callTip = [[NSWindow alloc] initWithContentRect: ctRect + NSWindow *callTip = [[NSWindow alloc] initWithContentRect: ctRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO]; @@ -1068,7 +1068,7 @@ void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled) ScintillaContextMenu *menu= reinterpret_cast<ScintillaContextMenu*>(popup.GetID()); [menu setOwner: this]; [menu setAutoenablesItems: NO]; - + if (cmd == 0) { item = [NSMenuItem separatorItem]; } else { @@ -1079,7 +1079,7 @@ void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled) [item setAction: @selector(handleCommand:)]; [item setTag: cmd]; [item setEnabled: enabled]; - + [menu addItem: item]; } @@ -1125,7 +1125,7 @@ void ScintillaCocoa::DragScroll() int line = pdoc->LineFromPosition(posDrag.Position()); int currentVisibleLine = cs.DisplayFromDoc(line); int lastVisibleLine = Platform::Minimum(topLine + LinesOnScreen(), cs.LinesDisplayed()) - 2; - + if (currentVisibleLine <= topLine && topLine > 0) ScrollTo(topLine - scrollSpeed); else @@ -1137,9 +1137,9 @@ void ScintillaCocoa::DragScroll() scrollTicks = 2000; return; } - + // TODO: also handle horizontal scrolling. - + if (scrollSpeed == 1) { scrollTicks -= timer.tickSize; @@ -1149,7 +1149,7 @@ void ScintillaCocoa::DragScroll() scrollTicks = 2000; } } - + } //-------------------------------------------------------------------------------------------------- @@ -1169,7 +1169,7 @@ void ScintillaCocoa::StartDrag() NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName: NSDragPboard]; CopySelectionRange(&selectedText); SetPasteboardData(pasteboard, selectedText); - + // calculate the bounds of the selection PRectangle client = GetTextRectangle(); int selStart = sel.RangeMain().Start().Position(); @@ -1179,13 +1179,13 @@ void ScintillaCocoa::StartDrag() Point pt; long startPos, endPos, ep; PRectangle rcSel; - + if (startLine==endLine && WndProc(SCI_GETWRAPMODE, 0, 0) != SC_WRAP_NONE) { // Komodo bug http://bugs.activestate.com/show_bug.cgi?id=87571 // Scintilla bug https://sourceforge.net/tracker/?func=detail&atid=102439&aid=3040200&group_id=2439 // If the width on a wrapped-line selection is negative, // find a better bounding rectangle. - + Point ptStart, ptEnd; startPos = WndProc(SCI_GETLINESELSTARTPOSITION, startLine, 0); endPos = WndProc(SCI_GETLINESELENDPOSITION, startLine, 0); @@ -1239,16 +1239,16 @@ void ScintillaCocoa::StartDrag() } // must convert to global coordinates for drag regions, but also save the // image rectangle for further calculations and copy operations - + // Prepare drag image. NSRect selectionRectangle = PRectangleToNSRect(rcSel); - + NSView* content = ContentView(); - + // To get a bitmap of the text we're dragging, we just use Paint on a pixmap surface. SurfaceImpl *sw = new SurfaceImpl(); SurfaceImpl *pixmap = NULL; - + bool lastHideSelection = hideSelection; hideSelection = true; if (sw) @@ -1260,23 +1260,23 @@ void ScintillaCocoa::StartDrag() paintState = painting; sw->InitPixMap(client.Width(), client.Height(), NULL, NULL); paintingAllText = true; - // Have to create a new context and make current as text drawing goes + // Have to create a new context and make current as text drawing goes // to the current context, not a passed context. - CGContextRef gcsw = sw->GetContext(); - NSGraphicsContext *nsgc = [NSGraphicsContext graphicsContextWithGraphicsPort: gcsw + CGContextRef gcsw = sw->GetContext(); + NSGraphicsContext *nsgc = [NSGraphicsContext graphicsContextWithGraphicsPort: gcsw flipped: YES]; [NSGraphicsContext setCurrentContext:nsgc]; CGContextTranslateCTM(gcsw, -client.left, -client.top); Paint(sw, client); paintState = notPainting; - + pixmap->InitPixMap(imageRect.Width(), imageRect.Height(), NULL, NULL); - - CGContextRef gc = pixmap->GetContext(); + + CGContextRef gc = pixmap->GetContext(); // To make Paint() work on a bitmap, we have to flip our coordinates and translate the origin CGContextTranslateCTM(gc, 0, imageRect.Height()); CGContextScaleCTM(gc, 1.0, -1.0); - + pixmap->CopyImageRectangle(*sw, imageRect, PRectangle(0, 0, imageRect.Width(), imageRect.Height())); // XXX TODO: overwrite any part of the image that is not part of the // selection to make it transparent. right now we just use @@ -1286,7 +1286,7 @@ void ScintillaCocoa::StartDrag() delete sw; } hideSelection = lastHideSelection; - + NSBitmapImageRep* bitmap = NULL; if (pixmap) { @@ -1296,20 +1296,20 @@ void ScintillaCocoa::StartDrag() pixmap->Release(); delete pixmap; } - + NSImage* image = [[[NSImage alloc] initWithSize: selectionRectangle.size] autorelease]; [image addRepresentation: bitmap]; - + NSImage* dragImage = [[[NSImage alloc] initWithSize: selectionRectangle.size] autorelease]; [dragImage setBackgroundColor: [NSColor clearColor]]; [dragImage lockFocus]; [image drawAtPoint: NSZeroPoint fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 0.5]; [dragImage unlockFocus]; - + NSPoint startPoint; startPoint.x = selectionRectangle.origin.x + client.left; startPoint.y = selectionRectangle.origin.y + selectionRectangle.size.height + client.top; - [content dragImage: dragImage + [content dragImage: dragImage at: startPoint offset: NSZeroSize event: lastMouseEvent // Set in MouseMove. @@ -1337,22 +1337,22 @@ NSDragOperation ScintillaCocoa::DraggingEntered(id <NSDraggingInfo> info) */ NSDragOperation ScintillaCocoa::DraggingUpdated(id <NSDraggingInfo> info) { - // Convert the drag location from window coordinates to view coordinates and + // Convert the drag location from window coordinates to view coordinates and // from there to a text position to finally set the drag position. Point location = ConvertPoint([info draggingLocation]); SetDragPosition(SPositionFromLocation(location)); - + NSDragOperation sourceDragMask = [info draggingSourceOperationMask]; if (sourceDragMask == NSDragOperationNone) return sourceDragMask; - + NSPasteboard* pasteboard = [info draggingPasteboard]; - + // Return what type of operation we will perform. Prefer move over copy. if ([[pasteboard types] containsObject: NSStringPboardType] || [[pasteboard types] containsObject: ScintillaRecPboardType]) return (sourceDragMask & NSDragOperationMove) ? NSDragOperationMove : NSDragOperationCopy; - + if ([[pasteboard types] containsObject: NSFilenamesPboardType]) return (sourceDragMask & NSDragOperationGeneric); return NSDragOperationNone; @@ -1378,7 +1378,7 @@ void ScintillaCocoa::DraggingExited(id <NSDraggingInfo> info) bool ScintillaCocoa::PerformDragOperation(id <NSDraggingInfo> info) { NSPasteboard* pasteboard = [info draggingPasteboard]; - + if ([[pasteboard types] containsObject: NSFilenamesPboardType]) { NSArray* files = [pasteboard propertyListForType: NSFilenamesPboardType]; @@ -1389,12 +1389,12 @@ bool ScintillaCocoa::PerformDragOperation(id <NSDraggingInfo> info) { SelectionText text; GetPasteboardData(pasteboard, &text); - + if (text.Length() > 0) { NSDragOperation operation = [info draggingSourceOperationMask]; bool moving = (operation & NSDragOperationMove) != 0; - + DropAt(posDrag, text.Data(), text.Length(), moving, text.rectangular); }; } @@ -1419,13 +1419,13 @@ void ScintillaCocoa::SetPasteboardData(NSPasteboard* board, const SelectionText [NSArray arrayWithObjects: NSStringPboardType, ScintillaRecPboardType, nil] : [NSArray arrayWithObjects: NSStringPboardType, nil]; [board declareTypes:pbTypes owner:nil]; - + if (selectedText.rectangular) { // This is specific to scintilla, allows us to drag rectangular selections around the document. [board setString: (NSString *)cfsVal forType: ScintillaRecPboardType]; } - + [board setString: (NSString *)cfsVal forType: NSStringPboardType]; if (cfsVal) @@ -1439,12 +1439,12 @@ void ScintillaCocoa::SetPasteboardData(NSPasteboard* board, const SelectionText */ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selectedText) { - NSArray* supportedTypes = [NSArray arrayWithObjects: ScintillaRecPboardType, - NSStringPboardType, + NSArray* supportedTypes = [NSArray arrayWithObjects: ScintillaRecPboardType, + NSStringPboardType, nil]; NSString *bestType = [board availableTypeFromArray: supportedTypes]; NSString* data = [board stringForType: bestType]; - + if (data != nil) { if (selectedText != nil) @@ -1457,7 +1457,7 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selec false, NULL, 0, &usedLen); std::vector<UInt8> buffer(usedLen); - + CFStringGetBytes((CFStringRef)data, rangeAll, encoding, '?', false, buffer.data(),usedLen, NULL); @@ -1471,7 +1471,7 @@ bool ScintillaCocoa::GetPasteboardData(NSPasteboard* board, SelectionText* selec } return true; } - + return false; } @@ -1744,7 +1744,7 @@ void ScintillaCocoa::NotifyFocus(bool focus) * @param scn The notification to send. */ void ScintillaCocoa::NotifyParent(SCNotification scn) -{ +{ scn.nmhdr.hwndFrom = (void*) this; scn.nmhdr.idFrom = GetCtrlID(); if (notifyProc != NULL) @@ -1760,7 +1760,7 @@ void ScintillaCocoa::NotifyURIDropped(const char *uri) SCNotification scn; scn.nmhdr.code = SCN_URIDROPPED; scn.text = uri; - + NotifyParent(scn); } @@ -1817,7 +1817,7 @@ bool ScintillaCocoa::Draw(NSRect rect, CGContextRef gc) } //-------------------------------------------------------------------------------------------------- - + /** * Helper function to translate OS X key codes to Scintilla key codes. */ @@ -1863,7 +1863,7 @@ static inline UniChar KeyTranslate(UniChar unicodeChar) //-------------------------------------------------------------------------------------------------- /** - * Translate NSEvent modifier flags into SCI_* modifier flags. + * Translate NSEvent modifier flags into SCI_* modifier flags. * * @param modifiers An integer bit set of NSSEvent modifier flags. * @return A set of SCI_* modifier flags. @@ -1882,7 +1882,7 @@ static int TranslateModifierFlags(NSUInteger modifiers) /** * Main keyboard input handling method. It is called for any key down event, including function keys, - * numeric keypad input and whatnot. + * numeric keypad input and whatnot. * * @param event The event instance associated with the key down event. * @return True if the input was handled, false otherwise. @@ -1891,23 +1891,23 @@ bool ScintillaCocoa::KeyboardInput(NSEvent* event) { // For now filter out function keys. NSString* input = [event characters]; - + bool handled = false; - + // Handle each entry individually. Usually we only have one entry anyway. for (size_t i = 0; i < input.length; i++) { const UniChar originalKey = [input characterAtIndex: i]; UniChar key = KeyTranslate(originalKey); - + bool consumed = false; // Consumed as command? - + if (KeyDownWithModifiers(key, TranslateModifierFlags([event modifierFlags]), &consumed)) handled = true; if (consumed) handled = true; } - + return handled; } @@ -1924,12 +1924,12 @@ int ScintillaCocoa::InsertText(NSString* input) CFIndex usedLen = 0; CFStringGetBytes((CFStringRef)input, rangeAll, encoding, '?', false, NULL, 0, &usedLen); - + std::vector<UInt8> buffer(usedLen); - + CFStringGetBytes((CFStringRef)input, rangeAll, encoding, '?', false, buffer.data(),usedLen, NULL); - + AddCharUTF((char*) buffer.data(), static_cast<unsigned int>(usedLen), false); return static_cast<int>(usedLen); } @@ -1974,7 +1974,7 @@ void ScintillaCocoa::MouseEntered(NSEvent* event) if (!HaveMouseCapture()) { WndProc(SCI_SETCURSOR, (long int)SC_CURSORNORMAL, 0); - + // Mouse location is given in screen coordinates and might also be outside of our bounds. Point location = ConvertPoint([event locationInWindow]); ButtonMove(location); @@ -1997,7 +1997,7 @@ void ScintillaCocoa::MouseDown(NSEvent* event) bool command = ([event modifierFlags] & NSCommandKeyMask) != 0; bool shift = ([event modifierFlags] & NSShiftKeyMask) != 0; bool alt = ([event modifierFlags] & NSAlternateKeyMask) != 0; - + ButtonDown(Point(location.x, location.y), (int) (time * 1000), shift, command, alt); } @@ -2027,13 +2027,13 @@ void ScintillaCocoa::MouseWheel(NSEvent* event) bool command = ([event modifierFlags] & NSCommandKeyMask) != 0; int dY = 0; - // In order to make scrolling with larger offset smoother we scroll less lines the larger the + // In order to make scrolling with larger offset smoother we scroll less lines the larger the // delta value is. if ([event deltaY] < 0) dY = -(int) sqrt(-10.0 * [event deltaY]); else dY = (int) sqrt(10.0 * [event deltaY]); - + if (command) { // Zoom! We play with the font sizes in the styles. @@ -2086,7 +2086,7 @@ NSMenu* ScintillaCocoa::CreateContextMenu(NSEvent* /* event */) { // Call ScintillaBase to create the context menu. ContextMenu(Point(0, 0)); - + return reinterpret_cast<NSMenu*>(popup.GetID()); } @@ -2139,16 +2139,16 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining [[content layer] addSublayer:layerFindIndicator]; } [layerFindIndicator removeAnimationForKey:@"animateFound"]; - + if (charRange.length) { CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); std::vector<char> buffer(charRange.length); pdoc->GetCharRange(&buffer[0], charRange.location, charRange.length); - + CFStringRef cfsFind = CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast<const UInt8 *>(&buffer[0]), + reinterpret_cast<const UInt8 *>(&buffer[0]), charRange.length, encoding, false); layerFindIndicator.sFind = (NSString *)cfsFind; if (cfsFind) @@ -2159,8 +2159,8 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining std::vector<char> bufferFontName(WndProc(SCI_STYLEGETFONT, style, 0) + 1); WndProc(SCI_STYLEGETFONT, style, (sptr_t)&bufferFontName[0]); layerFindIndicator.sFont = [NSString stringWithUTF8String: &bufferFontName[0]]; - - layerFindIndicator.fontSize = WndProc(SCI_STYLEGETSIZEFRACTIONAL, style, 0) / + + layerFindIndicator.fontSize = WndProc(SCI_STYLEGETSIZEFRACTIONAL, style, 0) / (float)SC_FONT_SIZE_MULTIPLIER; layerFindIndicator.widthText = WndProc(SCI_POINTXFROMPOSITION, 0, charRange.location + charRange.length) - WndProc(SCI_POINTXFROMPOSITION, 0, charRange.location); diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h index 39c008a61..51d60e9d5 100644 --- a/cocoa/ScintillaView.h +++ b/cocoa/ScintillaView.h @@ -98,15 +98,15 @@ extern NSString *const SCIUpdateUINotification; // The back end is kind of a controller and model in one. // It uses the content view for display. Scintilla::ScintillaCocoa* mBackend; - + // This is the actual content to which the backend renders itself. SCIContentView* mContent; - + NSScrollView *scrollView; SCIMarginView *marginView; - + CGFloat zoomDelta; - + // Area to display additional controls (e.g. zoom info, caret position, status info). NSView <InfoBarCommunicator>* mInfoBar; BOOL mInfoBarAtTop; diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 9bc0a5d1c..2db8fae12 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -80,7 +80,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) setFrame: (NSRect) frame { [super setFrame: frame]; - + [[self window] invalidateCursorRectsForView: self]; } @@ -131,7 +131,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) resetCursorRects { [super resetCursorRects]; - + int x = 0; NSRect marginRect = [self bounds]; size_t co = [currentCursors count]; @@ -160,18 +160,18 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSView*) initWithFrame: (NSRect) frame { self = [super initWithFrame: frame]; - + if (self != nil) { // Some initialization for our view. mCurrentCursor = [[NSCursor arrowCursor] retain]; mCurrentTrackingRect = 0; mMarkedTextRange = NSMakeRange(NSNotFound, 0); - + [self registerForDraggedTypes: [NSArray arrayWithObjects: NSStringPboardType, ScintillaRecPboardType, NSFilenamesPboardType, nil]]; } - + return self; } @@ -219,7 +219,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) resetCursorRects { [super resetCursorRects]; - + // We only have one cursor rect: our bounds. [self addCursorRect: [self bounds] cursor: mCurrentCursor]; [mCurrentCursor setOnMouseEntered: YES]; @@ -233,7 +233,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) drawRect: (NSRect) rect { CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; - + if (!mOwner.backend->Draw(rect, context)) { dispatch_async(dispatch_get_main_queue(), ^{ [self setNeedsDisplay:YES]; @@ -245,7 +245,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) /** * Windows uses a client coordinate system where the upper left corner is the origin in a window - * (and so does Scintilla). We have to adjust for that. However by returning YES here, we are + * (and so does Scintilla). We have to adjust for that. However by returning YES here, we are * already done with that. * Note that because of returning YES here most coordinates we use now (e.g. for painting, * invalidating rectangles etc.) are given with +Y pointing down! @@ -396,7 +396,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) newText = (NSString*) aString; else if ([aString isKindOfClass:[NSAttributedString class]]) newText = (NSString*) [aString string]; - + mOwner.backend->InsertText(newText); } @@ -435,7 +435,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) else if ([aString isKindOfClass:[NSAttributedString class]]) newText = (NSString*) [aString string]; - + long currentPosition = [mOwner getGeneralProperty: SCI_GETCURRENTPOS parameter: 0]; // Replace marked text if there is one. @@ -443,7 +443,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { [mOwner setGeneralProperty: SCI_SETSELECTIONSTART value: mMarkedTextRange.location]; - [mOwner setGeneralProperty: SCI_SETSELECTIONEND + [mOwner setGeneralProperty: SCI_SETSELECTIONEND value: mMarkedTextRange.location + mMarkedTextRange.length]; currentPosition = mMarkedTextRange.location; } @@ -474,7 +474,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) mMarkedTextRange.location = currentPosition; mMarkedTextRange.length = lengthInserted; - + if (lengthInserted > 0) { // Mark the just inserted text. Keep the marked range for later reset. @@ -516,7 +516,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) value: mMarkedTextRange.length]; mMarkedTextRange = NSMakeRange(NSNotFound, 0); - // Reenable undo action collection, after we are done with text composition. + // Reenable undo action collection, after we are done with text composition. if (undoCollectionWasActive) [mOwner setGeneralProperty: SCI_SETUNDOCOLLECTION value: 1]; } @@ -534,12 +534,12 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) // We have already marked text. Replace that. [mOwner setGeneralProperty: SCI_SETSELECTIONSTART value: mMarkedTextRange.location]; - [mOwner setGeneralProperty: SCI_SETSELECTIONEND + [mOwner setGeneralProperty: SCI_SETSELECTIONEND value: mMarkedTextRange.location + mMarkedTextRange.length]; mOwner.backend->InsertText(@""); mMarkedTextRange = NSMakeRange(NSNotFound, 0); - // Reenable undo action collection, after we are done with text composition. + // Reenable undo action collection, after we are done with text composition. if (undoCollectionWasActive) [mOwner setGeneralProperty: SCI_SETUNDOCOLLECTION value: 1]; } @@ -571,7 +571,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) //-------------------------------------------------------------------------------------------------- -- (void) mouseDown: (NSEvent *) theEvent +- (void) mouseDown: (NSEvent *) theEvent { mOwner.backend->MouseDown(theEvent); } @@ -674,7 +674,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) //-------------------------------------------------------------------------------------------------- /** - * Called when an external drag operation enters the view. + * Called when an external drag operation enters the view. */ - (NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender { @@ -713,7 +713,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender { - return mOwner.backend->PerformDragOperation(sender); + return mOwner.backend->PerformDragOperation(sender); } //-------------------------------------------------------------------------------------------------- @@ -867,11 +867,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) if (self == [ScintillaView class]) { NSBundle* bundle = [NSBundle bundleForClass: [ScintillaView class]]; - + NSString* path = [bundle pathForResource: @"mac_cursor_busy" ofType: @"tiff" inDirectory: nil]; NSImage* image = [[[NSImage alloc] initWithContentsOfFile: path] autorelease]; waitCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(2, 2)]; - + path = [bundle pathForResource: @"mac_cursor_flipped" ofType: @"tiff" inDirectory: nil]; image = [[[NSImage alloc] initWithContentsOfFile: path] autorelease]; reverseArrowCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(12, 2)]; @@ -903,7 +903,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) long zoomFactor = [self getGeneralProperty: SCI_GETZOOM] + zoomDelta; [self setGeneralProperty: SCI_SETZOOM parameter: zoomFactor value:0]; zoomDelta = 0.0; - } + } #endif } @@ -983,14 +983,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) notification: (Scintilla::SCNotification*)scn { // Parent notification. Details are passed as SCNotification structure. - + if (mDelegate != nil) { [mDelegate notification: scn]; if (scn->nmhdr.code != SCN_ZOOM && scn->nmhdr.code != SCN_UPDATEUI) return; } - + switch (scn->nmhdr.code) { case SCN_MARGINCLICK: @@ -1075,26 +1075,26 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [scrollView setHasHorizontalRuler:NO]; [scrollView setHasVerticalRuler:YES]; [scrollView setRulersVisible:YES]; - + mBackend = new ScintillaCocoa(mContent, marginView); // Establish a connection from the back end to this container so we can handle situations // which require our attention. mBackend->SetDelegate(self); - - // Setup a special indicator used in the editor to provide visual feedback for + + // Setup a special indicator used in the editor to provide visual feedback for // input composition, depending on language, keyboard etc. [self setColorProperty: SCI_INDICSETFORE parameter: INPUT_INDICATOR fromHTML: @"#FF0000"]; [self setGeneralProperty: SCI_INDICSETUNDER parameter: INPUT_INDICATOR value: 1]; [self setGeneralProperty: SCI_INDICSETSTYLE parameter: INPUT_INDICATOR value: INDIC_PLAIN]; [self setGeneralProperty: SCI_INDICSETALPHA parameter: INPUT_INDICATOR value: 100]; - + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; [center addObserver:self selector:@selector(applicationDidResignActive:) name:NSApplicationDidResignActiveNotification object:nil]; - + [center addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification @@ -1138,9 +1138,9 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) viewDidMoveToWindow { [super viewDidMoveToWindow]; - + [self positionSubViews]; - + // Enable also mouse move events for our window (and so this view). [[self window] setAcceptsMouseMovedEvents: YES]; } @@ -1232,7 +1232,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSString*) selectedString { NSString *result = @""; - + const long length = mBackend->WndProc(SCI_GETSELTEXT, 0, 0); if (length > 0) { @@ -1240,14 +1240,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) try { mBackend->WndProc(SCI_GETSELTEXT, length + 1, (sptr_t) &buffer[0]); - + result = [NSString stringWithUTF8String: buffer.c_str()]; } catch (...) { } } - + return result; } @@ -1260,7 +1260,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (NSString*) string { NSString *result = @""; - + const long length = mBackend->WndProc(SCI_GETLENGTH, 0, 0); if (length > 0) { @@ -1268,14 +1268,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) try { mBackend->WndProc(SCI_GETTEXT, length + 1, (sptr_t) &buffer[0]); - + result = [NSString stringWithUTF8String: buffer.c_str()]; } catch (...) { } } - + return result; } @@ -1422,7 +1422,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) */ - (long) getGeneralProperty: (int) property ref: (const void*) ref { - return mBackend->WndProc(property, 0, (sptr_t) ref); + return mBackend->WndProc(property, 0, (sptr_t) ref); } //-------------------------------------------------------------------------------------------------- @@ -1437,7 +1437,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) long red = [value redComponent] * 255; long green = [value greenComponent] * 255; long blue = [value blueComponent] * 255; - + long color = (blue << 16) + (green << 8) + red; mBackend->WndProc(property, parameter, color); } @@ -1454,7 +1454,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { bool longVersion = [fromHTML length] > 6; int index = 1; - + char value[3] = {0, 0, 0}; value[0] = [fromHTML characterAtIndex: index++]; if (longVersion) @@ -1470,7 +1470,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) value[1] = [fromHTML characterAtIndex: index++]; else value[1] = value[0]; - + unsigned rawGreen; [[NSScanner scannerWithString: [NSString stringWithUTF8String: value]] scanHexInt: &rawGreen]; @@ -1479,7 +1479,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) value[1] = [fromHTML characterAtIndex: index++]; else value[1] = value[0]; - + unsigned rawBlue; [[NSScanner scannerWithString: [NSString stringWithUTF8String: value]] scanHexInt: &rawBlue]; @@ -1593,7 +1593,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) if (mInfoBar != newBar) { [mInfoBar removeFromSuperview]; - + mInfoBar = newBar; mInfoBarAtTop = top; if (mInfoBar != nil) @@ -1601,7 +1601,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [self addSubview: mInfoBar]; [mInfoBar setCallback: self]; } - + [self positionSubViews]; } } @@ -1672,7 +1672,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) int selectionStart = [self getGeneralProperty: SCI_GETSELECTIONSTART parameter: 0]; int selectionEnd = [self getGeneralProperty: SCI_GETSELECTIONEND parameter: 0]; - + // Sets the start point for the coming search to the beginning of the current selection. // For forward searches we have therefore to set the selection start to the current selection end // for proper incremental search. This does not harm as we either get a new selection if something @@ -1772,7 +1772,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) const char* replacement = [newText UTF8String]; int targetLength = strlen(replacement); // Length in bytes. sptr_t result; - + int replaceCount = 0; if (doAll) { @@ -1818,7 +1818,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [self setGeneralProperty: SCI_SETSELECTIONEND value: [self getGeneralProperty: SCI_GETTARGETEND]]; } } - + return replaceCount; } |