2 * PROJECT: PAINT for ReactOS
5 * PURPOSE: Undo and redo functionality
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
12 #include "globalvar.h"
14 #include "definitions.h"
16 /* FUNCTIONS ********************************************************/
18 extern void updateCanvasAndScrollbars(void);
20 void setImgXYRes(int x
, int y
)
22 if ((imgXRes
!=x
)||(imgYRes
!=y
))
26 updateCanvasAndScrollbars();
32 DeleteObject(hBms
[(currInd
+1)%4]);
33 hBms
[(currInd
+1)%4] = CopyImage( hBms
[currInd
], IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
);
34 currInd
= (currInd
+1)%4;
35 if (undoSteps
<3) undoSteps
++;
37 SelectObject(hDrawingDC
, hBms
[currInd
]);
38 imgXRes
= GetDIBWidth(hBms
[currInd
]);
39 imgYRes
= GetDIBHeight(hBms
[currInd
]);
46 ShowWindow(hSelection
, SW_HIDE
);
47 currInd
= (currInd
+3)%4;
48 SelectObject(hDrawingDC
, hBms
[currInd
]);
50 if (redoSteps
<3) redoSteps
++;
51 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
59 ShowWindow(hSelection
, SW_HIDE
);
60 currInd
= (currInd
+1)%4;
61 SelectObject(hDrawingDC
, hBms
[currInd
]);
63 if (undoSteps
<3) undoSteps
++;
64 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
70 DeleteObject(hBms
[currInd
]);
71 hBms
[currInd
] = CopyImage( hBms
[(currInd
+3)%4], IMAGE_BITMAP
, 0, 0, LR_COPYRETURNORG
);
72 SelectObject(hDrawingDC
, hBms
[currInd
]);
73 imgXRes
= GetDIBWidth(hBms
[currInd
]);
74 imgYRes
= GetDIBHeight(hBms
[currInd
]);
83 void insertReversible(HBITMAP hbm
)
85 DeleteObject(hBms
[(currInd
+1)%4]);
86 hBms
[(currInd
+1)%4] = hbm
;
87 currInd
= (currInd
+1)%4;
88 if (undoSteps
<3) undoSteps
++;
90 SelectObject(hDrawingDC
, hBms
[currInd
]);
91 setImgXYRes(GetDIBWidth(hBms
[currInd
]), GetDIBHeight(hBms
[currInd
]));
94 void cropReversible(int x
, int y
)//FIXME: This function is broken
100 SelectObject(hDrawingDC
, hBms
[currInd
]);
101 DeleteObject(hBms
[(currInd
+1)%4]);
102 hBms
[(currInd
+1)%4] = CreateDIBWithProperties(x
, y
);
103 currInd
= (currInd
+1)%4;
104 if (undoSteps
<3) undoSteps
++;
107 oldBitmap
= SelectObject(hSelDC
, hBms
[currInd
]);
108 oldPen
= SelectObject(hSelDC
, CreatePen(PS_SOLID
, 1, bgColor
));
109 oldBrush
= SelectObject(hSelDC
, CreateSolidBrush(bgColor
));
110 Rectangle(hSelDC
, 0, 0, x
, y
);
111 DeleteObject(SelectObject(hSelDC
, oldBrush
));
112 DeleteObject(SelectObject(hSelDC
, oldPen
));
113 BitBlt(hDrawingDC
, 0, 0, imgXRes
, imgYRes
, hSelDC
, 0, 0, SRCCOPY
);
114 SelectObject(hDrawingDC
, SelectObject(hSelDC
, oldBitmap
));