mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 06:02:56 +00:00
[MSPAINT_NEW] use the same hard-coded observer pattern for the SelectionModel (WIP)
svn path=/trunk/; revision=68383
This commit is contained in:
parent
3116acb259
commit
1d4daced52
10 changed files with 40 additions and 25 deletions
|
@ -228,3 +228,4 @@
|
||||||
#define WM_PALETTEMODELPALETTECHANGED (WM_APP + 4)
|
#define WM_PALETTEMODELPALETTECHANGED (WM_APP + 4)
|
||||||
#define WM_IMAGEMODELDIMENSIONSCHANGED (WM_APP + 5)
|
#define WM_IMAGEMODELDIMENSIONSCHANGED (WM_APP + 5)
|
||||||
#define WM_IMAGEMODELIMAGECHANGED (WM_APP + 6)
|
#define WM_IMAGEMODELIMAGECHANGED (WM_APP + 6)
|
||||||
|
#define WM_SELECTIONMODELREFRESHNEEDED (WM_APP + 7)
|
||||||
|
|
|
@ -61,22 +61,14 @@ LRESULT CPaletteWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& b
|
||||||
LRESULT CPaletteWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CPaletteWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
if (GET_X_LPARAM(lParam) >= 31)
|
if (GET_X_LPARAM(lParam) >= 31)
|
||||||
{
|
|
||||||
paletteModel.SetFgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
paletteModel.SetFgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CPaletteWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CPaletteWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
if (GET_X_LPARAM(lParam) >= 31)
|
if (GET_X_LPARAM(lParam) >= 31)
|
||||||
{
|
|
||||||
paletteModel.SetBgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
paletteModel.SetBgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +80,6 @@ LRESULT CPaletteWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam,
|
||||||
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
||||||
choosecolor.rgbResult);
|
choosecolor.rgbResult);
|
||||||
paletteModel.SetFgColor(choosecolor.rgbResult);
|
paletteModel.SetFgColor(choosecolor.rgbResult);
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -102,8 +92,6 @@ LRESULT CPaletteWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam,
|
||||||
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
||||||
choosecolor.rgbResult);
|
choosecolor.rgbResult);
|
||||||
paletteModel.SetBgColor(choosecolor.rgbResult);
|
paletteModel.SetBgColor(choosecolor.rgbResult);
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ void PaletteModel::SetBgColor(int newColor)
|
||||||
void PaletteModel::NotifyColorChanged()
|
void PaletteModel::NotifyColorChanged()
|
||||||
{
|
{
|
||||||
paletteWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
|
paletteWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
|
||||||
|
selectionWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteModel::NotifyPaletteChanged()
|
void PaletteModel::NotifyPaletteChanged()
|
||||||
|
|
|
@ -229,3 +229,25 @@ LRESULT CSelectionWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CSelectionWindow::OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
if (toolsModel.GetActiveTool() == TOOL_TEXT)
|
||||||
|
ForceRefreshSelectionContents();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CSelectionWindow::OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
if (toolsModel.GetActiveTool() == TOOL_FREESEL ||
|
||||||
|
toolsModel.GetActiveTool() == TOOL_RECTSEL ||
|
||||||
|
toolsModel.GetActiveTool() == TOOL_TEXT)
|
||||||
|
ForceRefreshSelectionContents();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CSelectionWindow::OnSelectionModelRefreshNeeded(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
ForceRefreshSelectionContents();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,9 @@ public:
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||||
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
||||||
|
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
|
||||||
|
MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged)
|
||||||
|
MESSAGE_HANDLER(WM_SELECTIONMODELREFRESHNEEDED, OnSelectionModelRefreshNeeded)
|
||||||
END_MSG_MAP()
|
END_MSG_MAP()
|
||||||
|
|
||||||
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
@ -30,6 +33,9 @@ public:
|
||||||
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnSelectionModelRefreshNeeded(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const LPCTSTR m_lpszCursorLUT[9];
|
static const LPCTSTR m_lpszCursorLUT[9];
|
||||||
|
|
|
@ -183,6 +183,7 @@ void SelectionModel::FlipHorizontally()
|
||||||
SelectObject(m_hDC, m_hBm);
|
SelectObject(m_hDC, m_hBm);
|
||||||
StretchBlt(m_hDC, RECT_WIDTH(m_rcDest) - 1, 0, -RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), m_hDC,
|
StretchBlt(m_hDC, RECT_WIDTH(m_rcDest) - 1, 0, -RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), m_hDC,
|
||||||
0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY);
|
0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY);
|
||||||
|
NotifyRefreshNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionModel::FlipVertically()
|
void SelectionModel::FlipVertically()
|
||||||
|
@ -193,6 +194,7 @@ void SelectionModel::FlipVertically()
|
||||||
SelectObject(m_hDC, m_hBm);
|
SelectObject(m_hDC, m_hBm);
|
||||||
StretchBlt(m_hDC, 0, RECT_HEIGHT(m_rcDest) - 1, RECT_WIDTH(m_rcDest), -RECT_HEIGHT(m_rcDest), m_hDC,
|
StretchBlt(m_hDC, 0, RECT_HEIGHT(m_rcDest) - 1, RECT_WIDTH(m_rcDest), -RECT_HEIGHT(m_rcDest), m_hDC,
|
||||||
0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY);
|
0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY);
|
||||||
|
NotifyRefreshNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionModel::RotateNTimes90Degrees(int iN)
|
void SelectionModel::RotateNTimes90Degrees(int iN)
|
||||||
|
@ -206,6 +208,7 @@ void SelectionModel::RotateNTimes90Degrees(int iN)
|
||||||
StretchBlt(m_hDC, RECT_WIDTH(m_rcDest) - 1, RECT_HEIGHT(m_rcDest) - 1, -RECT_WIDTH(m_rcDest), -RECT_HEIGHT(m_rcDest), m_hDC,
|
StretchBlt(m_hDC, RECT_WIDTH(m_rcDest) - 1, RECT_HEIGHT(m_rcDest) - 1, -RECT_WIDTH(m_rcDest), -RECT_HEIGHT(m_rcDest), m_hDC,
|
||||||
0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY);
|
0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY);
|
||||||
}
|
}
|
||||||
|
NotifyRefreshNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
HBITMAP SelectionModel::GetBitmap()
|
HBITMAP SelectionModel::GetBitmap()
|
||||||
|
@ -326,3 +329,8 @@ void SelectionModel::DrawTextToolText(HDC hDCImage, COLORREF crFg, COLORREF crBg
|
||||||
{
|
{
|
||||||
Text(hDCImage, m_rcDest.left, m_rcDest.top, m_rcDest.right, m_rcDest.bottom, crFg, crBg, textToolText, hfontTextFont, bBgTransparent);
|
Text(hDCImage, m_rcDest.left, m_rcDest.top, m_rcDest.right, m_rcDest.bottom, crFg, crBg, textToolText, hfontTextFont, bBgTransparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectionModel::NotifyRefreshNeeded()
|
||||||
|
{
|
||||||
|
selectionWindow.SendMessage(WM_SELECTIONMODELREFRESHNEEDED);
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ private:
|
||||||
|
|
||||||
// void NotifySelectionChanging();
|
// void NotifySelectionChanging();
|
||||||
// void NotifySelectionChanged();
|
// void NotifySelectionChanged();
|
||||||
|
void NotifyRefreshNeeded();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SelectionModel();
|
SelectionModel();
|
||||||
|
|
|
@ -188,11 +188,7 @@ LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lPar
|
||||||
case TOOL_RECTSEL:
|
case TOOL_RECTSEL:
|
||||||
case TOOL_TEXT:
|
case TOOL_TEXT:
|
||||||
if ((y > 1) && (y < 64))
|
if ((y > 1) && (y < 64))
|
||||||
{
|
|
||||||
toolsModel.SetBackgroundTransparent((y - 2) / 31);
|
toolsModel.SetBackgroundTransparent((y - 2) / 31);
|
||||||
|
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TOOL_RUBBER:
|
case TOOL_RUBBER:
|
||||||
if ((y > 1) && (y < 62))
|
if ((y > 1) && (y < 62))
|
||||||
|
|
|
@ -122,6 +122,7 @@ void ToolsModel::NotifyToolChanged()
|
||||||
void ToolsModel::NotifyToolSettingsChanged()
|
void ToolsModel::NotifyToolSettingsChanged()
|
||||||
{
|
{
|
||||||
toolSettingsWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
|
toolSettingsWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
|
||||||
|
selectionWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolsModel::NotifyZoomChanged()
|
void ToolsModel::NotifyZoomChanged()
|
||||||
|
|
|
@ -448,10 +448,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
{
|
{
|
||||||
case 1: /* flip horizontally */
|
case 1: /* flip horizontally */
|
||||||
if (selectionWindow.IsWindowVisible())
|
if (selectionWindow.IsWindowVisible())
|
||||||
{
|
|
||||||
selectionModel.FlipHorizontally();
|
selectionModel.FlipHorizontally();
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
imageModel.CopyPrevious();
|
imageModel.CopyPrevious();
|
||||||
|
@ -462,10 +459,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
break;
|
break;
|
||||||
case 2: /* flip vertically */
|
case 2: /* flip vertically */
|
||||||
if (selectionWindow.IsWindowVisible())
|
if (selectionWindow.IsWindowVisible())
|
||||||
{
|
|
||||||
selectionModel.FlipVertically();
|
selectionModel.FlipVertically();
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
imageModel.CopyPrevious();
|
imageModel.CopyPrevious();
|
||||||
|
@ -478,10 +472,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
break;
|
break;
|
||||||
case 4: /* rotate 180 degrees */
|
case 4: /* rotate 180 degrees */
|
||||||
if (selectionWindow.IsWindowVisible())
|
if (selectionWindow.IsWindowVisible())
|
||||||
{
|
|
||||||
selectionModel.RotateNTimes90Degrees(2);
|
selectionModel.RotateNTimes90Degrees(2);
|
||||||
ForceRefreshSelectionContents();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
imageModel.CopyPrevious();
|
imageModel.CopyPrevious();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue