diff options
Diffstat (limited to 'cocoa')
| -rw-r--r-- | cocoa/PlatCocoa.h | 24 | ||||
| -rw-r--r-- | cocoa/PlatCocoa.mm | 53 | ||||
| -rw-r--r-- | cocoa/QuartzTextStyleAttribute.h | 3 | ||||
| -rw-r--r-- | cocoa/ScintillaCocoa.mm | 4 | ||||
| -rw-r--r-- | cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj | 4 | ||||
| -rw-r--r-- | cocoa/ScintillaTest/AppController.mm | 2 | 
6 files changed, 48 insertions, 42 deletions
| diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index 0e3c5f2e2..7f6a59705 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -96,20 +96,20 @@ public:    void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage);    void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);    void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource); -  void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, +  void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore,                       ColourAllocated back); -  void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore,  +  void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore,                         ColourAllocated back); -  void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore); -  void MeasureWidths(Font &font_, const char *s, int len, int *positions); -  int WidthText(Font &font_, const char *s, int len); -  int WidthChar(Font &font_, char ch); -  int Ascent(Font &font_); -  int Descent(Font &font_); -  int InternalLeading(Font &font_); -  int ExternalLeading(Font &font_); -  int Height(Font &font_); -  int AverageCharWidth(Font &font_); +  void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourAllocated fore); +  void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); +  XYPOSITION WidthText(Font &font_, const char *s, int len); +  XYPOSITION WidthChar(Font &font_, char ch); +  XYPOSITION Ascent(Font &font_); +  XYPOSITION Descent(Font &font_); +  XYPOSITION InternalLeading(Font &font_); +  XYPOSITION ExternalLeading(Font &font_); +  XYPOSITION Height(Font &font_); +  XYPOSITION AverageCharWidth(Font &font_);    int SetPalette(Scintilla::Palette *pal, bool inBackGround);    void SetClip(PRectangle rc); diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index fd66f671f..ce112f853 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -156,8 +156,7 @@ static int FontCharacterSet(Font &f) {  /**   * Creates a CTFontRef with the given properties.   */ -void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic,  -                  int /* extraFontFlag */) +void Font::Create(const FontParameters &fp)  {  	Release(); @@ -165,9 +164,9 @@ void Font::Create(const char *faceName, int characterSet, int size, bool bold, b  	fid = style;  	// Create the font with attributes -	QuartzFont font(faceName, strlen(faceName), size, bold, italic); +	QuartzFont font(fp.faceName, strlen(fp.faceName), fp.size, fp.weight, fp.italic);  	CTFontRef fontRef = font.getFontID(); -	style->setFontRef(fontRef, characterSet); +	style->setFontRef(fontRef, fp.characterSet);  }  //-------------------------------------------------------------------------------------------------- @@ -507,6 +506,9 @@ void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back)    if (gc)    {      FillColour(back); +    // Snap rectangle boundaries to nearest int +    rc.left = lround(rc.left); +    rc.right = lround(rc.right);      CGRect rect = PRectangleToCGRect(rc);      CGContextFillRect(gc, rect);    } @@ -641,7 +643,10 @@ void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, int /*cornerSize*/, C  {    if ( gc ) {      ColourDesired colour( fill.AsLong() ); -     +  +    // Snap rectangle boundaries to nearest int +    rc.left = lround(rc.left); +    rc.right = lround(rc.right);      // Set the Fill color to match      CGContextSetRGBFillColor( gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, colour.GetBlue() / 255.0, alphaFill / 255.0 );      CGRect rect = PRectangleToCGRect( rc ); @@ -836,7 +841,7 @@ void SurfaceImpl::Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSou  //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, +void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,                                   ColourAllocated fore, ColourAllocated back)  {    FillRectangle(rc, back); @@ -845,7 +850,7 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const ch  //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, +void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,                                    ColourAllocated fore, ColourAllocated back)  {    CGContextSaveGState(gc); @@ -913,7 +918,7 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet)    }  } -void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len,  +void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len,                                         ColourAllocated fore)  {  	CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); @@ -943,7 +948,7 @@ static size_t utf8LengthFromLead(unsigned char uch) {  //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) +void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)  {  	CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_));  	textLayout->setText (reinterpret_cast<const UInt8*>(s), len, encoding, *reinterpret_cast<QuartzTextStyle*>(font_.GetID())); @@ -962,7 +967,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi  			size_t codeUnits = (lenChar < 4) ? 1 : 2;  			CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, ui+1, NULL);  			for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) { -				positions[i++] = static_cast<int>(lround(xPosition)); +				positions[i++] = xPosition;  			}  			ui += codeUnits;  		} @@ -978,20 +983,20 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi  			size_t lenChar = Platform::IsDBCSLeadByte(codePage, s[i]) ? 2 : 1;  			CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, ui+1, NULL);  			for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) { -				positions[i++] = static_cast<int>(lround(xPosition)); +				positions[i++] = xPosition;  			}  			ui++;  		}  	} else {	// Single byte encoding  		for (int i=0;i<len;i++) {  			CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, i+1, NULL); -			positions[i] = static_cast<int>(lround(xPosition)); +			positions[i] = xPosition;  		}  	}  } -int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { +XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) {    if (font_.GetID())    {      CFStringEncoding encoding = EncodingFromCharacterSet(unicodeMode, FontCharacterSet(font_)); @@ -1002,7 +1007,7 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {    return 1;  } -int SurfaceImpl::WidthChar(Font &font_, char ch) { +XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) {    char str[2] = { ch, '\0' };    if (font_.GetID())    { @@ -1019,7 +1024,7 @@ int SurfaceImpl::WidthChar(Font &font_, char ch) {  const char sizeString[] = "`~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890"  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -int SurfaceImpl::Ascent(Font &font_) { +XYPOSITION SurfaceImpl::Ascent(Font &font_) {    if (!font_.GetID())      return 1; @@ -1028,7 +1033,7 @@ int SurfaceImpl::Ascent(Font &font_) {  } -int SurfaceImpl::Descent(Font &font_) { +XYPOSITION SurfaceImpl::Descent(Font &font_) {    if (!font_.GetID())      return 1; @@ -1037,11 +1042,11 @@ int SurfaceImpl::Descent(Font &font_) {  } -int SurfaceImpl::InternalLeading(Font &) { +XYPOSITION SurfaceImpl::InternalLeading(Font &) {    return 0;  } -int SurfaceImpl::ExternalLeading(Font &font_) { +XYPOSITION SurfaceImpl::ExternalLeading(Font &font_) {    if (!font_.GetID())      return 1; @@ -1050,13 +1055,13 @@ int SurfaceImpl::ExternalLeading(Font &font_) {  } -int SurfaceImpl::Height(Font &font_) { +XYPOSITION SurfaceImpl::Height(Font &font_) {  	int ht = Ascent(font_) + Descent(font_);  	return ht;  } -int SurfaceImpl::AverageCharWidth(Font &font_) { +XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) {    if (!font_.GetID())      return 1; @@ -1089,7 +1094,7 @@ void SurfaceImpl::SetDBCSMode(int codePage_) {      codePage = codePage_;  } -Surface *Surface::Allocate() +Surface *Surface::Allocate(int)  {    return new SurfaceImpl();  } @@ -1368,7 +1373,7 @@ static NSImage* ImageFromXPM(XPM* pxpm)      const int width = pxpm->GetWidth();      const int height = pxpm->GetHeight();      PRectangle rcxpm(0, 0, width, height); -    Surface* surfaceXPM = Surface::Allocate(); +    Surface* surfaceXPM = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);      if (surfaceXPM)      {        surfaceXPM->InitPixMap(width, height, NULL, NULL); @@ -1510,7 +1515,7 @@ public:    // ListBox methods    void SetFont(Font& font); -  void Create(Window& parent, int ctrlID, Scintilla::Point pt, int lineHeight_, bool unicodeMode_); +  void Create(Window& parent, int ctrlID, Scintilla::Point pt, int lineHeight_, bool unicodeMode_, int technology_);    void SetAverageCharWidth(int width);    void SetVisibleRows(int rows);    int GetVisibleRows() const; @@ -1595,7 +1600,7 @@ ListBox* ListBox::Allocate()  }  void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt, -    int lineHeight_, bool unicodeMode_) +    int lineHeight_, bool unicodeMode_, int)  {    lineHeight = lineHeight_;    unicodeMode = unicodeMode_; diff --git a/cocoa/QuartzTextStyleAttribute.h b/cocoa/QuartzTextStyleAttribute.h index 33c49281c..b9698645e 100644 --- a/cocoa/QuartzTextStyleAttribute.h +++ b/cocoa/QuartzTextStyleAttribute.h @@ -16,12 +16,13 @@ class QuartzFont  {  public:      /** Create a font style from a name. */ -	QuartzFont( const char* name, size_t length, float size, bool bold, bool italic ) +	QuartzFont( const char* name, size_t length, float size, int weight, bool italic )      {          assert( name != NULL && length > 0 && name[length] == '\0' );  		CFStringRef fontName = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingMacRoman);  		assert(fontName != NULL); +	        bool bold = weight > SC_WEIGHT_NORMAL;  		if (bold || italic)  		{ diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 089568d66..7927652a7 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -702,7 +702,7 @@ void ScintillaCocoa::Paste(bool forceRectangular)  void ScintillaCocoa::CTPaint(void* gc, NSRect rc) {  #pragma unused(rc) -    Surface *surfaceWindow = Surface::Allocate(); +    Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);      if (surfaceWindow) {          surfaceWindow->Init(gc, wMain.GetID());          surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ct.codePage); @@ -1251,7 +1251,7 @@ void ScintillaCocoa::SyncPaint(void* gc, PRectangle rc)    rcPaint = rc;    PRectangle rcText = GetTextRectangle();    paintingAllText = rcPaint.Contains(rcText); -  Surface *sw = Surface::Allocate(); +  Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);    if (sw)    {      sw->Init(gc, wMain.GetID()); diff --git a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj index 7765983a8..5ec9eb93a 100644 --- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj +++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj @@ -955,7 +955,7 @@  					SCI_LEXER,  				);  				GCC_VERSION = com.apple.compilers.llvmgcc42; -				GCC_WARN_UNINITIALIZED_AUTOS = YES; +				GCC_WARN_UNINITIALIZED_AUTOS = NO;  				GCC_WARN_UNKNOWN_PRAGMAS = YES;  				GCC_WARN_UNUSED_FUNCTION = YES;  				GCC_WARN_UNUSED_LABEL = YES; @@ -984,7 +984,7 @@  					SCI_LEXER,  				);  				GCC_VERSION = com.apple.compilers.llvmgcc42; -				GCC_WARN_UNINITIALIZED_AUTOS = YES; +				GCC_WARN_UNINITIALIZED_AUTOS = NO;  				GCC_WARN_UNKNOWN_PRAGMAS = YES;  				GCC_WARN_UNUSED_FUNCTION = YES;  				GCC_WARN_UNUSED_LABEL = YES; diff --git a/cocoa/ScintillaTest/AppController.mm b/cocoa/ScintillaTest/AppController.mm index 24941ffe2..294704f02 100644 --- a/cocoa/ScintillaTest/AppController.mm +++ b/cocoa/ScintillaTest/AppController.mm @@ -116,7 +116,7 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL.    [mEditor setReferenceProperty: SCI_SETKEYWORDS parameter: 7 value: user_keywords];    // Colors and styles for various syntactic elements. First the default style. -  [mEditor setStringProperty: SCI_STYLESETFONT parameter: STYLE_DEFAULT value: @"Andale Mono"]; +  [mEditor setStringProperty: SCI_STYLESETFONT parameter: STYLE_DEFAULT value: @"Helvetica"];    // [mEditor setStringProperty: SCI_STYLESETFONT parameter: STYLE_DEFAULT value: @"Monospac821 BT"]; // Very pleasing programmer's font.    [mEditor setGeneralProperty: SCI_STYLESETSIZE parameter: STYLE_DEFAULT value: 14];    [mEditor setColorProperty: SCI_STYLESETFORE parameter: STYLE_DEFAULT value: [NSColor blackColor]]; | 
