Author: bfreisen
Date: Thu Jul 23 13:52:02 2015
New Revision: 68566
URL:
http://svn.reactos.org/svn/reactos?rev=68566&view=rev
Log:
[MSPAINT_NEW] move hDrawingDC and mirror/rotate stuff to ImageModel
Modified:
trunk/reactos/base/applications/mspaint_new/globalvar.h
trunk/reactos/base/applications/mspaint_new/history.cpp
trunk/reactos/base/applications/mspaint_new/history.h
trunk/reactos/base/applications/mspaint_new/imgarea.cpp
trunk/reactos/base/applications/mspaint_new/main.cpp
trunk/reactos/base/applications/mspaint_new/miniature.cpp
trunk/reactos/base/applications/mspaint_new/selection.cpp
trunk/reactos/base/applications/mspaint_new/winproc.cpp
Modified: trunk/reactos/base/applications/mspaint_new/globalvar.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/globalvar.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/globalvar.h [iso-8859-1] Thu Jul 23
13:52:02 2015
@@ -14,8 +14,6 @@
} STRETCHSKEW;
/* VARIABLES declared in main.c *************************************/
-
-extern HDC hDrawingDC;
extern int widthSetInDlg;
extern int heightSetInDlg;
Modified: trunk/reactos/base/applications/mspaint_new/history.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/history.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/history.cpp [iso-8859-1] Thu Jul 23
13:52:02 2015
@@ -210,3 +210,35 @@
Rectangle(hDrawingDC, 0 - 1, 0 - 1, GetWidth() + 1, GetHeight() + 1);
NotifyImageChanged();
}
+
+HDC ImageModel::GetDC()
+{
+ return hDrawingDC;
+}
+
+void ImageModel::FlipHorizontally()
+{
+ CopyPrevious();
+ StretchBlt(hDrawingDC, GetWidth() - 1, 0, -GetWidth(), GetHeight(), GetDC(), 0, 0,
+ GetWidth(), GetHeight(), SRCCOPY);
+ NotifyImageChanged();
+}
+
+void ImageModel::FlipVertically()
+{
+ CopyPrevious();
+ StretchBlt(hDrawingDC, 0, GetHeight() - 1, GetWidth(), -GetHeight(), GetDC(), 0, 0,
+ GetWidth(), GetHeight(), SRCCOPY);
+ NotifyImageChanged();
+}
+
+void ImageModel::RotateNTimes90Degrees(int iN)
+{
+ if (iN == 2)
+ {
+ CopyPrevious();
+ StretchBlt(hDrawingDC, GetWidth() - 1, GetHeight() - 1, -GetWidth(),
-GetHeight(), GetDC(),
+ 0, 0, GetWidth(), GetHeight(), SRCCOPY);
+ }
+ NotifyImageChanged();
+}
Modified: trunk/reactos/base/applications/mspaint_new/history.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/history.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/history.h [iso-8859-1] Thu Jul 23 13:52:02
2015
@@ -11,6 +11,7 @@
private:
void NotifyDimensionsChanged();
void NotifyImageChanged();
+ HDC hDrawingDC;
public:
HBITMAP hBms[HISTORYSIZE];
private:
@@ -37,4 +38,8 @@
int GetHeight();
void InvertColors();
void Clear(COLORREF color = 0x00ffffff);
+ HDC GetDC();
+ void FlipHorizontally();
+ void FlipVertically();
+ void RotateNTimes90Degrees(int iN);
};
Modified: trunk/reactos/base/applications/mspaint_new/imgarea.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/imgarea.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/imgarea.cpp [iso-8859-1] Thu Jul 23
13:52:02 2015
@@ -99,7 +99,7 @@
HDC hdc = GetDC();
int imgXRes = imageModel.GetWidth();
int imgYRes = imageModel.GetHeight();
- StretchBlt(hdc, 0, 0, imgXRes * toolsModel.GetZoom() / 1000, imgYRes *
toolsModel.GetZoom() / 1000, hDrawingDC, 0, 0, imgXRes,
+ StretchBlt(hdc, 0, 0, imgXRes * toolsModel.GetZoom() / 1000, imgYRes *
toolsModel.GetZoom() / 1000, imageModel.GetDC(), 0, 0, imgXRes,
imgYRes, SRCCOPY);
if (showGrid && (toolsModel.GetZoom() >= 4000))
{
@@ -154,7 +154,7 @@
{
SetCapture();
drawing = TRUE;
- startPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
+ startPaintingL(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
paletteModel.GetFgColor(), paletteModel.GetBgColor());
}
else
@@ -174,7 +174,7 @@
{
SetCapture();
drawing = TRUE;
- startPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
+ startPaintingR(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
paletteModel.GetFgColor(), paletteModel.GetBgColor());
}
else
@@ -194,13 +194,13 @@
{
ReleaseCapture();
drawing = FALSE;
- endPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), paletteModel.GetFgColor(),
+ endPaintingL(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
if (toolsModel.GetActiveTool() == TOOL_COLOR)
{
COLORREF tempColor =
- GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
+ GetPixel(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
if (tempColor != CLR_INVALID)
paletteModel.SetFgColor(tempColor);
}
@@ -215,13 +215,13 @@
{
ReleaseCapture();
drawing = FALSE;
- endPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), paletteModel.GetFgColor(),
+ endPaintingR(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
if (toolsModel.GetActiveTool() == TOOL_COLOR)
{
COLORREF tempColor =
- GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
+ GetPixel(imageModel.GetDC(), GET_X_LPARAM(lParam) * 1000 /
toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
if (tempColor != CLR_INVALID)
paletteModel.SetBgColor(tempColor);
}
@@ -300,7 +300,7 @@
}
if ((wParam & MK_LBUTTON) != 0)
{
- whilePaintingL(hDrawingDC, xNow, yNow, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ whilePaintingL(imageModel.GetDC(), xNow, yNow, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
if ((toolsModel.GetActiveTool() >= TOOL_TEXT) ||
(toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() ==
TOOL_FREESEL))
{
@@ -313,7 +313,7 @@
}
if ((wParam & MK_RBUTTON) != 0)
{
- whilePaintingR(hDrawingDC, xNow, yNow, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ whilePaintingR(imageModel.GetDC(), xNow, yNow, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
if (toolsModel.GetActiveTool() >= TOOL_TEXT)
{
Modified: trunk/reactos/base/applications/mspaint_new/main.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/main.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/main.cpp [iso-8859-1] Thu Jul 23 13:52:02
2015
@@ -11,8 +11,6 @@
#include "precomp.h"
/* FUNCTIONS ********************************************************/
-
-HDC hDrawingDC;
int widthSetInDlg;
int heightSetInDlg;
Modified: trunk/reactos/base/applications/mspaint_new/miniature.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/miniature.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/miniature.cpp [iso-8859-1] Thu Jul 23
13:52:02 2015
@@ -27,7 +27,7 @@
HDC hdc;
miniature.GetClientRect(&mclient);
hdc = miniature.GetDC();
- StretchBlt(hdc, 0, 0, mclient.right, mclient.bottom, hDrawingDC, 0, 0,
imageModel.GetWidth(), imageModel.GetHeight(), SRCCOPY);
+ StretchBlt(hdc, 0, 0, mclient.right, mclient.bottom, imageModel.GetDC(), 0, 0,
imageModel.GetWidth(), imageModel.GetHeight(), SRCCOPY);
miniature.ReleaseDC(hdc);
return 0;
}
Modified: trunk/reactos/base/applications/mspaint_new/selection.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/selection.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/selection.cpp [iso-8859-1] Thu Jul 23
13:52:02 2015
@@ -178,14 +178,14 @@
if (toolsModel.GetActiveTool() == TOOL_TEXT)
{
- selectionModel.DrawTextToolText(hDrawingDC, paletteModel.GetFgColor(),
paletteModel.GetBgColor(), toolsModel.IsBackgroundTransparent());
+ selectionModel.DrawTextToolText(imageModel.GetDC(),
paletteModel.GetFgColor(), paletteModel.GetBgColor(),
toolsModel.IsBackgroundTransparent());
}
else
{
if (m_iAction != ACTION_MOVE)
- selectionModel.DrawSelectionStretched(hDrawingDC);
+ selectionModel.DrawSelectionStretched(imageModel.GetDC());
else
- selectionModel.DrawSelection(hDrawingDC, paletteModel.GetBgColor(),
toolsModel.IsBackgroundTransparent());
+ selectionModel.DrawSelection(imageModel.GetDC(),
paletteModel.GetBgColor(), toolsModel.IsBackgroundTransparent());
}
imageArea.InvalidateRect(NULL, FALSE);
imageArea.SendMessage(WM_PAINT, 0, 0);
Modified: trunk/reactos/base/applications/mspaint_new/winproc.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/winproc.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/winproc.cpp [iso-8859-1] Thu Jul 23
13:52:02 2015
@@ -306,9 +306,9 @@
/* Deselect */
if ((toolsModel.GetActiveTool() == TOOL_RECTSEL) ||
(toolsModel.GetActiveTool() == TOOL_FREESEL))
{
- startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
- whilePaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
- endPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ startPaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ whilePaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ endPaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
selectionWindow.ShowWindow(SW_HIDE);
}
}
@@ -443,14 +443,14 @@
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
//TODO: do this properly
- startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
- whilePaintingL(hDrawingDC, imageModel.GetWidth(), imageModel.GetHeight(),
paletteModel.GetFgColor(), paletteModel.GetBgColor());
- endPaintingL(hDrawingDC, imageModel.GetWidth(), imageModel.GetHeight(),
paletteModel.GetFgColor(), paletteModel.GetBgColor());
+ startPaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ whilePaintingL(imageModel.GetDC(), imageModel.GetWidth(),
imageModel.GetHeight(), paletteModel.GetFgColor(), paletteModel.GetBgColor());
+ endPaintingL(imageModel.GetDC(), imageModel.GetWidth(),
imageModel.GetHeight(), paletteModel.GetFgColor(), paletteModel.GetBgColor());
break;
}
case IDM_EDITCOPYTO:
if (GetSaveFileName(&ofn) != 0)
- SaveDIBToFile(selectionModel.GetBitmap(), ofn.lpstrFile, hDrawingDC,
NULL, NULL, fileHPPM, fileVPPM);
+ SaveDIBToFile(selectionModel.GetBitmap(), ofn.lpstrFile,
imageModel.GetDC(), NULL, NULL, fileHPPM, fileVPPM);
break;
case IDM_EDITPASTEFROM:
if (GetOpenFileName(&ofn) != 0)
@@ -481,7 +481,7 @@
}
case IDM_IMAGEDELETEIMAGE:
imageModel.CopyPrevious();
- Rect(hDrawingDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(),
paletteModel.GetBgColor(), paletteModel.GetBgColor(), 0, TRUE);
+ Rect(imageModel.GetDC(), 0, 0, imageModel.GetWidth(), imageModel.GetHeight(),
paletteModel.GetBgColor(), paletteModel.GetBgColor(), 0, TRUE);
imageArea.Invalidate(FALSE);
break;
case IDM_IMAGEROTATEMIRROR:
@@ -491,23 +491,13 @@
if (selectionWindow.IsWindowVisible())
selectionModel.FlipHorizontally();
else
- {
- imageModel.CopyPrevious();
- StretchBlt(hDrawingDC, imageModel.GetWidth() - 1, 0,
-imageModel.GetWidth(), imageModel.GetHeight(), hDrawingDC, 0, 0,
- imageModel.GetWidth(), imageModel.GetHeight(),
SRCCOPY);
- imageArea.Invalidate(FALSE);
- }
+ imageModel.FlipHorizontally();
break;
case 2: /* flip vertically */
if (selectionWindow.IsWindowVisible())
selectionModel.FlipVertically();
else
- {
- imageModel.CopyPrevious();
- StretchBlt(hDrawingDC, 0, imageModel.GetHeight() - 1,
imageModel.GetWidth(), -imageModel.GetHeight(), hDrawingDC, 0, 0,
- imageModel.GetWidth(), imageModel.GetHeight(),
SRCCOPY);
- imageArea.Invalidate(FALSE);
- }
+ imageModel.FlipVertically();
break;
case 3: /* rotate 90 degrees */
break;
@@ -515,12 +505,7 @@
if (selectionWindow.IsWindowVisible())
selectionModel.RotateNTimes90Degrees(2);
else
- {
- imageModel.CopyPrevious();
- StretchBlt(hDrawingDC, imageModel.GetWidth() - 1,
imageModel.GetHeight() - 1, -imageModel.GetWidth(), -imageModel.GetHeight(), hDrawingDC,
- 0, 0, imageModel.GetWidth(), imageModel.GetHeight(),
SRCCOPY);
- imageArea.Invalidate(FALSE);
- }
+ imageModel.RotateNTimes90Degrees(2);
break;
case 5: /* rotate 270 degrees */
break;