Author: bfreisen
Date: Tue Jul 7 11:44:50 2015
New Revision: 68370
URL:
http://svn.reactos.org/svn/reactos?rev=68370&view=rev
Log:
[MSPAINT_NEW] further ATLification, hard-coded observer pattern, minor cleanup (fourth
batch of git commits)
Added:
trunk/reactos/base/applications/mspaint_new/toolbox.cpp (with props)
trunk/reactos/base/applications/mspaint_new/toolbox.h (with props)
Modified:
trunk/reactos/base/applications/mspaint_new/CMakeLists.txt
trunk/reactos/base/applications/mspaint_new/definitions.h
trunk/reactos/base/applications/mspaint_new/globalvar.h
trunk/reactos/base/applications/mspaint_new/imgarea.cpp
trunk/reactos/base/applications/mspaint_new/imgarea.h
trunk/reactos/base/applications/mspaint_new/main.cpp
trunk/reactos/base/applications/mspaint_new/miniature.h
trunk/reactos/base/applications/mspaint_new/palette.cpp
trunk/reactos/base/applications/mspaint_new/palette.h
trunk/reactos/base/applications/mspaint_new/palettemodel.cpp
trunk/reactos/base/applications/mspaint_new/palettemodel.h
trunk/reactos/base/applications/mspaint_new/precomp.h
trunk/reactos/base/applications/mspaint_new/scrollbox.h
trunk/reactos/base/applications/mspaint_new/selection.h
trunk/reactos/base/applications/mspaint_new/sizebox.h
trunk/reactos/base/applications/mspaint_new/textedit.cpp
trunk/reactos/base/applications/mspaint_new/textedit.h
trunk/reactos/base/applications/mspaint_new/toolsettings.cpp
trunk/reactos/base/applications/mspaint_new/toolsettings.h
trunk/reactos/base/applications/mspaint_new/toolsmodel.cpp
trunk/reactos/base/applications/mspaint_new/toolsmodel.h
trunk/reactos/base/applications/mspaint_new/winproc.cpp
trunk/reactos/base/applications/mspaint_new/winproc.h
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:44:50 2015
@@ -20,6 +20,7 @@
selection.cpp
sizebox.cpp
textedit.cpp
+ toolbox.cpp
toolsettings.cpp
toolsmodel.cpp
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] Tue Jul 7
11:44:50 2015
@@ -220,3 +220,9 @@
#define IDS_ANGLE 932
#define IDS_LOADERRORTEXT 933
+
+#define WM_TOOLSMODELTOOLCHANGED WM_APP
+#define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1)
+#define WM_TOOLSMODELZOOMCHANGED (WM_APP + 2)
+#define WM_PALETTEMODELCOLORCHANGED (WM_APP + 3)
+#define WM_PALETTEMODELPALETTECHANGED (WM_APP + 4)
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:44:50 2015
@@ -58,7 +58,6 @@
extern PaletteModel paletteModel;
extern HWND hStatusBar;
-extern HWND hTrackbarZoom;
extern CHOOSECOLOR choosecolor;
extern OPENFILENAME ofn;
extern OPENFILENAME sfn;
@@ -88,6 +87,7 @@
class CMainWindow;
class CMiniatureWindow;
+class CToolBox;
class CToolSettingsWindow;
class CPaletteWindow;
class CScrollboxWindow;
@@ -98,7 +98,7 @@
extern CMainWindow mainWindow;
extern CMiniatureWindow miniature;
-extern CMainWindow toolBoxContainer;
+extern CToolBox toolBoxContainer;
extern CToolSettingsWindow toolSettingsWindow;
extern CPaletteWindow paletteWindow;
extern CScrollboxWindow scrollboxWindow;
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:44:50 2015
@@ -187,7 +187,6 @@
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
if (tempColor != CLR_INVALID)
paletteModel.SetFgColor(tempColor);
- paletteWindow.Invalidate(FALSE);
}
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
}
@@ -209,7 +208,6 @@
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(),
GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
if (tempColor != CLR_INVALID)
paletteModel.SetBgColor(tempColor);
- paletteWindow.Invalidate(FALSE);
}
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
}
Modified: trunk/reactos/base/applications/mspaint_new/imgarea.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/imgarea.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/imgarea.h [iso-8859-1] Tue Jul 7 11:44:50
2015
@@ -12,7 +12,7 @@
public:
DECLARE_WND_CLASS_EX(_T("ImgAreaWindow"), CS_DBLCLKS, COLOR_BTNFACE)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CImgAreaWindow)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
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:44:50
2015
@@ -48,7 +48,6 @@
PaletteModel paletteModel;
HWND hStatusBar;
-HWND hTrackbarZoom;
CHOOSECOLOR choosecolor;
OPENFILENAME ofn;
OPENFILENAME sfn;
@@ -78,7 +77,7 @@
CMainWindow mainWindow;
CMiniatureWindow miniature;
-CMainWindow toolBoxContainer;
+CToolBox toolBoxContainer;
CToolSettingsWindow toolSettingsWindow;
CPaletteWindow paletteWindow;
CScrollboxWindow scrollboxWindow;
@@ -106,12 +105,7 @@
TCHAR progtitle[1000];
TCHAR resstr[100];
HMENU menu;
- HWND hToolbar;
- HIMAGELIST hImageList;
HANDLE haccel;
- HBITMAP tempBm;
- int i;
- TCHAR tooltips[16][30];
HDC hDC;
TCHAR *c;
@@ -155,11 +149,11 @@
/* create main window */
RECT mainWindowPos = {0, 0, 544, 375}; // FIXME: use equivalent of CW_USEDEFAULT for
position
- hwnd = mainWindow.Create(HWND_DESKTOP, mainWindowPos, progtitle, WS_OVERLAPPEDWINDOW,
0, 0U, NULL);
+ hwnd = mainWindow.Create(HWND_DESKTOP, mainWindowPos, progtitle,
WS_OVERLAPPEDWINDOW);
RECT miniaturePos = {180, 200, 180 + 120, 200 + 100};
miniature.Create(hwnd, miniaturePos, miniaturetitle,
- WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
WS_EX_PALETTEWINDOW, 0U, NULL);
+ WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
WS_EX_PALETTEWINDOW);
/* loading and setting the window menu from resource */
menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
@@ -178,85 +172,40 @@
hCurPen = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_PEN));
hCurAirbrush = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_AIRBRUSH));
- CreateWindowEx(0, _T("STATIC"), _T(""), WS_CHILD | WS_VISIBLE |
SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL,
+ CreateWindowEx(0, _T("STATIC"), NULL, WS_CHILD | WS_VISIBLE |
SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL,
hThisInstance, NULL);
RECT toolBoxContainerPos = {2, 2, 2 + 52, 2 + 350};
- toolBoxContainer.Create(hwnd, toolBoxContainerPos, _T(""), WS_CHILD |
WS_VISIBLE, 0, 0U, NULL);
- /* creating the 16 bitmap radio buttons and setting the bitmap */
-
-
- /*
- * FIXME: Unintentionally there is a line above the tool bar (hidden by y-offset).
- * To prevent cropping of the buttons height has been increased from 200 to 205
- */
- hToolbar =
- CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
- WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT |
CCS_NORESIZE | TBSTYLE_TOOLTIPS,
- 1, -2, 50, 205, toolBoxContainer.m_hWnd, NULL, hThisInstance,
NULL);
- hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
- SendMessage(hToolbar, TB_SETIMAGELIST, 0, (LPARAM) hImageList);
- tempBm = (HBITMAP) LoadImage(hThisInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS),
IMAGE_BITMAP, 256, 16, 0);
- ImageList_AddMasked(hImageList, tempBm, 0xff00ff);
- DeleteObject(tempBm);
- SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
-
- for(i = 0; i < 16; i++)
- {
- TBBUTTON tbbutton;
- int wrapnow = 0;
-
- if (i % 2 == 1)
- wrapnow = TBSTATE_WRAP;
-
- LoadString(hThisInstance, IDS_TOOLTIP1 + i, tooltips[i], 30);
- ZeroMemory(&tbbutton, sizeof(TBBUTTON));
- tbbutton.iString = (INT_PTR) tooltips[i];
- tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
- tbbutton.fsState = TBSTATE_ENABLED | wrapnow;
- tbbutton.idCommand = ID_FREESEL + i;
- tbbutton.iBitmap = i;
- SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
- }
-
- SendMessage(hToolbar, TB_CHECKBUTTON, ID_PEN, MAKELONG(TRUE, 0));
- SendMessage(hToolbar, TB_SETMAXTEXTROWS, 0, 0);
- SendMessage(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(25, 25));
-
+ toolBoxContainer.Create(hwnd, toolBoxContainerPos, NULL, WS_CHILD | WS_VISIBLE);
/* creating the tool settings child window */
RECT toolSettingsWindowPos = {5, 208, 5 + 42, 208 + 140};
- toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos,
_T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
- hTrackbarZoom =
- CreateWindowEx(0, TRACKBAR_CLASS, _T(""), WS_CHILD | TBS_VERT |
TBS_AUTOTICKS, 1, 1, 40, 64,
- toolSettingsWindow.m_hWnd, NULL, hThisInstance, NULL);
- SendMessage(hTrackbarZoom, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
- SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 3);
+ toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos, NULL,
WS_CHILD | WS_VISIBLE);
/* creating the palette child window */
RECT paletteWindowPos = {56, 9, 56 + 255, 9 + 32};
- paletteWindow.Create(hwnd, paletteWindowPos, _T(""), WS_CHILD | WS_VISIBLE,
0, 0U, NULL);
+ paletteWindow.Create(hwnd, paletteWindowPos, NULL, WS_CHILD | WS_VISIBLE);
/* creating the scroll box */
RECT scrollboxWindowPos = {56, 49, 56 + 472, 49 + 248};
- scrollboxWindow.Create(hwnd, scrollboxWindowPos, _T(""),
- WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
WS_EX_CLIENTEDGE, 0U, NULL);
+ scrollboxWindow.Create(hwnd, scrollboxWindowPos, NULL,
+ WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE,
WS_EX_CLIENTEDGE);
/* creating the status bar */
hStatusBar =
- CreateWindowEx(0, STATUSCLASSNAME, _T(""), SBARS_SIZEGRIP | WS_CHILD |
WS_VISIBLE, 0, 0, 0, 0, hwnd,
+ CreateWindowEx(0, STATUSCLASSNAME, NULL, SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hwnd,
NULL, hThisInstance, NULL);
SendMessage(hStatusBar, SB_SETMINHEIGHT, 21, 0);
RECT scrlClientWindowPos = {0, 0, 0 + 500, 0 + 500};
- scrlClientWindow.Create(scrollboxWindow.m_hWnd, scrlClientWindowPos,
_T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
+ scrlClientWindow.Create(scrollboxWindow.m_hWnd, scrlClientWindowPos, NULL, WS_CHILD |
WS_VISIBLE);
/* create selection window (initially hidden) */
RECT selectionWindowPos = {350, 0, 350 + 100, 0 + 100};
- selectionWindow.Create(scrlClientWindow.m_hWnd, selectionWindowPos, _T(""),
WS_CHILD | BS_OWNERDRAW, 0, 0U, NULL);
+ selectionWindow.Create(scrlClientWindow.m_hWnd, selectionWindowPos, NULL, WS_CHILD |
BS_OWNERDRAW);
/* creating the window inside the scroll box, on which the image in hDrawingDC's
bitmap is drawn */
RECT imageAreaPos = {3, 3, 3 + imgXRes, 3 + imgYRes};
- imageArea.Create(scrlClientWindow.m_hWnd, imageAreaPos, _T(""), WS_CHILD |
WS_VISIBLE, 0, 0U, NULL);
+ imageArea.Create(scrlClientWindow.m_hWnd, imageAreaPos, NULL, WS_CHILD |
WS_VISIBLE);
hDC = imageArea.GetDC();
hDrawingDC = CreateCompatibleDC(hDC);
@@ -339,14 +288,14 @@
/* creating the size boxes */
RECT sizeboxPos = {0, 0, 0 + 3, 0 + 3};
- sizeboxLeftTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD
| WS_VISIBLE, 0, 0U, NULL);
- sizeboxCenterTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""),
WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
- sizeboxRightTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""),
WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
- sizeboxLeftCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""),
WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
- sizeboxRightCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""),
WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
- sizeboxLeftBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""),
WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
- sizeboxCenterBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""),
WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
- sizeboxRightBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""),
WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
+ sizeboxLeftTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
+ sizeboxCenterTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
+ sizeboxRightTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
+ sizeboxLeftCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
+ sizeboxRightCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
+ sizeboxLeftBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
+ sizeboxCenterBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
+ sizeboxRightBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD |
WS_VISIBLE);
/* placing the size boxes around the image */
imageArea.SendMessage(WM_SIZE, 0, 0);
@@ -355,12 +304,7 @@
/* creating the text editor window for the text tool */
RECT textEditWindowPos = {300, 0, 300 + 300, 0 + 200};
- textEditWindow.Create(hwnd, textEditWindowPos, _T(""), WS_OVERLAPPEDWINDOW,
0, 0U, NULL);
- /* creating the edit control within the editor window */
- hwndEditCtl =
- CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""),
- WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL |
ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
- 0, 0, 100, 100, textEditWindow.m_hWnd, NULL, hThisInstance,
NULL);
+ textEditWindow.Create(hwnd, textEditWindowPos, NULL, WS_OVERLAPPEDWINDOW);
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
Modified: trunk/reactos/base/applications/mspaint_new/miniature.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/miniature.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/miniature.h [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -12,7 +12,7 @@
public:
DECLARE_WND_CLASS_EX(_T("MiniatureWindow"), CS_DBLCLKS, COLOR_BTNFACE)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CMiniatureWindow)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
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:44:50 2015
@@ -63,7 +63,6 @@
if (GET_X_LPARAM(lParam) >= 31)
{
paletteModel.SetFgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 +
(GET_Y_LPARAM(lParam) / 16) * 14));
- InvalidateRect(NULL, FALSE);
if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
@@ -75,7 +74,6 @@
if (GET_X_LPARAM(lParam) >= 31)
{
paletteModel.SetBgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 +
(GET_Y_LPARAM(lParam) / 16) * 14));
- InvalidateRect(NULL, FALSE);
if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
@@ -90,7 +88,6 @@
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 +
(GET_Y_LPARAM(lParam) / 16) * 14,
choosecolor.rgbResult);
paletteModel.SetFgColor(choosecolor.rgbResult);
- InvalidateRect(NULL, FALSE);
if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
@@ -105,9 +102,20 @@
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 +
(GET_Y_LPARAM(lParam) / 16) * 14,
choosecolor.rgbResult);
paletteModel.SetBgColor(choosecolor.rgbResult);
- InvalidateRect(NULL, FALSE);
if (toolsModel.GetActiveTool() == 10)
ForceRefreshSelectionContents();
}
return 0;
}
+
+LRESULT CPaletteWindow::OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
+{
+ InvalidateRect(NULL, FALSE);
+ return 0;
+}
+
+LRESULT CPaletteWindow::OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
+{
+ InvalidateRect(NULL, FALSE);
+ return 0;
+}
Modified: trunk/reactos/base/applications/mspaint_new/palette.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/palette.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/palette.h [iso-8859-1] Tue Jul 7 11:44:50
2015
@@ -17,6 +17,8 @@
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
+ MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
+ MESSAGE_HANDLER(WM_PALETTEMODELPALETTECHANGED, OnPaletteModelPaletteChanged)
END_MSG_MAP()
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@@ -24,4 +26,6 @@
LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
};
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] Tue Jul 7
11:44:50 2015
@@ -45,6 +45,7 @@
else
return;
m_nSelectedPalette = nPalette;
+ NotifyPaletteChanged();
}
int PaletteModel::GetColor(int nIndex)
@@ -58,7 +59,10 @@
void PaletteModel::SetColor(int nIndex, int newColor)
{
if (nIndex < 28)
+ {
m_colors[nIndex] = newColor;
+ NotifyPaletteChanged();
+ }
}
int PaletteModel::GetFgColor()
@@ -69,6 +73,7 @@
void PaletteModel::SetFgColor(int newColor)
{
m_fgColor = newColor;
+ NotifyColorChanged();
}
int PaletteModel::GetBgColor()
@@ -79,4 +84,15 @@
void PaletteModel::SetBgColor(int newColor)
{
m_bgColor = newColor;
+ NotifyColorChanged();
}
+
+void PaletteModel::NotifyColorChanged()
+{
+ paletteWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
+}
+
+void PaletteModel::NotifyPaletteChanged()
+{
+ paletteWindow.SendMessage(WM_PALETTEMODELPALETTECHANGED);
+}
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/palettemodel.h [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -15,6 +15,10 @@
int m_nSelectedPalette;
int m_fgColor;
int m_bgColor;
+
+ void NotifyColorChanged();
+ void NotifyPaletteChanged();
+
public:
PaletteModel();
int SelectedPalette();
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:44:50
2015
@@ -32,6 +32,7 @@
#include "selection.h"
#include "sizebox.h"
#include "textedit.h"
+#include "toolbox.h"
#include "toolsettings.h"
#include "toolsmodel.h"
#include "winproc.h"
Modified: trunk/reactos/base/applications/mspaint_new/scrollbox.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/scrollbox.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/scrollbox.h [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -11,7 +11,7 @@
public:
DECLARE_WND_CLASS_EX(_T("Scrollbox"), 0, COLOR_APPWORKSPACE)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CScrollboxWindow)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
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] Tue Jul 7
11:44:50 2015
@@ -11,7 +11,7 @@
public:
DECLARE_WND_CLASS_EX(_T("Selection"), CS_DBLCLKS, COLOR_BTNFACE)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CSelectionWindow)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
Modified: trunk/reactos/base/applications/mspaint_new/sizebox.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/sizebox.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/sizebox.h [iso-8859-1] Tue Jul 7 11:44:50
2015
@@ -11,7 +11,7 @@
public:
DECLARE_WND_CLASS_EX(_T("Sizebox"), CS_DBLCLKS, COLOR_HIGHLIGHT)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CSizeboxWindow)
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
Modified: trunk/reactos/base/applications/mspaint_new/textedit.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/textedit.cpp [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/textedit.cpp [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -11,12 +11,21 @@
#include "precomp.h"
/* FUNCTIONS ********************************************************/
+LRESULT CTextEditWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ /* creating the edit control within the editor window */
+ RECT editControlPos = {0, 0, 0 + 100, 0 + 100};
+ hwndEditCtl = editControl.Create(_T("EDIT"), m_hWnd, editControlPos, NULL,
+ WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL |
WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
+ WS_EX_CLIENTEDGE);
+ return 0;
+}
LRESULT CTextEditWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
RECT clientRect;
GetClientRect(&clientRect);
- ::MoveWindow(hwndEditCtl, clientRect.left, clientRect.top, RECT_WIDTH(clientRect),
RECT_HEIGHT(clientRect), TRUE);
+ editControl.MoveWindow(clientRect.left, clientRect.top, RECT_WIDTH(clientRect),
RECT_HEIGHT(clientRect), TRUE);
return 0;
}
@@ -33,12 +42,18 @@
case EN_UPDATE:
{
HeapFree(GetProcessHeap(), 0, textToolText);
- textToolTextMaxLen = ::GetWindowTextLength(hwndEditCtl) + 1;
+ textToolTextMaxLen = editControl.GetWindowTextLength() + 1;
textToolText = (LPTSTR) HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS,
sizeof(TCHAR) * textToolTextMaxLen);
- ::GetWindowText(hwndEditCtl, textToolText, textToolTextMaxLen);
+ editControl.GetWindowText(textToolText, textToolTextMaxLen);
ForceRefreshSelectionContents();
break;
}
}
return 0;
}
+
+LRESULT CTextEditWindow::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
+{
+ ShowWindow((wParam == TOOL_TEXT) ? SW_SHOW : SW_HIDE);
+ return 0;
+}
Modified: trunk/reactos/base/applications/mspaint_new/textedit.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/textedit.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/textedit.h [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -11,13 +11,19 @@
public:
DECLARE_WND_CLASS_EX(_T("TextEdit"), CS_DBLCLKS, COLOR_BTNFACE)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CTextEditWindow)
+ MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
+ MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged)
END_MSG_MAP()
+ CWindow editControl;
+
+ LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
};
Added: trunk/reactos/base/applications/mspaint_new/toolbox.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/toolbox.cpp (added)
+++ trunk/reactos/base/applications/mspaint_new/toolbox.cpp [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -0,0 +1,135 @@
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: base/applications/mspaint_new/toolbox.cpp
+ * PURPOSE: Window procedure of the main window and all children apart from
+ * hPalWin, hToolSettings and hSelection
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+/* INCLUDES *********************************************************/
+
+#include "precomp.h"
+
+/* FUNCTIONS ********************************************************/
+
+LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ HIMAGELIST hImageList;
+ HBITMAP tempBm;
+ int i;
+ TCHAR tooltips[16][30];
+
+ /*
+ * FIXME: Unintentionally there is a line above the tool bar (hidden by y-offset).
+ * To prevent cropping of the buttons height has been increased from 200 to 205
+ */
+ RECT toolbarPos = {1, -2, 1 + 50, -2 + 205};
+ toolbar.Create(TOOLBARCLASSNAME, m_hWnd, toolbarPos, NULL,
+ WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE |
TBSTYLE_TOOLTIPS);
+ hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
+ toolbar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM) hImageList);
+ tempBm = (HBITMAP) LoadImage((HINSTANCE) GetWindowLong(GWL_HINSTANCE),
MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0);
+ ImageList_AddMasked(hImageList, tempBm, 0xff00ff);
+ DeleteObject(tempBm);
+ toolbar.SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
+
+ for(i = 0; i < 16; i++)
+ {
+ TBBUTTON tbbutton;
+ int wrapnow = 0;
+
+ if (i % 2 == 1)
+ wrapnow = TBSTATE_WRAP;
+
+ LoadString((HINSTANCE) GetWindowLong(GWL_HINSTANCE), IDS_TOOLTIP1 + i,
tooltips[i], 30);
+ ZeroMemory(&tbbutton, sizeof(TBBUTTON));
+ tbbutton.iString = (INT_PTR) tooltips[i];
+ tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
+ tbbutton.fsState = TBSTATE_ENABLED | wrapnow;
+ tbbutton.idCommand = ID_FREESEL + i;
+ tbbutton.iBitmap = i;
+ toolbar.SendMessage(TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
+ }
+
+ toolbar.SendMessage(TB_CHECKBUTTON, ID_PEN, MAKELPARAM(TRUE, 0));
+ toolbar.SendMessage(TB_SETMAXTEXTROWS, 0, 0);
+ toolbar.SendMessage(TB_SETBUTTONSIZE, 0, MAKELPARAM(25, 25));
+
+ return 0;
+}
+
+LRESULT CToolBox::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ SetCursor(LoadCursor(NULL, IDC_ARROW));
+ return 0;
+}
+
+LRESULT CToolBox::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
+{
+ toolbar.SendMessage(WM_SYSCOLORCHANGE, 0, 0);
+ return 0;
+}
+
+LRESULT CToolBox::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ switch (LOWORD(wParam))
+ {
+ case ID_FREESEL:
+ toolsModel.SetActiveTool(1);
+ break;
+ case ID_RECTSEL:
+ toolsModel.SetActiveTool(2);
+ break;
+ case ID_RUBBER:
+ toolsModel.SetActiveTool(3);
+ break;
+ case ID_FILL:
+ toolsModel.SetActiveTool(4);
+ break;
+ case ID_COLOR:
+ toolsModel.SetActiveTool(5);
+ break;
+ case ID_ZOOM:
+ toolsModel.SetActiveTool(6);
+ break;
+ case ID_PEN:
+ toolsModel.SetActiveTool(7);
+ break;
+ case ID_BRUSH:
+ toolsModel.SetActiveTool(8);
+ break;
+ case ID_AIRBRUSH:
+ toolsModel.SetActiveTool(9);
+ break;
+ case ID_TEXT:
+ toolsModel.SetActiveTool(10);
+ break;
+ case ID_LINE:
+ toolsModel.SetActiveTool(11);
+ break;
+ case ID_BEZIER:
+ toolsModel.SetActiveTool(12);
+ break;
+ case ID_RECT:
+ toolsModel.SetActiveTool(13);
+ break;
+ case ID_SHAPE:
+ toolsModel.SetActiveTool(14);
+ break;
+ case ID_ELLIPSE:
+ toolsModel.SetActiveTool(15);
+ break;
+ case ID_RRECT:
+ toolsModel.SetActiveTool(16);
+ break;
+ }
+ return 0;
+}
+
+LRESULT CToolBox::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
+{
+ selectionWindow.ShowWindow(SW_HIDE);
+ pointSP = 0; // resets the point-buffer of the polygon and bezier
functions
+ return 0;
+}
Propchange: trunk/reactos/base/applications/mspaint_new/toolbox.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/applications/mspaint_new/toolbox.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/toolbox.h (added)
+++ trunk/reactos/base/applications/mspaint_new/toolbox.h [iso-8859-1] Tue Jul 7 11:44:50
2015
@@ -0,0 +1,30 @@
+/*
+ * PROJECT: PAINT for ReactOS
+ * LICENSE: LGPL
+ * FILE: base/applications/mspaint_new/toolbox.h
+ * PURPOSE: Window procedure of the main window and all children apart from
+ * hPalWin, hToolSettings and hSelection
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+class CToolBox : public CWindowImpl<CMainWindow>
+{
+public:
+ DECLARE_WND_CLASS_EX(_T("ToolBox"), CS_DBLCLKS, COLOR_BTNFACE)
+
+ BEGIN_MSG_MAP(CToolBox)
+ MESSAGE_HANDLER(WM_CREATE, OnCreate)
+ MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
+ MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange)
+ MESSAGE_HANDLER(WM_COMMAND, OnCommand)
+ MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged)
+ END_MSG_MAP()
+
+ CWindow toolbar;
+
+ LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+};
Propchange: trunk/reactos/base/applications/mspaint_new/toolbox.h
------------------------------------------------------------------------------
svn:eol-style = native
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:44:50 2015
@@ -14,9 +14,18 @@
extern void zoomTo(int, int, int);
+LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam,
WINBOOL& bHandled)
+{
+ RECT trackbarZoomPos = {1, 1, 1 + 40, 1 + 64};
+ trackbarZoom.Create(TRACKBAR_CLASS, m_hWnd, trackbarZoomPos, NULL, WS_CHILD |
TBS_VERT | TBS_AUTOTICKS);
+ trackbarZoom.SendMessage(TBM_SETRANGE, (WPARAM) TRUE, MAKELPARAM(0, 6));
+ trackbarZoom.SendMessage(TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 3);
+ return 0;
+}
+
LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- zoomTo(125 << SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0), 0, 0);
+ zoomTo(125 << trackbarZoom.SendMessage(TBM_GETPOS, 0, 0), 0, 0);
return 0;
}
@@ -181,25 +190,17 @@
if ((y > 1) && (y < 64))
{
toolsModel.SetBackgroundTransparent((y - 2) / 31);
- InvalidateRect(NULL, TRUE);
ForceRefreshSelectionContents();
}
break;
case TOOL_RUBBER:
if ((y > 1) && (y < 62))
- {
toolsModel.SetRubberRadius((y - 2) / 15 + 2);
- InvalidateRect(NULL, TRUE);
- }
break;
case TOOL_BRUSH:
- if ((x > 1) && (x < 40) && (y > 1)
- && (y < 62))
- {
+ if ((x > 1) && (x < 40) && (y > 1) && (y
< 62))
toolsModel.SetBrushStyle((y - 2) / 15 * 3 + (x - 2) / 13);
- InvalidateRect(NULL, TRUE);
- }
break;
case TOOL_AIRBRUSH:
if (y < 62)
@@ -218,32 +219,49 @@
else
toolsModel.SetAirBrushWidth(12);
}
- InvalidateRect(NULL, TRUE);
}
break;
case TOOL_LINE:
case TOOL_BEZIER:
if (y <= 62)
- {
toolsModel.SetLineWidth((y - 2) / 12 + 1);
- InvalidateRect(NULL, TRUE);
- }
break;
case TOOL_RECT:
case TOOL_SHAPE:
case TOOL_ELLIPSE:
case TOOL_RRECT:
if (y <= 60)
- {
toolsModel.SetShapeStyle((y - 2) / 20);
- InvalidateRect(NULL, TRUE);
- }
if ((y >= 70) && (y <= 132))
- {
toolsModel.SetLineWidth((y - 72) / 12 + 1);
- InvalidateRect(NULL, TRUE);
- }
break;
}
return 0;
}
+
+LRESULT CToolSettingsWindow::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
+{
+ Invalidate();
+ trackbarZoom.ShowWindow((wParam == TOOL_ZOOM) ? SW_SHOW : SW_HIDE);
+ return 0;
+}
+
+LRESULT CToolSettingsWindow::OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
+{
+ Invalidate();
+ return 0;
+}
+
+LRESULT CToolSettingsWindow::OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
+{
+ int tbPos = 0;
+ int tempZoom = toolsModel.GetZoom();
+
+ while (tempZoom > 125)
+ {
+ tbPos++;
+ tempZoom = tempZoom >> 1;
+ }
+ trackbarZoom.SendMessage(TBM_SETPOS, (WPARAM) TRUE, (LPARAM) tbPos);
+ return 0;
+}
Modified: trunk/reactos/base/applications/mspaint_new/toolsettings.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/toolsettings.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/toolsettings.h [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -11,13 +11,23 @@
public:
DECLARE_WND_CLASS_EX(_T("ToolSettings"), CS_DBLCLKS, COLOR_BTNFACE)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CToolSettingsWindow)
+ MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
+ MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged)
+ MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged)
+ MESSAGE_HANDLER(WM_TOOLSMODELZOOMCHANGED, OnToolsModelZoomChanged)
END_MSG_MAP()
+ CWindow trackbarZoom;
+
+ LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
+ LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled);
+ LRESULT OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
};
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] Tue Jul 7
11:44:50 2015
@@ -32,6 +32,7 @@
void ToolsModel::SetLineWidth(int nLineWidth)
{
m_lineWidth = nLineWidth;
+ NotifyToolSettingsChanged();
}
int ToolsModel::GetShapeStyle()
@@ -42,6 +43,7 @@
void ToolsModel::SetShapeStyle(int nShapeStyle)
{
m_shapeStyle = nShapeStyle;
+ NotifyToolSettingsChanged();
}
int ToolsModel::GetBrushStyle()
@@ -52,6 +54,7 @@
void ToolsModel::SetBrushStyle(int nBrushStyle)
{
m_brushStyle = nBrushStyle;
+ NotifyToolSettingsChanged();
}
int ToolsModel::GetActiveTool()
@@ -62,6 +65,7 @@
void ToolsModel::SetActiveTool(int nActiveTool)
{
m_activeTool = nActiveTool;
+ NotifyToolChanged();
}
int ToolsModel::GetAirBrushWidth()
@@ -72,6 +76,7 @@
void ToolsModel::SetAirBrushWidth(int nAirBrushWidth)
{
m_airBrushWidth = nAirBrushWidth;
+ NotifyToolSettingsChanged();
}
int ToolsModel::GetRubberRadius()
@@ -82,6 +87,7 @@
void ToolsModel::SetRubberRadius(int nRubberRadius)
{
m_rubberRadius = nRubberRadius;
+ NotifyToolSettingsChanged();
}
BOOL ToolsModel::IsBackgroundTransparent()
@@ -92,6 +98,7 @@
void ToolsModel::SetBackgroundTransparent(BOOL bTransparent)
{
m_transpBg = bTransparent;
+ NotifyToolSettingsChanged();
}
int ToolsModel::GetZoom()
@@ -102,4 +109,22 @@
void ToolsModel::SetZoom(int nZoom)
{
m_zoom = nZoom;
+ NotifyZoomChanged();
}
+
+void ToolsModel::NotifyToolChanged()
+{
+ toolBoxContainer.SendMessage(WM_TOOLSMODELTOOLCHANGED, m_activeTool);
+ toolSettingsWindow.SendMessage(WM_TOOLSMODELTOOLCHANGED, m_activeTool);
+ textEditWindow.SendMessage(WM_TOOLSMODELTOOLCHANGED, m_activeTool);
+}
+
+void ToolsModel::NotifyToolSettingsChanged()
+{
+ toolSettingsWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
+}
+
+void ToolsModel::NotifyZoomChanged()
+{
+ toolSettingsWindow.SendMessage(WM_TOOLSMODELZOOMCHANGED);
+}
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/toolsmodel.h [iso-8859-1] Tue Jul 7
11:44:50 2015
@@ -19,6 +19,11 @@
int m_rubberRadius;
BOOL m_transpBg;
int m_zoom;
+
+ void NotifyToolChanged();
+ void NotifyToolSettingsChanged();
+ void NotifyZoomChanged();
+
public:
ToolsModel();
int GetLineWidth();
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:44:50 2015
@@ -16,16 +16,6 @@
/* FUNCTIONS ********************************************************/
-void CMainWindow::selectTool(int tool)
-{
- selectionWindow.ShowWindow(SW_HIDE);
- 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);
- textEditWindow.ShowWindow((tool == TOOL_TEXT) ? SW_SHOW : SW_HIDE);
-}
-
void
updateCanvasAndScrollbars()
{
@@ -41,9 +31,6 @@
void
zoomTo(int newZoom, int mouseX, int mouseY)
{
- int tbPos = 0;
- int tempZoom = newZoom;
-
RECT clientRectScrollbox;
RECT clientRectImageArea;
int x, y, w, h;
@@ -61,22 +48,15 @@
scrollboxWindow.Invalidate(TRUE);
imageArea.Invalidate(FALSE);
- scrollboxWindow.SendMessage(WM_HSCROLL, SB_THUMBPOSITION | (x << 16), 0);
- scrollboxWindow.SendMessage(WM_VSCROLL, SB_THUMBPOSITION | (y << 16), 0);
-
- while (tempZoom > 125)
- {
- tbPos++;
- tempZoom = tempZoom >> 1;
- }
- SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) tbPos);
+ scrollboxWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
+ scrollboxWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
}
void CMainWindow::alignChildrenToMainWindow()
{
int x, y, w, h;
RECT clientRect;
- mainWindow.GetClientRect(&clientRect);
+ GetClientRect(&clientRect);
if (toolBoxContainer.IsWindowVisible())
{
@@ -121,7 +101,7 @@
CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname));
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
_stprintf(tempstr, resstr, filename);
- mainWindow.SetWindowText(tempstr);
+ SetWindowText(tempstr);
isAFile = TRUE;
imageSaved = TRUE;
}
@@ -148,8 +128,8 @@
HBITMAP hTempMask;
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
- SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELONG(TRUE, 0));
- SendMessage(window, WM_COMMAND, ID_RECTSEL, 0);
+ SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
+ toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
DeleteObject(SelectObject(hSelDC, hSelBm = (HBITMAP) CopyImage(bitmap,
IMAGE_BITMAP, 0, 0,
@@ -290,25 +270,19 @@
LRESULT CMainWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
- if (m_hWnd == mainWindow.m_hWnd)
- {
- int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20
};
- SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
- SendMessage(hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
- alignChildrenToMainWindow();
- Invalidate(TRUE);
- }
+ int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
+ SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
+ SendMessage(hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
+ alignChildrenToMainWindow();
+ Invalidate(TRUE);
return 0;
}
LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
{
- if (m_hWnd == mainWindow.m_hWnd)
- {
- MINMAXINFO *mm = (LPMINMAXINFO) lParam;
- mm->ptMinTrackSize.x = 330;
- mm->ptMinTrackSize.y = 430;
- }
+ MINMAXINFO *mm = (LPMINMAXINFO) lParam;
+ mm->ptMinTrackSize.x = 330;
+ mm->ptMinTrackSize.y = 430;
return 0;
}
@@ -357,12 +331,12 @@
TCHAR infotext[200];
LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle));
LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext));
- ShellAbout(mainWindow.m_hWnd, infotitle, infotext, paintIcon);
+ ShellAbout(m_hWnd, infotitle, infotext, paintIcon);
DeleteObject(paintIcon);
break;
}
case IDM_HELPHELPTOPICS:
- HtmlHelp(mainWindow.m_hWnd, _T("help\\Paint.chm"), 0, 0);
+ HtmlHelp(m_hWnd, _T("help\\Paint.chm"), 0, 0);
break;
case IDM_FILEEXIT:
SendMessage(WM_CLOSE, wParam, lParam);
@@ -475,8 +449,8 @@
case IDM_EDITSELECTALL:
{
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME,
NULL);
- SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELONG(TRUE, 0));
- SendMessage(WM_COMMAND, ID_RECTSEL, 0);
+ SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
+ toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
whilePaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
endPaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(),
paletteModel.GetBgColor());
@@ -615,7 +589,6 @@
}
case IDM_IMAGEDRAWOPAQUE:
toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
- toolSettingsWindow.Invalidate(TRUE);
break;
case IDM_IMAGECROP:
insertReversible((HBITMAP) CopyImage(hSelBm, IMAGE_BITMAP, 0, 0,
LR_COPYRETURNORG));
@@ -667,54 +640,6 @@
case IDM_VIEWZOOM800:
zoomTo(8000, 0, 0);
break;
- case ID_FREESEL:
- selectTool(1);
- break;
- case ID_RECTSEL:
- selectTool(2);
- break;
- case ID_RUBBER:
- selectTool(3);
- break;
- case ID_FILL:
- selectTool(4);
- break;
- case ID_COLOR:
- selectTool(5);
- break;
- case ID_ZOOM:
- selectTool(6);
- break;
- case ID_PEN:
- selectTool(7);
- break;
- case ID_BRUSH:
- selectTool(8);
- break;
- case ID_AIRBRUSH:
- selectTool(9);
- break;
- case ID_TEXT:
- selectTool(10);
- break;
- case ID_LINE:
- selectTool(11);
- break;
- case ID_BEZIER:
- selectTool(12);
- break;
- case ID_RECT:
- selectTool(13);
- break;
- case ID_SHAPE:
- selectTool(14);
- break;
- case ID_ELLIPSE:
- selectTool(15);
- break;
- case ID_RRECT:
- selectTool(16);
- break;
- }
- return 0;
-}
+ }
+ return 0;
+}
Modified: trunk/reactos/base/applications/mspaint_new/winproc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mspaint_…
==============================================================================
--- trunk/reactos/base/applications/mspaint_new/winproc.h [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mspaint_new/winproc.h [iso-8859-1] Tue Jul 7 11:44:50
2015
@@ -12,7 +12,7 @@
public:
DECLARE_WND_CLASS_EX(_T("MainWindow"), CS_DBLCLKS, COLOR_BTNFACE)
- BEGIN_MSG_MAP(CPaletteWindow)
+ BEGIN_MSG_MAP(CMainWindow)
MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
@@ -38,7 +38,6 @@
LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
- void selectTool(int tool);
void alignChildrenToMainWindow();
void saveImage(BOOL overwrite);
void UpdateApplicationProperties(HBITMAP bitmap, LPTSTR newfilename, LPTSTR
newfilepathname);