diff options
| -rw-r--r-- | cocoa/PlatCocoa.mm | 2 | ||||
| -rw-r--r-- | doc/ScintillaDoc.html | 11 | ||||
| -rw-r--r-- | include/Scintilla.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 3 | ||||
| -rw-r--r-- | src/Editor.cxx | 7 | ||||
| -rw-r--r-- | src/Editor.h | 1 | ||||
| -rw-r--r-- | src/Indicator.cxx | 2 | ||||
| -rw-r--r-- | src/LineMarker.cxx | 12 | ||||
| -rw-r--r-- | src/LineMarker.h | 2 | ||||
| -rw-r--r-- | src/XPM.cxx | 5 | ||||
| -rw-r--r-- | src/XPM.h | 6 | 
11 files changed, 36 insertions, 16 deletions
| diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index d5cddb5b5..a4584528f 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -675,7 +675,7 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char  void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {  	CGImageRef image = ImageCreateFromRGBA(width, height, pixelsImage, true);  	if (image) { -		CGRect drawRect = CGRectMake(rc.left, rc.top, width, height); +		CGRect drawRect = CGRectMake(rc.left, rc.top, rc.Width(), rc.Height());  		CGContextDrawImage(gc, drawRect, image);  		CGImageRelease(image);  	} diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 2ab2d7f03..e0dc42bad 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -79,7 +79,7 @@      <h1>Scintilla Documentation</h1> -    <p>Last edited 15/July/2012 NH</p> +    <p>Last edited 21/July/2012 NH</p>      <p>There is <a class="jump" href="Design.html">an overview of the internal design of      Scintilla</a>.<br /> @@ -3365,6 +3365,7 @@ struct Sci_TextToFind {      const char *xpm)</a><br />       <a class="message" href="#SCI_RGBAIMAGESETWIDTH">SCI_RGBAIMAGESETWIDTH(int width)</a><br />       <a class="message" href="#SCI_RGBAIMAGESETHEIGHT">SCI_RGBAIMAGESETHEIGHT(int height)</a><br /> +     <a class="message" href="#SCI_RGBAIMAGESETSCALE">SCI_RGBAIMAGESETSCALE(int scalePercent)</a><br />       <a class="message" href="#SCI_MARKERDEFINERGBAIMAGE">SCI_MARKERDEFINERGBAIMAGE(int markerNumber,      const char *pixels)</a><br />       <a class="message" href="#SCI_MARKERSYMBOLDEFINED">SCI_MARKERSYMBOLDEFINED(int markerNumber) @@ -3554,12 +3555,16 @@ struct Sci_TextToFind {      <p>      <b id="SCI_RGBAIMAGESETWIDTH">SCI_RGBAIMAGESETWIDTH(int width)</b><br />      <b id="SCI_RGBAIMAGESETHEIGHT">SCI_RGBAIMAGESETHEIGHT(int height)</b><br /> +    <b id="SCI_RGBAIMAGESETSCALE">SCI_RGBAIMAGESETSCALE(int scalePercent)</b><br />      <b id="SCI_MARKERDEFINERGBAIMAGE">SCI_MARKERDEFINERGBAIMAGE(int markerNumber, const char *pixels)</b><br />       Markers can be set to translucent pixmaps with this message. The        <a class="jump" href="#RGBA">RGBA format</a> is used for the pixmap.       The width and height must previously been set with the <code>SCI_RGBAIMAGESETWIDTH</code> and  -     <code>SCI_RGBAIMAGESETHEIGHT</code> messages. -    Pixmaps use the <code>SC_MARK_RGBAIMAGE</code> marker symbol. </p> +     <code>SCI_RGBAIMAGESETHEIGHT</code> messages.</p> +     <p>A scale factor in percent may be set with <code>SCI_RGBAIMAGESETSCALE</code>. This is useful on OS X with +     a retina display where each display unit is 2 pixels: use a factor of 200 so that each image pixel is dsplayed using a screen pixel. +     The default scale, 100, will stretch each image pixel to cover 4 screen pixels on a retina display.</p> +    <p>Pixmaps use the <code>SC_MARK_RGBAIMAGE</code> marker symbol. </p>      <p><b id="SCI_MARKERSYMBOLDEFINED">SCI_MARKERSYMBOLDEFINED(int markerNumber)</b><br />       Returns the symbol defined for a markerNumber with <code>SCI_MARKERDEFINE</code> diff --git a/include/Scintilla.h b/include/Scintilla.h index 52d6eed15..4d467a175 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -837,6 +837,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SCI_GETIDENTIFIER 2623  #define SCI_RGBAIMAGESETWIDTH 2624  #define SCI_RGBAIMAGESETHEIGHT 2625 +#define SCI_RGBAIMAGESETSCALE 2651  #define SCI_MARKERDEFINERGBAIMAGE 2626  #define SCI_REGISTERRGBAIMAGE 2627  #define SCI_SCROLLTOSTART 2628 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index ef35fe6a4..e31863cfd 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2221,6 +2221,9 @@ set void RGBAImageSetWidth=2624(int width,)  # Set the height for future RGBA image data.  set void RGBAImageSetHeight=2625(int height,) +# Set the scale factor in percent for future RGBA image data. +set void RGBAImageSetScale=2651(int scalePercent,) +  # Define a marker from RGBA data.  # It has the width and height from RGBAImageSetWidth/Height  fun void MarkerDefineRGBAImage=2626(int markerNumber, string pixels) diff --git a/src/Editor.cxx b/src/Editor.cxx index 44226d11b..c3f1b984e 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -104,6 +104,7 @@ Editor::Editor() {  	stylesValid = false;  	technology = SC_TECHNOLOGY_DEFAULT; +	scaleRGBAImage = 100;  	printMagnification = 0;  	printColourMode = SC_PRINT_NORMAL; @@ -8159,9 +8160,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		sizeRGBAImage.y = wParam;  		break; +	case SCI_RGBAIMAGESETSCALE: +		scaleRGBAImage = wParam; +		break; +  	case SCI_MARKERDEFINERGBAIMAGE:  		if (wParam <= MARKER_MAX) { -			vs.markers[wParam].SetRGBAImage(sizeRGBAImage, reinterpret_cast<unsigned char *>(lParam)); +			vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0, reinterpret_cast<unsigned char *>(lParam));  			vs.CalcLargestMarkerHeight();  		};  		InvalidateStyleData(); diff --git a/src/Editor.h b/src/Editor.h index 00e4ec3a6..0ae1f115f 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -133,6 +133,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	ViewStyle vs;  	int technology;  	Point sizeRGBAImage; +	float scaleRGBAImage;  	int printMagnification;  	int printColourMode; diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 9ea4024bb..bd17c3d1c 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -95,7 +95,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r  		rcBox.right = rc.right;  		// Cap width at 4000 to avoid large allocations when mistakes made  		int width = Platform::Minimum(rcBox.Width(), 4000); -		RGBAImage image(width, rcBox.Height(), 0); +		RGBAImage image(width, rcBox.Height(), 1.0, 0);  		// Draw horizontal lines top and bottom  		for (int x=0; x<width; x++) {  			for (int y=0; y<rcBox.Height(); y += rcBox.Height()-1) { diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index 99e83265e..9b7f1cddc 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -32,9 +32,9 @@ void LineMarker::SetXPM(const char *const *linesForm) {  	markType = SC_MARK_PIXMAP;  } -void LineMarker::SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRGBAImage) { +void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage) {  	delete image; -	image = new RGBAImage(sizeRGBAImage.x, sizeRGBAImage.y, pixelsRGBAImage); +	image = new RGBAImage(sizeRGBAImage.x, sizeRGBAImage.y, scale, pixelsRGBAImage);  	markType = SC_MARK_RGBAIMAGE;  } @@ -99,10 +99,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac  	if ((markType == SC_MARK_RGBAIMAGE) && (image)) {  		// Make rectangle just large enough to fit image centred on centre of rcWhole  		PRectangle rcImage; -		rcImage.top = static_cast<int>(((rcWhole.top + rcWhole.bottom) - image->GetHeight()) / 2); -		rcImage.bottom = rcImage.top + image->GetHeight(); -		rcImage.left = static_cast<int>(((rcWhole.left + rcWhole.right) - image->GetWidth()) / 2); -		rcImage.right = rcImage.left + image->GetWidth(); +		rcImage.top = static_cast<int>(((rcWhole.top + rcWhole.bottom) - image->GetScaledHeight()) / 2); +		rcImage.bottom = rcImage.top + image->GetScaledHeight(); +		rcImage.left = static_cast<int>(((rcWhole.left + rcWhole.right) - image->GetScaledWidth()) / 2); +		rcImage.right = rcImage.left + image->GetScaledWidth();  		surface->DrawRGBAImage(rcImage, image->GetWidth(), image->GetHeight(), image->Pixels());  		return;  	} diff --git a/src/LineMarker.h b/src/LineMarker.h index 5c73a6217..e226ef5f5 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -66,7 +66,7 @@ public:  	}  	void SetXPM(const char *textForm);  	void SetXPM(const char *const *linesForm); -	void SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRGBAImage); +	void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage);  	void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle);  }; diff --git a/src/XPM.cxx b/src/XPM.cxx index db48ea227..7188c2465 100644 --- a/src/XPM.cxx +++ b/src/XPM.cxx @@ -319,8 +319,8 @@ int XPMSet::GetWidth() {  	return (width > 0) ? width : 0;  } -RGBAImage::RGBAImage(int width_, int height_, const unsigned char *pixels_) : -	height(height_), width(width_) { +RGBAImage::RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_) : +	height(height_), width(width_), scale(scale_) {  	if (pixels_) {  		pixelBytes.assign(pixels_, pixels_ + CountBytes());  	} else { @@ -331,6 +331,7 @@ RGBAImage::RGBAImage(int width_, int height_, const unsigned char *pixels_) :  RGBAImage::RGBAImage(const XPM &xpm) {  	height = xpm.GetHeight();  	width = xpm.GetWidth(); +	scale = 1;  	pixelBytes.resize(CountBytes());  	for (int y=0; y<height; y++) {  		for (int x=0; x<width; x++) { @@ -80,13 +80,17 @@ class RGBAImage {  	RGBAImage &operator=(const RGBAImage &);  	int height;  	int width; +	float scale;  	std::vector<unsigned char> pixelBytes;  public: -	RGBAImage(int width_, int height_, const unsigned char *pixels_); +	RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_);  	RGBAImage(const XPM &xpm);  	virtual ~RGBAImage();  	int GetHeight() const { return height; }  	int GetWidth() const { return width; } +	float GetScale() const { return scale; } +	float GetScaledHeight() const { return height / scale; } +	float GetScaledWidth() const { return width / scale; }  	int CountBytes() const;  	const unsigned char *Pixels() const;  	void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);  | 
