From f2e66d0408dea31db5a019c4bf3f3b49d908a5ab Mon Sep 17 00:00:00 2001 From: Benedikt Freisen Date: Wed, 21 Oct 2009 15:44:31 +0000 Subject: [PATCH] [PAINT] cleanup: - formatting for enhanced readability - removal of superfluous variables/assignments - corrected or added header comment in all files - change if ... else ... to ?-operator where sensible and readable - small bugfix in mouse.c concerning rectangle drawing - fixed some possible string buffer overruns svn path=/trunk/; revision=43671 --- reactos/base/applications/paint/definitions.h | 7 +- reactos/base/applications/paint/dialogs.c | 88 +-- reactos/base/applications/paint/dialogs.h | 2 +- reactos/base/applications/paint/dib.c | 34 +- reactos/base/applications/paint/dib.h | 5 +- reactos/base/applications/paint/drawing.c | 156 +++-- reactos/base/applications/paint/drawing.h | 2 +- reactos/base/applications/paint/globalvar.h | 9 +- reactos/base/applications/paint/history.c | 78 ++- reactos/base/applications/paint/lang/bg-BG.rc | 13 +- reactos/base/applications/paint/lang/cs-CZ.rc | 15 +- reactos/base/applications/paint/lang/de-DE.rc | 7 +- reactos/base/applications/paint/lang/en-GB.rc | 13 +- reactos/base/applications/paint/lang/en-US.rc | 13 +- reactos/base/applications/paint/lang/es-ES.rc | 13 +- reactos/base/applications/paint/lang/eu-ES.rc | 14 +- reactos/base/applications/paint/lang/fr-FR.rc | 13 +- reactos/base/applications/paint/lang/it-IT.rc | 13 +- reactos/base/applications/paint/lang/ja-JP.rc | 13 +- reactos/base/applications/paint/lang/nl-NL.rc | 13 +- reactos/base/applications/paint/lang/no-NO.rc | 13 +- reactos/base/applications/paint/lang/pl-PL.rc | 16 +- reactos/base/applications/paint/lang/pt-BR.rc | 13 +- reactos/base/applications/paint/lang/pt-PT.rc | 13 +- reactos/base/applications/paint/lang/ro-RO.rc | 13 +- reactos/base/applications/paint/lang/ru-RU.rc | 14 +- reactos/base/applications/paint/lang/sk-SK.rc | 14 +- reactos/base/applications/paint/lang/uk-UA.rc | 12 +- reactos/base/applications/paint/main.c | 272 +++++--- reactos/base/applications/paint/mouse.c | 133 ++-- reactos/base/applications/paint/mouse.h | 2 +- reactos/base/applications/paint/palette.c | 122 ++-- reactos/base/applications/paint/palette.h | 2 +- reactos/base/applications/paint/registry.c | 23 +- reactos/base/applications/paint/registry.h | 2 +- reactos/base/applications/paint/rsrc.rc | 2 +- reactos/base/applications/paint/selection.c | 42 +- reactos/base/applications/paint/selection.h | 4 +- reactos/base/applications/paint/sizebox.c | 99 ++- reactos/base/applications/paint/sizebox.h | 4 +- .../base/applications/paint/toolsettings.c | 434 ++++++------ .../base/applications/paint/toolsettings.h | 4 +- reactos/base/applications/paint/winproc.c | 624 +++++++++--------- reactos/base/applications/paint/winproc.h | 6 +- 44 files changed, 1319 insertions(+), 1085 deletions(-) diff --git a/reactos/base/applications/paint/definitions.h b/reactos/base/applications/paint/definitions.h index 54fcdefbebd..5fb041e7a4c 100644 --- a/reactos/base/applications/paint/definitions.h +++ b/reactos/base/applications/paint/definitions.h @@ -1,8 +1,8 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: definitions.h - * PURPOSE: Defines the resource ids + * FILE: base/applications/paint/definitions.h + * PURPOSE: Defines the resource ids and other stuff * PROGRAMMERS: Benedikt Freisen */ @@ -12,6 +12,7 @@ /* HISTORYSIZE = number of possible undo-steps + 1 */ #define SIZEOF(a) (sizeof(a) / sizeof((a)[0])) +/* sizeof for string constants; equals max. number of characters */ #define IDI_APPICON 500 @@ -72,7 +73,7 @@ #define IDM_IMAGEINVERTCOLORS 253 #define IDM_IMAGEATTRIBUTES 254 #define IDM_IMAGEDELETEIMAGE 255 -#define IDM_IMAGEDRAWOPAQUE 256 +#define IDM_IMAGEDRAWOPAQUE 256 #define IDM_COLORSEDITPALETTE 260 diff --git a/reactos/base/applications/paint/dialogs.c b/reactos/base/applications/paint/dialogs.c index b29bd900780..bf3111b1bb7 100644 --- a/reactos/base/applications/paint/dialogs.c +++ b/reactos/base/applications/paint/dialogs.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: dialogs.c + * FILE: base/applications/paint/dialogs.c * PURPOSE: Window procedures of the dialog windows plus launching functions * PROGRAMMERS: Benedikt Freisen */ @@ -15,7 +15,8 @@ /* FUNCTIONS ********************************************************/ -LRESULT CALLBACK MRDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +MRDlgWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { @@ -63,44 +64,46 @@ LRESULT CALLBACK MRDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lP return TRUE; } -int mirrorRotateDlg() +int +mirrorRotateDlg() { - return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_MIRRORROTATE), hMainWnd, (DLGPROC)MRDlgWinProc); + return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_MIRRORROTATE), hMainWnd, (DLGPROC) MRDlgWinProc); } -LRESULT CALLBACK ATTDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +ATTDlgWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: + { + TCHAR strrc[100]; + TCHAR res[100]; + + CheckDlgButton(hwnd, IDD_ATTRIBUTESRB3, BST_CHECKED); + CheckDlgButton(hwnd, IDD_ATTRIBUTESRB5, BST_CHECKED); + SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, imgXRes, FALSE); + SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, imgYRes, FALSE); + + if (isAFile) { - TCHAR strrc[100]; - TCHAR res[100]; - - CheckDlgButton(hwnd, IDD_ATTRIBUTESRB3, BST_CHECKED); - CheckDlgButton(hwnd, IDD_ATTRIBUTESRB5, BST_CHECKED); - SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, imgXRes, FALSE); - SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, imgYRes, FALSE); - - if (isAFile) - { - TCHAR date[100]; - TCHAR size[100]; - TCHAR temp[100]; - GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, sizeof(date)); - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, sizeof(temp)); - _tcscat(date, _T(" ")); - _tcscat(date, temp); - LoadString(hProgInstance, IDS_FILESIZE, strrc, sizeof(strrc)); - _stprintf(size, strrc, fileSize); - SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT6, date); - SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT7, size); - } - LoadString(hProgInstance, IDS_PRINTRES, strrc, sizeof(strrc)); - _stprintf(res, strrc, fileHPPM, fileVPPM); - SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT8, res); - return TRUE; + TCHAR date[100]; + TCHAR size[100]; + TCHAR temp[100]; + GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, SIZEOF(date)); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, SIZEOF(temp)); + _tcscat(date, _T(" ")); + _tcscat(date, temp); + LoadString(hProgInstance, IDS_FILESIZE, strrc, SIZEOF(strrc)); + _stprintf(size, strrc, fileSize); + SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT6, date); + SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT7, size); } + LoadString(hProgInstance, IDS_PRINTRES, strrc, SIZEOF(strrc)); + _stprintf(res, strrc, fileHPPM, fileVPPM); + SetDlgItemText(hwnd, IDD_ATTRIBUTESTEXT8, res); + return TRUE; + } case WM_CLOSE: EndDialog(hwnd, 0); break; @@ -108,7 +111,10 @@ LRESULT CALLBACK ATTDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l switch (LOWORD(wParam)) { case IDOK: - EndDialog(hwnd, GetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, NULL, FALSE) | (GetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, NULL, FALSE)<<16)); + EndDialog(hwnd, + GetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, NULL, + FALSE) | (GetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, NULL, + FALSE) << 16)); break; case IDCANCEL: EndDialog(hwnd, 0); @@ -127,12 +133,14 @@ LRESULT CALLBACK ATTDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l return TRUE; } -int attributesDlg() +int +attributesDlg() { - return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_ATTRIBUTES), hMainWnd, (DLGPROC)ATTDlgWinProc); + return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_ATTRIBUTES), hMainWnd, (DLGPROC) ATTDlgWinProc); } -LRESULT CALLBACK CHSIZEDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +CHSIZEDlgWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { @@ -147,7 +155,10 @@ LRESULT CALLBACK CHSIZEDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARA switch (LOWORD(wParam)) { case IDOK: - EndDialog(hwnd, GetDlgItemInt(hwnd, IDD_CHANGESIZEEDIT1, NULL, FALSE) | (GetDlgItemInt(hwnd, IDD_CHANGESIZEEDIT2, NULL, FALSE)<<16)); + EndDialog(hwnd, + GetDlgItemInt(hwnd, IDD_CHANGESIZEEDIT1, NULL, + FALSE) | (GetDlgItemInt(hwnd, IDD_CHANGESIZEEDIT2, NULL, + FALSE) << 16)); break; case IDCANCEL: EndDialog(hwnd, 0); @@ -160,7 +171,8 @@ LRESULT CALLBACK CHSIZEDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARA return TRUE; } -int changeSizeDlg() +int +changeSizeDlg() { - return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_CHANGESIZE), hMainWnd, (DLGPROC)CHSIZEDlgWinProc); + return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_CHANGESIZE), hMainWnd, (DLGPROC) CHSIZEDlgWinProc); } diff --git a/reactos/base/applications/paint/dialogs.h b/reactos/base/applications/paint/dialogs.h index 9f4b38b6994..dc608dac84c 100644 --- a/reactos/base/applications/paint/dialogs.h +++ b/reactos/base/applications/paint/dialogs.h @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: dialogs.h + * FILE: base/applications/paint/dialogs.h * PURPOSE: Window procedures of the dialog windows plus launching functions * PROGRAMMERS: Benedikt Freisen */ diff --git a/reactos/base/applications/paint/dib.c b/reactos/base/applications/paint/dib.c index b2d6dda87b8..7c58f43c92d 100644 --- a/reactos/base/applications/paint/dib.c +++ b/reactos/base/applications/paint/dib.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: dib.c + * FILE: base/applications/paint/dib.c * PURPOSE: Some DIB related functions * PROGRAMMERS: Benedikt Freisen */ @@ -12,7 +12,8 @@ /* FUNCTIONS ********************************************************/ -HBITMAP CreateDIBWithProperties(int width, int height) +HBITMAP +CreateDIBWithProperties(int width, int height) { BITMAPINFO bmi; ZeroMemory(&bmi, sizeof(BITMAPINFO)); @@ -25,21 +26,24 @@ HBITMAP CreateDIBWithProperties(int width, int height) return CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, NULL, NULL, 0); } -int GetDIBWidth(HBITMAP hBitmap) +int +GetDIBWidth(HBITMAP hBitmap) { BITMAP bm; GetObject(hBitmap, sizeof(BITMAP), &bm); return bm.bmWidth; } -int GetDIBHeight(HBITMAP hBitmap) +int +GetDIBHeight(HBITMAP hBitmap) { BITMAP bm; GetObject(hBitmap, sizeof(BITMAP), &bm); return bm.bmHeight; } -void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, int *size, int hRes, int vRes) +void +SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, int *size, int hRes, int vRes) { BITMAP bm; HANDLE hFile; @@ -47,7 +51,7 @@ void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, BITMAPINFOHEADER bi; int imgDataSize; DWORD dwBytesWritten; - char* buffer; + char *buffer; GetObject(hBitmap, sizeof(BITMAP), &bm); @@ -55,7 +59,7 @@ void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, ZeroMemory(&bi, sizeof(BITMAPINFOHEADER)); imgDataSize = bm.bmWidthBytes * bm.bmHeight; - bf.bfType = 0x4d42; /* BM */ + bf.bfType = 0x4d42; /* BM */ bf.bfSize = imgDataSize + 52; bf.bfOffBits = 54; bi.biSize = sizeof(BITMAPINFOHEADER); @@ -68,7 +72,7 @@ void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, bi.biYPelsPerMeter = vRes; buffer = HeapAlloc(GetProcessHeap(), 0, imgDataSize); - GetDIBits(hDC, hBitmap, 0, bm.bmHeight, buffer, (LPBITMAPINFO)&bi, DIB_RGB_COLORS); + GetDIBits(hDC, hBitmap, 0, bm.bmHeight, buffer, (LPBITMAPINFO) & bi, DIB_RGB_COLORS); hFile = CreateFile(FileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFile == INVALID_HANDLE_VALUE) @@ -91,18 +95,20 @@ void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, HeapFree(GetProcessHeap(), 0, buffer); } -void LoadDIBFromFile(HBITMAP *hBitmap, LPTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes) +void +LoadDIBFromFile(HBITMAP * hBitmap, LPTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes) { BITMAPFILEHEADER bfh; BITMAPINFO *bi; PVOID pvBits; DWORD dwBytesRead; HANDLE hFile; - + if (!hBitmap) return; - hFile = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); + hFile = + CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (hFile == INVALID_HANDLE_VALUE) return; @@ -113,7 +119,7 @@ void LoadDIBFromFile(HBITMAP *hBitmap, LPTSTR name, LPSYSTEMTIME time, int *size CloseHandle(hFile); return; } - + if (time) { FILETIME ft; @@ -130,12 +136,12 @@ void LoadDIBFromFile(HBITMAP *hBitmap, LPTSTR name, LPSYSTEMTIME time, int *size ReadFile(hFile, bi, bfh.bfOffBits - sizeof(BITMAPFILEHEADER), &dwBytesRead, NULL); *hBitmap = CreateDIBSection(NULL, bi, DIB_RGB_COLORS, &pvBits, NULL, 0); ReadFile(hFile, pvBits, bfh.bfSize - bfh.bfOffBits, &dwBytesRead, NULL); - + if (hRes) *hRes = (*bi).bmiHeader.biXPelsPerMeter; if (vRes) *vRes = (*bi).bmiHeader.biYPelsPerMeter; - + CloseHandle(hFile); HeapFree(GetProcessHeap(), 0, bi); } diff --git a/reactos/base/applications/paint/dib.h b/reactos/base/applications/paint/dib.h index 5c99fcf6409..22a21163421 100644 --- a/reactos/base/applications/paint/dib.h +++ b/reactos/base/applications/paint/dib.h @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: dib.h + * FILE: base/applications/paint/dib.h * PURPOSE: Some DIB related functions * PROGRAMMERS: Benedikt Freisen */ @@ -12,6 +12,7 @@ int GetDIBWidth(HBITMAP hbm); int GetDIBHeight(HBITMAP hbm); -void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, int *size, int hRes, int vRes); +void SaveDIBToFile(HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, int *size, int hRes, + int vRes); void LoadDIBFromFile(HBITMAP *hBitmap, LPTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes); diff --git a/reactos/base/applications/paint/drawing.c b/reactos/base/applications/paint/drawing.c index bb8d24a40a5..bafbe1cfe03 100644 --- a/reactos/base/applications/paint/drawing.c +++ b/reactos/base/applications/paint/drawing.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: drawing.c + * FILE: base/applications/paint/drawing.c * PURPOSE: The drawing functions used by the tools * PROGRAMMERS: Benedikt Freisen */ @@ -12,7 +12,8 @@ /* FUNCTIONS ********************************************************/ -void Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickness) +void +Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickness) { HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, color)); MoveToEx(hdc, x1, y1, NULL); @@ -20,13 +21,14 @@ void Line(HDC hdc, short x1, short y1, short x2, short y2, int color, int thickn DeleteObject(SelectObject(hdc, oldPen)); } -void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) +void +Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) { HBRUSH oldBrush; LOGBRUSH logbrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); - if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; - if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; + logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID; + logbrush.lbColor = (style == 2) ? fg : bg; logbrush.lbHatch = 0; oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Rectangle(hdc, x1, y1, x2, y2); @@ -34,13 +36,14 @@ void Rect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int t DeleteObject(SelectObject(hdc, oldPen)); } -void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) +void +Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) { HBRUSH oldBrush; LOGBRUSH logbrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); - if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; - if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; + logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID; + logbrush.lbColor = (style == 2) ? fg : bg; logbrush.lbHatch = 0; oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); Ellipse(hdc, x1, y1, x2, y2); @@ -48,13 +51,14 @@ void Ellp(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int t DeleteObject(SelectObject(hdc, oldPen)); } -void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) +void +RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int thickness, int style) { LOGBRUSH logbrush; HBRUSH oldBrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); - if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; - if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; + logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID; + logbrush.lbColor = (style == 2) ? fg : bg; logbrush.lbHatch = 0; oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); RoundRect(hdc, x1, y1, x2, y2, 16, 16); @@ -62,13 +66,14 @@ void RRect(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int DeleteObject(SelectObject(hdc, oldPen)); } -void Poly(HDC hdc, POINT *lpPoints, int nCount, int fg, int bg, int thickness, int style, BOOL closed) +void +Poly(HDC hdc, POINT * lpPoints, int nCount, int fg, int bg, int thickness, int style, BOOL closed) { LOGBRUSH logbrush; HBRUSH oldBrush; HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, thickness, fg)); - if (style==0) logbrush.lbStyle = BS_HOLLOW; else logbrush.lbStyle = BS_SOLID; - if (style==2) logbrush.lbColor = fg; else logbrush.lbColor = bg; + logbrush.lbStyle = (style == 0) ? BS_HOLLOW : BS_SOLID; + logbrush.lbColor = (style == 2) ? fg : bg; logbrush.lbHatch = 0; oldBrush = SelectObject(hdc, CreateBrushIndirect(&logbrush)); if (closed) @@ -79,7 +84,8 @@ void Poly(HDC hdc, POINT *lpPoints, int nCount, int fg, int bg, int thickness, i DeleteObject(SelectObject(hdc, oldPen)); } -void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness) +void +Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thickness) { HPEN oldPen; POINT fourPoints[4]; @@ -92,42 +98,55 @@ void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, int color, int thic DeleteObject(SelectObject(hdc, oldPen)); } -void Fill(HDC hdc, int x, int y, int color) +void +Fill(HDC hdc, int x, int y, int color) { HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); ExtFloodFill(hdc, x, y, GetPixel(hdc, x, y), FLOODFILLSURFACE); DeleteObject(SelectObject(hdc, oldBrush)); } -void Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius) +void +Erase(HDC hdc, short x1, short y1, short x2, short y2, int color, int radius) { short a; HPEN oldPen; HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); - for (a=0; a<=100; a++) - Rectangle(hdc, (x1*(100-a)+x2*a)/100-radius+1, (y1*(100-a)+y2*a)/100-radius+1, (x1*(100-a)+x2*a)/100+radius+1, (y1*(100-a)+y2*a)/100+radius+1); + for(a = 0; a <= 100; a++) + Rectangle(hdc, (x1 * (100 - a) + x2 * a) / 100 - radius + 1, + (y1 * (100 - a) + y2 * a) / 100 - radius + 1, (x1 * (100 - a) + x2 * a) / 100 + radius + 1, + (y1 * (100 - a) + y2 * a) / 100 + radius + 1); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); } -void Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int radius) +void +Replace(HDC hdc, short x1, short y1, short x2, short y2, int fg, int bg, int radius) { short a, x, y; - for (a=0; a<=100; a++) - for (y=(y1*(100-a)+y2*a)/100-radius+1; y<(y1*(100-a)+y2*a)/100+radius+1; y++) - for (x=(x1*(100-a)+x2*a)/100-radius+1; x<(x1*(100-a)+x2*a)/100+radius+1; x++) - if (GetPixel(hdc, x, y)==fg) SetPixel(hdc, x, y, bg); + for(a = 0; a <= 100; a++) + for(y = (y1 * (100 - a) + y2 * a) / 100 - radius + 1; + y < (y1 * (100 - a) + y2 * a) / 100 + radius + 1; y++) + for(x = (x1 * (100 - a) + x2 * a) / 100 - radius + 1; + x < (x1 * (100 - a) + x2 * a) / 100 + radius + 1; x++) + if (GetPixel(hdc, x, y) == fg) + SetPixel(hdc, x, y, bg); } -void Airbrush(HDC hdc, short x, short y, int color, int r) +void +Airbrush(HDC hdc, short x, short y, int color, int r) { short a; short b; - for (b=-r; b<=r; b++) for (a=-r; a<=r; a++) if ((a*a+b*b<=r*r)&&(rand()%4==0)) SetPixel(hdc, x+a, y+b, color); + for(b = -r; b <= r; b++) + for(a = -r; a <= r; a++) + if ((a * a + b * b <= r * r) && (rand() % 4 == 0)) + SetPixel(hdc, x + a, y + b, color); } -void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style) +void +Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style) { HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, color)); HBRUSH oldBrush = SelectObject(hdc, CreateSolidBrush(color)); @@ -135,12 +154,14 @@ void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style switch (style) { case 0: - for (a=0; a<=100; a++) - Ellipse(hdc, (x1*(100-a)+x2*a)/100-3, (y1*(100-a)+y2*a)/100-3, (x1*(100-a)+x2*a)/100+4, (y1*(100-a)+y2*a)/100+4); + for(a = 0; a <= 100; a++) + Ellipse(hdc, (x1 * (100 - a) + x2 * a) / 100 - 3, (y1 * (100 - a) + y2 * a) / 100 - 3, + (x1 * (100 - a) + x2 * a) / 100 + 4, (y1 * (100 - a) + y2 * a) / 100 + 4); break; case 1: - for (a=0; a<=100; a++) - Ellipse(hdc, (x1*(100-a)+x2*a)/100-1, (y1*(100-a)+y2*a)/100-1, (x1*(100-a)+x2*a)/100+3, (y1*(100-a)+y2*a)/100+3); + for(a = 0; a <= 100; a++) + Ellipse(hdc, (x1 * (100 - a) + x2 * a) / 100 - 1, (y1 * (100 - a) + y2 * a) / 100 - 1, + (x1 * (100 - a) + x2 * a) / 100 + 3, (y1 * (100 - a) + y2 * a) / 100 + 3); break; case 2: MoveToEx(hdc, x1, y1, NULL); @@ -148,57 +169,60 @@ void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style SetPixel(hdc, x2, y2, color); break; case 3: - for (a=0; a<=100; a++) - Rectangle(hdc, (x1*(100-a)+x2*a)/100-3, (y1*(100-a)+y2*a)/100-3, (x1*(100-a)+x2*a)/100+5, (y1*(100-a)+y2*a)/100+5); + for(a = 0; a <= 100; a++) + Rectangle(hdc, (x1 * (100 - a) + x2 * a) / 100 - 3, (y1 * (100 - a) + y2 * a) / 100 - 3, + (x1 * (100 - a) + x2 * a) / 100 + 5, (y1 * (100 - a) + y2 * a) / 100 + 5); break; case 4: - for (a=0; a<=100; a++) - Rectangle(hdc, (x1*(100-a)+x2*a)/100-2, (y1*(100-a)+y2*a)/100-2, (x1*(100-a)+x2*a)/100+3, (y1*(100-a)+y2*a)/100+3); + for(a = 0; a <= 100; a++) + Rectangle(hdc, (x1 * (100 - a) + x2 * a) / 100 - 2, (y1 * (100 - a) + y2 * a) / 100 - 2, + (x1 * (100 - a) + x2 * a) / 100 + 3, (y1 * (100 - a) + y2 * a) / 100 + 3); break; case 5: - for (a=0; a<=100; a++) - Rectangle(hdc, (x1*(100-a)+x2*a)/100-1, (y1*(100-a)+y2*a)/100-1, (x1*(100-a)+x2*a)/100+1, (y1*(100-a)+y2*a)/100+1); + for(a = 0; a <= 100; a++) + Rectangle(hdc, (x1 * (100 - a) + x2 * a) / 100 - 1, (y1 * (100 - a) + y2 * a) / 100 - 1, + (x1 * (100 - a) + x2 * a) / 100 + 1, (y1 * (100 - a) + y2 * a) / 100 + 1); break; case 6: - for (a=0; a<=100; a++) + for(a = 0; a <= 100; a++) { - MoveToEx(hdc, (x1*(100-a)+x2*a)/100-3, (y1*(100-a)+y2*a)/100+5, NULL); - LineTo(hdc, (x1*(100-a)+x2*a)/100+5, (y1*(100-a)+y2*a)/100-3); + MoveToEx(hdc, (x1 * (100 - a) + x2 * a) / 100 - 3, (y1 * (100 - a) + y2 * a) / 100 + 5, NULL); + LineTo(hdc, (x1 * (100 - a) + x2 * a) / 100 + 5, (y1 * (100 - a) + y2 * a) / 100 - 3); } break; case 7: - for (a=0; a<=100; a++) + for(a = 0; a <= 100; a++) { - MoveToEx(hdc, (x1*(100-a)+x2*a)/100-2, (y1*(100-a)+y2*a)/100+3, NULL); - LineTo(hdc, (x1*(100-a)+x2*a)/100+3, (y1*(100-a)+y2*a)/100-2); + MoveToEx(hdc, (x1 * (100 - a) + x2 * a) / 100 - 2, (y1 * (100 - a) + y2 * a) / 100 + 3, NULL); + LineTo(hdc, (x1 * (100 - a) + x2 * a) / 100 + 3, (y1 * (100 - a) + y2 * a) / 100 - 2); } break; case 8: - for (a=0; a<=100; a++) + for(a = 0; a <= 100; a++) { - MoveToEx(hdc, (x1*(100-a)+x2*a)/100-1, (y1*(100-a)+y2*a)/100+1, NULL); - LineTo(hdc, (x1*(100-a)+x2*a)/100+1, (y1*(100-a)+y2*a)/100-1); + MoveToEx(hdc, (x1 * (100 - a) + x2 * a) / 100 - 1, (y1 * (100 - a) + y2 * a) / 100 + 1, NULL); + LineTo(hdc, (x1 * (100 - a) + x2 * a) / 100 + 1, (y1 * (100 - a) + y2 * a) / 100 - 1); } break; case 9: - for (a=0; a<=100; a++) + for(a = 0; a <= 100; a++) { - MoveToEx(hdc, (x1*(100-a)+x2*a)/100-3, (y1*(100-a)+y2*a)/100-3, NULL); - LineTo(hdc, (x1*(100-a)+x2*a)/100+5, (y1*(100-a)+y2*a)/100+5); + MoveToEx(hdc, (x1 * (100 - a) + x2 * a) / 100 - 3, (y1 * (100 - a) + y2 * a) / 100 - 3, NULL); + LineTo(hdc, (x1 * (100 - a) + x2 * a) / 100 + 5, (y1 * (100 - a) + y2 * a) / 100 + 5); } break; case 10: - for (a=0; a<=100; a++) + for(a = 0; a <= 100; a++) { - MoveToEx(hdc, (x1*(100-a)+x2*a)/100-2, (y1*(100-a)+y2*a)/100-2, NULL); - LineTo(hdc, (x1*(100-a)+x2*a)/100+3, (y1*(100-a)+y2*a)/100+3); + MoveToEx(hdc, (x1 * (100 - a) + x2 * a) / 100 - 2, (y1 * (100 - a) + y2 * a) / 100 - 2, NULL); + LineTo(hdc, (x1 * (100 - a) + x2 * a) / 100 + 3, (y1 * (100 - a) + y2 * a) / 100 + 3); } break; case 11: - for (a=0; a<=100; a++) + for(a = 0; a <= 100; a++) { - MoveToEx(hdc, (x1*(100-a)+x2*a)/100-1, (y1*(100-a)+y2*a)/100-1, NULL); - LineTo(hdc, (x1*(100-a)+x2*a)/100+1, (y1*(100-a)+y2*a)/100+1); + MoveToEx(hdc, (x1 * (100 - a) + x2 * a) / 100 - 1, (y1 * (100 - a) + y2 * a) / 100 - 1, NULL); + LineTo(hdc, (x1 * (100 - a) + x2 * a) / 100 + 1, (y1 * (100 - a) + y2 * a) / 100 + 1); } break; } @@ -206,7 +230,8 @@ void Brush(HDC hdc, short x1, short y1, short x2, short y2, int color, int style DeleteObject(SelectObject(hdc, oldPen)); } -void RectSel(HDC hdc, short x1, short y1, short x2, short y2) +void +RectSel(HDC hdc, short x1, short y1, short x2, short y2) { HBRUSH oldBrush; LOGBRUSH logbrush; @@ -220,7 +245,8 @@ void RectSel(HDC hdc, short x1, short y1, short x2, short y2) DeleteObject(SelectObject(hdc, oldPen)); } -void SelectionFrame(HDC hdc, int x1, int y1, int x2, int y2) +void +SelectionFrame(HDC hdc, int x1, int y1, int x2, int y2) { HBRUSH oldBrush; LOGBRUSH logbrush; @@ -234,14 +260,14 @@ void SelectionFrame(HDC hdc, int x1, int y1, int x2, int y2) DeleteObject(SelectObject(hdc, oldPen)); oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00000000)); oldBrush = SelectObject(hdc, CreateSolidBrush(0x00000000)); - Rectangle(hdc, x1-1, y1-1, x1+2, y1+2); - Rectangle(hdc, x2-2, y1-1, x2+2, y1+2); - Rectangle(hdc, x1-1, y2-2, x1+2, y2+1); - Rectangle(hdc, x2-2, y2-2, x2+2, y2+1); - Rectangle(hdc, (x1+x2)/2-1, y1-1, (x1+x2)/2+2, y1+2); - Rectangle(hdc, (x1+x2)/2-1, y2-2, (x1+x2)/2+2, y2+1); - Rectangle(hdc, x1-1, (y1+y2)/2-1, x1+2, (y1+y2)/2+2); - Rectangle(hdc, x2-2, (y1+y2)/2-1, x2+1, (y1+y2)/2+2); + Rectangle(hdc, x1 - 1, y1 - 1, x1 + 2, y1 + 2); + Rectangle(hdc, x2 - 2, y1 - 1, x2 + 2, y1 + 2); + Rectangle(hdc, x1 - 1, y2 - 2, x1 + 2, y2 + 1); + Rectangle(hdc, x2 - 2, y2 - 2, x2 + 2, y2 + 1); + Rectangle(hdc, (x1 + x2) / 2 - 1, y1 - 1, (x1 + x2) / 2 + 2, y1 + 2); + Rectangle(hdc, (x1 + x2) / 2 - 1, y2 - 2, (x1 + x2) / 2 + 2, y2 + 1); + Rectangle(hdc, x1 - 1, (y1 + y2) / 2 - 1, x1 + 2, (y1 + y2) / 2 + 2); + Rectangle(hdc, x2 - 2, (y1 + y2) / 2 - 1, x2 + 1, (y1 + y2) / 2 + 2); DeleteObject(SelectObject(hdc, oldBrush)); DeleteObject(SelectObject(hdc, oldPen)); } diff --git a/reactos/base/applications/paint/drawing.h b/reactos/base/applications/paint/drawing.h index 71671d93384..db0d050d8d1 100644 --- a/reactos/base/applications/paint/drawing.h +++ b/reactos/base/applications/paint/drawing.h @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: drawing.h + * FILE: base/applications/paint/drawing.h * PURPOSE: The drawing functions used by the tools * PROGRAMMERS: Benedikt Freisen */ diff --git a/reactos/base/applications/paint/globalvar.h b/reactos/base/applications/paint/globalvar.h index 494019d64a3..964f28b71fa 100644 --- a/reactos/base/applications/paint/globalvar.h +++ b/reactos/base/applications/paint/globalvar.h @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: globalvar.h + * FILE: base/applications/paint/globalvar.h * PURPOSE: Declaring global variables for later initialization * PROGRAMMERS: Benedikt Freisen */ @@ -45,13 +45,16 @@ extern HWND hImageArea; extern HBITMAP hSelBm; extern int palColors[28]; + extern int fgColor; extern int bgColor; + extern HWND hStatusBar; extern HWND hScrollbox; extern HWND hMainWnd; extern HWND hPalWin; extern HWND hToolSettings; +extern HWND hTrackbarZoom; extern CHOOSECOLOR choosecolor; extern OPENFILENAME ofn; extern OPENFILENAME sfn; @@ -92,9 +95,7 @@ extern HWND hSizeboxLeftBottom; extern HWND hSizeboxCenterBottom; extern HWND hSizeboxRightBottom; -extern HWND hTrackbarZoom; - -/* VARIABLES declared in mouse.c *************************************/ +/* VARIABLES declared in mouse.c ************************************/ extern POINT pointStack[256]; extern short pointSP; diff --git a/reactos/base/applications/paint/history.c b/reactos/base/applications/paint/history.c index 8331c9d6768..e105dab0f0d 100644 --- a/reactos/base/applications/paint/history.c +++ b/reactos/base/applications/paint/history.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: history.c + * FILE: base/applications/paint/history.c * PURPOSE: Undo and redo functionality * PROGRAMMERS: Benedikt Freisen */ @@ -17,9 +17,10 @@ extern void updateCanvasAndScrollbars(void); -void setImgXYRes(int x, int y) +void +setImgXYRes(int x, int y) { - if ((imgXRes!=x)||(imgYRes!=y)) + if ((imgXRes != x) || (imgYRes != y)) { imgXRes = x; imgYRes = y; @@ -27,12 +28,14 @@ void setImgXYRes(int x, int y) } } -void newReversible() +void +newReversible() { - DeleteObject(hBms[(currInd+1)%HISTORYSIZE]); - hBms[(currInd+1)%HISTORYSIZE] = CopyImage( hBms[currInd], IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG); - currInd = (currInd+1)%HISTORYSIZE; - if (undoSteps0) + if (undoSteps > 0) { ShowWindow(hSelection, SW_HIDE); - currInd = (currInd+HISTORYSIZE-1)%HISTORYSIZE; + currInd = (currInd + HISTORYSIZE - 1) % HISTORYSIZE; SelectObject(hDrawingDC, hBms[currInd]); undoSteps--; - if (redoSteps0) + if (redoSteps > 0) { ShowWindow(hSelection, SW_HIDE); - currInd = (currInd+1)%HISTORYSIZE; + currInd = (currInd + 1) % HISTORYSIZE; SelectObject(hDrawingDC, hBms[currInd]); redoSteps--; - if (undoSteps=2) Poly(hdc, pointStack, pointSP+1, fg, bg, lineWidth, shapeStyle, FALSE); - if (pointSP==0) + if (pointSP + 1 >= 2) + Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE); + if (pointSP == 0) { newReversible(); pointSP++; @@ -86,24 +91,25 @@ void startPaintingL(HDC hdc, short x, short y, int fg, int bg) } } -void whilePaintingL(HDC hdc, short x, short y, int fg, int bg) +void +whilePaintingL(HDC hdc, short x, short y, int fg, int bg) { switch (activeTool) { case 2: - { - short tempX; - short tempY; - resetToU1(); - tempX = max(0, min(x, imgXRes)); - tempY = max(0, min(y, imgYRes)); - rectSel_dest[0] = rectSel_src[0] = min(startX, tempX); - rectSel_dest[1] = rectSel_src[1] = min(startY, tempY); - rectSel_dest[2] = rectSel_src[2] = max(startX, tempX)-min(startX, tempX); - rectSel_dest[3] = rectSel_src[3] = max(startY, tempY)-min(startY, tempY); - RectSel(hdc, startX, startY, tempX, tempY); - } + { + short tempX; + short tempY; + resetToU1(); + tempX = max(0, min(x, imgXRes)); + tempY = max(0, min(y, imgYRes)); + rectSel_dest[0] = rectSel_src[0] = min(startX, tempX); + rectSel_dest[1] = rectSel_src[1] = min(startY, tempY); + rectSel_dest[2] = rectSel_src[2] = max(startX, tempX) - min(startX, tempX); + rectSel_dest[3] = rectSel_src[3] = max(startY, tempY) - min(startY, tempY); + RectSel(hdc, startX, startY, tempX, tempY); break; + } case 3: Erase(hdc, lastX, lastY, x, y, bg, rubberRadius); break; @@ -126,9 +132,16 @@ void whilePaintingL(HDC hdc, short x, short y, int fg, int bg) pointStack[pointSP].y = y; switch (pointSP) { - case 1: Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, fg, lineWidth); break; - case 2: Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], fg, lineWidth); break; - case 3: Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], fg, lineWidth); break; + case 1: + Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, fg, + lineWidth); + break; + case 2: + Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], fg, lineWidth); + break; + case 3: + Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], fg, lineWidth); + break; } break; case 13: @@ -139,7 +152,8 @@ void whilePaintingL(HDC hdc, short x, short y, int fg, int bg) resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; - if (pointSP+1>=2) Poly(hdc, pointStack, pointSP+1, fg, bg, lineWidth, shapeStyle, FALSE); + if (pointSP + 1 >= 2) + Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE); break; case 15: resetToU1(); @@ -150,21 +164,25 @@ void whilePaintingL(HDC hdc, short x, short y, int fg, int bg) RRect(hdc, startX, startY, x, y, fg, bg, lineWidth, shapeStyle); break; } - + lastX = x; lastY = y; } -void endPaintingL(HDC hdc, short x, short y, int fg, int bg) +void +endPaintingL(HDC hdc, short x, short y, int fg, int bg) { switch (activeTool) { case 2: resetToU1(); - if ((rectSel_src[2]!=0)&&(rectSel_src[3]!=0)) + if ((rectSel_src[2] != 0) && (rectSel_src[3] != 0)) { - DeleteObject(SelectObject(hSelDC, hSelBm = (HBITMAP)CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]))); - BitBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0], rectSel_src[1], SRCCOPY); + DeleteObject(SelectObject + (hSelDC, hSelBm = + (HBITMAP) CreateDIBWithProperties(rectSel_src[2], rectSel_src[3]))); + BitBlt(hSelDC, 0, 0, rectSel_src[2], rectSel_src[3], hDrawingDC, rectSel_src[0], + rectSel_src[1], SRCCOPY); placeSelWin(); ShowWindow(hSelection, SW_SHOW); } @@ -182,7 +200,8 @@ void endPaintingL(HDC hdc, short x, short y, int fg, int bg) break; case 12: pointSP++; - if (pointSP==4) pointSP = 0; + if (pointSP == 4) + pointSP = 0; break; case 13: resetToU1(); @@ -193,9 +212,10 @@ void endPaintingL(HDC hdc, short x, short y, int fg, int bg) pointStack[pointSP].x = x; pointStack[pointSP].y = y; pointSP++; - if (pointSP>=2) + if (pointSP >= 2) { - if ( (pointStack[0].x-x)*(pointStack[0].x-x) + (pointStack[0].y-y)*(pointStack[0].y-y) <= lineWidth*lineWidth+1) + if ((pointStack[0].x - x) * (pointStack[0].x - x) + + (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1) { Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE); pointSP = 0; @@ -205,7 +225,8 @@ void endPaintingL(HDC hdc, short x, short y, int fg, int bg) Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE); } } - if (pointSP==255) pointSP--; + if (pointSP == 255) + pointSP--; break; case 15: resetToU1(); @@ -218,7 +239,8 @@ void endPaintingL(HDC hdc, short x, short y, int fg, int bg) } } -void startPaintingR(HDC hdc, short x, short y, int fg, int bg) +void +startPaintingR(HDC hdc, short x, short y, int fg, int bg) { startX = x; startY = y; @@ -229,6 +251,7 @@ void startPaintingR(HDC hdc, short x, short y, int fg, int bg) case 1: case 10: case 11: + case 13: case 15: case 16: newReversible(); @@ -255,7 +278,7 @@ void startPaintingR(HDC hdc, short x, short y, int fg, int bg) case 12: pointStack[pointSP].x = x; pointStack[pointSP].y = y; - if (pointSP==0) + if (pointSP == 0) { newReversible(); pointSP++; @@ -264,8 +287,9 @@ void startPaintingR(HDC hdc, short x, short y, int fg, int bg) case 14: pointStack[pointSP].x = x; pointStack[pointSP].y = y; - if (pointSP+1>=2) Poly(hdc, pointStack, pointSP+1, bg, fg, lineWidth, shapeStyle, FALSE); - if (pointSP==0) + if (pointSP + 1 >= 2) + Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE); + if (pointSP == 0) { newReversible(); pointSP++; @@ -274,7 +298,8 @@ void startPaintingR(HDC hdc, short x, short y, int fg, int bg) } } -void whilePaintingR(HDC hdc, short x, short y, int fg, int bg) +void +whilePaintingR(HDC hdc, short x, short y, int fg, int bg) { switch (activeTool) { @@ -300,9 +325,16 @@ void whilePaintingR(HDC hdc, short x, short y, int fg, int bg) pointStack[pointSP].y = y; switch (pointSP) { - case 1: Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, bg, lineWidth); break; - case 2: Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], bg, lineWidth); break; - case 3: Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], bg, lineWidth); break; + case 1: + Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, bg, + lineWidth); + break; + case 2: + Bezier(hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], bg, lineWidth); + break; + case 3: + Bezier(hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], bg, lineWidth); + break; } break; case 13: @@ -313,7 +345,8 @@ void whilePaintingR(HDC hdc, short x, short y, int fg, int bg) resetToU1(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; - if (pointSP+1>=2) Poly(hdc, pointStack, pointSP+1, bg, fg, lineWidth, shapeStyle, FALSE); + if (pointSP + 1 >= 2) + Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE); break; case 15: resetToU1(); @@ -324,12 +357,13 @@ void whilePaintingR(HDC hdc, short x, short y, int fg, int bg) RRect(hdc, startX, startY, x, y, bg, fg, lineWidth, shapeStyle); break; } - + lastX = x; lastY = y; } -void endPaintingR(HDC hdc, short x, short y, int fg, int bg) +void +endPaintingR(HDC hdc, short x, short y, int fg, int bg) { switch (activeTool) { @@ -346,7 +380,8 @@ void endPaintingR(HDC hdc, short x, short y, int fg, int bg) break; case 12: pointSP++; - if (pointSP==4) pointSP = 0; + if (pointSP == 4) + pointSP = 0; break; case 13: resetToU1(); @@ -357,9 +392,10 @@ void endPaintingR(HDC hdc, short x, short y, int fg, int bg) pointStack[pointSP].x = x; pointStack[pointSP].y = y; pointSP++; - if (pointSP>=2) + if (pointSP >= 2) { - if ( (pointStack[0].x-x)*(pointStack[0].x-x) + (pointStack[0].y-y)*(pointStack[0].y-y) <= lineWidth*lineWidth+1) + if ((pointStack[0].x - x) * (pointStack[0].x - x) + + (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth * lineWidth + 1) { Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, TRUE); pointSP = 0; @@ -369,7 +405,8 @@ void endPaintingR(HDC hdc, short x, short y, int fg, int bg) Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, FALSE); } } - if (pointSP==255) pointSP--; + if (pointSP == 255) + pointSP--; break; case 15: resetToU1(); diff --git a/reactos/base/applications/paint/mouse.h b/reactos/base/applications/paint/mouse.h index 878715efa21..49bbb408a96 100644 --- a/reactos/base/applications/paint/mouse.h +++ b/reactos/base/applications/paint/mouse.h @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: mouse.h + * FILE: base/applications/paint/mouse.h * PURPOSE: Things which should not be in the mouse event handler itself * PROGRAMMERS: Benedikt Freisen */ diff --git a/reactos/base/applications/paint/palette.c b/reactos/base/applications/paint/palette.c index 8e873041327..cc68516e2a3 100644 --- a/reactos/base/applications/paint/palette.c +++ b/reactos/base/applications/paint/palette.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: palette.c + * FILE: base/applications/paint/palette.c * PURPOSE: Window procedure of the palette window * PROGRAMMERS: Benedikt Freisen */ @@ -13,92 +13,94 @@ /* FUNCTIONS ********************************************************/ -LRESULT CALLBACK PalWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +PalWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_PAINT: + { + RECT rc = { 0, 0, 31, 32 }; + HDC hDC = GetDC(hwnd); + HPEN oldPen; + HBRUSH oldBrush; + int i, a, b; + + DefWindowProc(hwnd, message, wParam, lParam); + + for(b = 2; b < 30; b++) + for(a = 2; a < 29; a++) + if ((a + b) % 2 == 1) + SetPixel(hDC, a, b, GetSysColor(COLOR_BTNHILIGHT)); + + DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT); + DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_TOPLEFT | BF_BOTTOMRIGHT); + SetRect(&rc, 11, 12, 26, 27); + DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); + oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0)); + oldBrush = SelectObject(hDC, CreateSolidBrush(bgColor)); + Rectangle(hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1); + DeleteObject(SelectObject(hDC, oldBrush)); + SetRect(&rc, 4, 5, 19, 20); + DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); + oldBrush = SelectObject(hDC, CreateSolidBrush(fgColor)); + Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1); + DeleteObject(SelectObject(hDC, oldBrush)); + DeleteObject(SelectObject(hDC, oldPen)); + + for(i = 0; i < 28; i++) { - RECT rc = {0, 0, 31, 32}; - HDC hDC = GetDC(hwnd); - HPEN oldPen; - HBRUSH oldBrush; - int i, a, b; - - DefWindowProc (hwnd, message, wParam, lParam); - - for (b = 2; b < 30; b++) - for (a = 2; a < 29; a++) - if ((a + b) % 2 == 1) - SetPixel(hDC, a, b, GetSysColor(COLOR_BTNHILIGHT)); - + SetRect(&rc, 31 + (i % 14) * 16, + 0 + (i / 14) * 16, 16 + 31 + (i % 14) * 16, 16 + 0 + (i / 14) * 16); DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT); - DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_TOPLEFT|BF_BOTTOMRIGHT); - SetRect(&rc, 11, 12, 26, 27); - DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT|BF_MIDDLE); + DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT); oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0)); - oldBrush = SelectObject(hDC, CreateSolidBrush(bgColor)); - Rectangle(hDC, rc.left, rc.top + 2, rc.right -1, rc.bottom - 1); - DeleteObject(SelectObject(hDC, oldBrush)); - SetRect(&rc, 4, 5, 19, 20); - DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT|BF_MIDDLE); - oldBrush = SelectObject(hDC, CreateSolidBrush(fgColor)); - Rectangle( hDC, rc.left + 2,rc.top + 2, rc.right - 1, rc.bottom - 1); + oldBrush = SelectObject(hDC, CreateSolidBrush(palColors[i])); + Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1); DeleteObject(SelectObject(hDC, oldBrush)); DeleteObject(SelectObject(hDC, oldPen)); - - for (i=0; i<28; i++) - { - SetRect(&rc, 31 + (i % 14) * 16, - 0 + (i / 14) * 16, - 16 + 31 + (i % 14) * 16, - 16 + 0 + (i / 14) * 16); - DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT); - DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT); - oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0)); - oldBrush = SelectObject(hDC, CreateSolidBrush(palColors[i])); - Rectangle(hDC, rc.left + 2,rc.top + 2,rc.right - 1, rc.bottom - 1); - DeleteObject(SelectObject(hDC, oldBrush)); - DeleteObject(SelectObject(hDC, oldPen)); - } - ReleaseDC(hwnd, hDC); } + ReleaseDC(hwnd, hDC); break; + } case WM_LBUTTONDOWN: - if (LOWORD(lParam)>=31) + if (LOWORD(lParam) >= 31) { - fgColor = palColors[(LOWORD(lParam)-31)/16+(HIWORD(lParam)/16)*14]; + fgColor = palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14]; SendMessage(hwnd, WM_PAINT, 0, 0); } break; case WM_RBUTTONDOWN: - if (LOWORD(lParam)>=31) + if (LOWORD(lParam) >= 31) { - bgColor = palColors[(LOWORD(lParam)-31)/16+(HIWORD(lParam)/16)*14]; + bgColor = palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14]; SendMessage(hwnd, WM_PAINT, 0, 0); } break; case WM_LBUTTONDBLCLK: - if (LOWORD(lParam)>=31) if (ChooseColor(&choosecolor)) - { - palColors[(LOWORD(lParam)-31)/16+(HIWORD(lParam)/16)*14] = choosecolor.rgbResult; - fgColor = choosecolor.rgbResult; - SendMessage(hwnd, WM_PAINT, 0, 0); - } + if (LOWORD(lParam) >= 31) + if (ChooseColor(&choosecolor)) + { + palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14] = + choosecolor.rgbResult; + fgColor = choosecolor.rgbResult; + SendMessage(hwnd, WM_PAINT, 0, 0); + } break; case WM_RBUTTONDBLCLK: - if (LOWORD(lParam)>=31) if (ChooseColor(&choosecolor)) - { - palColors[(LOWORD(lParam)-31)/16+(HIWORD(lParam)/16)*14] = choosecolor.rgbResult; - bgColor = choosecolor.rgbResult; - SendMessage(hwnd, WM_PAINT, 0, 0); - } + if (LOWORD(lParam) >= 31) + if (ChooseColor(&choosecolor)) + { + palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14] = + choosecolor.rgbResult; + bgColor = choosecolor.rgbResult; + SendMessage(hwnd, WM_PAINT, 0, 0); + } break; - + default: - return DefWindowProc (hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } - diff --git a/reactos/base/applications/paint/palette.h b/reactos/base/applications/paint/palette.h index bb96ddc63db..4cac3388bb0 100644 --- a/reactos/base/applications/paint/palette.h +++ b/reactos/base/applications/paint/palette.h @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: palette.h + * FILE: base/applications/paint/palette.h * PURPOSE: Window procedure of the palette window * PROGRAMMERS: Benedikt Freisen */ diff --git a/reactos/base/applications/paint/registry.c b/reactos/base/applications/paint/registry.c index d9ec178671b..1134a718cb0 100644 --- a/reactos/base/applications/paint/registry.c +++ b/reactos/base/applications/paint/registry.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: registry.c + * FILE: base/applications/paint/registry.c * PURPOSE: Offering functions dealing with registry values * PROGRAMMERS: Benedikt Freisen */ @@ -13,27 +13,30 @@ /* FUNCTIONS ********************************************************/ -void SetWallpaper(TCHAR *FileName, DWORD dwStyle, DWORD dwTile) //FIXME: The pattern (tiled/stretched) is not set +void +SetWallpaper(TCHAR * FileName, DWORD dwStyle, DWORD dwTile) //FIXME: The pattern (tiled/stretched) is not set { SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID) FileName, SPIF_UPDATEINIFILE); - + /*HKEY hDesktop; TCHAR szStyle[3], szTile[3]; if ((dwStyle > 2) || (dwTile > 2)) return; - if (RegOpenKeyEx(HKEY_CURRENT_USER, - _T("Control Panel\\Desktop"), 0, - KEY_READ | KEY_SET_VALUE, &hDesktop) == ERROR_SUCCESS) + if (RegOpenKeyEx(HKEY_CURRENT_USER, + _T("Control Panel\\Desktop"), 0, KEY_READ | KEY_SET_VALUE, &hDesktop) == ERROR_SUCCESS) { - RegSetValueEx(hDesktop, _T("Wallpaper"), 0, REG_SZ, (LPBYTE) FileName, _tcslen(FileName) * sizeof(TCHAR)); + RegSetValueEx(hDesktop, _T("Wallpaper"), 0, REG_SZ, (LPBYTE) FileName, + _tcslen(FileName) * sizeof(TCHAR)); _stprintf(szStyle, _T("%i"), dwStyle); - _stprintf(szTile, _T("%i"), dwTile); + _stprintf(szTile, _T("%i"), dwTile); - RegSetValueEx(hDesktop, _T("WallpaperStyle"), 0, REG_SZ, (LPBYTE) szStyle, _tcslen(szStyle) * sizeof(TCHAR)); - RegSetValueEx(hDesktop, _T("TileWallpaper"), 0, REG_SZ, (LPBYTE) szTile, _tcslen(szTile) * sizeof(TCHAR)); + RegSetValueEx(hDesktop, _T("WallpaperStyle"), 0, REG_SZ, (LPBYTE) szStyle, + _tcslen(szStyle) * sizeof(TCHAR)); + RegSetValueEx(hDesktop, _T("TileWallpaper"), 0, REG_SZ, (LPBYTE) szTile, + _tcslen(szTile) * sizeof(TCHAR)); RegCloseKey(hDesktop); }*/ diff --git a/reactos/base/applications/paint/registry.h b/reactos/base/applications/paint/registry.h index c3f187e1f5d..8527805df8e 100644 --- a/reactos/base/applications/paint/registry.h +++ b/reactos/base/applications/paint/registry.h @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: registry.h + * FILE: base/applications/paint/registry.h * PURPOSE: Offering functions dealing with registry values * PROGRAMMERS: Benedikt Freisen */ diff --git a/reactos/base/applications/paint/rsrc.rc b/reactos/base/applications/paint/rsrc.rc index 285aaadfa0d..00bf8d4dd77 100644 --- a/reactos/base/applications/paint/rsrc.rc +++ b/reactos/base/applications/paint/rsrc.rc @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: rsrc.rc + * FILE: base/applications/paint/rsrc.rc * PURPOSE: Managing the resources * PROGRAMMERS: Benedikt Freisen */ diff --git a/reactos/base/applications/paint/selection.c b/reactos/base/applications/paint/selection.c index 9d7329ca836..f08b3b112f9 100644 --- a/reactos/base/applications/paint/selection.c +++ b/reactos/base/applications/paint/selection.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: selection.c + * FILE: base/applications/paint/selection.c * PURPOSE: Window procedure of the selection window * PROGRAMMERS: Benedikt Freisen */ @@ -20,21 +20,23 @@ BOOL moving = FALSE; short xPos; short yPos; -LRESULT CALLBACK SelectionWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +SelectionWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_PAINT: + { + if (!moving) { - if (!moving) - { - HDC hDC = GetDC(hwnd); - DefWindowProc (hwnd, message, wParam, lParam); - SelectionFrame(hDC, 1, 1, rectSel_dest[2]*zoom/1000+5, rectSel_dest[3]*zoom/1000+5); - ReleaseDC(hwnd, hDC); - } + HDC hDC = GetDC(hwnd); + DefWindowProc(hwnd, message, wParam, lParam); + SelectionFrame(hDC, 1, 1, rectSel_dest[2] * zoom / 1000 + 5, + rectSel_dest[3] * zoom / 1000 + 5); + ReleaseDC(hwnd, hDC); } break; + } case WM_LBUTTONDOWN: xPos = LOWORD(lParam); yPos = HIWORD(lParam); @@ -45,15 +47,19 @@ LRESULT CALLBACK SelectionWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARA if (moving) { resetToU1(); - rectSel_dest[0]+=(short)LOWORD(lParam)-xPos; - rectSel_dest[1]+=(short)HIWORD(lParam)-yPos; - - Rect(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[0]+rectSel_src[2], rectSel_src[1]+rectSel_src[3], bgColor, bgColor, 0, TRUE); - if (transpBg==0) - BitBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0, SRCCOPY); + rectSel_dest[0] += (short)LOWORD(lParam) - xPos; + rectSel_dest[1] += (short)HIWORD(lParam) - yPos; + + Rect(hDrawingDC, rectSel_src[0], rectSel_src[1], rectSel_src[0] + rectSel_src[2], + rectSel_src[1] + rectSel_src[3], bgColor, bgColor, 0, TRUE); + if (transpBg == 0) + BitBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], + hSelDC, 0, 0, SRCCOPY); else - BitBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0, SRCAND); - //TransparentBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0, rectSel_dest[2], rectSel_dest[3], bgColor); + BitBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], + hSelDC, 0, 0, SRCAND); + //TransparentBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], + // hSelDC, 0, 0, rectSel_dest[2], rectSel_dest[3], bgColor); SendMessage(hImageArea, WM_PAINT, 0, 0); xPos = LOWORD(lParam); yPos = HIWORD(lParam); @@ -71,7 +77,7 @@ LRESULT CALLBACK SelectionWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARA } break; default: - return DefWindowProc (hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); } return 0; diff --git a/reactos/base/applications/paint/selection.h b/reactos/base/applications/paint/selection.h index 3d0a183a3b3..c75715b4730 100644 --- a/reactos/base/applications/paint/selection.h +++ b/reactos/base/applications/paint/selection.h @@ -1,9 +1,9 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: selection.h + * FILE: base/applications/paint/selection.h * PURPOSE: Window procedure of the selection window * PROGRAMMERS: Benedikt Freisen */ -LRESULT CALLBACK SelectionWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK SelectionWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/reactos/base/applications/paint/sizebox.c b/reactos/base/applications/paint/sizebox.c index 60d0a033189..9fa05ec8bed 100644 --- a/reactos/base/applications/paint/sizebox.c +++ b/reactos/base/applications/paint/sizebox.c @@ -20,21 +20,20 @@ BOOL resizing = FALSE; short xOrig; short yOrig; -LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +SizeboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_SETCURSOR: - { - if ((hwnd==hSizeboxLeftTop)||(hwnd==hSizeboxRightBottom)) - SetCursor(LoadCursor(NULL, IDC_SIZENWSE)); - if ((hwnd==hSizeboxLeftBottom)||(hwnd==hSizeboxRightTop)) - SetCursor(LoadCursor(NULL, IDC_SIZENESW)); - if ((hwnd==hSizeboxLeftCenter)||(hwnd==hSizeboxRightCenter)) - SetCursor(LoadCursor(NULL, IDC_SIZEWE)); - if ((hwnd==hSizeboxCenterTop)||(hwnd==hSizeboxCenterBottom)) - SetCursor(LoadCursor(NULL, IDC_SIZENS)); - } + if ((hwnd == hSizeboxLeftTop) || (hwnd == hSizeboxRightBottom)) + SetCursor(LoadCursor(NULL, IDC_SIZENWSE)); + if ((hwnd == hSizeboxLeftBottom) || (hwnd == hSizeboxRightTop)) + SetCursor(LoadCursor(NULL, IDC_SIZENESW)); + if ((hwnd == hSizeboxLeftCenter) || (hwnd == hSizeboxRightCenter)) + SetCursor(LoadCursor(NULL, IDC_SIZEWE)); + if ((hwnd == hSizeboxCenterTop) || (hwnd == hSizeboxCenterBottom)) + SetCursor(LoadCursor(NULL, IDC_SIZENS)); break; case WM_LBUTTONDOWN: resizing = TRUE; @@ -48,25 +47,25 @@ LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM TCHAR sizeStr[100]; short xRel; short yRel; - xRel = ((short)LOWORD(lParam)-xOrig)*1000/zoom; - yRel = ((short)HIWORD(lParam)-yOrig)*1000/zoom; - if (hwnd==hSizeboxLeftTop) - _stprintf(sizeStr, _T("%d x %d"), imgXRes-xRel, imgYRes-yRel); - if (hwnd==hSizeboxCenterTop) - _stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes-yRel); - if (hwnd==hSizeboxRightTop) - _stprintf(sizeStr, _T("%d x %d"), imgXRes+xRel, imgYRes-yRel); - if (hwnd==hSizeboxLeftCenter) - _stprintf(sizeStr, _T("%d x %d"), imgXRes-xRel, imgYRes); - if (hwnd==hSizeboxRightCenter) - _stprintf(sizeStr, _T("%d x %d"), imgXRes+xRel, imgYRes); - if (hwnd==hSizeboxLeftBottom) - _stprintf(sizeStr, _T("%d x %d"), imgXRes-xRel, imgYRes+yRel); - if (hwnd==hSizeboxCenterBottom) - _stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes+yRel); - if (hwnd==hSizeboxRightBottom) - _stprintf(sizeStr, _T("%d x %d"), imgXRes+xRel, imgYRes+yRel); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)sizeStr); + xRel = ((short)LOWORD(lParam) - xOrig) * 1000 / zoom; + yRel = ((short)HIWORD(lParam) - yOrig) * 1000 / zoom; + if (hwnd == hSizeboxLeftTop) + _stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes - yRel); + if (hwnd == hSizeboxCenterTop) + _stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes - yRel); + if (hwnd == hSizeboxRightTop) + _stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes - yRel); + if (hwnd == hSizeboxLeftCenter) + _stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes); + if (hwnd == hSizeboxRightCenter) + _stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes); + if (hwnd == hSizeboxLeftBottom) + _stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes + yRel); + if (hwnd == hSizeboxCenterBottom) + _stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes + yRel); + if (hwnd == hSizeboxRightBottom) + _stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes + yRel); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); } break; case WM_LBUTTONUP: @@ -76,30 +75,30 @@ LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM short yRel; ReleaseCapture(); resizing = FALSE; - xRel = ((short)LOWORD(lParam)-xOrig)*1000/zoom; - yRel = ((short)HIWORD(lParam)-yOrig)*1000/zoom; - if (hwnd==hSizeboxLeftTop) - cropReversible(imgXRes-xRel, imgYRes-yRel, xRel, yRel); - if (hwnd==hSizeboxCenterTop) - cropReversible(imgXRes, imgYRes-yRel, 0, yRel); - if (hwnd==hSizeboxRightTop) - cropReversible(imgXRes+xRel, imgYRes-yRel, 0, yRel); - if (hwnd==hSizeboxLeftCenter) - cropReversible(imgXRes-xRel, imgYRes, xRel, 0); - if (hwnd==hSizeboxRightCenter) - cropReversible(imgXRes+xRel, imgYRes, 0, 0); - if (hwnd==hSizeboxLeftBottom) - cropReversible(imgXRes-xRel, imgYRes+yRel, xRel, 0); - if (hwnd==hSizeboxCenterBottom) - cropReversible(imgXRes, imgYRes+yRel, 0, 0); - if (hwnd==hSizeboxRightBottom) - cropReversible(imgXRes+xRel, imgYRes+yRel, 0, 0); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)_T("")); + xRel = ((short)LOWORD(lParam) - xOrig) * 1000 / zoom; + yRel = ((short)HIWORD(lParam) - yOrig) * 1000 / zoom; + if (hwnd == hSizeboxLeftTop) + cropReversible(imgXRes - xRel, imgYRes - yRel, xRel, yRel); + if (hwnd == hSizeboxCenterTop) + cropReversible(imgXRes, imgYRes - yRel, 0, yRel); + if (hwnd == hSizeboxRightTop) + cropReversible(imgXRes + xRel, imgYRes - yRel, 0, yRel); + if (hwnd == hSizeboxLeftCenter) + cropReversible(imgXRes - xRel, imgYRes, xRel, 0); + if (hwnd == hSizeboxRightCenter) + cropReversible(imgXRes + xRel, imgYRes, 0, 0); + if (hwnd == hSizeboxLeftBottom) + cropReversible(imgXRes - xRel, imgYRes + yRel, xRel, 0); + if (hwnd == hSizeboxCenterBottom) + cropReversible(imgXRes, imgYRes + yRel, 0, 0); + if (hwnd == hSizeboxRightBottom) + cropReversible(imgXRes + xRel, imgYRes + yRel, 0, 0); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T("")); } break; default: - return DefWindowProc (hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); } return 0; diff --git a/reactos/base/applications/paint/sizebox.h b/reactos/base/applications/paint/sizebox.h index 6329484221f..33787b8872f 100644 --- a/reactos/base/applications/paint/sizebox.h +++ b/reactos/base/applications/paint/sizebox.h @@ -1,9 +1,9 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: sizebox.h + * FILE: base/applications/paint/sizebox.h * PURPOSE: Window procedure of the size boxes * PROGRAMMERS: Benedikt Freisen */ -LRESULT CALLBACK SizeboxWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK SizeboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/reactos/base/applications/paint/toolsettings.c b/reactos/base/applications/paint/toolsettings.c index 020026516cd..bfb2172f0bf 100644 --- a/reactos/base/applications/paint/toolsettings.c +++ b/reactos/base/applications/paint/toolsettings.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: toolsettings.c + * FILE: base/applications/paint/toolsettings.c * PURPOSE: Window procedure of the tool settings window * PROGRAMMERS: Benedikt Freisen */ @@ -16,244 +16,242 @@ /* FUNCTIONS ********************************************************/ -LRESULT CALLBACK SettingsWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +extern void zoomTo(int, int, int); + +LRESULT CALLBACK +SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_VSCROLL: - { - zoomTo(125<= 13) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE); + switch (activeTool) { - HDC hdc = GetDC(hwnd); - int rectang[4] = {0, 0, 42, 66}; - int rectang2[4] = {0, 70, 42, 136}; - - DefWindowProc (hwnd, message, wParam, lParam); - - if (activeTool!=6) - DrawEdge(hdc, (LPRECT)&rectang, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE); - else - DrawEdge(hdc, (LPRECT)&rectang, BDR_SUNKENOUTER, BF_RECT); - if (activeTool>=13) - DrawEdge(hdc, (LPRECT)&rectang2, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE); - else - DrawEdge(hdc, (LPRECT)&rectang2, 0, BF_RECT | BF_MIDDLE); - switch (activeTool) + case 1: + case 2: + case 10: { - case 1: - case 2: - case 10: - { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, transpBg*31+2, 41, transpBg*31+33); - DeleteObject(SelectObject(hdc, oldPen)); - DrawIconEx(hdc, 1, 2, hNontranspIcon, 40, 30, 0, NULL, DI_NORMAL); - DrawIconEx(hdc, 1, 33, hTranspIcon, 40, 30, 0, NULL, DI_NORMAL); - } - break; - case 3: - { - int i; - HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - for (i=0; i<4; i++) - { - if (rubberRadius==i+2) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 14, i*15+2, 29, i*15+17); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); - } else SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); - Rectangle(hdc, 19-i, i*14+7, 24+i, i*16+12); - } - DeleteObject(SelectObject(hdc, oldPen)); - } - break; - case 8: - { - int i; - HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, brushStyle%3*13+2, brushStyle/3*15+2, brushStyle%3*13+15, brushStyle/3*15+17); - DeleteObject(SelectObject(hdc, oldPen)); - for (i=0; i<12; i++) - if (i==brushStyle) - Brush(hdc, i%3*13+7, i/3*15+8, i%3*13+7, i/3*15+8, GetSysColor(COLOR_HIGHLIGHTTEXT), i); - else - Brush(hdc, i%3*13+7, i/3*15+8, i%3*13+7, i/3*15+8, GetSysColor(COLOR_WINDOWTEXT), i); - } - break; - case 9: - { - HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - switch (airBrushWidth) - { - case 5: - Rectangle(hdc, 2, 2, 21, 31); - break; - case 8: - Rectangle(hdc, 20, 2, 41, 31); - break; - case 3: - Rectangle(hdc, 2, 30, 16, 61); - break; - case 12: - Rectangle(hdc, 15, 30, 41, 61); - break; - } - if (airBrushWidth==5) - Airbrush(hdc, 10, 15, GetSysColor(COLOR_HIGHLIGHTTEXT), 5); - else - Airbrush(hdc, 10, 15, GetSysColor(COLOR_WINDOWTEXT), 5); - if (airBrushWidth==8) - Airbrush(hdc, 30, 15, GetSysColor(COLOR_HIGHLIGHTTEXT), 8); - else - Airbrush(hdc, 30, 15, GetSysColor(COLOR_WINDOWTEXT), 8); - if (airBrushWidth==3) - Airbrush(hdc, 8, 45, GetSysColor(COLOR_HIGHLIGHTTEXT), 3); - else - Airbrush(hdc, 8, 45, GetSysColor(COLOR_WINDOWTEXT), 3); - if (airBrushWidth==12) - Airbrush(hdc, 27, 45, GetSysColor(COLOR_HIGHLIGHTTEXT), 12); - else - Airbrush(hdc, 27, 45, GetSysColor(COLOR_WINDOWTEXT), 12); - DeleteObject(SelectObject(hdc, oldPen)); - } - break; - case 11: - case 12: - { - int i; - HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - for (i=0; i<5; i++) - { - if (lineWidth==i+1) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, i*12+2, 41, i*12+14); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); - } else SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); - Rectangle(hdc, 5, i*12+6, 38, i*12+8+i); - } - DeleteObject(SelectObject(hdc, oldPen)); - } - break; - case 13: - case 14: - case 15: - case 16: - { - int i; - HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); - for (i=0; i<3; i++) - { - if (shapeStyle==i) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, i*20+2, 41, i*20+22); - } - } - if (shapeStyle==0) - Rect(hdc, 5, 6, 37, 16, GetSysColor(COLOR_HIGHLIGHTTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 0); - else - Rect(hdc, 5, 6, 37, 16, GetSysColor(COLOR_WINDOWTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 0); - if (shapeStyle==1) - Rect(hdc, 5, 26, 37, 36, GetSysColor(COLOR_HIGHLIGHTTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 1); - else - Rect(hdc, 5, 26, 37, 36, GetSysColor(COLOR_WINDOWTEXT), GetSysColor(COLOR_APPWORKSPACE), 1, 1); - Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE), 1, 1); - for (i=0; i<5; i++) - { - if (lineWidth==i+1) - { - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); - Rectangle(hdc, 2, i*12+72, 41, i*12+84); - SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); - } else SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); - Rectangle(hdc, 5, i*12+76, 38, i*12+78+i); - } - DeleteObject(SelectObject(hdc, oldPen)); - } - break; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + Rectangle(hdc, 2, transpBg * 31 + 2, 41, transpBg * 31 + 33); + DeleteObject(SelectObject(hdc, oldPen)); + DrawIconEx(hdc, 1, 2, hNontranspIcon, 40, 30, 0, NULL, DI_NORMAL); + DrawIconEx(hdc, 1, 33, hTranspIcon, 40, 30, 0, NULL, DI_NORMAL); + break; + } + case 3: + { + int i; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); + for(i = 0; i < 4; i++) + { + if (rubberRadius == i + 2) + { + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + Rectangle(hdc, 14, i * 15 + 2, 29, i * 15 + 17); + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); + } + else + SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); + Rectangle(hdc, 19 - i, i * 14 + 7, 24 + i, i * 16 + 12); + } + DeleteObject(SelectObject(hdc, oldPen)); + break; + } + case 8: + { + int i; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + Rectangle(hdc, brushStyle % 3 * 13 + 2, brushStyle / 3 * 15 + 2, brushStyle % 3 * 13 + 15, + brushStyle / 3 * 15 + 17); + DeleteObject(SelectObject(hdc, oldPen)); + for(i = 0; i < 12; i++) + Brush(hdc, i % 3 * 13 + 7, i / 3 * 15 + 8, i % 3 * 13 + 7, i / 3 * 15 + 8, + GetSysColor((i == brushStyle) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), i); + break; + } + case 9: + { + HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + switch (airBrushWidth) + { + case 5: + Rectangle(hdc, 2, 2, 21, 31); + break; + case 8: + Rectangle(hdc, 20, 2, 41, 31); + break; + case 3: + Rectangle(hdc, 2, 30, 16, 61); + break; + case 12: + Rectangle(hdc, 15, 30, 41, 61); + break; + } + Airbrush(hdc, 10, 15, + GetSysColor((airBrushWidth == 5) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 5); + Airbrush(hdc, 30, 15, + GetSysColor((airBrushWidth == 8) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 8); + Airbrush(hdc, 8, 45, + GetSysColor((airBrushWidth == 3) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 3); + Airbrush(hdc, 27, 45, + GetSysColor((airBrushWidth == 12) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 12); + DeleteObject(SelectObject(hdc, oldPen)); + break; + } + case 11: + case 12: + { + int i; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); + for(i = 0; i < 5; i++) + { + if (lineWidth == i + 1) + { + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + Rectangle(hdc, 2, i * 12 + 2, 41, i * 12 + 14); + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); + } + else + SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); + Rectangle(hdc, 5, i * 12 + 6, 38, i * 12 + 8 + i); + } + DeleteObject(SelectObject(hdc, oldPen)); + break; + } + case 13: + case 14: + case 15: + case 16: + { + int i; + HPEN oldPen = SelectObject(hdc, CreatePen(PS_NULL, 0, 0)); + for(i = 0; i < 3; i++) + { + if (shapeStyle == i) + { + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + Rectangle(hdc, 2, i * 20 + 2, 41, i * 20 + 22); + } + } + Rect(hdc, 5, 6, 37, 16, + GetSysColor((shapeStyle == 0) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), + GetSysColor(COLOR_APPWORKSPACE), 1, 0); + Rect(hdc, 5, 26, 37, 36, + GetSysColor((shapeStyle == 1) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), + GetSysColor(COLOR_APPWORKSPACE), 1, 1); + Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE), + 1, 1); + for(i = 0; i < 5; i++) + { + if (lineWidth == i + 1) + { + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT)); + Rectangle(hdc, 2, i * 12 + 72, 41, i * 12 + 84); + SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT)); + } + else + SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT)); + Rectangle(hdc, 5, i * 12 + 76, 38, i * 12 + 78 + i); + } + DeleteObject(SelectObject(hdc, oldPen)); + break; } - ReleaseDC(hwnd, hdc); } + ReleaseDC(hwnd, hdc); break; + } case WM_LBUTTONDOWN: + { + switch (activeTool) { - switch (activeTool) - { - case 1: - case 2: - case 10: - if ((HIWORD(lParam)>1)&&(HIWORD(lParam)<64)) + case 1: + case 2: + case 10: + if ((HIWORD(lParam) > 1) && (HIWORD(lParam) < 64)) + { + transpBg = (HIWORD(lParam) - 2) / 31; + SendMessage(hwnd, WM_PAINT, 0, 0); + } + break; + case 3: + if ((HIWORD(lParam) > 1) && (HIWORD(lParam) < 62)) + { + rubberRadius = (HIWORD(lParam) - 2) / 15 + 2; + SendMessage(hwnd, WM_PAINT, 0, 0); + } + break; + case 8: + if ((LOWORD(lParam) > 1) && (LOWORD(lParam) < 40) && (HIWORD(lParam) > 1) + && (HIWORD(lParam) < 62)) + { + brushStyle = (HIWORD(lParam) - 2) / 15 * 3 + (LOWORD(lParam) - 2) / 13; + SendMessage(hwnd, WM_PAINT, 0, 0); + } + break; + case 9: + if (HIWORD(lParam) < 62) + { + if (HIWORD(lParam) < 30) { - transpBg = (HIWORD(lParam)-2)/31; - SendMessage(hwnd, WM_PAINT, 0, 0); + if (LOWORD(lParam) < 20) + airBrushWidth = 5; + else + airBrushWidth = 8; } - break; - case 3: - if ((HIWORD(lParam)>1)&&(HIWORD(lParam)<62)) + else { - rubberRadius = (HIWORD(lParam)-2)/15+2; - SendMessage(hwnd, WM_PAINT, 0, 0); + if (LOWORD(lParam) < 15) + airBrushWidth = 3; + else + airBrushWidth = 12; } - break; - case 8: - if ((LOWORD(lParam)>1)&&(LOWORD(lParam)<40)&&(HIWORD(lParam)>1)&&(HIWORD(lParam)<62)) - { - brushStyle = (HIWORD(lParam)-2)/15*3+(LOWORD(lParam)-2)/13; - SendMessage(hwnd, WM_PAINT, 0, 0); - } - break; - case 9: - if (HIWORD(lParam)<62) - { - if (HIWORD(lParam)<30) - { - if (LOWORD(lParam)<20) airBrushWidth=5; else airBrushWidth=8; - }else - { - if (LOWORD(lParam)<15) airBrushWidth=3; else airBrushWidth=12; - } - SendMessage(hwnd, WM_PAINT, 0, 0); - } - break; - case 11: - case 12: - if (HIWORD(lParam)<=62) - { - lineWidth = (HIWORD(lParam)-2)/12+1; - SendMessage(hwnd, WM_PAINT, 0, 0); - } - break; - case 13: - case 14: - case 15: - case 16: - if (HIWORD(lParam)<=60) - { - shapeStyle = (HIWORD(lParam)-2)/20; - SendMessage(hwnd, WM_PAINT, 0, 0); - } - if ((HIWORD(lParam)>=70)&&(HIWORD(lParam)<=132)) - { - lineWidth = (HIWORD(lParam)-72)/12+1; - SendMessage(hwnd, WM_PAINT, 0, 0); - } - break; - } + SendMessage(hwnd, WM_PAINT, 0, 0); + } + break; + case 11: + case 12: + if (HIWORD(lParam) <= 62) + { + lineWidth = (HIWORD(lParam) - 2) / 12 + 1; + SendMessage(hwnd, WM_PAINT, 0, 0); + } + break; + case 13: + case 14: + case 15: + case 16: + if (HIWORD(lParam) <= 60) + { + shapeStyle = (HIWORD(lParam) - 2) / 20; + SendMessage(hwnd, WM_PAINT, 0, 0); + } + if ((HIWORD(lParam) >= 70) && (HIWORD(lParam) <= 132)) + { + lineWidth = (HIWORD(lParam) - 72) / 12 + 1; + SendMessage(hwnd, WM_PAINT, 0, 0); + } + break; } break; - + } + default: - return DefWindowProc (hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } - diff --git a/reactos/base/applications/paint/toolsettings.h b/reactos/base/applications/paint/toolsettings.h index 384b5e1c16b..8537dc160fb 100644 --- a/reactos/base/applications/paint/toolsettings.h +++ b/reactos/base/applications/paint/toolsettings.h @@ -1,9 +1,9 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: toolsettings.h + * FILE: base/applications/paint/toolsettings.h * PURPOSE: Window procedure of the tool settings window * PROGRAMMERS: Benedikt Freisen */ -LRESULT CALLBACK SettingsWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/reactos/base/applications/paint/winproc.c b/reactos/base/applications/paint/winproc.c index c72c266d773..ee02068998c 100644 --- a/reactos/base/applications/paint/winproc.c +++ b/reactos/base/applications/paint/winproc.c @@ -1,7 +1,7 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: winproc.c + * FILE: base/applications/paint/winproc.c * PURPOSE: Window procedure of the main window and all children apart from * hPalWin, hToolSettings and hSelection * PROGRAMMERS: Benedikt Freisen @@ -25,30 +25,30 @@ /* FUNCTIONS ********************************************************/ -void selectTool(int tool) +void +selectTool(int tool) { ShowWindow(hSelection, SW_HIDE); activeTool = tool; - pointSP = 0; // resets the point-buffer of the polygon and bezier functions + pointSP = 0; // resets the point-buffer of the polygon and bezier functions SendMessage(hToolSettings, WM_PAINT, 0, 0); - if (tool==6) - ShowWindow(hTrackbarZoom, SW_SHOW); - else - ShowWindow(hTrackbarZoom, SW_HIDE); + ShowWindow(hTrackbarZoom, (tool == 6) ? SW_SHOW : SW_HIDE); } -void updateCanvasAndScrollbars() +void +updateCanvasAndScrollbars() { ShowWindow(hSelection, SW_HIDE); - MoveWindow(hImageArea, 3, 3, imgXRes*zoom/1000, imgYRes*zoom/1000, FALSE); + MoveWindow(hImageArea, 3, 3, imgXRes * zoom / 1000, imgYRes * zoom / 1000, FALSE); InvalidateRect(hScrollbox, NULL, TRUE); InvalidateRect(hImageArea, NULL, FALSE); - + SetScrollPos(hScrollbox, SB_HORZ, 0, TRUE); SetScrollPos(hScrollbox, SB_VERT, 0, TRUE); } -void zoomTo(int newZoom, int mouseX, int mouseY) +void +zoomTo(int newZoom, int mouseX, int mouseY) { int tbPos = 0; int tempZoom = newZoom; @@ -56,32 +56,33 @@ void zoomTo(int newZoom, int mouseX, int mouseY) long clientRectScrollbox[4]; long clientRectImageArea[4]; int x, y, w, h; - GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox); - GetClientRect(hImageArea, (LPRECT)&clientRectImageArea); + GetClientRect(hScrollbox, (LPRECT) &clientRectScrollbox); + GetClientRect(hImageArea, (LPRECT) &clientRectImageArea); w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * newZoom / zoom); h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * newZoom / zoom); x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2)) * newZoom / zoom; y = max(0, min(clientRectImageArea[3] - h, mouseY - h / 2)) * newZoom / zoom; - + zoom = newZoom; - + ShowWindow(hSelection, SW_HIDE); - MoveWindow(hImageArea, 3, 3, imgXRes*zoom/1000, imgYRes*zoom/1000, FALSE); + MoveWindow(hImageArea, 3, 3, imgXRes * zoom / 1000, imgYRes * zoom / 1000, FALSE); InvalidateRect(hScrollbox, NULL, TRUE); InvalidateRect(hImageArea, NULL, FALSE); - + SendMessage(hScrollbox, WM_HSCROLL, SB_THUMBPOSITION | (x << 16), 0); SendMessage(hScrollbox, WM_VSCROLL, SB_THUMBPOSITION | (y << 16), 0); - - while (tempZoom>125) + + while (tempZoom > 125) { tbPos++; - tempZoom = tempZoom>>1; + tempZoom = tempZoom >> 1; } - SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)tbPos); + SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) tbPos); } -void drawZoomFrame(int mouseX, int mouseY) +void +drawZoomFrame(int mouseX, int mouseY) { HDC hdc; HPEN oldPen; @@ -92,13 +93,13 @@ void drawZoomFrame(int mouseX, int mouseY) long clientRectScrollbox[4]; long clientRectImageArea[4]; int x, y, w, h; - GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox); - GetClientRect(hImageArea, (LPRECT)&clientRectImageArea); + GetClientRect(hScrollbox, (LPRECT) &clientRectScrollbox); + GetClientRect(hImageArea, (LPRECT) &clientRectImageArea); w = clientRectImageArea[2] * clientRectScrollbox[2] / (clientRectImageArea[2] * 2); h = clientRectImageArea[3] * clientRectScrollbox[3] / (clientRectImageArea[3] * 2); x = max(0, min(clientRectImageArea[2] - w, mouseX - w / 2)); y = max(0, min(clientRectImageArea[3] - h, mouseY - h / 2)); - + hdc = GetDC(hImageArea); oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 0, 0)); logbrush.lbStyle = BS_HOLLOW; @@ -111,18 +112,19 @@ void drawZoomFrame(int mouseX, int mouseY) ReleaseDC(hImageArea, hdc); } -HDC hdc; BOOL drawing; -LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK +WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch (message) /* handle the messages */ + switch (message) /* handle the messages */ { case WM_DESTROY: - PostQuitMessage (0); /* send a WM_QUIT to the message queue */ + PostQuitMessage(0); /* send a WM_QUIT to the message queue */ break; + case WM_CLOSE: - if (hwnd==hwndMiniature) + if (hwnd == hwndMiniature) { ShowWindow(hwndMiniature, SW_HIDE); showMiniature = FALSE; @@ -152,29 +154,36 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM DestroyWindow(hwnd); } break; + case WM_INITMENUPOPUP: switch (lParam) { case 0: if (isAFile) { - EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERPLANE, MF_ENABLED | MF_BYCOMMAND); - EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERCENTERED, MF_ENABLED | MF_BYCOMMAND); - EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERSTRETCHED, MF_ENABLED | MF_BYCOMMAND); + EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERPLANE, + MF_ENABLED | MF_BYCOMMAND); + EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERCENTERED, + MF_ENABLED | MF_BYCOMMAND); + EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERSTRETCHED, + MF_ENABLED | MF_BYCOMMAND); } else { - EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERPLANE, MF_GRAYED | MF_BYCOMMAND); - EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERCENTERED, MF_GRAYED | MF_BYCOMMAND); - EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERSTRETCHED, MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERPLANE, + MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERCENTERED, + MF_GRAYED | MF_BYCOMMAND); + EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERSTRETCHED, + MF_GRAYED | MF_BYCOMMAND); } break; case 1: - if (undoSteps>0) + if (undoSteps > 0) EnableMenuItem(GetMenu(hMainWnd), IDM_EDITUNDO, MF_ENABLED | MF_BYCOMMAND); else EnableMenuItem(GetMenu(hMainWnd), IDM_EDITUNDO, MF_GRAYED | MF_BYCOMMAND); - if (redoSteps>0) + if (redoSteps > 0) EnableMenuItem(GetMenu(hMainWnd), IDM_EDITREDO, MF_ENABLED | MF_BYCOMMAND); else EnableMenuItem(GetMenu(hMainWnd), IDM_EDITREDO, MF_GRAYED | MF_BYCOMMAND); @@ -195,7 +204,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM EnableMenuItem(GetMenu(hMainWnd), IDM_EDITCOPYTO, MF_GRAYED | MF_BYCOMMAND); } OpenClipboard(hMainWnd); - if (GetClipboardData(CF_BITMAP)!=NULL) + if (GetClipboardData(CF_BITMAP) != NULL) EnableMenuItem(GetMenu(hMainWnd), IDM_EDITPASTE, MF_ENABLED | MF_BYCOMMAND); else EnableMenuItem(GetMenu(hMainWnd), IDM_EDITPASTE, MF_GRAYED | MF_BYCOMMAND); @@ -206,124 +215,99 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM EnableMenuItem(GetMenu(hMainWnd), IDM_IMAGECROP, MF_ENABLED | MF_BYCOMMAND); else EnableMenuItem(GetMenu(hMainWnd), IDM_IMAGECROP, MF_GRAYED | MF_BYCOMMAND); - if (transpBg==0) - CheckMenuItem(GetMenu(hMainWnd), IDM_IMAGEDRAWOPAQUE, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_IMAGEDRAWOPAQUE, MF_UNCHECKED | MF_BYCOMMAND); + CheckMenuItem(GetMenu(hMainWnd), IDM_IMAGEDRAWOPAQUE, (transpBg == 0) ? + (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); break; } if (IsWindowVisible(hStatusBar)) CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSTATUSBAR, MF_CHECKED | MF_BYCOMMAND); else CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSTATUSBAR, MF_UNCHECKED | MF_BYCOMMAND); - - if (showGrid) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSHOWGRID, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSHOWGRID, MF_UNCHECKED | MF_BYCOMMAND); - if (showMiniature) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSHOWMINIATURE, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSHOWMINIATURE, MF_UNCHECKED | MF_BYCOMMAND); - if (zoom==125) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM125, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM125, MF_UNCHECKED | MF_BYCOMMAND); - if (zoom==250) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM25, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM25, MF_UNCHECKED | MF_BYCOMMAND); - if (zoom==500) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM50, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM50, MF_UNCHECKED | MF_BYCOMMAND); - if (zoom==1000) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM100, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM100, MF_UNCHECKED | MF_BYCOMMAND); - if (zoom==2000) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM200, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM200, MF_UNCHECKED | MF_BYCOMMAND); - if (zoom==4000) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM400, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM400, MF_UNCHECKED | MF_BYCOMMAND); - if (zoom==8000) - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM800, MF_CHECKED | MF_BYCOMMAND); - else - CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM800, MF_UNCHECKED | MF_BYCOMMAND); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSHOWGRID, + showGrid ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWSHOWMINIATURE, + showMiniature ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM125, + (zoom == 125) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM25, + (zoom == 250) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM50, + (zoom == 500) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM100, + (zoom == 1000) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM200, + (zoom == 2000) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM400, + (zoom == 4000) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); + CheckMenuItem(GetMenu(hMainWnd), IDM_VIEWZOOM800, + (zoom == 8000) ? (MF_CHECKED | MF_BYCOMMAND) : (MF_UNCHECKED | MF_BYCOMMAND)); break; + case WM_SIZE: - if (hwnd==hMainWnd) - { - int test[] = {LOWORD(lParam)-260, LOWORD(lParam)-140, LOWORD(lParam)-20}; + if (hwnd == hMainWnd) + { + int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 }; SendMessage(hStatusBar, WM_SIZE, wParam, lParam); SendMessage(hStatusBar, SB_SETPARTS, 3, (int)&test); - MoveWindow(hScrollbox, 56, 49,LOWORD(lParam)-56, HIWORD(lParam)-72, TRUE); + MoveWindow(hScrollbox, 56, 49, LOWORD(lParam) - 56, HIWORD(lParam) - 72, TRUE); //InvalidateRect(hwnd, NULL, TRUE); } - if (hwnd==hImageArea) + if (hwnd == hImageArea) { - MoveWindow(hSizeboxLeftTop, - 0, - 0, 3, 3, TRUE); - MoveWindow(hSizeboxCenterTop, - imgXRes*zoom/2000+3*3/4, - 0, 3, 3, TRUE); - MoveWindow(hSizeboxRightTop, - imgXRes*zoom/1000+3, - 0, 3, 3, TRUE); - MoveWindow(hSizeboxLeftCenter, - 0, - imgYRes*zoom/2000+3*3/4, 3, 3, TRUE); - MoveWindow(hSizeboxRightCenter, - imgXRes*zoom/1000+3, - imgYRes*zoom/2000+3*3/4, 3, 3, TRUE); - MoveWindow(hSizeboxLeftBottom, - 0, - imgYRes*zoom/1000+3, 3, 3, TRUE); - MoveWindow(hSizeboxCenterBottom, - imgXRes*zoom/2000+3*3/4, - imgYRes*zoom/1000+3, 3, 3, TRUE); - MoveWindow(hSizeboxRightBottom, - imgXRes*zoom/1000+3, - imgYRes*zoom/1000+3, 3, 3, TRUE); + MoveWindow(hSizeboxLeftTop, + 0, + 0, 3, 3, TRUE); + MoveWindow(hSizeboxCenterTop, + imgXRes * zoom / 2000 + 3 * 3 / 4, + 0, 3, 3, TRUE); + MoveWindow(hSizeboxRightTop, + imgXRes * zoom / 1000 + 3, + 0, 3, 3, TRUE); + MoveWindow(hSizeboxLeftCenter, + 0, + imgYRes * zoom / 2000 + 3 * 3 / 4, 3, 3, TRUE); + MoveWindow(hSizeboxRightCenter, + imgXRes * zoom / 1000 + 3, + imgYRes * zoom / 2000 + 3 * 3 / 4, 3, 3, TRUE); + MoveWindow(hSizeboxLeftBottom, + 0, + imgYRes * zoom / 1000 + 3, 3, 3, TRUE); + MoveWindow(hSizeboxCenterBottom, + imgXRes * zoom / 2000 + 3 * 3 / 4, + imgYRes * zoom / 1000 + 3, 3, 3, TRUE); + MoveWindow(hSizeboxRightBottom, + imgXRes * zoom / 1000 + 3, + imgYRes * zoom / 1000 + 3, 3, 3, TRUE); } - if ((hwnd==hImageArea)||(hwnd==hScrollbox)) + if ((hwnd == hImageArea) || (hwnd == hScrollbox)) { long clientRectScrollbox[4]; long clientRectImageArea[4]; - SCROLLINFO horzScroll; - SCROLLINFO vertScroll; - GetClientRect(hScrollbox, (LPRECT)&clientRectScrollbox); - GetClientRect(hImageArea, (LPRECT)&clientRectImageArea); - horzScroll.cbSize = sizeof(SCROLLINFO); - horzScroll.fMask = SIF_PAGE | SIF_RANGE; - horzScroll.nMax = clientRectImageArea[2]+6-1; - horzScroll.nMin = 0; - horzScroll.nPage = clientRectScrollbox[2]; - horzScroll.nPos = 0; - horzScroll.nTrackPos = 0; - SetScrollInfo(hScrollbox, SB_HORZ, &horzScroll, TRUE); - GetClientRect(hScrollbox, (LPRECT)clientRectScrollbox); - vertScroll.cbSize = sizeof(SCROLLINFO); - vertScroll.fMask = SIF_PAGE | SIF_RANGE; - vertScroll.nMax = clientRectImageArea[3]+6-1; - vertScroll.nMin = 0; - vertScroll.nPage = clientRectScrollbox[3]; - vertScroll.nPos = 0; - vertScroll.nTrackPos = 0; - SetScrollInfo(hScrollbox, SB_VERT, &vertScroll, TRUE); - MoveWindow(hScrlClient, - -GetScrollPos(hScrollbox, SB_HORZ), -GetScrollPos(hScrollbox, SB_VERT), - max(clientRectImageArea[2]+6, clientRectScrollbox[2]), max(clientRectImageArea[3]+6, clientRectScrollbox[3]), TRUE); + SCROLLINFO si; + GetClientRect(hScrollbox, (LPRECT) &clientRectScrollbox); + GetClientRect(hImageArea, (LPRECT) &clientRectImageArea); + si.cbSize = sizeof(SCROLLINFO); + si.fMask = SIF_PAGE | SIF_RANGE; + si.nMax = clientRectImageArea[2] + 6 - 1; + si.nMin = 0; + si.nPage = clientRectScrollbox[2]; + SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE); + GetClientRect(hScrollbox, (LPRECT) clientRectScrollbox); + si.nMax = clientRectImageArea[3] + 6 - 1; + si.nPage = clientRectScrollbox[3]; + SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE); + MoveWindow(hScrlClient, + -GetScrollPos(hScrollbox, SB_HORZ), -GetScrollPos(hScrollbox, SB_VERT), + max(clientRectImageArea[2] + 6, clientRectScrollbox[2]), + max(clientRectImageArea[3] + 6, clientRectScrollbox[3]), TRUE); } break; + case WM_HSCROLL: - if (hwnd==hScrollbox) + if (hwnd == hScrollbox) { SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); @@ -349,12 +333,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; } SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE); - MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ), - -GetScrollPos(hScrollbox, SB_VERT), imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE); + MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ), + -GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6, + imgYRes * zoom / 1000 + 6, TRUE); } break; + case WM_VSCROLL: - if (hwnd==hScrollbox) + if (hwnd == hScrollbox) { SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); @@ -380,60 +366,65 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; } SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE); - MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ), - -GetScrollPos(hScrollbox, SB_VERT), imgXRes*zoom/1000+6, imgYRes*zoom/1000+6, TRUE); + MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ), + -GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6, + imgYRes * zoom / 1000 + 6, TRUE); } break; + case WM_GETMINMAXINFO: - if (hwnd==hMainWnd) + if (hwnd == hMainWnd) { - MINMAXINFO *mm = (LPMINMAXINFO)lParam; + MINMAXINFO *mm = (LPMINMAXINFO) lParam; (*mm).ptMinTrackSize.x = 330; (*mm).ptMinTrackSize.y = 430; } break; + case WM_PAINT: - DefWindowProc (hwnd, message, wParam, lParam); - if (hwnd==hImageArea) + DefWindowProc(hwnd, message, wParam, lParam); + if (hwnd == hImageArea) { HDC hdc = GetDC(hImageArea); - StretchBlt(hdc, 0, 0, imgXRes*zoom/1000, imgYRes*zoom/1000, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY); - if (showGrid && (zoom>=4000)) + StretchBlt(hdc, 0, 0, imgXRes * zoom / 1000, imgYRes * zoom / 1000, hDrawingDC, 0, 0, imgXRes, + imgYRes, SRCCOPY); + if (showGrid && (zoom >= 4000)) { HPEN oldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00a0a0a0)); int counter; - for (counter = 0; counter <= imgYRes; counter++) + for(counter = 0; counter <= imgYRes; counter++) { - MoveToEx(hdc, 0, counter*zoom/1000, NULL); - LineTo(hdc, imgXRes*zoom/1000, counter*zoom/1000); + MoveToEx(hdc, 0, counter * zoom / 1000, NULL); + LineTo(hdc, imgXRes * zoom / 1000, counter * zoom / 1000); } - for (counter = 0; counter <= imgXRes; counter++) + for(counter = 0; counter <= imgXRes; counter++) { - MoveToEx(hdc, counter*zoom/1000, 0, NULL); - LineTo(hdc, counter*zoom/1000, imgYRes*zoom/1000); + MoveToEx(hdc, counter * zoom / 1000, 0, NULL); + LineTo(hdc, counter * zoom / 1000, imgYRes * zoom / 1000); } DeleteObject(SelectObject(hdc, oldPen)); } ReleaseDC(hImageArea, hdc); SendMessage(hSelection, WM_PAINT, 0, 0); SendMessage(hwndMiniature, WM_PAINT, 0, 0); - }else - if (hwnd==hwndMiniature) + } + else if (hwnd == hwndMiniature) { long mclient[4]; HDC hdc; - GetClientRect(hwndMiniature, (LPRECT)&mclient); + GetClientRect(hwndMiniature, (LPRECT) &mclient); hdc = GetDC(hwndMiniature); - BitBlt(hdc, -min(imgXRes*GetScrollPos(hScrollbox, SB_HORZ)/10000, imgXRes-mclient[2]), - -min(imgYRes*GetScrollPos(hScrollbox, SB_VERT)/10000, imgYRes-mclient[3]), imgXRes, imgYRes, hDrawingDC, 0, 0, SRCCOPY); + BitBlt(hdc, -min(imgXRes * GetScrollPos(hScrollbox, SB_HORZ) / 10000, imgXRes - mclient[2]), + -min(imgYRes * GetScrollPos(hScrollbox, SB_VERT) / 10000, imgYRes - mclient[3]), + imgXRes, imgYRes, hDrawingDC, 0, 0, SRCCOPY); ReleaseDC(hwndMiniature, hdc); } - break; - - // mouse events used for drawing - + break; + + // mouse events used for drawing + case WM_SETCURSOR: - if (hwnd==hImageArea) + if (hwnd == hImageArea) { switch (activeTool) { @@ -455,91 +446,111 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM default: SetCursor(LoadCursor(NULL, IDC_CROSS)); } - } else DefWindowProc(hwnd, message, wParam, lParam); + } + else + DefWindowProc(hwnd, message, wParam, lParam); break; + case WM_LBUTTONDOWN: - if (hwnd==hImageArea) - { - if ((!drawing)||(activeTool==5)) + if (hwnd == hImageArea) + { + if ((!drawing) || (activeTool == 5)) { SetCapture(hImageArea); drawing = TRUE; - startPaintingL(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor); - }else + startPaintingL(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom, + fgColor, bgColor); + } + else { SendMessage(hwnd, WM_LBUTTONUP, wParam, lParam); undo(); } SendMessage(hImageArea, WM_PAINT, 0, 0); - if ((activeTool==6)&&(zoom<8000)) zoomTo(zoom*2, (short)LOWORD(lParam), (short)HIWORD(lParam)); + if ((activeTool == 6) && (zoom < 8000)) + zoomTo(zoom * 2, (short)LOWORD(lParam), (short)HIWORD(lParam)); } - break; + break; + case WM_RBUTTONDOWN: - if (hwnd==hImageArea) - { - if ((!drawing)||(activeTool==5)) + if (hwnd == hImageArea) + { + if ((!drawing) || (activeTool == 5)) { SetCapture(hImageArea); drawing = TRUE; - startPaintingR(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor); - }else + startPaintingR(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom, + fgColor, bgColor); + } + else { SendMessage(hwnd, WM_RBUTTONUP, wParam, lParam); undo(); } SendMessage(hImageArea, WM_PAINT, 0, 0); - if ((activeTool==6)&&(zoom>125)) zoomTo(zoom/2, (short)LOWORD(lParam), (short)HIWORD(lParam)); + if ((activeTool == 6) && (zoom > 125)) + zoomTo(zoom / 2, (short)LOWORD(lParam), (short)HIWORD(lParam)); } - break; + break; + case WM_LBUTTONUP: - if ((hwnd==hImageArea)&&drawing) - { - ReleaseCapture(); - drawing = FALSE; - endPaintingL(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor); - SendMessage(hImageArea, WM_PAINT, 0, 0); - if (activeTool==5) - { - int tempColor = GetPixel(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom); - if (tempColor!=CLR_INVALID) fgColor = tempColor; - SendMessage(hPalWin, WM_PAINT, 0, 0); - } - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)""); - } - break; - case WM_RBUTTONUP: - if ((hwnd==hImageArea)&&drawing) - { - ReleaseCapture(); - drawing = FALSE; - endPaintingR(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom, fgColor, bgColor); - SendMessage(hImageArea, WM_PAINT, 0, 0); - if (activeTool==5) - { - int tempColor = GetPixel(hDrawingDC, LOWORD(lParam)*1000/zoom, HIWORD(lParam)*1000/zoom); - if (tempColor!=CLR_INVALID) bgColor = tempColor; - SendMessage(hPalWin, WM_PAINT, 0, 0); - } - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)""); - } - break; - case WM_MOUSEMOVE: - if (hwnd==hImageArea) + if ((hwnd == hImageArea) && drawing) { - if ((!drawing)||(activeTool<=9)) + ReleaseCapture(); + drawing = FALSE; + endPaintingL(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom, fgColor, + bgColor); + SendMessage(hImageArea, WM_PAINT, 0, 0); + if (activeTool == 5) + { + int tempColor = + GetPixel(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom); + if (tempColor != CLR_INVALID) + fgColor = tempColor; + SendMessage(hPalWin, WM_PAINT, 0, 0); + } + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) ""); + } + break; + + case WM_RBUTTONUP: + if ((hwnd == hImageArea) && drawing) + { + ReleaseCapture(); + drawing = FALSE; + endPaintingR(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom, fgColor, + bgColor); + SendMessage(hImageArea, WM_PAINT, 0, 0); + if (activeTool == 5) + { + int tempColor = + GetPixel(hDrawingDC, LOWORD(lParam) * 1000 / zoom, HIWORD(lParam) * 1000 / zoom); + if (tempColor != CLR_INVALID) + bgColor = tempColor; + SendMessage(hPalWin, WM_PAINT, 0, 0); + } + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) ""); + } + break; + + case WM_MOUSEMOVE: + if (hwnd == hImageArea) + { + if ((!drawing) || (activeTool <= 9)) { TRACKMOUSEEVENT tme; TCHAR coordStr[100]; - _stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom); - SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)coordStr); - + _stprintf(coordStr, _T("%d, %d"), (short)LOWORD(lParam) * 1000 / zoom, + (short)HIWORD(lParam) * 1000 / zoom); + SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) coordStr); + if (activeTool == 6) { SendMessage(hImageArea, WM_PAINT, 0, 0); drawZoomFrame((short)LOWORD(lParam), (short)HIWORD(lParam)); } - + tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE; tme.hwndTrack = hImageArea; @@ -548,55 +559,58 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM } if (drawing) { - if ((wParam&MK_LBUTTON)!=0) + if ((wParam & MK_LBUTTON) != 0) { - whilePaintingL(hDrawingDC, (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom, fgColor, bgColor); + whilePaintingL(hDrawingDC, (short)LOWORD(lParam) * 1000 / zoom, + (short)HIWORD(lParam) * 1000 / zoom, fgColor, bgColor); SendMessage(hImageArea, WM_PAINT, 0, 0); - if ((activeTool>=10)||(activeTool==2)) + if ((activeTool >= 10) || (activeTool == 2)) { TCHAR sizeStr[100]; - _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)sizeStr); + _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam) * 1000 / zoom - startX, + (short)HIWORD(lParam) * 1000 / zoom - startY); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); } } - if ((wParam&MK_RBUTTON)!=0) + if ((wParam & MK_RBUTTON) != 0) { - whilePaintingR(hDrawingDC, (short)LOWORD(lParam)*1000/zoom, (short)HIWORD(lParam)*1000/zoom, fgColor, bgColor); + whilePaintingR(hDrawingDC, (short)LOWORD(lParam) * 1000 / zoom, + (short)HIWORD(lParam) * 1000 / zoom, fgColor, bgColor); SendMessage(hImageArea, WM_PAINT, 0, 0); - if (activeTool>=10) + if (activeTool >= 10) { TCHAR sizeStr[100]; - _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam)*1000/zoom-startX, (short)HIWORD(lParam)*1000/zoom-startY); - SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)sizeStr); + _stprintf(sizeStr, _T("%d x %d"), (short)LOWORD(lParam) * 1000 / zoom - startX, + (short)HIWORD(lParam) * 1000 / zoom - startY); + SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr); } } } } break; + case WM_MOUSELEAVE: - { - SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)_T("")); - if (activeTool == 6) - SendMessage(hImageArea, WM_PAINT, 0, 0); - } + SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) _T("")); + if (activeTool == 6) + SendMessage(hImageArea, WM_PAINT, 0, 0); break; - + // menu and button events - + case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_HELPINFO: - { - HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON)); - TCHAR infotitle[100]; - TCHAR infotext[200]; - LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle)); - LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext)); - ShellAbout(hMainWnd, infotitle, infotext, paintIcon); - DeleteObject(paintIcon); - } + { + HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON)); + TCHAR infotitle[100]; + TCHAR infotext[200]; + LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle)); + LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext)); + ShellAbout(hMainWnd, infotitle, infotext, paintIcon); + DeleteObject(paintIcon); break; + } case IDM_HELPHELPTOPICS: //HtmlHelp(hMainWnd, "help\\Paint.chm", 0, 0); break; @@ -604,15 +618,15 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM SendMessage(hwnd, WM_CLOSE, wParam, lParam); break; case IDM_FILENEW: - Rectangle(hDrawingDC, 0-1, 0-1, imgXRes+1, imgYRes+1); + Rectangle(hDrawingDC, 0 - 1, 0 - 1, imgXRes + 1, imgYRes + 1); SendMessage(hImageArea, WM_PAINT, 0, 0); break; case IDM_FILEOPEN: - if (GetOpenFileName(&ofn)!=0) + if (GetOpenFileName(&ofn) != 0) { HBITMAP bmNew = NULL; LoadDIBFromFile(&bmNew, ofn.lpstrFile, &fileTime, &fileSize, &fileHPPM, &fileVPPM); - if (bmNew!=NULL) + if (bmNew != NULL) { TCHAR tempstr[1000]; TCHAR resstr[100]; @@ -631,18 +645,20 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDM_FILESAVE: if (isAFile) { - SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC, &fileTime, &fileSize, fileHPPM, fileVPPM); + SaveDIBToFile(hBms[currInd], filepathname, hDrawingDC, &fileTime, &fileSize, fileHPPM, + fileVPPM); imageSaved = TRUE; } else SendMessage(hwnd, WM_COMMAND, IDM_FILESAVEAS, 0); break; case IDM_FILESAVEAS: - if (GetSaveFileName(&sfn)!=0) + if (GetSaveFileName(&sfn) != 0) { TCHAR tempstr[1000]; TCHAR resstr[100]; - SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC, &fileTime, &fileSize, fileHPPM, fileVPPM); + SaveDIBToFile(hBms[currInd], sfn.lpstrFile, hDrawingDC, &fileTime, &fileSize, + fileHPPM, fileVPPM); CopyMemory(filename, sfn.lpstrFileTitle, sizeof(filename)); CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname)); LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr)); @@ -677,15 +693,18 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case IDM_EDITPASTE: OpenClipboard(hMainWnd); - if (GetClipboardData(CF_BITMAP)!=NULL) + if (GetClipboardData(CF_BITMAP) != NULL) { - DeleteObject(SelectObject(hSelDC, hSelBm = CopyImage(GetClipboardData(CF_BITMAP), IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG))); + DeleteObject(SelectObject(hSelDC, hSelBm = CopyImage(GetClipboardData(CF_BITMAP), + IMAGE_BITMAP, 0, 0, + LR_COPYRETURNORG))); newReversible(); rectSel_src[0] = rectSel_src[1] = rectSel_src[2] = rectSel_src[3] = 0; rectSel_dest[0] = rectSel_dest[1] = 0; rectSel_dest[2] = GetDIBWidth(hSelBm); rectSel_dest[3] = GetDIBHeight(hSelBm); - BitBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], hSelDC, 0, 0, SRCCOPY); + BitBlt(hDrawingDC, rectSel_dest[0], rectSel_dest[1], rectSel_dest[2], rectSel_dest[3], + hSelDC, 0, 0, SRCCOPY); placeSelWin(); ShowWindow(hSelection, SW_SHOW); } @@ -695,7 +714,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM ShowWindow(hSelection, SW_HIDE); break; case IDM_EDITSELECTALL: - if (activeTool==2) + if (activeTool == 2) { startPaintingL(hDrawingDC, 0, 0, fgColor, bgColor); whilePaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor); @@ -703,7 +722,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM } break; case IDM_EDITCOPYTO: - if (GetSaveFileName(&ofn)!=0) SaveDIBToFile(hSelBm, ofn.lpstrFile, hDrawingDC, NULL, NULL, fileHPPM, fileVPPM); + if (GetSaveFileName(&ofn) != 0) + SaveDIBToFile(hSelBm, ofn.lpstrFile, hDrawingDC, NULL, NULL, fileHPPM, fileVPPM); break; case IDM_COLORSEDITPALETTE: if (ChooseColor(&choosecolor)) @@ -713,14 +733,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM } break; case IDM_IMAGEINVERTCOLORS: - { - RECT tempRect; - newReversible(); - SetRect(&tempRect, 0, 0, imgXRes, imgYRes); - InvertRect(hDrawingDC, &tempRect); - SendMessage(hImageArea, WM_PAINT, 0, 0); - } - break; + { + RECT tempRect; + newReversible(); + SetRect(&tempRect, 0, 0, imgXRes, imgYRes); + InvertRect(hDrawingDC, &tempRect); + SendMessage(hImageArea, WM_PAINT, 0, 0); + break; + } case IDM_IMAGEDELETEIMAGE: newReversible(); Rect(hDrawingDC, 0, 0, imgXRes, imgYRes, bgColor, bgColor, 0, TRUE); @@ -731,55 +751,57 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM { case 1: newReversible(); - StretchBlt(hDrawingDC, imgXRes-1, 0, -imgXRes, imgYRes, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY); + StretchBlt(hDrawingDC, imgXRes - 1, 0, -imgXRes, imgYRes, hDrawingDC, 0, 0, + imgXRes, imgYRes, SRCCOPY); SendMessage(hImageArea, WM_PAINT, 0, 0); break; case 2: newReversible(); - StretchBlt(hDrawingDC, 0, imgYRes-1, imgXRes, -imgYRes, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY); + StretchBlt(hDrawingDC, 0, imgYRes - 1, imgXRes, -imgYRes, hDrawingDC, 0, 0, + imgXRes, imgYRes, SRCCOPY); SendMessage(hImageArea, WM_PAINT, 0, 0); break; case 4: newReversible(); - StretchBlt(hDrawingDC, imgXRes-1, imgYRes-1, -imgXRes, -imgYRes, hDrawingDC, 0, 0, imgXRes, imgYRes, SRCCOPY); + StretchBlt(hDrawingDC, imgXRes - 1, imgYRes - 1, -imgXRes, -imgYRes, hDrawingDC, + 0, 0, imgXRes, imgYRes, SRCCOPY); SendMessage(hImageArea, WM_PAINT, 0, 0); break; } break; case IDM_IMAGEATTRIBUTES: + { + int retVal = attributesDlg(); + if ((LOWORD(retVal) != 0) && (HIWORD(retVal) != 0)) { - int retVal = attributesDlg(); - if ((LOWORD(retVal)!=0)&&(HIWORD(retVal)!=0)) - { - cropReversible(LOWORD(retVal), HIWORD(retVal), 0, 0); - updateCanvasAndScrollbars(); - } + cropReversible(LOWORD(retVal), HIWORD(retVal), 0, 0); + updateCanvasAndScrollbars(); } break; + } case IDM_IMAGECHANGESIZE: + { + int retVal = changeSizeDlg(); + if ((LOWORD(retVal) != 0) && (HIWORD(retVal) != 0)) { - int retVal = changeSizeDlg(); - if ((LOWORD(retVal)!=0)&&(HIWORD(retVal)!=0)) - { - insertReversible(CopyImage(hBms[currInd], IMAGE_BITMAP, imgXRes*LOWORD(retVal)/100, imgYRes*HIWORD(retVal)/100, 0)); - updateCanvasAndScrollbars(); - } + insertReversible(CopyImage(hBms[currInd], IMAGE_BITMAP, + imgXRes * LOWORD(retVal) / 100, + imgYRes * HIWORD(retVal) / 100, 0)); + updateCanvasAndScrollbars(); } break; + } case IDM_IMAGEDRAWOPAQUE: - transpBg = 1-transpBg; + transpBg = 1 - transpBg; SendMessage(hToolSettings, WM_PAINT, 0, 0); break; case IDM_IMAGECROP: insertReversible(CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG)); updateCanvasAndScrollbars(); break; - + case IDM_VIEWSTATUSBAR: - if (IsWindowVisible(hStatusBar)) - ShowWindow(hStatusBar, SW_HIDE); - else - ShowWindow(hStatusBar, SW_SHOW); + ShowWindow(hStatusBar, IsWindowVisible(hStatusBar) ? SW_HIDE : SW_SHOW); break; case IDM_VIEWSHOWGRID: @@ -787,12 +809,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case IDM_VIEWSHOWMINIATURE: showMiniature = !showMiniature; - if (showMiniature) - ShowWindow(hwndMiniature, SW_SHOW); - else - ShowWindow(hwndMiniature, SW_HIDE); + ShowWindow(hwndMiniature, showMiniature ? SW_SHOW : SW_HIDE); break; - + case IDM_VIEWZOOM125: zoomTo(125, 0, 0); break; @@ -816,58 +835,57 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case ID_FREESEL: selectTool(1); - break; + break; case ID_RECTSEL: selectTool(2); - break; + break; case ID_RUBBER: selectTool(3); - break; + break; case ID_FILL: selectTool(4); - break; + break; case ID_COLOR: selectTool(5); - break; + break; case ID_ZOOM: selectTool(6); - break; + break; case ID_PEN: selectTool(7); - break; + break; case ID_BRUSH: selectTool(8); - break; + break; case ID_AIRBRUSH: selectTool(9); - break; + break; case ID_TEXT: selectTool(10); - break; + break; case ID_LINE: selectTool(11); - break; + break; case ID_BEZIER: selectTool(12); - break; + break; case ID_RECT: selectTool(13); - break; + break; case ID_SHAPE: selectTool(14); - break; + break; case ID_ELLIPSE: selectTool(15); - break; + break; case ID_RRECT: selectTool(16); break; } break; default: - return DefWindowProc (hwnd, message, wParam, lParam); + return DefWindowProc(hwnd, message, wParam, lParam); } return 0; } - diff --git a/reactos/base/applications/paint/winproc.h b/reactos/base/applications/paint/winproc.h index 0b016be35ab..62d972bebd5 100644 --- a/reactos/base/applications/paint/winproc.h +++ b/reactos/base/applications/paint/winproc.h @@ -1,12 +1,10 @@ /* * PROJECT: PAINT for ReactOS * LICENSE: LGPL - * FILE: winproc.h + * FILE: base/applications/paint/winproc.h * PURPOSE: Window procedure of the main window and all children apart from * hPalWin, hToolSettings and hSelection * PROGRAMMERS: Benedikt Freisen */ -void ZoomTo(int newZoom); - -LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);