mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 05:00:27 +00:00
[MSPAINT_NEW]
- move bitmap and DC initialization to ImageModel - remove unused global variables - remove copy-pasta bug from SelectionModel::DrawSelection svn path=/trunk/; revision=68565
This commit is contained in:
parent
9a5944f03d
commit
e49e629215
7 changed files with 23 additions and 40 deletions
|
@ -6,11 +6,6 @@
|
||||||
* PROGRAMMERS: Benedikt Freisen
|
* PROGRAMMERS: Benedikt Freisen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *********************************************************/
|
|
||||||
|
|
||||||
//#include <windows.h>
|
|
||||||
//#include "definitions.h"
|
|
||||||
|
|
||||||
/* TYPES ************************************************************/
|
/* TYPES ************************************************************/
|
||||||
|
|
||||||
typedef struct tagSTRETCHSKEW {
|
typedef struct tagSTRETCHSKEW {
|
||||||
|
@ -21,8 +16,6 @@ typedef struct tagSTRETCHSKEW {
|
||||||
/* VARIABLES declared in main.c *************************************/
|
/* VARIABLES declared in main.c *************************************/
|
||||||
|
|
||||||
extern HDC hDrawingDC;
|
extern HDC hDrawingDC;
|
||||||
extern int *bmAddress;
|
|
||||||
extern BITMAPINFO bitmapinfo;
|
|
||||||
|
|
||||||
extern int widthSetInDlg;
|
extern int widthSetInDlg;
|
||||||
extern int heightSetInDlg;
|
extern int heightSetInDlg;
|
||||||
|
@ -42,7 +35,6 @@ extern ToolsModel toolsModel;
|
||||||
class SelectionModel;
|
class SelectionModel;
|
||||||
extern SelectionModel selectionModel;
|
extern SelectionModel selectionModel;
|
||||||
|
|
||||||
extern HWND hwndEditCtl;
|
|
||||||
extern LOGFONT lfTextFont;
|
extern LOGFONT lfTextFont;
|
||||||
extern HFONT hfontTextFont;
|
extern HFONT hfontTextFont;
|
||||||
extern LPTSTR textToolText;
|
extern LPTSTR textToolText;
|
||||||
|
|
|
@ -28,6 +28,18 @@ ImageModel::ImageModel()
|
||||||
undoSteps = 0;
|
undoSteps = 0;
|
||||||
redoSteps = 0;
|
redoSteps = 0;
|
||||||
imageSaved = TRUE;
|
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()
|
void ImageModel::CopyPrevious()
|
||||||
|
|
|
@ -13,9 +13,11 @@ private:
|
||||||
void NotifyImageChanged();
|
void NotifyImageChanged();
|
||||||
public:
|
public:
|
||||||
HBITMAP hBms[HISTORYSIZE];
|
HBITMAP hBms[HISTORYSIZE];
|
||||||
|
private:
|
||||||
int currInd;
|
int currInd;
|
||||||
int undoSteps;
|
int undoSteps;
|
||||||
int redoSteps;
|
int redoSteps;
|
||||||
|
public:
|
||||||
BOOL imageSaved;
|
BOOL imageSaved;
|
||||||
|
|
||||||
ImageModel();
|
ImageModel();
|
||||||
|
|
|
@ -13,19 +13,12 @@
|
||||||
/* FUNCTIONS ********************************************************/
|
/* FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
HDC hDrawingDC;
|
HDC hDrawingDC;
|
||||||
int *bmAddress;
|
|
||||||
BITMAPINFO bitmapinfo;
|
|
||||||
int imgXRes = 400;
|
|
||||||
int imgYRes = 300;
|
|
||||||
|
|
||||||
int widthSetInDlg;
|
int widthSetInDlg;
|
||||||
int heightSetInDlg;
|
int heightSetInDlg;
|
||||||
|
|
||||||
STRETCHSKEW stretchSkew;
|
STRETCHSKEW stretchSkew;
|
||||||
|
|
||||||
ImageModel imageModel;
|
|
||||||
BOOL askBeforeEnlarging = FALSE; // TODO: initialize from registry
|
|
||||||
|
|
||||||
POINT start;
|
POINT start;
|
||||||
POINT last;
|
POINT last;
|
||||||
|
|
||||||
|
@ -41,6 +34,9 @@ int textToolTextMaxLen = 0;
|
||||||
|
|
||||||
PaletteModel paletteModel;
|
PaletteModel paletteModel;
|
||||||
|
|
||||||
|
ImageModel imageModel;
|
||||||
|
BOOL askBeforeEnlarging = FALSE; // TODO: initialize from registry
|
||||||
|
|
||||||
HWND hStatusBar;
|
HWND hStatusBar;
|
||||||
CHOOSECOLOR choosecolor;
|
CHOOSECOLOR choosecolor;
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
|
@ -100,7 +96,6 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
||||||
TCHAR resstr[100];
|
TCHAR resstr[100];
|
||||||
HMENU menu;
|
HMENU menu;
|
||||||
HANDLE haccel;
|
HANDLE haccel;
|
||||||
HDC hDC;
|
|
||||||
|
|
||||||
TCHAR *c;
|
TCHAR *c;
|
||||||
TCHAR sfnFilename[1000];
|
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);
|
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 */
|
/* 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);
|
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)
|
if (lpszArgument[0] != 0)
|
||||||
{
|
{
|
||||||
HBITMAP bmNew = NULL;
|
HBITMAP bmNew = NULL;
|
||||||
|
|
|
@ -16,11 +16,8 @@ SelectionModel::SelectionModel()
|
||||||
{
|
{
|
||||||
m_ptStack = NULL;
|
m_ptStack = NULL;
|
||||||
m_iPtSP = 0;
|
m_iPtSP = 0;
|
||||||
}
|
|
||||||
|
|
||||||
void SelectionModel::SetDC(HDC hDC)
|
m_hDC = CreateCompatibleDC(NULL);
|
||||||
{
|
|
||||||
m_hDC = hDC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionModel::ResetPtStack()
|
void SelectionModel::ResetPtStack()
|
||||||
|
@ -106,7 +103,7 @@ void SelectionModel::DrawBackgroundPoly(HDC hDCImage, COLORREF crBg)
|
||||||
|
|
||||||
void SelectionModel::DrawBackgroundRect(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
|
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)
|
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)
|
if (!bBgTransparent)
|
||||||
MaskBlt(hDCImage, m_rcDest.left, m_rcDest.top, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest),
|
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));
|
m_hDC, 0, 0, m_hMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
|
||||||
|
|
|
@ -37,7 +37,6 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SelectionModel();
|
SelectionModel();
|
||||||
void SetDC(HDC hDC);
|
|
||||||
void ResetPtStack();
|
void ResetPtStack();
|
||||||
void PushToPtStack(LONG x, LONG y);
|
void PushToPtStack(LONG x, LONG y);
|
||||||
void CalculateBoundingBoxAndContents(HDC hDCImage);
|
void CalculateBoundingBoxAndContents(HDC hDCImage);
|
||||||
|
|
|
@ -15,9 +15,9 @@ LRESULT CTextEditWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
|
||||||
{
|
{
|
||||||
/* creating the edit control within the editor window */
|
/* creating the edit control within the editor window */
|
||||||
RECT editControlPos = {0, 0, 0 + 100, 0 + 100};
|
RECT editControlPos = {0, 0, 0 + 100, 0 + 100};
|
||||||
hwndEditCtl = editControl.Create(_T("EDIT"), m_hWnd, editControlPos, NULL,
|
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_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
|
||||||
WS_EX_CLIENTEDGE);
|
WS_EX_CLIENTEDGE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue