Author: bfreisen
Date: Sat Oct 3 18:33:41 2009
New Revision: 43266
URL:
http://svn.reactos.org/svn/reactos?rev=43266&view=rev
Log:
* only show message box on exit if the image has not been saved and is not blank
* set as wallpaper: now working, setting wallpaper style: not yet
* made number of undo-steps changeable through define-statement; increased to 10 (see
original)
* zoom tool got its track bar (see original)
Modified:
trunk/reactos/base/applications/paint/definitions.h
trunk/reactos/base/applications/paint/globalvar.h
trunk/reactos/base/applications/paint/history.c
trunk/reactos/base/applications/paint/main.c
trunk/reactos/base/applications/paint/registry.c
trunk/reactos/base/applications/paint/toolsettings.c
trunk/reactos/base/applications/paint/winproc.c
trunk/reactos/base/applications/paint/winproc.h
Modified: trunk/reactos/base/applications/paint/definitions.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/de…
==============================================================================
--- trunk/reactos/base/applications/paint/definitions.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/definitions.h [iso-8859-1] Sat Oct 3 18:33:41
2009
@@ -7,6 +7,9 @@
*/
/* DEFINES **********************************************************/
+
+#define HISTORYSIZE 11
+/* HISTORYSIZE = number of possible undo-steps + 1 */
#define SIZEOF(a) (sizeof(a) / sizeof((a)[0]))
Modified: trunk/reactos/base/applications/paint/globalvar.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/gl…
==============================================================================
--- trunk/reactos/base/applications/paint/globalvar.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/globalvar.h [iso-8859-1] Sat Oct 3 18:33:41
2009
@@ -9,6 +9,7 @@
/* INCLUDES *********************************************************/
#include <windows.h>
+#include "definitions.h"
/* VARIABLES declared in main.c *************************************/
@@ -19,10 +20,11 @@
extern int imgXRes;
extern int imgYRes;
-extern HBITMAP hBms[4];
+extern HBITMAP hBms[HISTORYSIZE];
extern int currInd;
extern int undoSteps;
extern int redoSteps;
+extern BOOL imageSaved;
extern short startX;
extern short startY;
@@ -86,6 +88,8 @@
extern HWND hSizeboxCenterBottom;
extern HWND hSizeboxRightBottom;
+extern HWND hTrackbarZoom;
+
/* VARIABLES declared in mouse.c *************************************/
extern POINT pointStack[256];
Modified: trunk/reactos/base/applications/paint/history.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/hi…
==============================================================================
--- trunk/reactos/base/applications/paint/history.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/history.c [iso-8859-1] Sat Oct 3 18:33:41 2009
@@ -29,14 +29,15 @@
void newReversible()
{
- DeleteObject(hBms[(currInd+1)%4]);
- hBms[(currInd+1)%4] = CopyImage( hBms[currInd], IMAGE_BITMAP, 0, 0,
LR_COPYRETURNORG);
- currInd = (currInd+1)%4;
- if (undoSteps<3) undoSteps++;
+ DeleteObject(hBms[(currInd+1)%HISTORYSIZE]);
+ hBms[(currInd+1)%HISTORYSIZE] = CopyImage( hBms[currInd], IMAGE_BITMAP, 0, 0,
LR_COPYRETURNORG);
+ currInd = (currInd+1)%HISTORYSIZE;
+ if (undoSteps<HISTORYSIZE-1) undoSteps++;
redoSteps = 0;
SelectObject(hDrawingDC, hBms[currInd]);
imgXRes = GetDIBWidth(hBms[currInd]);
imgYRes = GetDIBHeight(hBms[currInd]);
+ imageSaved = FALSE;
}
void undo()
@@ -44,10 +45,10 @@
if (undoSteps>0)
{
ShowWindow(hSelection, SW_HIDE);
- currInd = (currInd+3)%4;
+ currInd = (currInd+HISTORYSIZE-1)%HISTORYSIZE;
SelectObject(hDrawingDC, hBms[currInd]);
undoSteps--;
- if (redoSteps<3) redoSteps++;
+ if (redoSteps<HISTORYSIZE-1) redoSteps++;
setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
}
}
@@ -57,10 +58,10 @@
if (redoSteps>0)
{
ShowWindow(hSelection, SW_HIDE);
- currInd = (currInd+1)%4;
+ currInd = (currInd+1)%HISTORYSIZE;
SelectObject(hDrawingDC, hBms[currInd]);
redoSteps--;
- if (undoSteps<3) undoSteps++;
+ if (undoSteps<HISTORYSIZE-1) undoSteps++;
setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
}
}
@@ -68,7 +69,7 @@
void resetToU1()
{
DeleteObject(hBms[currInd]);
- hBms[currInd] = CopyImage( hBms[(currInd+3)%4], IMAGE_BITMAP, 0, 0,
LR_COPYRETURNORG);
+ hBms[currInd] = CopyImage( hBms[(currInd+HISTORYSIZE-1)%HISTORYSIZE], IMAGE_BITMAP,
0, 0, LR_COPYRETURNORG);
SelectObject(hDrawingDC, hBms[currInd]);
imgXRes = GetDIBWidth(hBms[currInd]);
imgYRes = GetDIBHeight(hBms[currInd]);
@@ -82,10 +83,10 @@
void insertReversible(HBITMAP hbm)
{
- DeleteObject(hBms[(currInd+1)%4]);
- hBms[(currInd+1)%4] = hbm;
- currInd = (currInd+1)%4;
- if (undoSteps<3) undoSteps++;
+ DeleteObject(hBms[(currInd+1)%HISTORYSIZE]);
+ hBms[(currInd+1)%HISTORYSIZE] = hbm;
+ currInd = (currInd+1)%HISTORYSIZE;
+ if (undoSteps<HISTORYSIZE-1) undoSteps++;
redoSteps = 0;
SelectObject(hDrawingDC, hBms[currInd]);
setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
@@ -98,10 +99,10 @@
HBRUSH oldBrush;
SelectObject(hDrawingDC, hBms[currInd]);
- DeleteObject(hBms[(currInd+1)%4]);
- hBms[(currInd+1)%4] = CreateDIBWithProperties(width, height);
- currInd = (currInd+1)%4;
- if (undoSteps<3) undoSteps++;
+ DeleteObject(hBms[(currInd+1)%HISTORYSIZE]);
+ hBms[(currInd+1)%HISTORYSIZE] = CreateDIBWithProperties(width, height);
+ currInd = (currInd+1)%HISTORYSIZE;
+ if (undoSteps<HISTORYSIZE-1) undoSteps++;
redoSteps = 0;
hdc = CreateCompatibleDC(hDrawingDC);
Modified: trunk/reactos/base/applications/paint/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/ma…
==============================================================================
--- trunk/reactos/base/applications/paint/main.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/main.c [iso-8859-1] Sat Oct 3 18:33:41 2009
@@ -37,10 +37,11 @@
int imgXRes = 400;
int imgYRes = 300;
-HBITMAP hBms[4];
+HBITMAP hBms[HISTORYSIZE];
int currInd = 0;
int undoSteps = 0;
int redoSteps = 0;
+BOOL imageSaved = TRUE;
// global status variables
@@ -116,6 +117,8 @@
HWND hSizeboxLeftBottom;
HWND hSizeboxCenterBottom;
HWND hSizeboxRightBottom;
+
+HWND hTrackbarZoom;
int WINAPI _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR
lpszArgument, int nFunsterStil)
{
@@ -305,6 +308,9 @@
/* creating the tool settings child window */
hToolSettings = CreateWindowEx(0, _T("ToolSettings"), _T(""),
WS_CHILD | WS_VISIBLE, 7, 210, 42, 140, hwnd, NULL, hThisInstance, NULL);
+ hTrackbarZoom = CreateWindowEx(0, TRACKBAR_CLASS, _T(""), WS_CHILD |
TBS_VERT | TBS_AUTOTICKS, 1, 1, 40, 64, hToolSettings, NULL, hThisInstance, NULL);
+ SendMessage(hTrackbarZoom, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, 6));
+ SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)3);
/* creating the palette child window */
hPalWin = CreateWindowEx(0, _T("Palette"), _T(""), WS_CHILD |
WS_VISIBLE, 56, 9, 255, 32, hwnd, NULL, hThisInstance, NULL);
Modified: trunk/reactos/base/applications/paint/registry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/re…
==============================================================================
--- trunk/reactos/base/applications/paint/registry.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/registry.c [iso-8859-1] Sat Oct 3 18:33:41
2009
@@ -13,9 +13,11 @@
/* FUNCTIONS ********************************************************/
-void SetWallpaper(TCHAR *FileName, DWORD dwStyle, DWORD dwTile)
+void SetWallpaper(TCHAR *FileName, DWORD dwStyle, DWORD dwTile) //FIXME: The pattern
(tiled/stretched) is not set
{
- HKEY hDesktop;
+ SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) FileName, SPIF_UPDATEINIFILE);
+
+ /*HKEY hDesktop;
TCHAR szStyle[3], szTile[3];
if ((dwStyle > 2) || (dwTile > 2))
@@ -34,5 +36,5 @@
RegSetValueEx(hDesktop, _T("TileWallpaper"), 0, REG_SZ, (LPBYTE)
szTile, _tcslen(szTile) * sizeof(TCHAR));
RegCloseKey(hDesktop);
- }
+ }*/
}
Modified: trunk/reactos/base/applications/paint/toolsettings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/to…
==============================================================================
--- trunk/reactos/base/applications/paint/toolsettings.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/toolsettings.c [iso-8859-1] Sat Oct 3 18:33:41
2009
@@ -9,8 +9,10 @@
/* INCLUDES *********************************************************/
#include <windows.h>
+#include <commctrl.h>
#include "globalvar.h"
#include "drawing.h"
+#include "winproc.h"
/* FUNCTIONS ********************************************************/
@@ -18,6 +20,11 @@
{
switch (message)
{
+ case WM_VSCROLL:
+ {
+ ZoomTo(125<<SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0));
+ }
+ break;
case WM_PAINT:
{
HDC hdc = GetDC(hwnd);
@@ -25,8 +32,11 @@
int rectang2[4] = {0, 70, 42, 136};
DefWindowProc (hwnd, message, wParam, lParam);
-
- DrawEdge(hdc, (LPRECT)&rectang, BDR_SUNKENOUTER, BF_RECT |
BF_MIDDLE);
+
+ if (activeTool!=6)
+ DrawEdge(hdc, (LPRECT)&rectang, BDR_SUNKENOUTER, BF_RECT |
BF_MIDDLE);
+ else
+ DrawEdge(hdc, (LPRECT)&rectang, BDR_SUNKENOUTER, BF_RECT);
if (activeTool>=13)
DrawEdge(hdc, (LPRECT)&rectang2, BDR_SUNKENOUTER, BF_RECT |
BF_MIDDLE);
else
Modified: trunk/reactos/base/applications/paint/winproc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/wi…
==============================================================================
--- trunk/reactos/base/applications/paint/winproc.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/winproc.c [iso-8859-1] Sat Oct 3 18:33:41 2009
@@ -31,6 +31,10 @@
activeTool = tool;
pointSP = 0; // resets the point-buffer of the polygon and bezier functions
SendMessage(hToolSettings, WM_PAINT, 0, 0);
+ if (tool==6)
+ ShowWindow(hTrackbarZoom, SW_SHOW);
+ else
+ ShowWindow(hTrackbarZoom, SW_HIDE);
}
void updateCanvasAndScrollbars()
@@ -48,6 +52,14 @@
{
zoom = newZoom;
updateCanvasAndScrollbars();
+ int tbPos = 0;
+ int tempZoom = newZoom;
+ while (tempZoom>125)
+ {
+ tbPos++;
+ tempZoom = tempZoom>>1;
+ }
+ SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)tbPos);
}
HDC hdc;
@@ -67,7 +79,7 @@
showMiniature = FALSE;
break;
}
- if (undoSteps>0)
+ if (!imageSaved)
{
TCHAR programname[20];
TCHAR saveprompttext[100];
@@ -503,7 +515,10 @@
break;
case IDM_FILESAVE:
if (isAFile)
+ {
SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC);
+ imageSaved = TRUE;
+ }
else
SendMessage(hwnd, WM_COMMAND, IDM_FILESAVEAS, 0);
break;
@@ -514,11 +529,12 @@
TCHAR resstr[100];
SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC);
CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename));
- CopyMemory(filepathname, sfn.lpstrFileTitle,
sizeof(filepathname));
+ CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname));
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr,
SIZEOF(resstr));
_stprintf(tempstr, resstr, filename);
SetWindowText(hMainWnd, tempstr);
isAFile = TRUE;
+ imageSaved = TRUE;
}
break;
case IDM_FILEASWALLPAPERPLANE:
Modified: trunk/reactos/base/applications/paint/winproc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/paint/wi…
==============================================================================
--- trunk/reactos/base/applications/paint/winproc.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/paint/winproc.h [iso-8859-1] Sat Oct 3 18:33:41 2009
@@ -7,4 +7,6 @@
* PROGRAMMERS: Benedikt Freisen
*/
+void ZoomTo(int newZoom);
+
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam);