Author: bfreisen
Date: Thu Jul 23 13:11:54 2015
New Revision: 68565
URL:
http://svn.reactos.org/svn/reactos?rev=68565&view=rev
Log:
[MSPAINT_NEW]
- move bitmap and DC initialization to ImageModel
- remove unused global variables
- remove copy-pasta bug from SelectionModel::DrawSelection
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/main.cpp
trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp
trunk/reactos/base/applications/mspaint_new/selectionmodel.h
trunk/reactos/base/applications/mspaint_new/textedit.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:11:54 2015
@@ -5,11 +5,6 @@
* PURPOSE: Declaring global variables for later initialization
* PROGRAMMERS: Benedikt Freisen
*/
-
-/* INCLUDES *********************************************************/
-
-//#include <windows.h>
-//#include "definitions.h"
/* TYPES ************************************************************/
@@ -21,8 +16,6 @@
/* VARIABLES declared in main.c *************************************/
extern HDC hDrawingDC;
-extern int *bmAddress;
-extern BITMAPINFO bitmapinfo;
extern int widthSetInDlg;
extern int heightSetInDlg;
@@ -42,7 +35,6 @@
class SelectionModel;
extern SelectionModel selectionModel;
-extern HWND hwndEditCtl;
extern LOGFONT lfTextFont;
extern HFONT hfontTextFont;
extern LPTSTR textToolText;
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:11:54 2015
@@ -28,6 +28,18 @@
undoSteps = 0;
redoSteps = 0;
imageSaved = TRUE;
+
+ // TODO: load dimensions from registry
+ int imgXRes = 400;
+ int imgYRes = 300;
+
+ hDrawingDC = CreateCompatibleDC(NULL);
+ SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, paletteModel.GetFgColor()));
+ SelectObject(hDrawingDC, CreateSolidBrush(paletteModel.GetBgColor()));
+
+ hBms[0] = CreateDIBWithProperties(imgXRes, imgYRes);
+ SelectObject(hDrawingDC, hBms[0]);
+ Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);
}
void ImageModel::CopyPrevious()
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:11:54
2015
@@ -13,9 +13,11 @@
void NotifyImageChanged();
public:
HBITMAP hBms[HISTORYSIZE];
+private:
int currInd;
int undoSteps;
int redoSteps;
+public:
BOOL imageSaved;
ImageModel();
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:11:54
2015
@@ -13,18 +13,11 @@
/* FUNCTIONS ********************************************************/
HDC hDrawingDC;
-int *bmAddress;
-BITMAPINFO bitmapinfo;
-int imgXRes = 400;
-int imgYRes = 300;
int widthSetInDlg;
int heightSetInDlg;
STRETCHSKEW stretchSkew;
-
-ImageModel imageModel;
-BOOL askBeforeEnlarging = FALSE; // TODO: initialize from registry
POINT start;
POINT last;
@@ -40,6 +33,9 @@
int textToolTextMaxLen = 0;
PaletteModel paletteModel;
+
+ImageModel imageModel;
+BOOL askBeforeEnlarging = FALSE; // TODO: initialize from registry
HWND hStatusBar;
CHOOSECOLOR choosecolor;
@@ -100,7 +96,6 @@
TCHAR resstr[100];
HMENU menu;
HANDLE haccel;
- HDC hDC;
TCHAR *c;
TCHAR sfnFilename[1000];
@@ -198,20 +193,8 @@
selectionWindow.Create(scrlClientWindow.m_hWnd, selectionWindowPos, NULL, WS_CHILD |
BS_OWNERDRAW);
/* creating the window inside the scroll box, on which the image in hDrawingDC's
bitmap is drawn */
- RECT imageAreaPos = {3, 3, 3 + imgXRes, 3 + imgYRes};
+ RECT imageAreaPos = {3, 3, 3 + imageModel.GetWidth(), 3 + imageModel.GetHeight()};
imageArea.Create(scrlClientWindow.m_hWnd, imageAreaPos, NULL, WS_CHILD |
WS_VISIBLE);
-
- hDC = imageArea.GetDC();
- hDrawingDC = CreateCompatibleDC(hDC);
- selectionModel.SetDC(CreateCompatibleDC(hDC));
- imageArea.ReleaseDC(hDC);
- SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, paletteModel.GetFgColor()));
- SelectObject(hDrawingDC, CreateSolidBrush(paletteModel.GetBgColor()));
-
- //TODO: move to ImageModel
- imageModel.hBms[0] = CreateDIBWithProperties(imgXRes, imgYRes);
- SelectObject(hDrawingDC, imageModel.hBms[0]);
- Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1);
if (lpszArgument[0] != 0)
{
Modified: trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp [iso-8859-1] Thu Jul 23
13:11:54 2015
@@ -16,11 +16,8 @@
{
m_ptStack = NULL;
m_iPtSP = 0;
-}
-
-void SelectionModel::SetDC(HDC hDC)
-{
- m_hDC = hDC;
+
+ m_hDC = CreateCompatibleDC(NULL);
}
void SelectionModel::ResetPtStack()
@@ -106,7 +103,7 @@
void SelectionModel::DrawBackgroundRect(HDC hDCImage, COLORREF crBg)
{
- Rect(hDCImage, m_rcSrc.left, m_rcSrc.top, m_rcSrc.right, m_rcSrc.bottom, crBg, crBg,
0, TRUE);
+ Rect(hDCImage, m_rcSrc.left, m_rcSrc.top, m_rcSrc.right, m_rcSrc.bottom, crBg, crBg,
0, 1);
}
extern BOOL
@@ -114,8 +111,6 @@
void SelectionModel::DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent)
{
- MaskBlt(hDCImage, m_rcSrc.left, m_rcSrc.top, RECT_WIDTH(m_rcSrc),
RECT_HEIGHT(m_rcSrc), m_hDC, 0,
- 0, m_hMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
if (!bBgTransparent)
MaskBlt(hDCImage, m_rcDest.left, m_rcDest.top, RECT_WIDTH(m_rcDest),
RECT_HEIGHT(m_rcDest),
m_hDC, 0, 0, m_hMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
Modified: trunk/reactos/base/applications/mspaint_new/selectionmodel.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/selectionmodel.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/selectionmodel.h [iso-8859-1] Thu Jul 23
13:11:54 2015
@@ -37,7 +37,6 @@
public:
SelectionModel();
- void SetDC(HDC hDC);
void ResetPtStack();
void PushToPtStack(LONG x, LONG y);
void CalculateBoundingBoxAndContents(HDC hDCImage);
Modified: trunk/reactos/base/applications/mspaint_new/textedit.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/textedit.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/textedit.cpp [iso-8859-1] Thu Jul 23
13:11:54 2015
@@ -15,9 +15,9 @@
{
/* creating the edit control within the editor window */
RECT editControlPos = {0, 0, 0 + 100, 0 + 100};
- hwndEditCtl = editControl.Create(_T("EDIT"), m_hWnd, editControlPos, NULL,
- WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL |
WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
- WS_EX_CLIENTEDGE);
+ editControl.Create(_T("EDIT"), m_hWnd, editControlPos, NULL,
+ WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL |
ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
+ WS_EX_CLIENTEDGE);
return 0;
}