1 /* 2 * PROJECT: PAINT for ReactOS 3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later) 4 * PURPOSE: Undo and redo functionality 5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net> 6 */ 7 8 #pragma once 9 10 /* HISTORYSIZE = number of possible undo-steps + 1 */ 11 #define HISTORYSIZE 11 12 13 class ImageModel 14 { 15 public: 16 ImageModel(); 17 virtual ~ImageModel(); 18 19 HDC GetDC(); 20 BOOL CanUndo() const { return m_undoSteps > 0; } 21 BOOL CanRedo() const { return m_redoSteps > 0; } 22 void PushImageForUndo(); 23 void PushImageForUndo(HBITMAP hbm); 24 void Undo(BOOL bClearRedo = FALSE); 25 void Redo(void); 26 void ClearHistory(void); 27 void Crop(int nWidth, int nHeight, int nOffsetX = 0, int nOffsetY = 0); 28 void SaveImage(LPCWSTR lpFileName); 29 BOOL IsImageSaved() const; 30 void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0); 31 int GetWidth() const; 32 int GetHeight() const; 33 HBITMAP CopyBitmap(); 34 HBITMAP LockBitmap(); 35 void UnlockBitmap(HBITMAP hbmLocked); 36 void InvertColors(); 37 void FlipHorizontally(); 38 void FlipVertically(); 39 void RotateNTimes90Degrees(int iN); 40 void Clamp(POINT& pt) const; 41 void NotifyImageChanged(); 42 BOOL IsBlackAndWhite(); 43 void PushBlackAndWhite(); 44 void SelectionClone(BOOL bUndoable = TRUE); 45 46 protected: 47 HDC m_hDrawingDC; // The device context for this class 48 int m_currInd; // The current index in m_hBms 49 int m_undoSteps; // The undo-able count 50 int m_redoSteps; // The redo-able count 51 HBITMAP m_hBms[HISTORYSIZE]; // A rotation buffer of HBITMAPs 52 HGDIOBJ m_hbmOld; 53 }; 54