Author: bfreisen
Date: Tue Jul 7 11:15:24 2015
New Revision: 68368
URL:
http://svn.reactos.org/svn/reactos?rev=68368&view=rev
Log:
[MSPAINT_NEW] manage palette and tools data in a PaletteModel and ToolsModel class,
respectively; fix tiny bug in mouse.cpp (third batch of git commits)
Added:
trunk/reactos/base/applications/mspaint_new/palettemodel.cpp (with props)
trunk/reactos/base/applications/mspaint_new/palettemodel.h (with props)
trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp (with props)
trunk/reactos/base/applications/mspaint_new/toolsmodel.h (with props)
Modified:
trunk/reactos/base/applications/mspaint_new/CMakeLists.txt
trunk/reactos/base/applications/mspaint_new/globalvar.h
trunk/reactos/base/applications/mspaint_new/history.cpp
trunk/reactos/base/applications/mspaint_new/imgarea.cpp
trunk/reactos/base/applications/mspaint_new/main.cpp
trunk/reactos/base/applications/mspaint_new/mouse.cpp
trunk/reactos/base/applications/mspaint_new/palette.cpp
trunk/reactos/base/applications/mspaint_new/precomp.h
trunk/reactos/base/applications/mspaint_new/scrollbox.cpp
trunk/reactos/base/applications/mspaint_new/selection.cpp
trunk/reactos/base/applications/mspaint_new/sizebox.cpp
trunk/reactos/base/applications/mspaint_new/toolsettings.cpp
trunk/reactos/base/applications/mspaint_new/winproc.cpp
Modified: trunk/reactos/base/applications/mspaint_new/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/CMakeLists.txt [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -14,12 +14,14 @@
miniature.cpp
mouse.cpp
palette.cpp
+ palettemodel.cpp
registry.cpp
scrollbox.cpp
selection.cpp
sizebox.cpp
textedit.cpp
toolsettings.cpp
+ toolsmodel.cpp
winproc.cpp
precomp.h)
Modified: trunk/reactos/base/applications/mspaint_new/globalvar.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/globalvar.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/globalvar.h [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -40,14 +40,10 @@
extern POINT start;
extern POINT last;
-extern int lineWidth;
-extern int shapeStyle;
-extern int brushStyle;
-extern int activeTool;
-extern int airBrushWidth;
-extern int rubberRadius;
-extern int transpBg;
-extern int zoom;
+
+class ToolsModel;
+extern ToolsModel toolsModel;
+
extern RECT rectSel_src;
extern RECT rectSel_dest;
extern HBITMAP hSelBm;
@@ -58,13 +54,8 @@
extern LPTSTR textToolText;
extern int textToolTextMaxLen;
-extern int palColors[28];
-extern int modernPalColors[28];
-extern int oldPalColors[28];
-extern int selectedPalette;
-
-extern int fgColor;
-extern int bgColor;
+class PaletteModel;
+extern PaletteModel paletteModel;
extern HWND hStatusBar;
extern HWND hTrackbarZoom;
Modified: trunk/reactos/base/applications/mspaint_new/history.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/history.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/history.cpp [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -119,8 +119,8 @@
hdc = CreateCompatibleDC(hDrawingDC);
SelectObject(hdc, hBms[currInd]);
- oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, bgColor));
- oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(bgColor));
+ oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1,
paletteModel.GetBgColor()));
+ oldBrush = (HBRUSH) SelectObject(hdc, CreateSolidBrush(paletteModel.GetBgColor()));
Rectangle(hdc, 0, 0, width, height);
BitBlt(hdc, -xOffset, -yOffset, imgXRes, imgYRes, hDrawingDC, 0, 0, SRCCOPY);
DeleteObject(SelectObject(hdc, oldBrush));
Modified: trunk/reactos/base/applications/mspaint_new/imgarea.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/imgarea.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/imgarea.cpp [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -55,26 +55,26 @@
0,
0, 3, 3, TRUE);
sizeboxCenterTop.MoveWindow(
- imgXRes * zoom / 2000 + 3 * 3 / 4,
+ imgXRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4,
0, 3, 3, TRUE);
sizeboxRightTop.MoveWindow(
- imgXRes * zoom / 1000 + 3,
+ imgXRes * toolsModel.GetZoom() / 1000 + 3,
0, 3, 3, TRUE);
sizeboxLeftCenter.MoveWindow(
0,
- imgYRes * zoom / 2000 + 3 * 3 / 4, 3, 3, TRUE);
+ imgYRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4, 3, 3, TRUE);
sizeboxRightCenter.MoveWindow(
- imgXRes * zoom / 1000 + 3,
- imgYRes * zoom / 2000 + 3 * 3 / 4, 3, 3, TRUE);
+ imgXRes * toolsModel.GetZoom() / 1000 + 3,
+ imgYRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4, 3, 3, TRUE);
sizeboxLeftBottom.MoveWindow(
0,
- imgYRes * zoom / 1000 + 3, 3, 3, TRUE);
+ imgYRes * toolsModel.GetZoom() / 1000 + 3, 3, 3, TRUE);
sizeboxCenterBottom.MoveWindow(
- imgXRes * zoom / 2000 + 3 * 3 / 4,
- imgYRes * zoom / 1000 + 3, 3, 3, TRUE);
+ imgXRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4,
+ imgYRes * toolsModel.GetZoom() / 1000 + 3, 3, 3, TRUE);
sizeboxRightBottom.MoveWindow(
- imgXRes * zoom / 1000 + 3,
- imgYRes * zoom / 1000 + 3, 3, 3, TRUE);
+ imgXRes * toolsModel.GetZoom() / 1000 + 3,
+ imgYRes * toolsModel.GetZoom() / 1000 + 3, 3, 3, TRUE);
UpdateScrollbox();
return 0;
}
@@ -83,21 +83,21 @@
{
DefWindowProc(WM_PAINT, wParam, lParam);
HDC hdc = imageArea.GetDC();
- StretchBlt(hdc, 0, 0, imgXRes * zoom / 1000, imgYRes * zoom / 1000, hDrawingDC, 0, 0,
imgXRes,
+ StretchBlt(hdc, 0, 0, imgXRes * toolsModel.GetZoom() / 1000, imgYRes *
toolsModel.GetZoom() / 1000, hDrawingDC, 0, 0, imgXRes,
imgYRes, SRCCOPY);
- if (showGrid && (zoom >= 4000))
+ if (showGrid && (toolsModel.GetZoom() >= 4000))
{
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00a0a0a0));
int 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 * toolsModel.GetZoom() / 1000, NULL);
+ LineTo(hdc, imgXRes * toolsModel.GetZoom() / 1000, counter *
toolsModel.GetZoom() / 1000);
}
for(counter = 0; counter <= imgXRes; counter++)
{
- MoveToEx(hdc, counter * zoom / 1000, 0, NULL);
- LineTo(hdc, counter * zoom / 1000, imgYRes * zoom / 1000);
+ MoveToEx(hdc, counter * toolsModel.GetZoom() / 1000, 0, NULL);
+ LineTo(hdc, counter * toolsModel.GetZoom() / 1000, imgYRes *
toolsModel.GetZoom() / 1000);
}
DeleteObject(SelectObject(hdc, oldPen));
}
@@ -109,7 +109,7 @@
LRESULT CImgAreaWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_FILL:
SetCursor(hCurFill);
@@ -134,12 +134,12 @@
LRESULT CImgAreaWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- if ((!drawing) || (activeTool == TOOL_COLOR))
+ if ((!drawing) || (toolsModel.GetActiveTool() == TOOL_COLOR))
{
SetCapture();
drawing = TRUE;
- startPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom,
GET_Y_LPARAM(lParam) * 1000 / zoom,
- fgColor, bgColor);
+ startPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
+ paletteModel.GetFgColor(), paletteModel.GetBgColor());
}
else
{
@@ -147,19 +147,19 @@
undo();
}
Invalidate(FALSE);
- if ((activeTool == TOOL_ZOOM) && (zoom < 8000))
- zoomTo(zoom * 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+ if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() <
8000))
+ zoomTo(toolsModel.GetZoom() * 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return 0;
}
LRESULT CImgAreaWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- if ((!drawing) || (activeTool == TOOL_COLOR))
+ if ((!drawing) || (toolsModel.GetActiveTool() == TOOL_COLOR))
{
SetCapture();
drawing = TRUE;
- startPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom,
GET_Y_LPARAM(lParam) * 1000 / zoom,
- fgColor, bgColor);
+ startPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
+ paletteModel.GetFgColor(), paletteModel.GetBgColor());
}
else
{
@@ -167,8 +167,8 @@
undo();
}
Invalidate(FALSE);
- if ((activeTool == TOOL_ZOOM) && (zoom > 125))
- zoomTo(zoom / 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+ if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() >
125))
+ zoomTo(toolsModel.GetZoom() / 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return 0;
}
@@ -178,15 +178,15 @@
{
ReleaseCapture();
drawing = FALSE;
- endPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam)
* 1000 / zoom, fgColor,
- bgColor);
+ endPaintingL(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), paletteModel.GetFgColor(),
+ paletteModel.GetBgColor());
Invalidate(FALSE);
- if (activeTool == TOOL_COLOR)
+ if (toolsModel.GetActiveTool() == TOOL_COLOR)
{
COLORREF tempColor =
- GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom,
GET_Y_LPARAM(lParam) * 1000 / zoom);
+ GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
if (tempColor != CLR_INVALID)
- fgColor = tempColor;
+ paletteModel.SetFgColor(tempColor);
paletteWindow.Invalidate(FALSE);
}
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
@@ -200,15 +200,15 @@
{
ReleaseCapture();
drawing = FALSE;
- endPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom, GET_Y_LPARAM(lParam)
* 1000 / zoom, fgColor,
- bgColor);
+ endPaintingR(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), paletteModel.GetFgColor(),
+ paletteModel.GetBgColor());
Invalidate(FALSE);
- if (activeTool == TOOL_COLOR)
+ if (toolsModel.GetActiveTool() == TOOL_COLOR)
{
COLORREF tempColor =
- GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / zoom,
GET_Y_LPARAM(lParam) * 1000 / zoom);
+ GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
if (tempColor != CLR_INVALID)
- bgColor = tempColor;
+ paletteModel.SetBgColor(tempColor);
paletteWindow.Invalidate(FALSE);
}
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
@@ -218,13 +218,13 @@
LRESULT CImgAreaWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- LONG xNow = GET_X_LPARAM(lParam) * 1000 / zoom;
- LONG yNow = GET_Y_LPARAM(lParam) * 1000 / zoom;
- if ((!drawing) || (activeTool <= TOOL_AIRBRUSH))
+ LONG xNow = GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom();
+ LONG yNow = GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom();
+ if ((!drawing) || (toolsModel.GetActiveTool() <= TOOL_AIRBRUSH))
{
TRACKMOUSEEVENT tme;
- if (activeTool == TOOL_ZOOM)
+ if (toolsModel.GetActiveTool() == TOOL_ZOOM)
{
Invalidate(FALSE);
UpdateWindow();
@@ -250,7 +250,7 @@
LONG xRel = xNow - start.x;
LONG yRel = yNow - start.y;
/* freesel, rectsel and text tools always show numbers limited to fit into image
area */
- if ((activeTool == TOOL_FREESEL) || (activeTool == TOOL_RECTSEL) || (activeTool
== TOOL_TEXT))
+ if ((toolsModel.GetActiveTool() == TOOL_FREESEL) || (toolsModel.GetActiveTool()
== TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_TEXT))
{
if (xRel < 0)
xRel = (xNow < 0) ? -start.x : xRel;
@@ -262,7 +262,7 @@
yRel = imgYRes-start.y;
}
/* rectsel and shape tools always show non-negative numbers when drawing */
- if ((activeTool == TOOL_RECTSEL) || (activeTool == TOOL_SHAPE))
+ if ((toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool()
== TOOL_SHAPE))
{
if (xRel < 0)
xRel = -xRel;
@@ -270,7 +270,7 @@
yRel = -yRel;
}
/* while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14 */
- switch(activeTool)
+ switch(toolsModel.GetActiveTool())
{
case TOOL_RUBBER:
case TOOL_PEN:
@@ -286,12 +286,12 @@
}
if ((wParam & MK_LBUTTON) != 0)
{
- whilePaintingL(hDrawingDC, xNow, yNow, fgColor, bgColor);
+ whilePaintingL(hDrawingDC, xNow, yNow, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
- if ((activeTool >= TOOL_TEXT) || (activeTool == TOOL_RECTSEL) ||
(activeTool == TOOL_FREESEL))
+ if ((toolsModel.GetActiveTool() >= TOOL_TEXT) ||
(toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() ==
TOOL_FREESEL))
{
TCHAR sizeStr[100];
- if ((activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT)
< 0))
+ if ((toolsModel.GetActiveTool() >= TOOL_LINE) &&
(GetAsyncKeyState(VK_SHIFT) < 0))
yRel = xRel;
_stprintf(sizeStr, _T("%ld x %ld"), xRel, yRel);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
@@ -299,12 +299,12 @@
}
if ((wParam & MK_RBUTTON) != 0)
{
- whilePaintingR(hDrawingDC, xNow, yNow, fgColor, bgColor);
+ whilePaintingR(hDrawingDC, xNow, yNow, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
Invalidate(FALSE);
- if (activeTool >= TOOL_TEXT)
+ if (toolsModel.GetActiveTool() >= TOOL_TEXT)
{
TCHAR sizeStr[100];
- if ((activeTool >= TOOL_LINE) && (GetAsyncKeyState(VK_SHIFT)
< 0))
+ if ((toolsModel.GetActiveTool() >= TOOL_LINE) &&
(GetAsyncKeyState(VK_SHIFT) < 0))
yRel = xRel;
_stprintf(sizeStr, _T("%ld x %ld"), xRel, yRel);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
@@ -317,7 +317,7 @@
LRESULT CImgAreaWindow::OnMouseLeave(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) _T(""));
- if (activeTool == TOOL_ZOOM)
+ if (toolsModel.GetActiveTool() == TOOL_ZOOM)
imageArea.Invalidate(FALSE);
return 0;
}
Modified: trunk/reactos/base/applications/mspaint_new/main.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/main.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/main.cpp [iso-8859-1] Tue Jul 7 11:15:24
2015
@@ -32,14 +32,9 @@
POINT start;
POINT last;
-int lineWidth = 1;
-int shapeStyle = 0;
-int brushStyle = 0;
-int activeTool = TOOL_PEN;
-int airBrushWidth = 5;
-int rubberRadius = 4;
-int transpBg = 0;
-int zoom = 1000;
+
+ToolsModel toolsModel;
+
RECT rectSel_src;
RECT rectSel_dest;
HBITMAP hSelBm;
@@ -50,29 +45,7 @@
LPTSTR textToolText = NULL;
int textToolTextMaxLen = 0;
-/* array holding palette colors; may be changed by the user during execution */
-int palColors[28];
-
-/* modern palette */
-int modernPalColors[28] = { 0x000000, 0x464646, 0x787878, 0x300099, 0x241ced, 0x0078ff,
0x0ec2ff,
- 0x00f2ff, 0x1de6a8, 0x4cb122, 0xefb700, 0xf36d4d, 0x99362f, 0x98316f,
- 0xffffff, 0xdcdcdc, 0xb4b4b4, 0x3c5a9c, 0xb1a3ff, 0x7aaae5, 0x9ce4f5,
- 0xbdf9ff, 0xbcf9d3, 0x61bb9d, 0xead999, 0xd19a70, 0x8e6d54, 0xd5a5b5
-};
-
-/* older palette containing VGA colors */
-int oldPalColors[28] = { 0x000000, 0x808080, 0x000080, 0x008080, 0x008000, 0x808000,
0x800000,
- 0x800080, 0x408080, 0x404000, 0xff8000, 0x804000, 0xff0040, 0x004080,
- 0xffffff, 0xc0c0c0, 0x0000ff, 0x00ffff, 0x00ff00, 0xffff00, 0xff0000,
- 0xff00ff, 0x80ffff, 0x80ff00, 0xffff80, 0xff8080, 0x8000ff, 0x4080ff
-};
-
-/* palette currently in use (1: modern, 2: old) */
-int selectedPalette;
-
-/* foreground and background colors with initial value */
-int fgColor = 0x00000000;
-int bgColor = 0x00ffffff;
+PaletteModel paletteModel;
HWND hStatusBar;
HWND hTrackbarZoom;
@@ -170,10 +143,6 @@
lstrcpy(lfTextFont.lfFaceName, _T(""));
hfontTextFont = CreateFontIndirect(&lfTextFont);
- /* init palette */
- selectedPalette = 1;
- CopyMemory(palColors, modernPalColors, sizeof(palColors));
-
hProgInstance = hThisInstance;
/* initialize common controls library */
@@ -293,8 +262,8 @@
hDrawingDC = CreateCompatibleDC(hDC);
hSelDC = CreateCompatibleDC(hDC);
imageArea.ReleaseDC(hDC);
- SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, fgColor));
- SelectObject(hDrawingDC, CreateSolidBrush(bgColor));
+ SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, paletteModel.GetFgColor()));
+ SelectObject(hDrawingDC, CreateSolidBrush(paletteModel.GetBgColor()));
hBms[0] = CreateDIBWithProperties(imgXRes, imgYRes);
SelectObject(hDrawingDC, hBms[0]);
Modified: trunk/reactos/base/applications/mspaint_new/mouse.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/mouse.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/mouse.cpp [iso-8859-1] Tue Jul 7 11:15:24
2015
@@ -15,8 +15,8 @@
void
placeSelWin()
{
- selectionWindow.MoveWindow(rectSel_dest.left * zoom / 1000, rectSel_dest.top * zoom /
1000,
- RECT_WIDTH(rectSel_dest) * zoom / 1000 + 6, RECT_HEIGHT(rectSel_dest) * zoom /
1000 + 6, TRUE);
+ selectionWindow.MoveWindow(rectSel_dest.left * toolsModel.GetZoom() / 1000,
rectSel_dest.top * toolsModel.GetZoom() / 1000,
+ RECT_WIDTH(rectSel_dest) * toolsModel.GetZoom() / 1000 + 6,
RECT_HEIGHT(rectSel_dest) * toolsModel.GetZoom() / 1000 + 6, TRUE);
selectionWindow.BringWindowToTop();
imageArea.InvalidateRect(NULL, FALSE);
}
@@ -61,7 +61,7 @@
start.y = y;
last.x = x;
last.y = y;
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_FREESEL:
selectionWindow.ShowWindow(SW_HIDE);
@@ -87,7 +87,7 @@
break;
case TOOL_RUBBER:
newReversible();
- Erase(hdc, x, y, x, y, bg, rubberRadius);
+ Erase(hdc, x, y, x, y, bg, toolsModel.GetRubberRadius());
break;
case TOOL_FILL:
newReversible();
@@ -99,11 +99,11 @@
break;
case TOOL_BRUSH:
newReversible();
- Brush(hdc, x, y, x, y, fg, brushStyle);
+ Brush(hdc, x, y, x, y, fg, toolsModel.GetBrushStyle());
break;
case TOOL_AIRBRUSH:
newReversible();
- Airbrush(hdc, x, y, fg, airBrushWidth);
+ Airbrush(hdc, x, y, fg, toolsModel.GetAirBrushWidth());
break;
case TOOL_BEZIER:
pointStack[pointSP].x = x;
@@ -118,7 +118,7 @@
pointStack[pointSP].x = x;
pointStack[pointSP].y = y;
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), FALSE, FALSE);
if (pointSP == 0)
{
newReversible();
@@ -131,7 +131,7 @@
void
whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_FREESEL:
if (ptSP == 0)
@@ -159,22 +159,22 @@
break;
}
case TOOL_RUBBER:
- Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
+ Erase(hdc, last.x, last.y, x, y, bg, toolsModel.GetRubberRadius());
break;
case TOOL_PEN:
Line(hdc, last.x, last.y, x, y, fg, 1);
break;
case TOOL_BRUSH:
- Brush(hdc, last.x, last.y, x, y, fg, brushStyle);
+ Brush(hdc, last.x, last.y, x, y, fg, toolsModel.GetBrushStyle());
break;
case TOOL_AIRBRUSH:
- Airbrush(hdc, x, y, fg, airBrushWidth);
+ Airbrush(hdc, x, y, fg, toolsModel.GetAirBrushWidth());
break;
case TOOL_LINE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
roundTo8Directions(start.x, start.y, &x, &y);
- Line(hdc, start.x, start.y, x, y, fg, lineWidth);
+ Line(hdc, start.x, start.y, x, y, fg, toolsModel.GetLineWidth());
break;
case TOOL_BEZIER:
resetToU1();
@@ -184,13 +184,13 @@
{
case 1:
Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x,
pointStack[1].y, fg,
- lineWidth);
+ toolsModel.GetLineWidth());
break;
case 2:
- Bezier(hdc, pointStack[0], pointStack[2], pointStack[2],
pointStack[1], fg, lineWidth);
+ Bezier(hdc, pointStack[0], pointStack[2], pointStack[2],
pointStack[1], fg, toolsModel.GetLineWidth());
break;
case 3:
- Bezier(hdc, pointStack[0], pointStack[2], pointStack[3],
pointStack[1], fg, lineWidth);
+ Bezier(hdc, pointStack[0], pointStack[2], pointStack[3],
pointStack[1], fg, toolsModel.GetLineWidth());
break;
}
break;
@@ -198,7 +198,7 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
+ Rect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_SHAPE:
resetToU1();
@@ -208,19 +208,19 @@
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
&pointStack[pointSP].x,
&pointStack[pointSP].y);
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, fg, bg, lineWidth, shapeStyle, FALSE,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), FALSE, FALSE);
break;
case TOOL_ELLIPSE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
+ Ellp(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
+ RRect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
}
@@ -231,7 +231,7 @@
void
endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_FREESEL:
{
@@ -303,7 +303,7 @@
BitBlt(hSelDC, 0, 0, RECT_WIDTH(rectSel_src), RECT_HEIGHT(rectSel_src),
hDrawingDC, rectSel_src.left,
rectSel_src.top, SRCCOPY);
Rect(hdc, rectSel_src.left, rectSel_src.top, rectSel_src.right,
- rectSel_src.bottom, bgColor, bgColor, 0, TRUE);
+ rectSel_src.bottom, bg, bg, 0, TRUE);
newReversible();
BitBlt(hDrawingDC, rectSel_src.left, rectSel_src.top,
RECT_WIDTH(rectSel_src), RECT_HEIGHT(rectSel_src), hSelDC, 0,
@@ -326,7 +326,7 @@
}
break;
case TOOL_RUBBER:
- Erase(hdc, last.x, last.y, x, y, bg, rubberRadius);
+ Erase(hdc, last.x, last.y, x, y, bg, toolsModel.GetRubberRadius());
break;
case TOOL_PEN:
Line(hdc, last.x, last.y, x, y, fg, 1);
@@ -336,7 +336,7 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
roundTo8Directions(start.x, start.y, &x, &y);
- Line(hdc, start.x, start.y, x, y, fg, lineWidth);
+ Line(hdc, start.x, start.y, x, y, fg, toolsModel.GetLineWidth());
break;
case TOOL_BEZIER:
pointSP++;
@@ -347,7 +347,7 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Rect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
+ Rect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_SHAPE:
resetToU1();
@@ -360,14 +360,14 @@
if (pointSP >= 2)
{
if ((pointStack[0].x - x) * (pointStack[0].x - x) +
- (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth *
lineWidth + 1)
+ (pointStack[0].y - y) * (pointStack[0].y - y) <=
toolsModel.GetLineWidth() * toolsModel.GetLineWidth() + 1)
{
- Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, TRUE,
FALSE);
+ Poly(hdc, pointStack, pointSP, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), TRUE, FALSE);
pointSP = 0;
}
else
{
- Poly(hdc, pointStack, pointSP, fg, bg, lineWidth, shapeStyle, FALSE,
FALSE);
+ Poly(hdc, pointStack, pointSP, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), FALSE, FALSE);
}
}
if (pointSP == 255)
@@ -377,13 +377,13 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Ellp(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
+ Ellp(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- RRect(hdc, start.x, start.y, x, y, fg, bg, lineWidth, shapeStyle);
+ RRect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
}
}
@@ -395,7 +395,7 @@
start.y = y;
last.x = x;
last.y = y;
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_FREESEL:
case TOOL_TEXT:
@@ -407,7 +407,7 @@
break;
case TOOL_RUBBER:
newReversible();
- Replace(hdc, x, y, x, y, fg, bg, rubberRadius);
+ Replace(hdc, x, y, x, y, fg, bg, toolsModel.GetRubberRadius());
break;
case TOOL_FILL:
newReversible();
@@ -419,11 +419,11 @@
break;
case TOOL_BRUSH:
newReversible();
- Brush(hdc, x, y, x, y, bg, brushStyle);
+ Brush(hdc, x, y, x, y, bg, toolsModel.GetBrushStyle());
break;
case TOOL_AIRBRUSH:
newReversible();
- Airbrush(hdc, x, y, bg, airBrushWidth);
+ Airbrush(hdc, x, y, bg, toolsModel.GetAirBrushWidth());
break;
case TOOL_BEZIER:
pointStack[pointSP].x = x;
@@ -438,7 +438,7 @@
pointStack[pointSP].x = x;
pointStack[pointSP].y = y;
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), FALSE, FALSE);
if (pointSP == 0)
{
newReversible();
@@ -451,25 +451,25 @@
void
whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_RUBBER:
- Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
+ Replace(hdc, last.x, last.y, x, y, fg, bg, toolsModel.GetRubberRadius());
break;
case TOOL_PEN:
Line(hdc, last.x, last.y, x, y, bg, 1);
break;
case TOOL_BRUSH:
- Brush(hdc, last.x, last.y, x, y, bg, brushStyle);
+ Brush(hdc, last.x, last.y, x, y, bg, toolsModel.GetBrushStyle());
break;
case TOOL_AIRBRUSH:
- Airbrush(hdc, x, y, bg, airBrushWidth);
+ Airbrush(hdc, x, y, bg, toolsModel.GetAirBrushWidth());
break;
case TOOL_LINE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
roundTo8Directions(start.x, start.y, &x, &y);
- Line(hdc, start.x, start.y, x, y, bg, lineWidth);
+ Line(hdc, start.x, start.y, x, y, bg, toolsModel.GetLineWidth());
break;
case TOOL_BEZIER:
resetToU1();
@@ -479,13 +479,13 @@
{
case 1:
Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x,
pointStack[1].y, bg,
- lineWidth);
+ toolsModel.GetLineWidth());
break;
case 2:
- Bezier(hdc, pointStack[0], pointStack[2], pointStack[2],
pointStack[1], bg, lineWidth);
+ Bezier(hdc, pointStack[0], pointStack[2], pointStack[2],
pointStack[1], bg, toolsModel.GetLineWidth());
break;
case 3:
- Bezier(hdc, pointStack[0], pointStack[2], pointStack[3],
pointStack[1], bg, lineWidth);
+ Bezier(hdc, pointStack[0], pointStack[2], pointStack[3],
pointStack[1], bg, toolsModel.GetLineWidth());
break;
}
break;
@@ -493,7 +493,7 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
+ Rect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_SHAPE:
resetToU1();
@@ -503,19 +503,19 @@
roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y,
&pointStack[pointSP].x,
&pointStack[pointSP].y);
if (pointSP + 1 >= 2)
- Poly(hdc, pointStack, pointSP + 1, bg, fg, lineWidth, shapeStyle, FALSE,
FALSE);
+ Poly(hdc, pointStack, pointSP + 1, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), FALSE, FALSE);
break;
case TOOL_ELLIPSE:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
+ Ellp(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
+ RRect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
}
@@ -526,10 +526,10 @@
void
endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
{
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_RUBBER:
- Replace(hdc, last.x, last.y, x, y, fg, bg, rubberRadius);
+ Replace(hdc, last.x, last.y, x, y, fg, bg, toolsModel.GetRubberRadius());
break;
case TOOL_PEN:
Line(hdc, last.x, last.y, x, y, bg, 1);
@@ -539,7 +539,7 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
roundTo8Directions(start.x, start.y, &x, &y);
- Line(hdc, start.x, start.y, x, y, bg, lineWidth);
+ Line(hdc, start.x, start.y, x, y, bg, toolsModel.GetLineWidth());
break;
case TOOL_BEZIER:
pointSP++;
@@ -550,7 +550,7 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Rect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
+ Rect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_SHAPE:
resetToU1();
@@ -563,14 +563,14 @@
if (pointSP >= 2)
{
if ((pointStack[0].x - x) * (pointStack[0].x - x) +
- (pointStack[0].y - y) * (pointStack[0].y - y) <= lineWidth *
lineWidth + 1)
+ (pointStack[0].y - y) * (pointStack[0].y - y) <=
toolsModel.GetLineWidth() * toolsModel.GetLineWidth() + 1)
{
- Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, TRUE,
FALSE);
+ Poly(hdc, pointStack, pointSP, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), TRUE, FALSE);
pointSP = 0;
}
else
{
- Poly(hdc, pointStack, pointSP, bg, fg, lineWidth, shapeStyle, FALSE,
FALSE);
+ Poly(hdc, pointStack, pointSP, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle(), FALSE, FALSE);
}
}
if (pointSP == 255)
@@ -580,13 +580,13 @@
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- Ellp(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
+ Ellp(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
break;
case TOOL_RRECT:
resetToU1();
if (GetAsyncKeyState(VK_SHIFT) < 0)
regularize(start.x, start.y, &x, &y);
- RRect(hdc, start.x, start.y, x, y, bg, fg, lineWidth, shapeStyle);
- break;
- }
-}
+ RRect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(),
toolsModel.GetShapeStyle());
+ break;
+ }
+}
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] Tue Jul 7
11:15:24 2015
@@ -32,12 +32,12 @@
SetRect(&rc, 11, 12, 26, 27);
DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
- oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(bgColor));
+ oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(paletteModel.GetBgColor()));
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 = (HBRUSH) SelectObject(hDC, CreateSolidBrush(fgColor));
+ oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(paletteModel.GetFgColor()));
Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
DeleteObject(SelectObject(hDC, oldBrush));
DeleteObject(SelectObject(hDC, oldPen));
@@ -49,7 +49,7 @@
DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT);
oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
- oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(palColors[i]));
+ oldBrush = (HBRUSH) SelectObject(hDC,
CreateSolidBrush(paletteModel.GetColor(i)));
Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
DeleteObject(SelectObject(hDC, oldBrush));
DeleteObject(SelectObject(hDC, oldPen));
@@ -62,9 +62,9 @@
{
if (GET_X_LPARAM(lParam) >= 31)
{
- fgColor = palColors[(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));
InvalidateRect(NULL, FALSE);
- if (activeTool == 10)
+ if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
return 0;
@@ -74,9 +74,9 @@
{
if (GET_X_LPARAM(lParam) >= 31)
{
- bgColor = palColors[(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));
InvalidateRect(NULL, FALSE);
- if (activeTool == 10)
+ if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
return 0;
@@ -87,11 +87,11 @@
if (GET_X_LPARAM(lParam) >= 31)
if (ChooseColor(&choosecolor))
{
- palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) *
14] =
- choosecolor.rgbResult;
- fgColor = choosecolor.rgbResult;
+ paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 +
(GET_Y_LPARAM(lParam) / 16) * 14,
+ choosecolor.rgbResult);
+ paletteModel.SetFgColor(choosecolor.rgbResult);
InvalidateRect(NULL, FALSE);
- if (activeTool == 10)
+ if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
return 0;
@@ -102,11 +102,11 @@
if (GET_X_LPARAM(lParam) >= 31)
if (ChooseColor(&choosecolor))
{
- palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) *
14] =
- choosecolor.rgbResult;
- bgColor = choosecolor.rgbResult;
+ paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 +
(GET_Y_LPARAM(lParam) / 16) * 14,
+ choosecolor.rgbResult);
+ paletteModel.SetBgColor(choosecolor.rgbResult);
InvalidateRect(NULL, FALSE);
- if (activeTool == 10)
+ if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
return 0;
Added: 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 (added)
+++ trunk/reactos/base/applications/mspaint_new/palettemodel.cpp [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -0,0 +1,82 @@
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: base/applications/mspaint_new/palettemodel.cpp
+ * PURPOSE: Keep track of palette data, notify listeners
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+/* INCLUDES *********************************************************/
+
+#include "precomp.h"
+
+/* FUNCTIONS ********************************************************/
+
+PaletteModel::PaletteModel()
+{
+ m_fgColor = 0x00000000;
+ m_bgColor = 0x00ffffff;
+ SelectPalette(1);
+}
+
+int PaletteModel::SelectedPalette()
+{
+ return m_nSelectedPalette;
+}
+
+void PaletteModel::SelectPalette(int nPalette)
+{
+ int modernColors[28] = {
+ 0x000000, 0x464646, 0x787878, 0x300099, 0x241ced, 0x0078ff, 0x0ec2ff,
+ 0x00f2ff, 0x1de6a8, 0x4cb122, 0xefb700, 0xf36d4d, 0x99362f, 0x98316f,
+ 0xffffff, 0xdcdcdc, 0xb4b4b4, 0x3c5a9c, 0xb1a3ff, 0x7aaae5, 0x9ce4f5,
+ 0xbdf9ff, 0xbcf9d3, 0x61bb9d, 0xead999, 0xd19a70, 0x8e6d54, 0xd5a5b5
+ };
+ int oldColors[28] = {
+ 0x000000, 0x808080, 0x000080, 0x008080, 0x008000, 0x808000, 0x800000,
+ 0x800080, 0x408080, 0x404000, 0xff8000, 0x804000, 0xff0040, 0x004080,
+ 0xffffff, 0xc0c0c0, 0x0000ff, 0x00ffff, 0x00ff00, 0xffff00, 0xff0000,
+ 0xff00ff, 0x80ffff, 0x80ff00, 0xffff80, 0xff8080, 0x8000ff, 0x4080ff
+ };
+ if (nPalette == 1)
+ CopyMemory(m_colors, modernColors, sizeof(m_colors));
+ else if (nPalette == 2)
+ CopyMemory(m_colors, oldColors, sizeof(m_colors));
+ else
+ return;
+ m_nSelectedPalette = nPalette;
+}
+
+int PaletteModel::GetColor(int nIndex)
+{
+ if (nIndex < 28)
+ return m_colors[nIndex];
+ else
+ return 0;
+}
+
+void PaletteModel::SetColor(int nIndex, int newColor)
+{
+ if (nIndex < 28)
+ m_colors[nIndex] = newColor;
+}
+
+int PaletteModel::GetFgColor()
+{
+ return m_fgColor;
+}
+
+void PaletteModel::SetFgColor(int newColor)
+{
+ m_fgColor = newColor;
+}
+
+int PaletteModel::GetBgColor()
+{
+ return m_bgColor;
+}
+
+void PaletteModel::SetBgColor(int newColor)
+{
+ m_bgColor = newColor;
+}
Propchange: trunk/reactos/base/applications/mspaint_new/palettemodel.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/applications/mspaint_new/palettemodel.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/palettemodel.h (added)
+++ trunk/reactos/base/applications/mspaint_new/palettemodel.h [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -0,0 +1,28 @@
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: base/applications/mspaint_new/palettemodel.h
+ * PURPOSE: Keep track of palette data, notify listeners
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+/* CLASSES **********************************************************/
+
+class PaletteModel
+{
+private:
+ int m_colors[28];
+ int m_nSelectedPalette;
+ int m_fgColor;
+ int m_bgColor;
+public:
+ PaletteModel();
+ int SelectedPalette();
+ void SelectPalette(int nPalette);
+ int GetColor(int nIndex);
+ void SetColor(int nIndex, int newColor);
+ int GetFgColor();
+ void SetFgColor(int newColor);
+ int GetBgColor();
+ void SetBgColor(int newColor);
+};
Propchange: trunk/reactos/base/applications/mspaint_new/palettemodel.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/base/applications/mspaint_new/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/precomp.h [iso-8859-1] Tue Jul 7 11:15:24
2015
@@ -27,11 +27,13 @@
#include "miniature.h"
#include "mouse.h"
#include "palette.h"
+#include "palettemodel.h"
#include "scrollbox.h"
#include "selection.h"
#include "sizebox.h"
#include "textedit.h"
#include "toolsettings.h"
+#include "toolsmodel.h"
#include "winproc.h"
#endif /* _MSPAINT_H */
Modified: trunk/reactos/base/applications/mspaint_new/scrollbox.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/scrollbox.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/scrollbox.cpp [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -74,8 +74,8 @@
}
scrollboxWindow.SetScrollInfo(SB_HORZ, &si);
scrlClientWindow.MoveWindow(-scrollboxWindow.GetScrollPos(SB_HORZ),
- -scrollboxWindow.GetScrollPos(SB_VERT), imgXRes * zoom / 1000 + 6,
- imgYRes * zoom / 1000 + 6, TRUE);
+ -scrollboxWindow.GetScrollPos(SB_VERT), imgXRes * toolsModel.GetZoom()
/ 1000 + 6,
+ imgYRes * toolsModel.GetZoom() / 1000 + 6, TRUE);
}
return 0;
}
@@ -109,8 +109,8 @@
}
scrollboxWindow.SetScrollInfo(SB_VERT, &si);
scrlClientWindow.MoveWindow(-scrollboxWindow.GetScrollPos(SB_HORZ),
- -scrollboxWindow.GetScrollPos(SB_VERT), imgXRes * zoom / 1000 + 6,
- imgYRes * zoom / 1000 + 6, TRUE);
+ -scrollboxWindow.GetScrollPos(SB_VERT), imgXRes * toolsModel.GetZoom()
/ 1000 + 6,
+ imgYRes * toolsModel.GetZoom() / 1000 + 6, TRUE);
}
return 0;
}
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] Tue Jul 7
11:15:24 2015
@@ -118,8 +118,8 @@
{
HDC hDC = GetDC();
DefWindowProc(WM_PAINT, wParam, lParam);
- SelectionFrame(hDC, 1, 1, RECT_WIDTH(rectSel_dest) * zoom / 1000 + 5,
- RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 5,
+ SelectionFrame(hDC, 1, 1, RECT_WIDTH(rectSel_dest) * toolsModel.GetZoom() / 1000
+ 5,
+ RECT_HEIGHT(rectSel_dest) * toolsModel.GetZoom() / 1000 + 5,
system_selection_color);
ReleaseDC(hDC);
}
@@ -178,17 +178,17 @@
resetToU1();
frac.x += GET_X_LPARAM(lParam) - pos.x;
frac.y += GET_Y_LPARAM(lParam) - pos.y;
- delta.x += frac.x * 1000 / zoom;
- delta.y += frac.y * 1000 / zoom;
- if (zoom < 1000)
+ delta.x += frac.x * 1000 / toolsModel.GetZoom();
+ delta.y += frac.y * 1000 / toolsModel.GetZoom();
+ if (toolsModel.GetZoom() < 1000)
{
frac.x = 0;
frac.y = 0;
}
else
{
- frac.x -= (frac.x * 1000 / zoom) * zoom / 1000;
- frac.y -= (frac.y * 1000 / zoom) * zoom / 1000;
+ frac.x -= (frac.x * 1000 / toolsModel.GetZoom()) * toolsModel.GetZoom() /
1000;
+ frac.y -= (frac.y * 1000 / toolsModel.GetZoom()) * toolsModel.GetZoom() /
1000;
}
switch (action)
{
@@ -248,22 +248,22 @@
_stprintf(sizeStr, _T("%d x %d"), RECT_WIDTH(rectSel_dest),
RECT_HEIGHT(rectSel_dest));
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
- if (activeTool == TOOL_TEXT)
- {
- Text(hDrawingDC, rectSel_dest.left, rectSel_dest.top, rectSel_dest.right,
rectSel_dest.bottom, fgColor, bgColor, textToolText, hfontTextFont, transpBg);
+ if (toolsModel.GetActiveTool() == TOOL_TEXT)
+ {
+ Text(hDrawingDC, rectSel_dest.left, rectSel_dest.top, rectSel_dest.right,
rectSel_dest.bottom, paletteModel.GetFgColor(), paletteModel.GetBgColor(), textToolText,
hfontTextFont, toolsModel.IsBackgroundTransparent());
}
else
{
if (action != ACTION_MOVE)
StretchBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top,
RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC, 0, 0, GetDIBWidth(hSelBm),
GetDIBHeight(hSelBm), SRCCOPY);
else
- if (transpBg == 0)
+ if (toolsModel.IsBackgroundTransparent() == 0)
MaskBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top,
RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest),
hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
else
{
ColorKeyedMaskBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top,
RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest),
- hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY,
SRCAND), bgColor);
+ hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY,
SRCAND), paletteModel.GetBgColor());
}
}
imageArea.InvalidateRect(NULL, FALSE);
@@ -273,8 +273,8 @@
}
else
{
- int w = RECT_WIDTH(rectSel_dest) * zoom / 1000 + 6;
- int h = RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 6;
+ int w = RECT_WIDTH(rectSel_dest) * toolsModel.GetZoom() / 1000 + 6;
+ int h = RECT_HEIGHT(rectSel_dest) * toolsModel.GetZoom() / 1000 + 6;
pos.x = GET_X_LPARAM(lParam);
pos.y = GET_Y_LPARAM(lParam);
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) NULL);
@@ -293,7 +293,7 @@
ReleaseCapture();
if (action != ACTION_MOVE)
{
- if (activeTool == TOOL_TEXT)
+ if (toolsModel.GetActiveTool() == TOOL_TEXT)
{
// FIXME: What to do?
}
Modified: trunk/reactos/base/applications/mspaint_new/sizebox.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/sizebox.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/sizebox.cpp [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -45,8 +45,8 @@
TCHAR sizeStr[100];
short xRel;
short yRel;
- xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
- yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
+ xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom();
+ yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / toolsModel.GetZoom();
if (m_hWnd == sizeboxLeftTop.m_hWnd)
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes - yRel);
if (m_hWnd == sizeboxCenterTop.m_hWnd)
@@ -76,8 +76,8 @@
short yRel;
ReleaseCapture();
resizing = FALSE;
- xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
- yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
+ xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / toolsModel.GetZoom();
+ yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / toolsModel.GetZoom();
if (m_hWnd == sizeboxLeftTop)
cropReversible(imgXRes - xRel, imgYRes - yRel, xRel, yRel);
if (m_hWnd == sizeboxCenterTop.m_hWnd)
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] Tue Jul 7
11:15:24 2015
@@ -28,9 +28,9 @@
DefWindowProc(WM_PAINT, wParam, lParam);
- DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (activeTool == TOOL_ZOOM) ? BF_RECT :
BF_RECT | BF_MIDDLE);
- DrawEdge(hdc, &rect2, (activeTool >= TOOL_RECT) ? BDR_SUNKENOUTER : 0, BF_RECT
| BF_MIDDLE);
- switch (activeTool)
+ DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (toolsModel.GetActiveTool() == TOOL_ZOOM)
? BF_RECT : BF_RECT | BF_MIDDLE);
+ DrawEdge(hdc, &rect2, (toolsModel.GetActiveTool() >= TOOL_RECT) ?
BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
+ switch (toolsModel.GetActiveTool())
{
case TOOL_FREESEL:
case TOOL_RECTSEL:
@@ -38,7 +38,7 @@
{
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
- Rectangle(hdc, 2, transpBg * 31 + 2, 41, transpBg * 31 + 33);
+ Rectangle(hdc, 2, toolsModel.IsBackgroundTransparent() * 31 + 2, 41,
toolsModel.IsBackgroundTransparent() * 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);
@@ -50,7 +50,7 @@
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
for(i = 0; i < 4; i++)
{
- if (rubberRadius == i + 2)
+ if (toolsModel.GetRubberRadius() == i + 2)
{
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
Rectangle(hdc, 14, i * 15 + 2, 29, i * 15 + 17);
@@ -68,19 +68,19 @@
int i;
HPEN oldPen = (HPEN) 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);
+ Rectangle(hdc, toolsModel.GetBrushStyle() % 3 * 13 + 2,
toolsModel.GetBrushStyle() / 3 * 15 + 2, toolsModel.GetBrushStyle() % 3 * 13 + 15,
+ toolsModel.GetBrushStyle() / 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);
+ GetSysColor((i == toolsModel.GetBrushStyle()) ? COLOR_HIGHLIGHTTEXT
: COLOR_WINDOWTEXT), i);
break;
}
case TOOL_AIRBRUSH:
{
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
- switch (airBrushWidth)
+ switch (toolsModel.GetAirBrushWidth())
{
case 5:
Rectangle(hdc, 2, 2, 21, 31);
@@ -96,13 +96,13 @@
break;
}
Airbrush(hdc, 10, 15,
- GetSysColor((airBrushWidth == 5) ? COLOR_HIGHLIGHTTEXT :
COLOR_WINDOWTEXT), 5);
+ GetSysColor((toolsModel.GetAirBrushWidth() == 5) ?
COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 5);
Airbrush(hdc, 30, 15,
- GetSysColor((airBrushWidth == 8) ? COLOR_HIGHLIGHTTEXT :
COLOR_WINDOWTEXT), 8);
+ GetSysColor((toolsModel.GetAirBrushWidth() == 8) ?
COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 8);
Airbrush(hdc, 8, 45,
- GetSysColor((airBrushWidth == 3) ? COLOR_HIGHLIGHTTEXT :
COLOR_WINDOWTEXT), 3);
+ GetSysColor((toolsModel.GetAirBrushWidth() == 3) ?
COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 3);
Airbrush(hdc, 27, 45,
- GetSysColor((airBrushWidth == 12) ? COLOR_HIGHLIGHTTEXT :
COLOR_WINDOWTEXT), 12);
+ GetSysColor((toolsModel.GetAirBrushWidth() == 12) ?
COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 12);
DeleteObject(SelectObject(hdc, oldPen));
break;
}
@@ -113,7 +113,7 @@
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
for(i = 0; i < 5; i++)
{
- if (lineWidth == i + 1)
+ if (toolsModel.GetLineWidth() == i + 1)
{
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
Rectangle(hdc, 2, i * 12 + 2, 41, i * 12 + 14);
@@ -135,23 +135,23 @@
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
for(i = 0; i < 3; i++)
{
- if (shapeStyle == i)
+ if (toolsModel.GetShapeStyle() == 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((toolsModel.GetShapeStyle() == 0) ? COLOR_HIGHLIGHTTEXT :
COLOR_WINDOWTEXT),
GetSysColor(COLOR_APPWORKSPACE), 1, 0);
Rect(hdc, 5, 26, 37, 36,
- GetSysColor((shapeStyle == 1) ? COLOR_HIGHLIGHTTEXT :
COLOR_WINDOWTEXT),
+ GetSysColor((toolsModel.GetShapeStyle() == 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)
+ if (toolsModel.GetLineWidth() == i + 1)
{
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
Rectangle(hdc, 2, i * 12 + 72, 41, i * 12 + 84);
@@ -173,14 +173,14 @@
{
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam);
- switch (activeTool)
+ switch (toolsModel.GetActiveTool())
{
case TOOL_FREESEL:
case TOOL_RECTSEL:
case TOOL_TEXT:
if ((y > 1) && (y < 64))
{
- transpBg = (y - 2) / 31;
+ toolsModel.SetBackgroundTransparent((y - 2) / 31);
InvalidateRect(NULL, TRUE);
ForceRefreshSelectionContents();
@@ -189,7 +189,7 @@
case TOOL_RUBBER:
if ((y > 1) && (y < 62))
{
- rubberRadius = (y - 2) / 15 + 2;
+ toolsModel.SetRubberRadius((y - 2) / 15 + 2);
InvalidateRect(NULL, TRUE);
}
break;
@@ -197,7 +197,7 @@
if ((x > 1) && (x < 40) && (y > 1)
&& (y < 62))
{
- brushStyle = (y - 2) / 15 * 3 + (x - 2) / 13;
+ toolsModel.SetBrushStyle((y - 2) / 15 * 3 + (x - 2) / 13);
InvalidateRect(NULL, TRUE);
}
break;
@@ -207,16 +207,16 @@
if (y < 30)
{
if (x < 20)
- airBrushWidth = 5;
+ toolsModel.SetAirBrushWidth(5);
else
- airBrushWidth = 8;
+ toolsModel.SetAirBrushWidth(8);
}
else
{
if (x < 15)
- airBrushWidth = 3;
+ toolsModel.SetAirBrushWidth(3);
else
- airBrushWidth = 12;
+ toolsModel.SetAirBrushWidth(12);
}
InvalidateRect(NULL, TRUE);
}
@@ -225,7 +225,7 @@
case TOOL_BEZIER:
if (y <= 62)
{
- lineWidth = (y - 2) / 12 + 1;
+ toolsModel.SetLineWidth((y - 2) / 12 + 1);
InvalidateRect(NULL, TRUE);
}
break;
@@ -235,12 +235,12 @@
case TOOL_RRECT:
if (y <= 60)
{
- shapeStyle = (y - 2) / 20;
+ toolsModel.SetShapeStyle((y - 2) / 20);
InvalidateRect(NULL, TRUE);
}
if ((y >= 70) && (y <= 132))
{
- lineWidth = (y - 72) / 12 + 1;
+ toolsModel.SetLineWidth((y - 72) / 12 + 1);
InvalidateRect(NULL, TRUE);
}
break;
Added: 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 (added)
+++ trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -0,0 +1,105 @@
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: base/applications/mspaint_new/toolsmodel.cpp
+ * PURPOSE: Keep track of tool parameters, notify listeners
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+/* INCLUDES *********************************************************/
+
+#include "precomp.h"
+
+/* FUNCTIONS ********************************************************/
+
+ToolsModel::ToolsModel()
+{
+ m_lineWidth = 1;
+ m_shapeStyle = 0;
+ m_brushStyle = 0;
+ m_activeTool = TOOL_PEN;
+ m_airBrushWidth = 5;
+ m_rubberRadius = 4;
+ m_transpBg = FALSE;
+ m_zoom = 1000;
+}
+
+int ToolsModel::GetLineWidth()
+{
+ return m_lineWidth;
+}
+
+void ToolsModel::SetLineWidth(int nLineWidth)
+{
+ m_lineWidth = nLineWidth;
+}
+
+int ToolsModel::GetShapeStyle()
+{
+ return m_shapeStyle;
+}
+
+void ToolsModel::SetShapeStyle(int nShapeStyle)
+{
+ m_shapeStyle = nShapeStyle;
+}
+
+int ToolsModel::GetBrushStyle()
+{
+ return m_brushStyle;
+}
+
+void ToolsModel::SetBrushStyle(int nBrushStyle)
+{
+ m_brushStyle = nBrushStyle;
+}
+
+int ToolsModel::GetActiveTool()
+{
+ return m_activeTool;
+}
+
+void ToolsModel::SetActiveTool(int nActiveTool)
+{
+ m_activeTool = nActiveTool;
+}
+
+int ToolsModel::GetAirBrushWidth()
+{
+ return m_airBrushWidth;
+}
+
+void ToolsModel::SetAirBrushWidth(int nAirBrushWidth)
+{
+ m_airBrushWidth = nAirBrushWidth;
+}
+
+int ToolsModel::GetRubberRadius()
+{
+ return m_rubberRadius;
+}
+
+void ToolsModel::SetRubberRadius(int nRubberRadius)
+{
+ m_rubberRadius = nRubberRadius;
+}
+
+BOOL ToolsModel::IsBackgroundTransparent()
+{
+ return m_transpBg;
+}
+
+void ToolsModel::SetBackgroundTransparent(BOOL bTransparent)
+{
+ m_transpBg = bTransparent;
+}
+
+int ToolsModel::GetZoom()
+{
+ return m_zoom;
+}
+
+void ToolsModel::SetZoom(int nZoom)
+{
+ m_zoom = nZoom;
+}
Propchange: trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/applications/mspaint_new/toolsmodel.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/toolsmodel.h (added)
+++ trunk/reactos/base/applications/mspaint_new/toolsmodel.h [iso-8859-1] Tue Jul 7
11:15:24 2015
@@ -0,0 +1,40 @@
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: base/applications/mspaint_new/toolsmodel.h
+ * PURPOSE: Keep track of tool parameters, notify listeners
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+/* CLASSES **********************************************************/
+
+class ToolsModel
+{
+private:
+ int m_lineWidth;
+ int m_shapeStyle;
+ int m_brushStyle;
+ int m_activeTool;
+ int m_airBrushWidth;
+ int m_rubberRadius;
+ BOOL m_transpBg;
+ int m_zoom;
+public:
+ ToolsModel();
+ int GetLineWidth();
+ void SetLineWidth(int nLineWidth);
+ int GetShapeStyle();
+ void SetShapeStyle(int nShapeStyle);
+ int GetBrushStyle();
+ void SetBrushStyle(int nBrushStyle);
+ int GetActiveTool();
+ void SetActiveTool(int nActiveTool);
+ int GetAirBrushWidth();
+ void SetAirBrushWidth(int nAirBrushWidth);
+ int GetRubberRadius();
+ void SetRubberRadius(int nRubberRadius);
+ BOOL IsBackgroundTransparent();
+ void SetBackgroundTransparent(BOOL bTransparent);
+ int GetZoom();
+ void SetZoom(int nZoom);
+};
Propchange: trunk/reactos/base/applications/mspaint_new/toolsmodel.h
------------------------------------------------------------------------------
svn:eol-style = native
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] Tue Jul 7
11:15:24 2015
@@ -19,7 +19,7 @@
void CMainWindow::selectTool(int tool)
{
selectionWindow.ShowWindow(SW_HIDE);
- activeTool = tool;
+ toolsModel.SetActiveTool(tool);
pointSP = 0; // resets the point-buffer of the polygon and bezier
functions
toolSettingsWindow.Invalidate(TRUE);
::ShowWindow(hTrackbarZoom, (tool == TOOL_ZOOM) ? SW_SHOW : SW_HIDE);
@@ -30,7 +30,7 @@
updateCanvasAndScrollbars()
{
selectionWindow.ShowWindow(SW_HIDE);
- imageArea.MoveWindow(3, 3, imgXRes * zoom / 1000, imgYRes * zoom / 1000, FALSE);
+ imageArea.MoveWindow(3, 3, imgXRes * toolsModel.GetZoom() / 1000, imgYRes *
toolsModel.GetZoom() / 1000, FALSE);
scrollboxWindow.Invalidate(TRUE);
imageArea.Invalidate(FALSE);
@@ -49,15 +49,15 @@
int x, y, w, h;
scrollboxWindow.GetClientRect(&clientRectScrollbox);
imageArea.GetClientRect(&clientRectImageArea);
- w = clientRectImageArea.right * clientRectScrollbox.right /
(clientRectImageArea.right * newZoom / zoom);
- h = clientRectImageArea.bottom * clientRectScrollbox.bottom /
(clientRectImageArea.bottom * newZoom / zoom);
- x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom / zoom;
- y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom / zoom;
-
- zoom = newZoom;
+ w = clientRectImageArea.right * clientRectScrollbox.right /
(clientRectImageArea.right * newZoom / toolsModel.GetZoom());
+ h = clientRectImageArea.bottom * clientRectScrollbox.bottom /
(clientRectImageArea.bottom * newZoom / toolsModel.GetZoom());
+ x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom /
toolsModel.GetZoom();
+ y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom /
toolsModel.GetZoom();
+
+ toolsModel.SetZoom(newZoom);
selectionWindow.ShowWindow(SW_HIDE);
- imageArea.MoveWindow(3, 3, imgXRes * zoom / 1000, imgYRes * zoom / 1000, FALSE);
+ imageArea.MoveWindow(3, 3, imgXRes * toolsModel.GetZoom() / 1000, imgYRes *
toolsModel.GetZoom() / 1000, FALSE);
scrollboxWindow.Invalidate(TRUE);
imageArea.Invalidate(FALSE);
@@ -239,7 +239,7 @@
LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
HMENU menu = GetMenu();
- BOOL trueSelection = (selectionWindow.IsWindowVisible() && ((activeTool ==
TOOL_FREESEL) || (activeTool == TOOL_RECTSEL)));
+ BOOL trueSelection = (selectionWindow.IsWindowVisible() &&
((toolsModel.GetActiveTool() == TOOL_FREESEL) || (toolsModel.GetActiveTool() ==
TOOL_RECTSEL)));
switch (lParam)
{
case 0: /* File menu */
@@ -264,27 +264,27 @@
CheckMenuItem(menu, IDM_VIEWCOLORPALETTE,
CHECKED_IF(paletteWindow.IsWindowVisible()));
CheckMenuItem(menu, IDM_VIEWSTATUSBAR,
CHECKED_IF(::IsWindowVisible(hStatusBar)));
CheckMenuItem(menu, IDM_FORMATICONBAR,
CHECKED_IF(textEditWindow.IsWindowVisible()));
- EnableMenuItem(menu, IDM_FORMATICONBAR, ENABLED_IF(activeTool ==
TOOL_TEXT));
+ EnableMenuItem(menu, IDM_FORMATICONBAR,
ENABLED_IF(toolsModel.GetActiveTool() == TOOL_TEXT));
CheckMenuItem(menu, IDM_VIEWSHOWGRID, CHECKED_IF(showGrid));
CheckMenuItem(menu, IDM_VIEWSHOWMINIATURE, CHECKED_IF(showMiniature));
break;
case 3: /* Image menu */
EnableMenuItem(menu, IDM_IMAGECROP,
ENABLED_IF(selectionWindow.IsWindowVisible()));
- CheckMenuItem(menu, IDM_IMAGEDRAWOPAQUE, CHECKED_IF(transpBg == 0));
- break;
- }
-
- CheckMenuItem(menu, IDM_VIEWZOOM125, CHECKED_IF(zoom == 125));
- CheckMenuItem(menu, IDM_VIEWZOOM25, CHECKED_IF(zoom == 250));
- CheckMenuItem(menu, IDM_VIEWZOOM50, CHECKED_IF(zoom == 500));
- CheckMenuItem(menu, IDM_VIEWZOOM100, CHECKED_IF(zoom == 1000));
- CheckMenuItem(menu, IDM_VIEWZOOM200, CHECKED_IF(zoom == 2000));
- CheckMenuItem(menu, IDM_VIEWZOOM400, CHECKED_IF(zoom == 4000));
- CheckMenuItem(menu, IDM_VIEWZOOM800, CHECKED_IF(zoom == 8000));
-
- CheckMenuItem(menu, IDM_COLORSMODERNPALETTE, CHECKED_IF(selectedPalette == 1));
- CheckMenuItem(menu, IDM_COLORSOLDPALETTE, CHECKED_IF(selectedPalette == 2));
+ CheckMenuItem(menu, IDM_IMAGEDRAWOPAQUE,
CHECKED_IF(!toolsModel.IsBackgroundTransparent()));
+ break;
+ }
+
+ CheckMenuItem(menu, IDM_VIEWZOOM125, CHECKED_IF(toolsModel.GetZoom() == 125));
+ CheckMenuItem(menu, IDM_VIEWZOOM25, CHECKED_IF(toolsModel.GetZoom() == 250));
+ CheckMenuItem(menu, IDM_VIEWZOOM50, CHECKED_IF(toolsModel.GetZoom() == 500));
+ CheckMenuItem(menu, IDM_VIEWZOOM100, CHECKED_IF(toolsModel.GetZoom() == 1000));
+ CheckMenuItem(menu, IDM_VIEWZOOM200, CHECKED_IF(toolsModel.GetZoom() == 2000));
+ CheckMenuItem(menu, IDM_VIEWZOOM400, CHECKED_IF(toolsModel.GetZoom() == 4000));
+ CheckMenuItem(menu, IDM_VIEWZOOM800, CHECKED_IF(toolsModel.GetZoom() == 8000));
+
+ CheckMenuItem(menu, IDM_COLORSMODERNPALETTE,
CHECKED_IF(paletteModel.SelectedPalette() == 1));
+ CheckMenuItem(menu, IDM_COLORSOLDPALETTE,
CHECKED_IF(paletteModel.SelectedPalette() == 2));
return 0;
}
@@ -325,11 +325,11 @@
if (!imageArea.drawing)
{
/* Deselect */
- if ((activeTool == TOOL_RECTSEL) || (activeTool == TOOL_FREESEL))
- {
- startPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
- whilePaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
- endPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
+ if ((toolsModel.GetActiveTool() == TOOL_RECTSEL) ||
(toolsModel.GetActiveTool() == TOOL_FREESEL))
+ {
+ startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ whilePaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ endPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
selectionWindow.ShowWindow(SW_HIDE);
}
}
@@ -459,13 +459,13 @@
/* remove selection window and already painted content using undo(),
paint Rect for rectangular selections and Poly for freeform selections */
undo();
- if (activeTool == TOOL_RECTSEL)
+ if (toolsModel.GetActiveTool() == TOOL_RECTSEL)
{
newReversible();
Rect(hDrawingDC, rectSel_dest.left, rectSel_dest.top,
rectSel_dest.right,
- rectSel_dest.bottom, bgColor, bgColor, 0, TRUE);
- }
- if (activeTool == TOOL_FREESEL)
+ rectSel_dest.bottom, paletteModel.GetBgColor(),
paletteModel.GetBgColor(), 0, TRUE);
+ }
+ if (toolsModel.GetActiveTool() == TOOL_FREESEL)
{
newReversible();
Poly(hDrawingDC, ptStack, ptSP + 1, 0, 0, 2, 0, FALSE, TRUE);
@@ -477,9 +477,9 @@
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME,
NULL);
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELONG(TRUE, 0));
SendMessage(WM_COMMAND, ID_RECTSEL, 0);
- startPaintingL(hDrawingDC, 0, 0, fgColor, bgColor);
- whilePaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
- endPaintingL(hDrawingDC, imgXRes, imgYRes, fgColor, bgColor);
+ startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ whilePaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
+ endPaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
break;
}
case IDM_EDITCOPYTO:
@@ -501,18 +501,16 @@
case IDM_COLORSEDITPALETTE:
if (ChooseColor(&choosecolor))
{
- fgColor = choosecolor.rgbResult;
+ paletteModel.SetFgColor(choosecolor.rgbResult);
paletteWindow.Invalidate(FALSE);
}
break;
case IDM_COLORSMODERNPALETTE:
- selectedPalette = 1;
- CopyMemory(palColors, modernPalColors, sizeof(palColors));
+ paletteModel.SelectPalette(1);
paletteWindow.Invalidate(FALSE);
break;
case IDM_COLORSOLDPALETTE:
- selectedPalette = 2;
- CopyMemory(palColors, oldPalColors, sizeof(palColors));
+ paletteModel.SelectPalette(2);
paletteWindow.Invalidate(FALSE);
break;
case IDM_IMAGEINVERTCOLORS:
@@ -526,7 +524,7 @@
}
case IDM_IMAGEDELETEIMAGE:
newReversible();
- Rect(hDrawingDC, 0, 0, imgXRes, imgYRes, bgColor, bgColor, 0, TRUE);
+ Rect(hDrawingDC, 0, 0, imgXRes, imgYRes, paletteModel.GetBgColor(),
paletteModel.GetBgColor(), 0, TRUE);
imageArea.Invalidate(FALSE);
break;
case IDM_IMAGEROTATEMIRROR:
@@ -616,7 +614,7 @@
break;
}
case IDM_IMAGEDRAWOPAQUE:
- transpBg = 1 - transpBg;
+ toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
toolSettingsWindow.Invalidate(TRUE);
break;
case IDM_IMAGECROP: