ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

history.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:     PAINT for ReactOS
00003  * LICENSE:     LGPL
00004  * FILE:        base/applications/paint/history.c
00005  * PURPOSE:     Undo and redo functionality
00006  * PROGRAMMERS: Benedikt Freisen
00007  */
00008 
00009 /* INCLUDES *********************************************************/
00010 
00011 #include "precomp.h"
00012 
00013 /* FUNCTIONS ********************************************************/
00014 
00015 extern void updateCanvasAndScrollbars(void);
00016 
00017 void
00018 setImgXYRes(int x, int y)
00019 {
00020     if ((imgXRes != x) || (imgYRes != y))
00021     {
00022         imgXRes = x;
00023         imgYRes = y;
00024         updateCanvasAndScrollbars();
00025     }
00026 }
00027 
00028 void
00029 newReversible()
00030 {
00031     DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]);
00032     hBms[(currInd + 1) % HISTORYSIZE] = CopyImage(hBms[currInd], IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG);
00033     currInd = (currInd + 1) % HISTORYSIZE;
00034     if (undoSteps < HISTORYSIZE - 1)
00035         undoSteps++;
00036     redoSteps = 0;
00037     SelectObject(hDrawingDC, hBms[currInd]);
00038     imgXRes = GetDIBWidth(hBms[currInd]);
00039     imgYRes = GetDIBHeight(hBms[currInd]);
00040     imageSaved = FALSE;
00041 }
00042 
00043 void
00044 undo()
00045 {
00046     if (undoSteps > 0)
00047     {
00048         ShowWindow(hSelection, SW_HIDE);
00049         currInd = (currInd + HISTORYSIZE - 1) % HISTORYSIZE;
00050         SelectObject(hDrawingDC, hBms[currInd]);
00051         undoSteps--;
00052         if (redoSteps < HISTORYSIZE - 1)
00053             redoSteps++;
00054         setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
00055     }
00056 }
00057 
00058 void
00059 redo()
00060 {
00061     if (redoSteps > 0)
00062     {
00063         ShowWindow(hSelection, SW_HIDE);
00064         currInd = (currInd + 1) % HISTORYSIZE;
00065         SelectObject(hDrawingDC, hBms[currInd]);
00066         redoSteps--;
00067         if (undoSteps < HISTORYSIZE - 1)
00068             undoSteps++;
00069         setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
00070     }
00071 }
00072 
00073 void
00074 resetToU1()
00075 {
00076     DeleteObject(hBms[currInd]);
00077     hBms[currInd] =
00078         CopyImage(hBms[(currInd + HISTORYSIZE - 1) % HISTORYSIZE], IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG);
00079     SelectObject(hDrawingDC, hBms[currInd]);
00080     imgXRes = GetDIBWidth(hBms[currInd]);
00081     imgYRes = GetDIBHeight(hBms[currInd]);
00082 }
00083 
00084 void
00085 clearHistory()
00086 {
00087     undoSteps = 0;
00088     redoSteps = 0;
00089 }
00090 
00091 void
00092 insertReversible(HBITMAP hbm)
00093 {
00094     DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]);
00095     hBms[(currInd + 1) % HISTORYSIZE] = hbm;
00096     currInd = (currInd + 1) % HISTORYSIZE;
00097     if (undoSteps < HISTORYSIZE - 1)
00098         undoSteps++;
00099     redoSteps = 0;
00100     SelectObject(hDrawingDC, hBms[currInd]);
00101     setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
00102 }
00103 
00104 void
00105 cropReversible(int width, int height, int xOffset, int yOffset)
00106 {
00107     HDC hdc;
00108     HPEN oldPen;
00109     HBRUSH oldBrush;
00110 
00111     SelectObject(hDrawingDC, hBms[currInd]);
00112     DeleteObject(hBms[(currInd + 1) % HISTORYSIZE]);
00113     hBms[(currInd + 1) % HISTORYSIZE] = CreateDIBWithProperties(width, height);
00114     currInd = (currInd + 1) % HISTORYSIZE;
00115     if (undoSteps < HISTORYSIZE - 1)
00116         undoSteps++;
00117     redoSteps = 0;
00118 
00119     hdc = CreateCompatibleDC(hDrawingDC);
00120     SelectObject(hdc, hBms[currInd]);
00121 
00122     oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, bgColor));
00123     oldBrush = SelectObject(hdc, CreateSolidBrush(bgColor));
00124     Rectangle(hdc, 0, 0, width, height);
00125     BitBlt(hdc, -xOffset, -yOffset, imgXRes, imgYRes, hDrawingDC, 0, 0, SRCCOPY);
00126     DeleteObject(SelectObject(hdc, oldBrush));
00127     DeleteObject(SelectObject(hdc, oldPen));
00128     DeleteDC(hdc);
00129     SelectObject(hDrawingDC, hBms[currInd]);
00130 
00131     setImgXYRes(width, height);
00132 }

Generated on Fri May 25 2012 04:15:23 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.