diff --git a/src/Control/Map.cpp b/src/Control/Map.cpp index fb604b95..fae65ecc 100644 --- a/src/Control/Map.cpp +++ b/src/Control/Map.cpp @@ -161,15 +161,15 @@ END_EVENT_MAP() // CMapView() constructor // ******************************************************************** CMapView::CMapView() - : _vals("AZ0CY1EX2GV3IT4KR5MP6ON7QL8SJ9UH0WF1DB2"), +: _vals("AZ0CY1EX2GV3IT4KR5MP6ON7QL8SJ9UH0WF1DB2"), _valsLen(39), _isSnapshot(false), - _brushBlue(Gdiplus::Color::Blue), - _brushBlack(Gdiplus::Color::Black), - _brushWhite(Gdiplus::Color::White), - _brushLightGray(Gdiplus::Color::LightGray), - _penGray(Gdiplus::Color::Gray), - _brushGray(Gdiplus::Color::Gray), - _penDarkGray(Gdiplus::Color::DarkSlateGray), + _brushBlue(NULL), + _brushBlack(NULL), + _brushWhite(NULL), + _brushLightGray(NULL), + _brushGray(NULL), + _penGray(NULL), + _penDarkGray(NULL), _propertyExchange(NULL), _bufferBitmap(NULL), _tilesBitmap(NULL), @@ -231,6 +231,14 @@ void CMapView::Startup() { InitializeIIDs(&IID_DMap, &IID_DMapEvents); + _brushBlue = new Gdiplus::SolidBrush(Gdiplus::Color::Blue); + _brushBlack = new Gdiplus::SolidBrush(Gdiplus::Color::Black); + _brushWhite = new Gdiplus::SolidBrush(Gdiplus::Color::White); + _brushLightGray = new Gdiplus::SolidBrush(Gdiplus::Color::LightGray); + _brushGray = new Gdiplus::SolidBrush(Gdiplus::Color::Gray); + _penGray = new Gdiplus::Pen(Gdiplus::Color::Gray); + _penDarkGray = new Gdiplus::Pen(Gdiplus::Color::DarkSlateGray); + Utility::InitGdiPlusFont(&_fontCourier, L"Courier New", 9.0f); Utility::InitGdiPlusFont(&_fontArial, L"Arial", 9.0f); _fontCourierSmall = new Gdiplus::Font(L"Courier New", 8.0f); diff --git a/src/Control/Map.h b/src/Control/Map.h index 0b08e3d5..4812614f 100644 --- a/src/Control/Map.h +++ b/src/Control/Map.h @@ -761,13 +761,14 @@ class CMapView : public COleControl, IMapViewCallback Gdiplus::Bitmap* _moveBitmap; // shapes being moved are rendered to this bitmap Gdiplus::Bitmap* _tempBitmap; // to scale contents of the rest bitmaps - Gdiplus::SolidBrush _brushBlue; - Gdiplus::SolidBrush _brushBlack; - Gdiplus::SolidBrush _brushWhite; - Gdiplus::SolidBrush _brushLightGray; - Gdiplus::SolidBrush _brushGray; - Gdiplus::Pen _penGray; - Gdiplus::Pen _penDarkGray; + Gdiplus::SolidBrush* _brushBlue; + Gdiplus::SolidBrush* _brushBlack; + Gdiplus::SolidBrush* _brushWhite; + Gdiplus::SolidBrush* _brushLightGray; + Gdiplus::SolidBrush* _brushGray; + Gdiplus::Pen* _penGray; + Gdiplus::Pen* _penDarkGray; + Gdiplus::Font* _fontCourier; Gdiplus::Font* _fontCourierSmall; Gdiplus::Font* _fontCourierLink; diff --git a/src/Control/Map_Scalebar.cpp b/src/Control/Map_Scalebar.cpp index a43696f2..82801d11 100644 --- a/src/Control/Map_Scalebar.cpp +++ b/src/Control/Map_Scalebar.cpp @@ -258,12 +258,12 @@ void CMapView::DrawScaleBar(Gdiplus::Graphics* g) for(size_t i = 0; i < parts.size(); i++) { - g->FillRectangle(&_brushWhite, parts[i]->X - 2, parts[i]->Y - 2, parts[i]->Width + 4, parts[i]->Height + 4); + g->FillRectangle(_brushWhite, parts[i]->X - 2, parts[i]->Y - 2, parts[i]->Width + 4, parts[i]->Height + 4); } for(size_t i = 0; i < parts.size(); i++) { - g->FillRectangle(&_brushBlack, parts[i]->X - 1, parts[i]->Y - 1, parts[i]->Width + 2, parts[i]->Height + 2); + g->FillRectangle(_brushBlack, parts[i]->X - 1, parts[i]->Y - 1, parts[i]->Width + 2, parts[i]->Height + 2); } for(size_t i = 0; i < parts.size(); i++) @@ -289,19 +289,19 @@ void CMapView::DrawScaleBar(Gdiplus::Graphics* g) { s.Format(L"0"); Gdiplus::PointF point(xPadding + 4.0f, -4.0f); - DrawStringWithShade(g, s, &font, point, &_brushBlack, &_brushWhite); + DrawStringWithShade(g, s, &font, point, _brushBlack, _brushWhite); // max FormatUnits(s, step, power, count); point.X = (Gdiplus::REAL)(step * count/unitsPerPixel + xPadding + 3 + 1.0f); point.Y = -4.0f; - DrawStringWithShade(g, s, &font, point, &_brushBlack, &_brushWhite); + DrawStringWithShade(g, s, &font, point, _brushBlack, _brushWhite); // units s = Utility::GetLocalizedUnitsText(targetUnits); point.X = (Gdiplus::REAL)(step * count/unitsPerPixel + xPadding + 3 + 1.0f); point.Y = (Gdiplus::REAL)(barHeight - yPadding - 12 + 1.0f); - DrawStringWithShade(g, s, &font, point, &_brushBlack, &_brushWhite); + DrawStringWithShade(g, s, &font, point, _brushBlack, _brushWhite); } else { @@ -309,12 +309,12 @@ void CMapView::DrawScaleBar(Gdiplus::Graphics* g) USES_CONVERSION; s.Format(L"%s %s", FormatUnits(s, step, power, count), Utility::GetLocalizedUnitsText(targetUnits)); Gdiplus::PointF point(xPadding + 8.0f, -10.0f); - DrawStringWithShade(g, s, &font, point, &_brushBlack, &_brushWhite); + DrawStringWithShade(g, s, &font, point, _brushBlack, _brushWhite); // miles s.Format(L"%s %s", FormatUnits(s, step2, power2, count2), Utility::GetLocalizedUnitsText(targetUnits2)); point.Y = 8.0f; - DrawStringWithShade(g, s, &font, point, &_brushBlack, &_brushWhite); + DrawStringWithShade(g, s, &font, point, _brushBlack, _brushWhite); } g->SetTextRenderingHint(hint); g->ResetTransform(); @@ -365,12 +365,12 @@ void CMapView::ShowRedrawTime(Gdiplus::Graphics* g, float time, bool layerRedraw _copyrightRect.Y += point.Y; //bool active = _copyrightRect.Contains((Gdiplus::REAL)mousePnt.x, (Gdiplus::REAL)mousePnt.y); - Gdiplus::SolidBrush* textBrush = _copyrightLinkActive ? &_brushBlue : &_brushBlack; + Gdiplus::SolidBrush* textBrush = _copyrightLinkActive ? _brushBlue : _brushBlack; Gdiplus::Font* font = _copyrightLinkActive ? _fontCourierLink : _fontCourierSmall; format.SetAlignment(Gdiplus::StringAlignmentCenter); format.SetLineAlignment(Gdiplus::StringAlignmentCenter); - g->FillRectangle(&_brushLightGray, _copyrightRect); + g->FillRectangle(_brushLightGray, _copyrightRect); g->DrawString(s.GetString(), s.GetLength(), font, _copyrightRect, &format, textBrush); } } @@ -386,7 +386,7 @@ void CMapView::ShowRedrawTime(Gdiplus::Graphics* g, float time, bool layerRedraw { point.X = (float)(_viewWidth - rect.Width); point.Y = (float)(_viewHeight - rect.Height - _copyrightRect.Height - 3); - DrawStringWithShade(g, s, _fontCourierSmall, point, &_brushBlack, &_brushWhite); + DrawStringWithShade(g, s, _fontCourierSmall, point, _brushBlack, _brushWhite); } } @@ -407,7 +407,7 @@ void CMapView::ShowRedrawTime(Gdiplus::Graphics* g, float time, bool layerRedraw { point.X = (float)(_viewWidth - rect.Width - 10); point.Y = _showCoordinates != cdmNone ? 10.0f + rect.Height : 10.0f; - DrawStringWithShade(g, s, _fontCourier, point, &_brushBlack, &_brushWhite); + DrawStringWithShade(g, s, _fontCourier, point, _brushBlack, _brushWhite); } } gstate.RestoreTextRenderingHint(g); @@ -524,8 +524,8 @@ void CMapView::DrawZoombar(Gdiplus::Graphics* g) BOOL highlight = _zoombarParts.PlusButton.PtInRect(pnt); g->TranslateTransform(x, y); DrawGradientShadowForPath(path, g); - g->FillPath(&_brushWhite, &path); - g->DrawPath( highlight ? &_penDarkGray : &_penGray, &path); + g->FillPath(_brushWhite, &path); + g->DrawPath( highlight ? _penDarkGray : _penGray, &path); g->SetTransform(&m); // lower minus button @@ -533,17 +533,17 @@ void CMapView::DrawZoombar(Gdiplus::Graphics* g) highlight = _zoombarParts.MinusButton.PtInRect(pnt); g->TranslateTransform(x, y + height); DrawGradientShadowForPath(path, g); - g->FillPath(&_brushWhite, &path); - g->DrawPath(highlight ? &_penDarkGray : &_penGray, &path); + g->FillPath(_brushWhite, &path); + g->DrawPath(highlight ? _penDarkGray : _penGray, &path); g->SetTransform(&m); // plus sign g->SetPixelOffsetMode(Gdiplus::PixelOffsetMode::PixelOffsetModeHighQuality); - g->FillRectangle(&_brushGray, x + 5.0f, y + 8.0f, 8.0f, 2.0f); - g->FillRectangle(&_brushGray, x + 8.0f, y + 5.0f, 2.0f, 8.0f); + g->FillRectangle(_brushGray, x + 5.0f, y + 8.0f, 8.0f, 2.0f); + g->FillRectangle(_brushGray, x + 8.0f, y + 5.0f, 2.0f, 8.0f); // minus sign - g->FillRectangle(&_brushGray, x + 5.0f, y + height + 8.0f, 8.0f, 2.0f); + g->FillRectangle(_brushGray, x + 5.0f, y + height + 8.0f, 8.0f, 2.0f); g->SetPixelOffsetMode(pixelOffsetMode); @@ -631,9 +631,9 @@ void CMapView::DrawZoombar(Gdiplus::Graphics* g) Gdiplus::SolidBrush tooltipBrush(Gdiplus::Color(255, 255, 255)/*Gdiplus::Color(246, 212, 178 )*/); tooltipBox.Inflate(9.0f, 5.0f); g->FillRectangle(&tooltipBrush, tooltipBox); - g->DrawRectangle(&_penGray, tooltipBox); + g->DrawRectangle(_penGray, tooltipBox); tooltipBox.Inflate(-9.0f, -5.0f); - g->DrawString(s, s.GetLength(), _fontArial, tooltipOrigin, &_brushBlack ); + g->DrawString(s, s.GetLength(), _fontArial, tooltipOrigin, _brushBlack ); } } @@ -648,8 +648,8 @@ void CMapView::DrawZoombar(Gdiplus::Graphics* g) path3.AddRectangle(line); DrawGradientShadowForPath(path3, g); - g->FillRectangle(&_brushWhite, line); - g->DrawRectangle(highlight && !handleHighlight ? &_penDarkGray : &_penGray, line); + g->FillRectangle(_brushWhite, line); + g->DrawRectangle(highlight && !handleHighlight ? _penDarkGray : _penGray, line); // notches for zoom levels @@ -659,7 +659,7 @@ void CMapView::DrawZoombar(Gdiplus::Graphics* g) for (int i = 1; i < maxZoom - minZoom; i++) { float tempY = (float)(int)(y + boxSize + lineOffset + step * i + 0.5); - g->FillRectangle(&_brushGray, tempX, tempY, 4.0f, 1.0f); + g->FillRectangle(_brushGray, tempX, tempY, 4.0f, 1.0f); } g->SetPixelOffsetMode(pixelOffsetMode); @@ -678,15 +678,15 @@ void CMapView::DrawZoombar(Gdiplus::Graphics* g) // drawing the handle g->TranslateTransform(x, handleY); // boxSize/4.0 = center of handle is the position DrawGradientShadowForPath(path2, g); - g->FillPath(&_brushWhite, &path2); - g->DrawPath(handleHighlight ? &_penDarkGray : &_penGray, &path2); + g->FillPath(_brushWhite, &path2); + g->DrawPath(handleHighlight ? _penDarkGray : _penGray, &path2); g->SetTransform(&m); // minus sign g->SetPixelOffsetMode(Gdiplus::PixelOffsetMode::PixelOffsetModeHighQuality); - g->FillRectangle(&_brushGray, x + 5.0f, handleY + 4.0f, 8.0f, 2.0f); + g->FillRectangle(_brushGray, x + 5.0f, handleY + 4.0f, 8.0f, 2.0f); g->SetPixelOffsetMode(pixelOffsetMode); - _penDarkGray.SetWidth(1.0f); + _penDarkGray->SetWidth(1.0f); } // ****************************************************************