From 0c39c1292e6d4a176e0b146e743d2ba1578b173f Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 4 Apr 2019 10:53:56 -0400 Subject: [PATCH] Remove wx/dc.h from ImageRoll.h ... ... I wish I could just forward-declare the enumeration wxRasterOperationMode, but it's not defined as a sized enum --- src/widgets/ImageRoll.cpp | 27 +++++++++++++++++---------- src/widgets/ImageRoll.h | 12 +++++++----- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/widgets/ImageRoll.cpp b/src/widgets/ImageRoll.cpp index acdff5d2f..917bf1151 100644 --- a/src/widgets/ImageRoll.cpp +++ b/src/widgets/ImageRoll.cpp @@ -297,20 +297,27 @@ bool ImageRoll::Ok() const } void ImageRoll::DrawBitmap(wxDC &dc, wxBitmap &bitmap, - int x, int y, wxRasterOperationMode logicalFunc) + int x, int y, int logicalFunc) { - if (logicalFunc == wxCOPY) + auto func = static_cast< wxRasterOperationMode >( logicalFunc ); + if (func == wxCOPY) dc.DrawBitmap(bitmap, x, y); else { wxMemoryDC memDC; memDC.SelectObject(bitmap); dc.Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), - &memDC, 0, 0, logicalFunc); + &memDC, 0, 0, func); } } -void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logicalFunc)) +void ImageRoll::Draw(wxDC &dc, wxRect rect) { + Draw( dc, rect, wxCOPY ); +} + +void ImageRoll::Draw(wxDC &dc, wxRect rect, int WXUNUSED(logicalFunc)) +{ + auto func = wxCOPY; int width = rect.width; int height = rect.height; int num = (int)mPieces.size(); @@ -335,7 +342,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic // fixed if (mPieces[i].Ok()) - DrawBitmap(dc, mPieces[i], rect.x + x, rect.y); + DrawBitmap(dc, mPieces[i], rect.x + x, rect.y, func); x += w; } else { @@ -348,7 +355,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic j = 0; while(j < space) { if (mPieces[i].Ok()) - DrawBitmap(dc, mPieces[i], rect.x + x + j, rect.y); + DrawBitmap(dc, mPieces[i], rect.x + x + j, rect.y, func); j += w; } @@ -375,7 +382,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic // fixed if (mPieces[i].Ok()) - DrawBitmap(dc, mPieces[i], rect.x, rect.y + y); + DrawBitmap(dc, mPieces[i], rect.x, rect.y + y, func); y += h; } else { @@ -388,7 +395,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic j = 0; while(j < space) { if (mPieces[i].Ok()) - DrawBitmap(dc, mPieces[i], rect.x, rect.y + y + j); + DrawBitmap(dc, mPieces[i], rect.x, rect.y + y + j, func); j += h; } @@ -398,7 +405,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic } break; // case VerticalRoll case FixedImage: - DrawBitmap(dc, mPieces[0], rect.x, rect.y); + DrawBitmap(dc, mPieces[0], rect.x, rect.y, func); break; /* the other possible cases don't really make sense, but not having them * listed gives a GCC warning */ @@ -432,7 +439,7 @@ ImageRollPanel::ImageRollPanel(wxWindow *parent, // mImageRoll.GetMaxSize()); } -void ImageRollPanel::SetLogicalFunction(wxRasterOperationMode func) +void ImageRollPanel::SetLogicalFunction(int /*wxRasterOperationMode*/ func) { mLogicalFunction = func; } diff --git a/src/widgets/ImageRoll.h b/src/widgets/ImageRoll.h index 943b9bfda..915f5804c 100644 --- a/src/widgets/ImageRoll.h +++ b/src/widgets/ImageRoll.h @@ -13,7 +13,7 @@ #define __AUDACITY_IMAGE_ROLL__ #include -#include // for enum wxRasterOperationMode +// #include // for enum wxRasterOperationMode #include #include "wxPanelWrapper.h" // to inherit @@ -45,7 +45,8 @@ class ImageRoll wxSize GetMaxSize() const { return mMaxSize; } void Draw(wxDC &dc, wxRect rect, - wxRasterOperationMode logicalFunc = wxCOPY); + int /* wxRasterOperationMode */ logicalFunc); + void Draw(wxDC &dc, wxRect rect); // default logicalFunc to wxCOPY static ImageArray SplitH(const wxImage &src, wxColour magicColor); static ImageArray SplitV(const wxImage &src, wxColour magicColor); @@ -53,7 +54,8 @@ class ImageRoll protected: void DrawBitmap(wxDC &dc, wxBitmap &bitmap, - int x, int y, wxRasterOperationMode logicalFunc = wxCOPY); + int x, int y, + int /* wxRasterOperationMode */ logicalFunc); void Init(RollType type, const wxImage &src, wxColour magicColor); @@ -78,7 +80,7 @@ class ImageRollPanel final : public wxPanelWrapper const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL); - void SetLogicalFunction(wxRasterOperationMode func); + void SetLogicalFunction(int /*wxRasterOperationMode*/ func); void OnPaint(wxPaintEvent &evt); void OnSize(wxSizeEvent &evt); @@ -86,7 +88,7 @@ class ImageRollPanel final : public wxPanelWrapper protected: //ImageRoll mImageRoll; - wxRasterOperationMode mLogicalFunction; + int /*wxRasterOperationMode*/ mLogicalFunction; DECLARE_EVENT_TABLE()