mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 17:45:06 +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_IMAGEMODELDIMENSIONSCHANGED (WM_APP + 5)
|
||||
#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)
|
||||
{
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
{
|
||||
paletteModel.SetFgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
||||
if (toolsModel.GetActiveTool() == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CPaletteWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
{
|
||||
paletteModel.SetBgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
||||
if (toolsModel.GetActiveTool() == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
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,
|
||||
choosecolor.rgbResult);
|
||||
paletteModel.SetFgColor(choosecolor.rgbResult);
|
||||
if (toolsModel.GetActiveTool() == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
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,
|
||||
choosecolor.rgbResult);
|
||||
paletteModel.SetBgColor(choosecolor.rgbResult);
|
||||
if (toolsModel.GetActiveTool() == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ void PaletteModel::SetBgColor(int newColor)
|
|||
void PaletteModel::NotifyColorChanged()
|
||||
{
|
||||
paletteWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
|
||||
selectionWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
|
||||
}
|
||||
|
||||
void PaletteModel::NotifyPaletteChanged()
|
||||
|
|
|
@ -229,3 +229,25 @@ LRESULT CSelectionWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
|||
}
|
||||
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_MOUSEMOVE, OnMouseMove)
|
||||
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
||||
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
|
||||
MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged)
|
||||
MESSAGE_HANDLER(WM_SELECTIONMODELREFRESHNEEDED, OnSelectionModelRefreshNeeded)
|
||||
END_MSG_MAP()
|
||||
|
||||
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 OnMouseMove(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:
|
||||
static const LPCTSTR m_lpszCursorLUT[9];
|
||||
|
|
|
@ -183,6 +183,7 @@ void SelectionModel::FlipHorizontally()
|
|||
SelectObject(m_hDC, m_hBm);
|
||||
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);
|
||||
NotifyRefreshNeeded();
|
||||
}
|
||||
|
||||
void SelectionModel::FlipVertically()
|
||||
|
@ -193,6 +194,7 @@ void SelectionModel::FlipVertically()
|
|||
SelectObject(m_hDC, m_hBm);
|
||||
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);
|
||||
NotifyRefreshNeeded();
|
||||
}
|
||||
|
||||
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,
|
||||
0, 0, RECT_WIDTH(m_rcDest), RECT_HEIGHT(m_rcDest), SRCCOPY);
|
||||
}
|
||||
NotifyRefreshNeeded();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void SelectionModel::NotifyRefreshNeeded()
|
||||
{
|
||||
selectionWindow.SendMessage(WM_SELECTIONMODELREFRESHNEEDED);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ private:
|
|||
|
||||
// void NotifySelectionChanging();
|
||||
// void NotifySelectionChanged();
|
||||
void NotifyRefreshNeeded();
|
||||
|
||||
public:
|
||||
SelectionModel();
|
||||
|
|
|
@ -188,11 +188,7 @@ LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lPar
|
|||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
if ((y > 1) && (y < 64))
|
||||
{
|
||||
toolsModel.SetBackgroundTransparent((y - 2) / 31);
|
||||
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
case TOOL_RUBBER:
|
||||
if ((y > 1) && (y < 62))
|
||||
|
|
|
@ -122,6 +122,7 @@ void ToolsModel::NotifyToolChanged()
|
|||
void ToolsModel::NotifyToolSettingsChanged()
|
||||
{
|
||||
toolSettingsWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
|
||||
selectionWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
|
||||
}
|
||||
|
||||
void ToolsModel::NotifyZoomChanged()
|
||||
|
|
|
@ -448,10 +448,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
{
|
||||
case 1: /* flip horizontally */
|
||||
if (selectionWindow.IsWindowVisible())
|
||||
{
|
||||
selectionModel.FlipHorizontally();
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
else
|
||||
{
|
||||
imageModel.CopyPrevious();
|
||||
|
@ -462,10 +459,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
break;
|
||||
case 2: /* flip vertically */
|
||||
if (selectionWindow.IsWindowVisible())
|
||||
{
|
||||
selectionModel.FlipVertically();
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
else
|
||||
{
|
||||
imageModel.CopyPrevious();
|
||||
|
@ -478,10 +472,7 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
|||
break;
|
||||
case 4: /* rotate 180 degrees */
|
||||
if (selectionWindow.IsWindowVisible())
|
||||
{
|
||||
selectionModel.RotateNTimes90Degrees(2);
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
else
|
||||
{
|
||||
imageModel.CopyPrevious();
|
||||
|
|
Loading…
Reference in a new issue