2015-05-08 16:02:36 +00:00
|
|
|
/*
|
2023-06-23 11:04:32 +00:00
|
|
|
* PROJECT: PAINT for ReactOS
|
|
|
|
* LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
|
|
|
|
* PURPOSE: Window procedure of the tool settings window
|
2023-06-27 18:22:21 +00:00
|
|
|
* COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
|
2023-06-23 11:04:32 +00:00
|
|
|
* Copyright 2018 Stanislav Motylkov <x86corez@gmail.com>
|
|
|
|
* Copyright 2021-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
2015-05-08 16:02:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precomp.h"
|
|
|
|
|
2023-03-21 04:13:53 +00:00
|
|
|
#define X_TOOLSETTINGS 0
|
|
|
|
#define Y_TOOLSETTINGS (CY_TOOLBAR + 3)
|
|
|
|
#define CX_TOOLSETTINGS CX_TOOLBAR
|
|
|
|
#define CY_TOOLSETTINGS 140
|
|
|
|
|
|
|
|
#define CX_TRANS_ICON 40
|
|
|
|
#define CY_TRANS_ICON 30
|
|
|
|
#define MARGIN1 3
|
|
|
|
#define MARGIN2 2
|
|
|
|
|
2023-10-10 01:59:29 +00:00
|
|
|
#define MAX_ZOOM_TRACK 6
|
|
|
|
#define MIN_ZOOM_TRACK 0
|
|
|
|
#define DEFAULT_ZOOM_TRACK 3
|
|
|
|
|
2023-03-21 04:13:53 +00:00
|
|
|
static const BYTE s_AirRadius[4] = { 5, 8, 3, 12 };
|
|
|
|
|
2023-03-28 13:31:26 +00:00
|
|
|
CToolSettingsWindow toolSettingsWindow;
|
|
|
|
|
2015-05-08 16:02:36 +00:00
|
|
|
/* FUNCTIONS ********************************************************/
|
|
|
|
|
2023-03-21 04:13:53 +00:00
|
|
|
BOOL CToolSettingsWindow::DoCreate(HWND hwndParent)
|
|
|
|
{
|
|
|
|
RECT toolSettingsWindowPos =
|
|
|
|
{
|
|
|
|
X_TOOLSETTINGS, Y_TOOLSETTINGS,
|
|
|
|
X_TOOLSETTINGS + CX_TOOLSETTINGS, Y_TOOLSETTINGS + CY_TOOLSETTINGS
|
|
|
|
};
|
|
|
|
return !!Create(toolBoxContainer, toolSettingsWindowPos, NULL, WS_CHILD | WS_VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT
|
|
|
|
getSplitRects(RECT *rects, INT cColumns, INT cRows, LPCRECT prc, LPPOINT ppt)
|
|
|
|
{
|
|
|
|
INT cx = prc->right - prc->left, cy = prc->bottom - prc->top;
|
|
|
|
for (INT i = 0, iRow = 0; iRow < cRows; ++iRow)
|
|
|
|
{
|
|
|
|
for (INT iColumn = 0; iColumn < cColumns; ++iColumn)
|
|
|
|
{
|
|
|
|
RECT& rc = rects[i];
|
|
|
|
rc.left = prc->left + (iColumn * cx / cColumns);
|
|
|
|
rc.top = prc->top + (iRow * cy / cRows);
|
|
|
|
rc.right = prc->left + ((iColumn + 1) * cx / cColumns);
|
|
|
|
rc.bottom = prc->top + ((iRow + 1) * cy / cRows);
|
|
|
|
if (ppt && ::PtInRect(&rc, *ppt))
|
|
|
|
return i;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline INT getTransRects(RECT rects[2], LPCRECT prc, LPPOINT ppt = NULL)
|
|
|
|
{
|
|
|
|
return getSplitRects(rects, 1, 2, prc, ppt);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID CToolSettingsWindow::drawTrans(HDC hdc, LPCRECT prc)
|
|
|
|
{
|
|
|
|
RECT rc[2];
|
|
|
|
getTransRects(rc, prc);
|
|
|
|
|
2023-06-15 01:55:59 +00:00
|
|
|
::FillRect(hdc, &rc[toolsModel.IsBackgroundTransparent()], (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
2023-03-21 04:13:53 +00:00
|
|
|
::DrawIconEx(hdc, rc[0].left, rc[0].top, m_hNontranspIcon,
|
|
|
|
CX_TRANS_ICON, CY_TRANS_ICON, 0, NULL, DI_NORMAL);
|
|
|
|
::DrawIconEx(hdc, rc[1].left, rc[1].top, m_hTranspIcon,
|
|
|
|
CX_TRANS_ICON, CY_TRANS_ICON, 0, NULL, DI_NORMAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline INT getRubberRects(RECT rects[4], LPCRECT prc, LPPOINT ppt = NULL)
|
|
|
|
{
|
|
|
|
return getSplitRects(rects, 1, 4, prc, ppt);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID CToolSettingsWindow::drawRubber(HDC hdc, LPCRECT prc)
|
|
|
|
{
|
|
|
|
RECT rects[4], rcRubber;
|
|
|
|
getRubberRects(rects, prc);
|
|
|
|
INT xCenter = (prc->left + prc->right) / 2;
|
|
|
|
for (INT i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
INT iColor, radius = i + 2;
|
|
|
|
if (toolsModel.GetRubberRadius() == radius)
|
|
|
|
{
|
|
|
|
::FillRect(hdc, &rects[i], ::GetSysColorBrush(COLOR_HIGHLIGHT));
|
|
|
|
iColor = COLOR_HIGHLIGHTTEXT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iColor = COLOR_WINDOWTEXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
INT yCenter = (rects[i].top + rects[i].bottom) / 2;
|
|
|
|
rcRubber.left = xCenter - radius;
|
|
|
|
rcRubber.top = yCenter - radius;
|
|
|
|
rcRubber.right = rcRubber.left + radius * 2;
|
|
|
|
rcRubber.bottom = rcRubber.top + radius * 2;
|
|
|
|
::FillRect(hdc, &rcRubber, GetSysColorBrush(iColor));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline INT getBrushRects(RECT rects[12], LPCRECT prc, LPPOINT ppt = NULL)
|
|
|
|
{
|
|
|
|
return getSplitRects(rects, 3, 4, prc, ppt);
|
|
|
|
}
|
|
|
|
|
2023-09-28 12:30:34 +00:00
|
|
|
struct BrushStyleAndWidth
|
|
|
|
{
|
|
|
|
BrushStyle style;
|
|
|
|
INT width;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BrushStyleAndWidth c_BrushPresets[] =
|
|
|
|
{
|
|
|
|
{ BrushStyleRound, 7 }, { BrushStyleRound, 4 }, { BrushStyleRound, 1 },
|
|
|
|
{ BrushStyleSquare, 8 }, { BrushStyleSquare, 5 }, { BrushStyleSquare, 2 },
|
|
|
|
{ BrushStyleForeSlash, 8 }, { BrushStyleForeSlash, 5 }, { BrushStyleForeSlash, 2 },
|
|
|
|
{ BrushStyleBackSlash, 8 }, { BrushStyleBackSlash, 5 }, { BrushStyleBackSlash, 2 },
|
|
|
|
};
|
|
|
|
|
2023-03-21 04:13:53 +00:00
|
|
|
VOID CToolSettingsWindow::drawBrush(HDC hdc, LPCRECT prc)
|
|
|
|
{
|
|
|
|
RECT rects[12];
|
|
|
|
getBrushRects(rects, prc);
|
|
|
|
|
|
|
|
for (INT i = 0; i < 12; i++)
|
|
|
|
{
|
|
|
|
RECT rcItem = rects[i];
|
|
|
|
INT x = (rcItem.left + rcItem.right) / 2, y = (rcItem.top + rcItem.bottom) / 2;
|
2023-09-28 12:30:34 +00:00
|
|
|
|
2023-03-21 04:13:53 +00:00
|
|
|
INT iColor;
|
2023-09-28 12:30:34 +00:00
|
|
|
const BrushStyleAndWidth& data = c_BrushPresets[i];
|
|
|
|
if (data.width == toolsModel.GetBrushWidth() && data.style == toolsModel.GetBrushStyle())
|
|
|
|
{
|
2023-03-21 04:13:53 +00:00
|
|
|
iColor = COLOR_HIGHLIGHTTEXT;
|
2023-09-28 12:30:34 +00:00
|
|
|
::FillRect(hdc, &rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
|
|
|
|
}
|
2023-03-21 04:13:53 +00:00
|
|
|
else
|
2023-09-28 12:30:34 +00:00
|
|
|
{
|
2023-03-21 04:13:53 +00:00
|
|
|
iColor = COLOR_WINDOWTEXT;
|
2023-09-28 12:30:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Brush(hdc, x, y, x, y, ::GetSysColor(iColor), data.style, data.width);
|
2023-03-21 04:13:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline INT getLineRects(RECT rects[5], LPCRECT prc, LPPOINT ppt = NULL)
|
|
|
|
{
|
|
|
|
return getSplitRects(rects, 1, 5, prc, ppt);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID CToolSettingsWindow::drawLine(HDC hdc, LPCRECT prc)
|
|
|
|
{
|
|
|
|
RECT rects[5];
|
|
|
|
getLineRects(rects, prc);
|
|
|
|
|
|
|
|
for (INT i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
INT penWidth = i + 1;
|
2023-11-23 06:01:29 +00:00
|
|
|
CRect rcLine = rects[i];
|
|
|
|
rcLine.InflateRect(-2, 0);
|
2023-03-21 04:13:53 +00:00
|
|
|
rcLine.top = (rcLine.top + rcLine.bottom - penWidth) / 2;
|
|
|
|
rcLine.bottom = rcLine.top + penWidth;
|
|
|
|
if (toolsModel.GetLineWidth() == penWidth)
|
|
|
|
{
|
|
|
|
::FillRect(hdc, &rects[i], ::GetSysColorBrush(COLOR_HIGHLIGHT));
|
|
|
|
::FillRect(hdc, &rcLine, ::GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::FillRect(hdc, &rcLine, ::GetSysColorBrush(COLOR_WINDOWTEXT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static INT getAirBrushRects(RECT rects[4], LPCRECT prc, LPPOINT ppt = NULL)
|
|
|
|
{
|
|
|
|
INT cx = (prc->right - prc->left), cy = (prc->bottom - prc->top);
|
|
|
|
|
|
|
|
rects[0] = rects[1] = rects[2] = rects[3] = *prc;
|
|
|
|
|
|
|
|
rects[0].right = rects[1].left = prc->left + cx * 3 / 8;
|
|
|
|
rects[0].bottom = rects[1].bottom = prc->top + cy / 2;
|
|
|
|
|
|
|
|
rects[2].top = rects[3].top = prc->top + cy / 2;
|
|
|
|
rects[2].right = rects[3].left = prc->left + cx * 2 / 8;
|
|
|
|
|
|
|
|
if (ppt)
|
|
|
|
{
|
|
|
|
for (INT i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
if (::PtInRect(&rects[i], *ppt))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID CToolSettingsWindow::drawAirBrush(HDC hdc, LPCRECT prc)
|
|
|
|
{
|
|
|
|
RECT rects[4];
|
|
|
|
getAirBrushRects(rects, prc);
|
|
|
|
|
|
|
|
srand(0);
|
|
|
|
for (size_t i = 0; i < 4; ++i)
|
|
|
|
{
|
|
|
|
RECT& rc = rects[i];
|
|
|
|
INT x = (rc.left + rc.right) / 2;
|
|
|
|
INT y = (rc.top + rc.bottom) / 2;
|
2023-11-16 06:45:06 +00:00
|
|
|
BOOL bHigh = (s_AirRadius[i] == toolsModel.GetAirBrushRadius());
|
2023-03-21 04:13:53 +00:00
|
|
|
if (bHigh)
|
|
|
|
{
|
|
|
|
::FillRect(hdc, &rc, ::GetSysColorBrush(COLOR_HIGHLIGHT));
|
2023-06-17 12:15:35 +00:00
|
|
|
|
|
|
|
for (int k = 0; k < 3; ++k)
|
|
|
|
Airbrush(hdc, x, y, ::GetSysColor(COLOR_HIGHLIGHTTEXT), s_AirRadius[i]);
|
2023-03-21 04:13:53 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-17 12:15:35 +00:00
|
|
|
for (int k = 0; k < 3; ++k)
|
|
|
|
Airbrush(hdc, x, y, ::GetSysColor(COLOR_WINDOWTEXT), s_AirRadius[i]);
|
2023-03-21 04:13:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline INT getBoxRects(RECT rects[3], LPCRECT prc, LPPOINT ppt = NULL)
|
|
|
|
{
|
|
|
|
return getSplitRects(rects, 1, 3, prc, ppt);
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID CToolSettingsWindow::drawBox(HDC hdc, LPCRECT prc)
|
|
|
|
{
|
2023-11-23 06:01:29 +00:00
|
|
|
CRect rects[3];
|
2023-03-21 04:13:53 +00:00
|
|
|
getBoxRects(rects, prc);
|
|
|
|
|
|
|
|
for (INT iItem = 0; iItem < 3; ++iItem)
|
|
|
|
{
|
2023-11-23 06:01:29 +00:00
|
|
|
CRect& rcItem = rects[iItem];
|
2023-03-21 04:13:53 +00:00
|
|
|
|
|
|
|
if (toolsModel.GetShapeStyle() == iItem)
|
|
|
|
::FillRect(hdc, &rcItem, ::GetSysColorBrush(COLOR_HIGHLIGHT));
|
|
|
|
|
2023-11-23 06:01:29 +00:00
|
|
|
rcItem.InflateRect(-5, -5);
|
2023-03-21 04:13:53 +00:00
|
|
|
|
|
|
|
if (iItem <= 1)
|
|
|
|
{
|
|
|
|
COLORREF rgbPen;
|
|
|
|
if (toolsModel.GetShapeStyle() == iItem)
|
|
|
|
rgbPen = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
|
|
|
|
else
|
|
|
|
rgbPen = ::GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
HGDIOBJ hOldBrush;
|
|
|
|
if (iItem == 0)
|
|
|
|
hOldBrush = ::SelectObject(hdc, ::GetStockObject(NULL_BRUSH));
|
|
|
|
else
|
|
|
|
hOldBrush = ::SelectObject(hdc, ::GetSysColorBrush(COLOR_APPWORKSPACE));
|
|
|
|
HGDIOBJ hOldPen = ::SelectObject(hdc, ::CreatePen(PS_SOLID, 1, rgbPen));
|
|
|
|
::Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom);
|
|
|
|
::DeleteObject(::SelectObject(hdc, hOldPen));
|
|
|
|
::SelectObject(hdc, hOldBrush);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (toolsModel.GetShapeStyle() == iItem)
|
|
|
|
::FillRect(hdc, &rcItem, ::GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
|
|
|
else
|
|
|
|
::FillRect(hdc, &rcItem, ::GetSysColorBrush(COLOR_WINDOWTEXT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 10:13:20 +00:00
|
|
|
LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
2015-07-07 11:44:50 +00:00
|
|
|
{
|
2023-03-17 23:24:19 +00:00
|
|
|
/* preloading the draw transparent/nontransparent icons for later use */
|
2023-11-04 10:25:45 +00:00
|
|
|
m_hNontranspIcon = (HICON)LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDI_NONTRANSPARENT),
|
|
|
|
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
|
|
|
|
m_hTranspIcon = (HICON)LoadImageW(g_hinstExe, MAKEINTRESOURCEW(IDI_TRANSPARENT),
|
|
|
|
IMAGE_ICON, CX_TRANS_ICON, CY_TRANS_ICON, LR_DEFAULTCOLOR);
|
2023-03-17 23:24:19 +00:00
|
|
|
|
2023-11-23 06:01:29 +00:00
|
|
|
CRect trackbarZoomPos, rect2;
|
2023-10-10 01:59:29 +00:00
|
|
|
calculateTwoBoxes(trackbarZoomPos, rect2);
|
2023-11-23 06:01:29 +00:00
|
|
|
trackbarZoomPos.InflateRect(-1, -1);
|
2023-10-10 01:59:29 +00:00
|
|
|
|
2015-07-07 11:44:50 +00:00
|
|
|
trackbarZoom.Create(TRACKBAR_CLASS, m_hWnd, trackbarZoomPos, NULL, WS_CHILD | TBS_VERT | TBS_AUTOTICKS);
|
2023-10-10 01:59:29 +00:00
|
|
|
trackbarZoom.SendMessage(TBM_SETRANGE, TRUE, MAKELPARAM(MIN_ZOOM_TRACK, MAX_ZOOM_TRACK));
|
|
|
|
trackbarZoom.SendMessage(TBM_SETPOS, TRUE, DEFAULT_ZOOM_TRACK);
|
2015-07-07 11:44:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-03-17 23:24:19 +00:00
|
|
|
LRESULT CToolSettingsWindow::OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
::DestroyIcon(m_hNontranspIcon);
|
|
|
|
::DestroyIcon(m_hTranspIcon);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-10-10 01:59:29 +00:00
|
|
|
INT trackPos = MAX_ZOOM_TRACK - (INT)trackbarZoom.SendMessage(TBM_GETPOS, 0, 0);
|
2023-10-16 22:25:50 +00:00
|
|
|
canvasWindow.zoomTo(MIN_ZOOM << trackPos);
|
2023-10-10 01:59:29 +00:00
|
|
|
|
|
|
|
INT zoomRate = toolsModel.GetZoom();
|
|
|
|
|
2023-11-04 10:25:45 +00:00
|
|
|
CStringW strZoom;
|
2023-10-10 01:59:29 +00:00
|
|
|
if (zoomRate % 10 == 0)
|
2023-11-04 10:25:45 +00:00
|
|
|
strZoom.Format(L"%d%%", zoomRate / 10);
|
2023-10-10 01:59:29 +00:00
|
|
|
else
|
2023-11-04 10:25:45 +00:00
|
|
|
strZoom.Format(L"%d.%d%%", zoomRate / 10, zoomRate % 10);
|
2023-10-10 01:59:29 +00:00
|
|
|
|
2023-11-04 10:25:45 +00:00
|
|
|
::SendMessageW(g_hStatusBar, SB_SETTEXT, 1, (LPARAM)(LPCWSTR)strZoom);
|
2023-10-10 01:59:29 +00:00
|
|
|
|
|
|
|
OnToolsModelZoomChanged(nMsg, wParam, lParam, bHandled);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CToolSettingsWindow::OnNotify(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
NMHDR *pnmhdr = (NMHDR*)lParam;
|
|
|
|
if (pnmhdr->code == NM_CUSTOMDRAW)
|
2018-04-14 12:42:34 +00:00
|
|
|
{
|
2023-10-10 01:59:29 +00:00
|
|
|
NMCUSTOMDRAW *pCustomDraw = (NMCUSTOMDRAW*)pnmhdr;
|
|
|
|
pCustomDraw->uItemState &= ~CDIS_FOCUS; // Do not draw the focus
|
2018-04-14 12:42:34 +00:00
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
return 0;
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
|
|
|
|
2023-11-23 06:01:29 +00:00
|
|
|
VOID CToolSettingsWindow::calculateTwoBoxes(CRect& rect1, CRect& rect2)
|
2023-03-21 04:13:53 +00:00
|
|
|
{
|
2023-11-23 06:01:29 +00:00
|
|
|
CRect rcClient;
|
2023-03-21 04:13:53 +00:00
|
|
|
GetClientRect(&rcClient);
|
2023-11-23 06:01:29 +00:00
|
|
|
rcClient.InflateRect(-MARGIN1, -MARGIN1);
|
2023-03-21 04:13:53 +00:00
|
|
|
|
|
|
|
INT yCenter = (rcClient.top + rcClient.bottom) / 2;
|
2023-11-23 06:01:29 +00:00
|
|
|
rect1.SetRect(rcClient.left, rcClient.top, rcClient.right, yCenter);
|
|
|
|
rect2.SetRect(rcClient.left, yCenter, rcClient.right, rcClient.bottom);
|
2023-03-21 04:13:53 +00:00
|
|
|
|
2023-11-23 06:01:29 +00:00
|
|
|
rect1.InflateRect(-MARGIN2, -MARGIN2);
|
|
|
|
rect2.InflateRect(-MARGIN2, -MARGIN2);
|
2023-03-21 04:13:53 +00:00
|
|
|
}
|
|
|
|
|
2015-07-07 10:42:49 +00:00
|
|
|
LRESULT CToolSettingsWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2023-11-23 06:01:29 +00:00
|
|
|
CRect rect1, rect2;
|
2023-03-21 04:13:53 +00:00
|
|
|
calculateTwoBoxes(rect1, rect2);
|
2015-07-07 10:42:49 +00:00
|
|
|
|
2023-03-21 04:13:53 +00:00
|
|
|
PAINTSTRUCT ps;
|
2022-01-30 03:05:23 +00:00
|
|
|
HDC hdc = BeginPaint(&ps);
|
2023-03-21 04:13:53 +00:00
|
|
|
|
2023-10-10 01:59:29 +00:00
|
|
|
if (toolsModel.GetActiveTool() != TOOL_ZOOM)
|
2023-03-21 04:13:53 +00:00
|
|
|
::DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
|
|
|
|
|
|
|
|
if (toolsModel.GetActiveTool() >= TOOL_RECT)
|
|
|
|
::DrawEdge(hdc, &rect2, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE);
|
|
|
|
|
2023-11-23 06:01:29 +00:00
|
|
|
rect1.InflateRect(-MARGIN2, -MARGIN2);
|
|
|
|
rect2.InflateRect(-MARGIN2, -MARGIN2);
|
2015-07-07 11:15:24 +00:00
|
|
|
switch (toolsModel.GetActiveTool())
|
2015-05-08 16:02:36 +00:00
|
|
|
{
|
2015-07-07 10:42:49 +00:00
|
|
|
case TOOL_FREESEL:
|
|
|
|
case TOOL_RECTSEL:
|
|
|
|
case TOOL_TEXT:
|
2023-03-21 04:13:53 +00:00
|
|
|
drawTrans(hdc, &rect1);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case TOOL_RUBBER:
|
2023-03-21 04:13:53 +00:00
|
|
|
drawRubber(hdc, &rect1);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_BRUSH:
|
2023-03-21 04:13:53 +00:00
|
|
|
drawBrush(hdc, &rect1);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_AIRBRUSH:
|
2023-03-21 04:13:53 +00:00
|
|
|
drawAirBrush(hdc, &rect1);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_LINE:
|
|
|
|
case TOOL_BEZIER:
|
2023-03-21 04:13:53 +00:00
|
|
|
drawLine(hdc, &rect1);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_RECT:
|
|
|
|
case TOOL_SHAPE:
|
|
|
|
case TOOL_ELLIPSE:
|
|
|
|
case TOOL_RRECT:
|
2023-03-21 04:13:53 +00:00
|
|
|
drawBox(hdc, &rect1);
|
|
|
|
drawLine(hdc, &rect2);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
2021-12-27 14:23:32 +00:00
|
|
|
case TOOL_FILL:
|
|
|
|
case TOOL_COLOR:
|
|
|
|
case TOOL_ZOOM:
|
|
|
|
case TOOL_PEN:
|
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
}
|
2022-01-30 03:05:23 +00:00
|
|
|
EndPaint(&ps);
|
2015-07-07 10:42:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2023-03-21 04:13:53 +00:00
|
|
|
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
|
|
|
|
2023-11-23 06:01:29 +00:00
|
|
|
CRect rect1, rect2;
|
2023-03-21 04:13:53 +00:00
|
|
|
calculateTwoBoxes(rect1, rect2);
|
|
|
|
RECT rects[12];
|
|
|
|
|
|
|
|
INT iItem;
|
2015-07-07 11:15:24 +00:00
|
|
|
switch (toolsModel.GetActiveTool())
|
2015-07-07 10:42:49 +00:00
|
|
|
{
|
|
|
|
case TOOL_FREESEL:
|
|
|
|
case TOOL_RECTSEL:
|
|
|
|
case TOOL_TEXT:
|
2023-03-21 04:13:53 +00:00
|
|
|
iItem = getTransRects(rects, &rect1, &pt);
|
|
|
|
if (iItem != -1)
|
|
|
|
toolsModel.SetBackgroundTransparent(iItem);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_RUBBER:
|
2023-03-21 04:13:53 +00:00
|
|
|
iItem = getRubberRects(rects, &rect1, &pt);
|
|
|
|
if (iItem != -1)
|
|
|
|
toolsModel.SetRubberRadius(iItem + 2);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_BRUSH:
|
2023-03-21 04:13:53 +00:00
|
|
|
iItem = getBrushRects(rects, &rect1, &pt);
|
|
|
|
if (iItem != -1)
|
2023-09-28 12:30:34 +00:00
|
|
|
{
|
|
|
|
const BrushStyleAndWidth& data = c_BrushPresets[iItem];
|
|
|
|
toolsModel.SetBrushStyle(data.style);
|
|
|
|
toolsModel.SetBrushWidth(data.width);
|
|
|
|
}
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_AIRBRUSH:
|
2023-03-21 04:13:53 +00:00
|
|
|
iItem = getAirBrushRects(rects, &rect1, &pt);
|
|
|
|
if (iItem != -1)
|
2023-11-16 06:45:06 +00:00
|
|
|
toolsModel.SetAirBrushRadius(s_AirRadius[iItem]);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2015-07-07 10:42:49 +00:00
|
|
|
case TOOL_LINE:
|
|
|
|
case TOOL_BEZIER:
|
2023-03-21 04:13:53 +00:00
|
|
|
iItem = getLineRects(rects, &rect1, &pt);
|
|
|
|
if (iItem != -1)
|
|
|
|
toolsModel.SetLineWidth(iItem + 1);
|
2015-07-07 10:42:49 +00:00
|
|
|
break;
|
|
|
|
case TOOL_RECT:
|
|
|
|
case TOOL_SHAPE:
|
|
|
|
case TOOL_ELLIPSE:
|
|
|
|
case TOOL_RRECT:
|
2023-03-21 04:13:53 +00:00
|
|
|
iItem = getBoxRects(rects, &rect1, &pt);
|
|
|
|
if (iItem != -1)
|
|
|
|
toolsModel.SetShapeStyle(iItem);
|
|
|
|
|
|
|
|
iItem = getLineRects(rects, &rect2, &pt);
|
|
|
|
if (iItem != -1)
|
|
|
|
toolsModel.SetLineWidth(iItem + 1);
|
2015-05-08 16:02:36 +00:00
|
|
|
break;
|
2021-12-27 14:23:32 +00:00
|
|
|
case TOOL_FILL:
|
|
|
|
case TOOL_COLOR:
|
|
|
|
case TOOL_ZOOM:
|
|
|
|
case TOOL_PEN:
|
|
|
|
break;
|
2015-05-08 16:02:36 +00:00
|
|
|
}
|
2023-04-03 05:34:56 +00:00
|
|
|
|
|
|
|
::SetCapture(::GetParent(m_hWnd));
|
2015-05-08 16:02:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-07-07 11:44:50 +00:00
|
|
|
|
|
|
|
LRESULT CToolSettingsWindow::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
trackbarZoom.ShowWindow((wParam == TOOL_ZOOM) ? SW_SHOW : SW_HIDE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CToolSettingsWindow::OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
LRESULT CToolSettingsWindow::OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
|
{
|
2023-10-10 01:59:29 +00:00
|
|
|
int tbPos = MIN_ZOOM_TRACK;
|
2015-07-07 11:44:50 +00:00
|
|
|
int tempZoom = toolsModel.GetZoom();
|
|
|
|
|
2021-12-27 13:20:22 +00:00
|
|
|
while (tempZoom > MIN_ZOOM)
|
2015-07-07 11:44:50 +00:00
|
|
|
{
|
|
|
|
tbPos++;
|
|
|
|
tempZoom = tempZoom >> 1;
|
|
|
|
}
|
2023-10-10 01:59:29 +00:00
|
|
|
|
|
|
|
trackbarZoom.SendMessage(TBM_SETPOS, TRUE, MAX_ZOOM_TRACK - tbPos);
|
2015-07-07 11:44:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|