-
Notifications
You must be signed in to change notification settings - Fork 1
/
history.h
66 lines (58 loc) · 1.83 KB
/
history.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* PROJECT: PAINT for ReactOS
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
* PURPOSE: Undo and redo functionality
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
*/
#pragma once
/* HISTORYSIZE = number of possible undo-steps + 1 */
#define HISTORYSIZE 11
struct IMAGE_PART
{
CRect m_rcPart;
HBITMAP m_hbmImage;
BOOL m_bPartial;
void clear();
};
class ImageModel
{
public:
ImageModel();
virtual ~ImageModel();
HDC GetDC();
BOOL CanUndo() const { return m_undoSteps > 0; }
BOOL CanRedo() const { return m_redoSteps > 0; }
void PushImageForUndo();
void PushImageForUndo(HBITMAP hbm);
void PushImageForUndo(const RECT& rcPartial);
void Undo(BOOL bClearRedo = FALSE);
void Redo(void);
void ClearHistory(void);
void Crop(int nWidth, int nHeight, int nOffsetX = 0, int nOffsetY = 0);
void SaveImage(LPCWSTR lpFileName);
BOOL IsImageSaved() const;
void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0);
int GetWidth() const;
int GetHeight() const;
HBITMAP CopyBitmap();
HBITMAP LockBitmap();
void UnlockBitmap(HBITMAP hbmLocked);
void InvertColors();
void FlipHorizontally();
void FlipVertically();
void RotateNTimes90Degrees(int iN);
void Clamp(POINT& pt) const;
void NotifyImageChanged();
BOOL IsBlackAndWhite();
void PushBlackAndWhite();
protected:
HDC m_hDrawingDC; // The device context for this class
HBITMAP m_hbmMaster; // The master bitmap
int m_currInd; // The current index in m_hBms
int m_undoSteps; // The undo-able count
int m_redoSteps; // The redo-able count
IMAGE_PART m_historyItems[HISTORYSIZE]; // A ring buffer of IMAGE_PARTs
HGDIOBJ m_hbmOld;
void SwapPart();
void PushDone();
};