diff --git a/reactos/base/applications/mspaint_new/globalvar.h b/reactos/base/applications/mspaint_new/globalvar.h index 9581eadbe6c..534647f20dc 100644 --- a/reactos/base/applications/mspaint_new/globalvar.h +++ b/reactos/base/applications/mspaint_new/globalvar.h @@ -6,11 +6,6 @@ * PROGRAMMERS: Benedikt Freisen */ -/* INCLUDES *********************************************************/ - -//#include -//#include "definitions.h" - /* TYPES ************************************************************/ typedef struct tagSTRETCHSKEW { @@ -21,8 +16,6 @@ typedef struct tagSTRETCHSKEW { /* VARIABLES declared in main.c *************************************/ extern HDC hDrawingDC; -extern int *bmAddress; -extern BITMAPINFO bitmapinfo; extern int widthSetInDlg; extern int heightSetInDlg; @@ -42,7 +35,6 @@ extern ToolsModel toolsModel; class SelectionModel; extern SelectionModel selectionModel; -extern HWND hwndEditCtl; extern LOGFONT lfTextFont; extern HFONT hfontTextFont; extern LPTSTR textToolText; diff --git a/reactos/base/applications/mspaint_new/history.cpp b/reactos/base/applications/mspaint_new/history.cpp index 855447623fc..8e6996b76ed 100644 --- a/reactos/base/applications/mspaint_new/history.cpp +++ b/reactos/base/applications/mspaint_new/history.cpp @@ -28,6 +28,18 @@ ImageModel::ImageModel() 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() diff --git a/reactos/base/applications/mspaint_new/history.h b/reactos/base/applications/mspaint_new/history.h index f33e43a1ce1..e02f27ae9e1 100644 --- a/reactos/base/applications/mspaint_new/history.h +++ b/reactos/base/applications/mspaint_new/history.h @@ -13,9 +13,11 @@ private: void NotifyImageChanged(); public: HBITMAP hBms[HISTORYSIZE]; +private: int currInd; int undoSteps; int redoSteps; +public: BOOL imageSaved; ImageModel(); diff --git a/reactos/base/applications/mspaint_new/main.cpp b/reactos/base/applications/mspaint_new/main.cpp index f68136b526f..e39c435aeaa 100644 --- a/reactos/base/applications/mspaint_new/main.cpp +++ b/reactos/base/applications/mspaint_new/main.cpp @@ -13,19 +13,12 @@ /* 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; @@ -41,6 +34,9 @@ int textToolTextMaxLen = 0; PaletteModel paletteModel; +ImageModel imageModel; +BOOL askBeforeEnlarging = FALSE; // TODO: initialize from registry + HWND hStatusBar; CHOOSECOLOR choosecolor; OPENFILENAME ofn; @@ -100,7 +96,6 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument TCHAR resstr[100]; HMENU menu; HANDLE haccel; - HDC hDC; TCHAR *c; TCHAR sfnFilename[1000]; @@ -198,21 +193,9 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument 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) { HBITMAP bmNew = NULL; diff --git a/reactos/base/applications/mspaint_new/selectionmodel.cpp b/reactos/base/applications/mspaint_new/selectionmodel.cpp index af720fa3d3e..c69e3e026d6 100644 --- a/reactos/base/applications/mspaint_new/selectionmodel.cpp +++ b/reactos/base/applications/mspaint_new/selectionmodel.cpp @@ -16,11 +16,8 @@ SelectionModel::SelectionModel() { 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::DrawBackgroundPoly(HDC hDCImage, COLORREF crBg) 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 @@ ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, 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)); diff --git a/reactos/base/applications/mspaint_new/selectionmodel.h b/reactos/base/applications/mspaint_new/selectionmodel.h index 0fec3315a03..1b3c82529bf 100644 --- a/reactos/base/applications/mspaint_new/selectionmodel.h +++ b/reactos/base/applications/mspaint_new/selectionmodel.h @@ -37,7 +37,6 @@ private: public: SelectionModel(); - void SetDC(HDC hDC); void ResetPtStack(); void PushToPtStack(LONG x, LONG y); void CalculateBoundingBoxAndContents(HDC hDCImage); diff --git a/reactos/base/applications/mspaint_new/textedit.cpp b/reactos/base/applications/mspaint_new/textedit.cpp index b65223b966f..9c71ac5ec5e 100644 --- a/reactos/base/applications/mspaint_new/textedit.cpp +++ b/reactos/base/applications/mspaint_new/textedit.cpp @@ -15,9 +15,9 @@ LRESULT CTextEditWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& { /* 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; }