Author: bfreisen
Date: Thu Jul 9 18:48:42 2015
New Revision: 68383
URL:
http://svn.reactos.org/svn/reactos?rev=68383&view=rev
Log:
[MSPAINT_NEW] use the same hard-coded observer pattern for the SelectionModel (WIP)
Modified:
trunk/reactos/base/applications/mspaint_new/definitions.h
trunk/reactos/base/applications/mspaint_new/palette.cpp
trunk/reactos/base/applications/mspaint_new/palettemodel.cpp
trunk/reactos/base/applications/mspaint_new/selection.cpp
trunk/reactos/base/applications/mspaint_new/selection.h
trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp
trunk/reactos/base/applications/mspaint_new/selectionmodel.h
trunk/reactos/base/applications/mspaint_new/toolsettings.cpp
trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp
trunk/reactos/base/applications/mspaint_new/winproc.cpp
Modified: trunk/reactos/base/applications/mspaint_new/definitions.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/definitions.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/definitions.h [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -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)
Modified: trunk/reactos/base/applications/mspaint_new/palette.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/palette.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/palette.cpp [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -61,22 +61,14 @@
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 @@
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 @@
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;
}
Modified: trunk/reactos/base/applications/mspaint_new/palettemodel.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/palettemodel.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/palettemodel.cpp [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -90,6 +90,7 @@
void PaletteModel::NotifyColorChanged()
{
paletteWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
+ selectionWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
}
void PaletteModel::NotifyPaletteChanged()
Modified: trunk/reactos/base/applications/mspaint_new/selection.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/selection.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/selection.cpp [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -229,3 +229,25 @@
}
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;
+}
Modified: trunk/reactos/base/applications/mspaint_new/selection.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/selection.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/selection.h [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -20,6 +20,9 @@
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 @@
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];
Modified: trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp [iso-8859-1]
(original)
+++ trunk/reactos/base/applications/mspaint_new/selectionmodel.cpp [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -183,6 +183,7 @@
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 @@
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 @@
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 @@
{
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);
+}
Modified: trunk/reactos/base/applications/mspaint_new/selectionmodel.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/selectionmodel.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/selectionmodel.h [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -33,6 +33,7 @@
// void NotifySelectionChanging();
// void NotifySelectionChanged();
+ void NotifyRefreshNeeded();
public:
SelectionModel();
Modified: trunk/reactos/base/applications/mspaint_new/toolsettings.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/toolsettings.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/toolsettings.cpp [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -188,11 +188,7 @@
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))
Modified: trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -122,6 +122,7 @@
void ToolsModel::NotifyToolSettingsChanged()
{
toolSettingsWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
+ selectionWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
}
void ToolsModel::NotifyZoomChanged()
Modified: trunk/reactos/base/applications/mspaint_new/winproc.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/winproc.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/winproc.cpp [iso-8859-1] Thu Jul 9
18:48:42 2015
@@ -448,10 +448,7 @@
{
case 1: /* flip horizontally */
if (selectionWindow.IsWindowVisible())
- {
selectionModel.FlipHorizontally();
- ForceRefreshSelectionContents();
- }
else
{
imageModel.CopyPrevious();
@@ -462,10 +459,7 @@
break;
case 2: /* flip vertically */
if (selectionWindow.IsWindowVisible())
- {
selectionModel.FlipVertically();
- ForceRefreshSelectionContents();
- }
else
{
imageModel.CopyPrevious();
@@ -478,10 +472,7 @@
break;
case 4: /* rotate 180 degrees */
if (selectionWindow.IsWindowVisible())
- {
selectionModel.RotateNTimes90Degrees(2);
- ForceRefreshSelectionContents();
- }
else
{
imageModel.CopyPrevious();