1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 17:39:25 +02:00

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
This commit is contained in:
Paul Licameli 2019-04-04 10:53:56 -04:00
parent 5f218a4ab4
commit 0c39c1292e
2 changed files with 24 additions and 15 deletions

View File

@ -297,20 +297,27 @@ bool ImageRoll::Ok() const
} }
void ImageRoll::DrawBitmap(wxDC &dc, wxBitmap &bitmap, 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); dc.DrawBitmap(bitmap, x, y);
else { else {
wxMemoryDC memDC; wxMemoryDC memDC;
memDC.SelectObject(bitmap); memDC.SelectObject(bitmap);
dc.Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), 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 width = rect.width;
int height = rect.height; int height = rect.height;
int num = (int)mPieces.size(); int num = (int)mPieces.size();
@ -335,7 +342,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic
// fixed // fixed
if (mPieces[i].Ok()) 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; x += w;
} }
else { else {
@ -348,7 +355,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic
j = 0; j = 0;
while(j < space) { while(j < space) {
if (mPieces[i].Ok()) 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; j += w;
} }
@ -375,7 +382,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic
// fixed // fixed
if (mPieces[i].Ok()) 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; y += h;
} }
else { else {
@ -388,7 +395,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic
j = 0; j = 0;
while(j < space) { while(j < space) {
if (mPieces[i].Ok()) 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; j += h;
} }
@ -398,7 +405,7 @@ void ImageRoll::Draw(wxDC &dc, wxRect rect, wxRasterOperationMode WXUNUSED(logic
} break; // case VerticalRoll } break; // case VerticalRoll
case FixedImage: case FixedImage:
DrawBitmap(dc, mPieces[0], rect.x, rect.y); DrawBitmap(dc, mPieces[0], rect.x, rect.y, func);
break; break;
/* the other possible cases don't really make sense, but not having them /* the other possible cases don't really make sense, but not having them
* listed gives a GCC warning */ * listed gives a GCC warning */
@ -432,7 +439,7 @@ ImageRollPanel::ImageRollPanel(wxWindow *parent,
// mImageRoll.GetMaxSize()); // mImageRoll.GetMaxSize());
} }
void ImageRollPanel::SetLogicalFunction(wxRasterOperationMode func) void ImageRollPanel::SetLogicalFunction(int /*wxRasterOperationMode*/ func)
{ {
mLogicalFunction = func; mLogicalFunction = func;
} }

View File

@ -13,7 +13,7 @@
#define __AUDACITY_IMAGE_ROLL__ #define __AUDACITY_IMAGE_ROLL__
#include <vector> #include <vector>
#include <wx/dc.h> // for enum wxRasterOperationMode // #include <wx/dc.h> // for enum wxRasterOperationMode
#include <wx/defs.h> #include <wx/defs.h>
#include "wxPanelWrapper.h" // to inherit #include "wxPanelWrapper.h" // to inherit
@ -45,7 +45,8 @@ class ImageRoll
wxSize GetMaxSize() const { return mMaxSize; } wxSize GetMaxSize() const { return mMaxSize; }
void Draw(wxDC &dc, wxRect rect, 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 SplitH(const wxImage &src, wxColour magicColor);
static ImageArray SplitV(const wxImage &src, wxColour magicColor); static ImageArray SplitV(const wxImage &src, wxColour magicColor);
@ -53,7 +54,8 @@ class ImageRoll
protected: protected:
void DrawBitmap(wxDC &dc, wxBitmap &bitmap, 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); void Init(RollType type, const wxImage &src, wxColour magicColor);
@ -78,7 +80,7 @@ class ImageRollPanel final : public wxPanelWrapper
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL); long style = wxTAB_TRAVERSAL);
void SetLogicalFunction(wxRasterOperationMode func); void SetLogicalFunction(int /*wxRasterOperationMode*/ func);
void OnPaint(wxPaintEvent &evt); void OnPaint(wxPaintEvent &evt);
void OnSize(wxSizeEvent &evt); void OnSize(wxSizeEvent &evt);
@ -86,7 +88,7 @@ class ImageRollPanel final : public wxPanelWrapper
protected: protected:
//ImageRoll mImageRoll; //ImageRoll mImageRoll;
wxRasterOperationMode mLogicalFunction; int /*wxRasterOperationMode*/ mLogicalFunction;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()