Audacity  2.2.2
ImageRoll.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ImageRoll.h
6 
7  Dominic Mazzoni
8 
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_IMAGE_ROLL__
13 #define __AUDACITY_IMAGE_ROLL__
14 
15 #include <vector>
16 #include <wx/dc.h>
17 #include <wx/dcclient.h>
18 #include <wx/defs.h>
19 #include <wx/version.h>
20 #include "wxPanelWrapper.h"
21 
22 #if !wxCHECK_VERSION(3,0,0)
23 #define wxRasterOperationMode int
24 #endif
25 
26 // wxImage copies cheaply with reference counting
27 using ImageArray = std::vector<wxImage>;
28 
29 class ImageRoll
30 {
31  public:
32  enum RollType {
38  };
39 
40  ImageRoll();
41  ImageRoll(const wxImage &src);
42  ImageRoll(RollType type, const wxImage &src, wxColour magicColor);
43 
44  bool Ok() const;
45 
46  wxSize GetMinSize() const { return mMinSize; }
47  wxSize GetMaxSize() const { return mMaxSize; }
48 
49  void Draw(wxDC &dc, wxRect rect,
50  wxRasterOperationMode logicalFunc = wxCOPY);
51 
52  static ImageArray SplitH(const wxImage &src, wxColour magicColor);
53  static ImageArray SplitV(const wxImage &src, wxColour magicColor);
54 
55  protected:
56 
57  void DrawBitmap(wxDC &dc, wxBitmap &bitmap,
58  int x, int y, wxRasterOperationMode logicalFunc = wxCOPY);
59 
60  void Init(RollType type, const wxImage &src, wxColour magicColor);
61 
63  // wxBitmap copies cheaply with reference counting
64  std::vector<wxBitmap> mPieces;
65  wxSize mMinSize;
66  wxSize mMaxSize;
67 };
68 
69 // A very simple class that just display an ImageRoll that doesn't
70 // do anything
71 class ImageRollPanel final : public wxPanelWrapper
72 {
73  public:
74  DECLARE_DYNAMIC_CLASS(ImageRollPanel)
75 
76  ImageRollPanel(wxWindow *parent,
77  wxWindowID id,
78  //ImageRoll &imgRoll,
79  const wxPoint& pos = wxDefaultPosition,
80  const wxSize& size = wxDefaultSize,
81  long style = wxTAB_TRAVERSAL);
82 
84 
85  void OnPaint(wxPaintEvent &evt);
86  void OnSize(wxSizeEvent &evt);
87 
88  protected:
89  //ImageRoll mImageRoll;
90 
92 
93  DECLARE_EVENT_TABLE()
94 
95 };
96 
97 #endif // __AUDACITY_IMAGE_ROLL__
wxSize mMaxSize
Definition: ImageRoll.h:66
void SetLogicalFunction(wxRasterOperationMode func)
Definition: ImageRoll.cpp:435
ImageRollPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Definition: ImageRoll.cpp:421
void OnPaint(wxPaintEvent &evt)
Definition: ImageRoll.cpp:440
wxRasterOperationMode mLogicalFunction
Definition: ImageRoll.h:91
bool Ok() const
Definition: ImageRoll.cpp:294
std::vector< wxBitmap > mPieces
Definition: ImageRoll.h:64
wxSize GetMinSize() const
Definition: ImageRoll.h:46
std::vector< wxImage > ImageArray
Definition: ImageRoll.h:27
static ImageArray SplitH(const wxImage &src, wxColour magicColor)
Definition: ImageRoll.cpp:106
A wxPanel which displays an ImageRoll.
Definition: ImageRoll.h:71
static ImageArray SplitV(const wxImage &src, wxColour magicColor)
Definition: ImageRoll.cpp:162
RollType mType
Definition: ImageRoll.h:62
void OnSize(wxSizeEvent &evt)
Definition: ImageRoll.cpp:447
wxSize mMinSize
Definition: ImageRoll.h:65
void Draw(wxDC &dc, wxRect rect, wxRasterOperationMode logicalFunc=wxCOPY)
Definition: ImageRoll.cpp:312
#define wxRasterOperationMode
Definition: ImageRoll.h:23
void Init(RollType type, const wxImage &src, wxColour magicColor)
Definition: ImageRoll.cpp:216
void DrawBitmap(wxDC &dc, wxBitmap &bitmap, int x, int y, wxRasterOperationMode logicalFunc=wxCOPY)
Definition: ImageRoll.cpp:299
wxSize GetMaxSize() const
Definition: ImageRoll.h:47
An ImageRoll is an image that can be expanded to an arbitrary size; it is made up of both fixed piece...
Definition: ImageRoll.h:29