aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cocoa/PlatCocoa.mm41
-rw-r--r--cocoa/ScintillaCocoa.mm4
2 files changed, 15 insertions, 30 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index bbc8ba35c..3de8139ea 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -73,21 +73,6 @@ inline CGRect PRectangleToCGRect(PRectangle& rc)
return CGRectMake(rc.left, rc.top, rc.Width(), rc.Height());
}
-//--------------------------------------------------------------------------------------------------
-
-/**
- * Converts a Quartz-style rectangle to a PRectangle structure as used by Scintilla.
- */
-inline PRectangle CGRectToPRectangle(const CGRect& rect)
-{
- PRectangle rc;
- rc.left = (int)(rect.origin.x + 0.5);
- rc.top = (int)(rect.origin.y + 0.5);
- rc.right = (int)(rect.origin.x + rect.size.width + 0.5);
- rc.bottom = (int)(rect.origin.y + rect.size.height + 0.5);
- return rc;
-}
-
//----------------- Font ---------------------------------------------------------------------------
Font::Font(): fid(0)
@@ -319,7 +304,7 @@ CGImageRef SurfaceImpl::GetImage()
{
// For now, assume that GetImage can only be called on PixMap surfaces.
if (!bitmapData)
- return nullptr;
+ return NULL;
CGContextFlush(gc);
@@ -328,8 +313,8 @@ CGImageRef SurfaceImpl::GetImage()
if( colorSpace == NULL )
return NULL;
- const int bitmapBytesPerRow = ((int) bitmapWidth * BYTES_PER_PIXEL);
- const int bitmapByteCount = (bitmapBytesPerRow * (int) bitmapHeight);
+ const int bitmapBytesPerRow = bitmapWidth * BYTES_PER_PIXEL;
+ const int bitmapByteCount = bitmapBytesPerRow * bitmapHeight;
// Make a copy of the bitmap data for the image creation and divorce it
// From the SurfaceImpl lifetime
@@ -719,8 +704,8 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char
// Create an RGB color space.
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (colorSpace) {
- const int bitmapBytesPerRow = ((int) width * 4);
- const int bitmapByteCount = (bitmapBytesPerRow * (int) height);
+ const int bitmapBytesPerRow = width * 4;
+ const int bitmapByteCount = bitmapBytesPerRow * height;
// Create a data provider.
CGDataProviderRef dataProvider = 0;
@@ -791,8 +776,8 @@ void SurfaceImpl::CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect,
CGRect dst = PRectangleToCGRect(dstRect);
/* source from QuickDrawToQuartz2D.pdf on developer.apple.com */
- float w = (float) CGImageGetWidth(image);
- float h = (float) CGImageGetHeight(image);
+ const float w = static_cast<float>(CGImageGetWidth(image));
+ const float h = static_cast<float>(CGImageGetHeight(image));
CGRect drawRect = CGRectMake (0, 0, w, h);
if (!CGRectEqualToRect (src, dst))
{
@@ -1051,7 +1036,7 @@ XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) {
const int sizeStringLength = ELEMENTS( sizeString );
XYPOSITION width = WidthText( font_, sizeString, sizeStringLength );
- return (int) ((width / (float) sizeStringLength) + 0.5);
+ return round(width / sizeStringLength);
}
void SurfaceImpl::SetClip(PRectangle rc) {
@@ -1751,8 +1736,8 @@ void ListBoxImpl::SetList(const char* list, char separator, char typesep)
Clear();
size_t count = strlen(list) + 1;
std::vector<char> words(list, list+count);
- char* startword = words.data();
- char* numword = NULL;
+ char *startword = words.data();
+ char *numword = nullptr;
int i = 0;
for (; words[i]; i++)
{
@@ -1763,7 +1748,7 @@ void ListBoxImpl::SetList(const char* list, char separator, char typesep)
*numword = '\0';
Append(startword, numword?atoi(numword + 1):-1);
startword = words.data() + i + 1;
- numword = NULL;
+ numword = nullptr;
}
else if (words[i] == typesep)
{
@@ -2086,12 +2071,12 @@ void Platform::Assert(const char *c, const char *file, int line)
* 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.
+ * @return A library instance or nullptr if the module could not be found or another problem occurred.
*/
DynamicLibrary* DynamicLibrary::Load(const char* /* modulePath */)
{
// Not implemented.
- return NULL;
+ return nullptr;
}
//--------------------------------------------------------------------------------------------------
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 39f0a9726..74113a364 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -2477,9 +2477,9 @@ void ScintillaCocoa::MouseWheel(NSEvent* event)
// 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]);
+ dY = -static_cast<int>(sqrt(-10.0 * [event deltaY]));
else
- dY = (int) sqrt(10.0 * [event deltaY]);
+ dY = static_cast<int>(sqrt(10.0 * [event deltaY]));
if (command)
{