ReactOS 0.4.15-dev-8102-g108db8f
history.h
Go to the documentation of this file.
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
14{
18
19 void clear();
20};
21
23{
24public:
25 ImageModel();
26 virtual ~ImageModel();
27
28 HDC GetDC();
29 BOOL CanUndo() const { return m_undoSteps > 0; }
30 BOOL CanRedo() const { return m_redoSteps > 0; }
31 void PushImageForUndo();
33 void PushImageForUndo(const RECT& rcPartial);
34 void Undo(BOOL bClearRedo = FALSE);
35 void Redo(void);
36 void ClearHistory(void);
37 void Crop(int nWidth, int nHeight, int nOffsetX = 0, int nOffsetY = 0);
39 BOOL IsImageSaved() const;
40 void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX = 0, int nSkewDegY = 0);
41 int GetWidth() const;
42 int GetHeight() const;
45 void UnlockBitmap(HBITMAP hbmLocked);
46 void InvertColors();
47 void FlipHorizontally();
48 void FlipVertically();
49 void RotateNTimes90Degrees(int iN);
50 void Clamp(POINT& pt) const;
51 void NotifyImageChanged();
53 void PushBlackAndWhite();
54
55protected:
56 HDC m_hDrawingDC; // The device context for this class
57 HBITMAP m_hbmMaster; // The master bitmap
58 int m_currInd; // The current index in m_hBms
59 int m_undoSteps; // The undo-able count
60 int m_redoSteps; // The redo-able count
61 IMAGE_PART m_historyItems[HISTORYSIZE]; // A ring buffer of IMAGE_PARTs
63
64 void SwapPart();
65 void PushDone();
66};
#define HISTORYSIZE
Definition: history.h:11
HBITMAP CopyBitmap()
Definition: history.cpp:320
void SwapPart()
Definition: history.cpp:57
int m_undoSteps
Definition: history.h:59
int GetWidth() const
Definition: history.cpp:253
HBITMAP LockBitmap()
Definition: history.cpp:345
BOOL CanUndo() const
Definition: history.h:29
void FlipVertically()
Definition: history.cpp:284
void FlipHorizontally()
Definition: history.cpp:276
BOOL CanRedo() const
Definition: history.h:30
void PushBlackAndWhite()
Definition: history.cpp:336
HGDIOBJ m_hbmOld
Definition: history.h:62
int m_redoSteps
Definition: history.h:60
ImageModel()
Definition: history.cpp:35
void InvertColors()
Definition: history.cpp:263
BOOL IsImageSaved() const
Definition: history.cpp:224
void Redo(void)
Definition: history.cpp:96
void PushImageForUndo()
Definition: history.cpp:127
HBITMAP m_hbmMaster
Definition: history.h:57
void NotifyImageChanged()
Definition: history.cpp:23
virtual ~ImageModel()
Definition: history.cpp:49
int m_currInd
Definition: history.h:58
void RotateNTimes90Degrees(int iN)
Definition: history.cpp:292
void Crop(int nWidth, int nHeight, int nOffsetX=0, int nOffsetY=0)
Definition: history.cpp:191
void UnlockBitmap(HBITMAP hbmLocked)
Definition: history.cpp:354
int GetHeight() const
Definition: history.cpp:258
void PushDone()
Definition: history.cpp:179
HDC GetDC()
Definition: history.cpp:271
void Clamp(POINT &pt) const
Definition: history.cpp:314
void SaveImage(LPCWSTR lpFileName)
Definition: history.cpp:219
HDC m_hDrawingDC
Definition: history.h:56
void ClearHistory(void)
Definition: history.cpp:116
IMAGE_PART m_historyItems[HISTORYSIZE]
Definition: history.h:61
void StretchSkew(int nStretchPercentX, int nStretchPercentY, int nSkewDegX=0, int nSkewDegY=0)
Definition: history.cpp:229
BOOL IsBlackAndWhite()
Definition: history.cpp:328
#define FALSE
Definition: types.h:117
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
_In_ HBITMAP hbm
Definition: ntgdi.h:2776
void Undo(void)
Definition: solundo.cpp:53
CRect m_rcPart
Definition: history.h:15
HBITMAP m_hbmImage
Definition: history.h:16
void clear()
Definition: history.cpp:15
BOOL m_bPartial
Definition: history.h:17
_In_ LPCSTR lpFileName
Definition: winbase.h:3071
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185