mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +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
|
||||
*/
|
||||
|
||||
/* INCLUDES *********************************************************/
|
||||
|
||||
//#include <windows.h>
|
||||
//#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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -13,9 +13,11 @@ private:
|
|||
void NotifyImageChanged();
|
||||
public:
|
||||
HBITMAP hBms[HISTORYSIZE];
|
||||
private:
|
||||
int currInd;
|
||||
int undoSteps;
|
||||
int redoSteps;
|
||||
public:
|
||||
BOOL imageSaved;
|
||||
|
||||
ImageModel();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -37,7 +37,6 @@ private:
|
|||
|
||||
public:
|
||||
SelectionModel();
|
||||
void SetDC(HDC hDC);
|
||||
void ResetPtStack();
|
||||
void PushToPtStack(LONG x, LONG y);
|
||||
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 */
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue