ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
January 2022
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
28 participants
173 discussions
Start a n
N
ew thread
[reactos] 02/02: [NTOS:KE] Fix buffer overflow when displaying x64 bug checks
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a4b2c80853b36079b93d5…
commit a4b2c80853b36079b93d528bdf7189f001c8c83a Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Mon Jan 3 10:15:57 2022 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Mon Jan 3 13:25:09 2022 -0500 [NTOS:KE] Fix buffer overflow when displaying x64 bug checks --- ntoskrnl/ke/bug.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ntoskrnl/ke/bug.c b/ntoskrnl/ke/bug.c index 8930e5fc88d..78bea627ad8 100644 --- a/ntoskrnl/ke/bug.c +++ b/ntoskrnl/ke/bug.c @@ -611,7 +611,7 @@ KiDisplayBlueScreen(IN ULONG MessageId, IN PCHAR HardErrMessage OPTIONAL, IN PCHAR Message) { - CHAR AnsiName[75]; + CHAR AnsiName[107]; /* Check if bootvid is installed */ if (InbvIsBootDriverInstalled()) @@ -676,13 +676,14 @@ KiDisplayBlueScreen(IN ULONG MessageId, KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL); /* Show the technical Data */ - sprintf(AnsiName, - "\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n", - (ULONG)KiBugCheckData[0], - (PVOID)KiBugCheckData[1], - (PVOID)KiBugCheckData[2], - (PVOID)KiBugCheckData[3], - (PVOID)KiBugCheckData[4]); + RtlStringCbPrintfA(AnsiName, + sizeof(AnsiName), + "\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n", + (ULONG)KiBugCheckData[0], + (PVOID)KiBugCheckData[1], + (PVOID)KiBugCheckData[2], + (PVOID)KiBugCheckData[3], + (PVOID)KiBugCheckData[4]); InbvDisplayString(AnsiName); /* Check if we have a driver*/
2 years, 11 months
1
0
0
0
[reactos] 01/02: [WIN32K:NTUSER] Fix reference leak
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2a2f8dbebd3d8a4f2358d…
commit 2a2f8dbebd3d8a4f2358d1110d01f392bebd2ad0 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Mon Jan 3 13:23:57 2022 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Mon Jan 3 13:25:09 2022 -0500 [WIN32K:NTUSER] Fix reference leak --- win32ss/user/ntuser/ntstubs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/win32ss/user/ntuser/ntstubs.c b/win32ss/user/ntuser/ntstubs.c index ddf9ba09381..015f8e30650 100644 --- a/win32ss/user/ntuser/ntstubs.c +++ b/win32ss/user/ntuser/ntstubs.c @@ -513,7 +513,10 @@ NtUserCreateInputContext(ULONG_PTR dwClientImcData) pIMC = UserCreateInputContext(dwClientImcData); if (pIMC) + { ret = UserHMGetHandle(pIMC); + UserDereferenceObject(pIMC); + } Quit: UserLeave();
2 years, 11 months
1
0
0
0
[reactos] 01/01: [MPLAY32] Update Spanish (es-ES) translation (#4200)
by Javier Fernandez
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b23e21a03eefac6395db2…
commit b23e21a03eefac6395db2cb71b06768f70d25bad Author: Javier Fernandez <elhoir(a)users.noreply.github.com> AuthorDate: Mon Jan 3 17:30:56 2022 +0100 Commit: GitHub <noreply(a)github.com> CommitDate: Mon Jan 3 19:30:56 2022 +0300 [MPLAY32] Update Spanish (es-ES) translation (#4200) --- base/applications/mplay32/lang/es-ES.rc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/base/applications/mplay32/lang/es-ES.rc b/base/applications/mplay32/lang/es-ES.rc index 7b382bd9efc..315536700bc 100644 --- a/base/applications/mplay32/lang/es-ES.rc +++ b/base/applications/mplay32/lang/es-ES.rc @@ -44,14 +44,14 @@ END STRINGTABLE BEGIN - IDS_MODE_UNKNOWN "Unknown" - IDS_MODE_OPEN "Opened" - IDS_MODE_STOP "Stopped" - IDS_MODE_PLAY "Playing" - IDS_MODE_PAUSE "Paused" - IDS_MODE_RECORD "Recording" - IDS_MODE_SEEK "Seeking" - IDS_MODE_NOT_READY "Not ready" + IDS_MODE_UNKNOWN "Desconocido" + IDS_MODE_OPEN "Abierto" + IDS_MODE_STOP "Detenido" + IDS_MODE_PLAY "Reproduciendo" + IDS_MODE_PAUSE "Pausado" + IDS_MODE_RECORD "Grabando" + IDS_MODE_SEEK "Buscando" + IDS_MODE_NOT_READY "No está listo" IDS_ALL_TYPES_FILTER "Todos los archivos soportados" IDS_TOOLTIP_PLAY "Reproducir" IDS_TOOLTIP_STOP "Detener" @@ -60,7 +60,7 @@ BEGIN IDS_TOOLTIP_SEEKBACK "Rebobinar" IDS_TOOLTIP_SEEKFORW "Avance rápido" IDS_TOOLTIP_FORWARD "Siguiente marca" - IDS_TOOLTIP_PAUSE "Pause" + IDS_TOOLTIP_PAUSE "Pausa" IDS_APPTITLE "Reproductor multimedia de ReactOS" IDS_PLAY "Reproducir" IDS_DEFAULTMCIERRMSG "No hay una descripción disponible para este error."
2 years, 11 months
1
0
0
0
[reactos] 01/01: [IMM32_APITEST] Fix failure messages.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7c3902e57bb1158633da3…
commit 7c3902e57bb1158633da3d0ca29e8947d4c8ec22 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sun Jan 2 12:54:45 2022 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sun Jan 2 12:54:59 2022 -0500 [IMM32_APITEST] Fix failure messages. --- modules/rostests/apitests/imm32/himc.c | 138 +++++++++++++++++++++------------ 1 file changed, 90 insertions(+), 48 deletions(-) diff --git a/modules/rostests/apitests/imm32/himc.c b/modules/rostests/apitests/imm32/himc.c index 05ba76448ca..050bd324e10 100644 --- a/modules/rostests/apitests/imm32/himc.c +++ b/modules/rostests/apitests/imm32/himc.c @@ -16,96 +16,138 @@ START_TEST(himc) /* ImmCreateContext/ImmDestroyContext and ImmLockIMC/ImmUnlockIMC */ hNewIMC = ImmCreateContext(); - ok(hNewIMC != NULL, "\n"); + ok(hNewIMC != NULL, "ImmCreateContext failed\n"); pIC = ImmLockIMC(hNewIMC); - ok(pIC == NULL, "\n"); + ok(pIC == NULL, "ImmLockIMC succeeded unexpectedly\n"); ImmUnlockIMC(hNewIMC); - ok(ImmDestroyContext(hNewIMC), "\n"); + ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n"); /* ImmGetContext against NULL */ hIMC = ImmGetContext(NULL); - ok(hIMC == NULL, "\n"); + ok(hIMC == NULL, "ImmGetContext failed\n"); /* Create EDIT control */ style = ES_MULTILINE | ES_LEFT; hwndEdit = CreateWindowW(L"EDIT", NULL, style, 0, 0, 100, 20, NULL, NULL, GetModuleHandleW(NULL), NULL); - ok(hwndEdit != NULL, "\n"); + ok(hwndEdit != NULL, "CreateWindowW failed\n"); /* Create STATIC control */ style = SS_LEFT; hwndStatic = CreateWindowW(L"STATIC", NULL, style, 0, 30, 100, 20, NULL, NULL, GetModuleHandleW(NULL), NULL); - ok(hwndStatic != NULL, "\n"); + ok(hwndStatic != NULL, "CreateWindowW failed\n"); /* ImmGetContext/ImmReleaseContext and ImmLockIMC/ImmUnlockIMC */ hIMC1 = hIMC = ImmGetContext(hwndEdit); - ok(hIMC != NULL, "\n"); + ok(hIMC != NULL, "ImmGetContext failed\n"); pIC = ImmLockIMC(hIMC); - ok(pIC != NULL, "\n"); - ok(pIC && pIC->hWnd == NULL, "\n"); - ok(pIC && !pIC->fOpen, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hCompStr) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hCandInfo) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hGuideLine) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hPrivate) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hMsgBuf) != 0, "\n"); + ok(pIC != NULL, "ImmLockIMC failed\n"); + if (pIC != NULL) + { + ok(pIC->hWnd == NULL, "pIC->hWnd = %p\n", pIC->hWnd); + ok(!pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen); + ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n"); + ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n"); + ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n"); + ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n"); + ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n"); + } + else + { + skip("No pIC\n"); + } ImmUnlockIMC(hNewIMC); SetFocus(hwndEdit); pIC = ImmLockIMC(hIMC); - ok(pIC != NULL, "\n"); - ok(pIC && pIC->hWnd == hwndEdit, "\n"); - ok(pIC && !pIC->fOpen, "\n"); + ok(pIC != NULL, "ImmLockIMC failed\n"); + if (pIC != NULL) + { + ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit); + ok(!pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen); + } + else + { + skip("No pIC\n"); + } ImmUnlockIMC(hNewIMC); SetFocus(NULL); pIC = ImmLockIMC(hIMC); - ok(pIC != NULL, "\n"); - ok(pIC && pIC->hWnd == hwndEdit, "\n"); + ok(pIC != NULL, "ImmLockIMC failed\n"); + if (pIC != NULL) + { + ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit); + } + else + { + skip("No pIC\n"); + } ImmUnlockIMC(hNewIMC); - ok(ImmSetOpenStatus(hIMC, TRUE), "\n"); + ok(ImmSetOpenStatus(hIMC, TRUE), "ImmSetOpenStatus failed\n"); pIC = ImmLockIMC(hIMC); - ok(pIC != NULL, "\n"); - ok(pIC && pIC->fOpen, "\n"); + ok(pIC != NULL, "ImmLockIMC failed\n"); + if (pIC != NULL) + { + ok(pIC->fOpen, "pIC->fOpen = %d\n", pIC->fOpen); + } + else + { + skip("No pIC\n"); + } ImmUnlockIMC(hNewIMC); - ok(ImmReleaseContext(hwndEdit, hIMC), "\n"); + ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n"); hIMC2 = hIMC = ImmGetContext(hwndStatic); - ok(hIMC != NULL, "\n"); + ok(hIMC != NULL, "ImmGetContext failed\n"); pIC = ImmLockIMC(hIMC); - ok(pIC != NULL, "\n"); - ok(pIC && pIC->hWnd == hwndEdit, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hCompStr) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hCandInfo) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hGuideLine) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hPrivate) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hMsgBuf) != 0, "\n"); + ok(pIC != NULL, "ImmLockIMC failed\n"); + if (pIC != NULL) + { + ok(pIC->hWnd == hwndEdit, "pIC->hWnd = %p, expected %p\n", pIC->hWnd, hwndEdit); + ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n"); + ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n"); + ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n"); + ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n"); + ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n"); + } + else + { + skip("No pIC\n"); + } ImmUnlockIMC(hNewIMC); - ok(ImmReleaseContext(hwndEdit, hIMC), "\n"); + ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n"); - ok(hIMC1 == hIMC2, "\n"); + ok(hIMC1 == hIMC2, "hIMC1 = %p, expected %p\n", hIMC1, hIMC2); /* ImmAssociateContext */ hNewIMC = ImmCreateContext(); - ok(hNewIMC != NULL, "\n"); + ok(hNewIMC != NULL, "ImmCreateContext failed \n"); pIC = ImmLockIMC(hNewIMC); - ok(pIC != NULL, "\n"); + ok(pIC != NULL, "ImmLockIMC failed\n"); ImmUnlockIMC(hNewIMC); hOldIMC = ImmAssociateContext(hwndEdit, hNewIMC); - ok(hNewIMC != hOldIMC, "\n"); + ok(hNewIMC != hOldIMC, "hNewIMC = %p, expected not %p\n", hNewIMC, hOldIMC); hIMC = ImmGetContext(hwndEdit); - ok(hIMC == hNewIMC, "\n"); - ok(hIMC != hOldIMC, "\n"); + ok(hIMC == hNewIMC, "hIMC = %p, expected %p\n", hIMC, hNewIMC); + ok(hIMC != hOldIMC, "hIMC = %p, expected not %p\n", hIMC, hOldIMC); pIC = ImmLockIMC(hNewIMC); - ok(pIC != NULL, "\n"); - ok(pIC && pIC->hWnd == NULL, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hCompStr) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hCandInfo) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hGuideLine) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hPrivate) != 0, "\n"); - ok(pIC && ImmGetIMCCSize(pIC->hMsgBuf) != 0, "\n"); + ok(pIC != NULL, "ImmLockIMC failed\n"); + if (pIC != NULL) + { + ok(pIC->hWnd == NULL, "pIC->hWnd = %p\n", pIC->hWnd); + ok(ImmGetIMCCSize(pIC->hCompStr) != 0, "hCompStr size is 0\n"); + ok(ImmGetIMCCSize(pIC->hCandInfo) != 0, "hCandInfo size is 0\n"); + ok(ImmGetIMCCSize(pIC->hGuideLine) != 0, "hGuideLine size is 0\n"); + ok(ImmGetIMCCSize(pIC->hPrivate) != 0, "hPrivate size is 0\n"); + ok(ImmGetIMCCSize(pIC->hMsgBuf) != 0, "hMsgBuf size is 0\n"); + } + else + { + skip("No pIC\n"); + } ImmUnlockIMC(hNewIMC); - ok(ImmReleaseContext(hwndEdit, hIMC), "\n"); - ok(ImmDestroyContext(hNewIMC), "\n"); + ok(ImmReleaseContext(hwndEdit, hIMC), "ImmReleaseContext failed\n"); + ok(ImmDestroyContext(hNewIMC), "ImmDestroyContext failed\n"); DestroyWindow(hwndEdit); DestroyWindow(hwndStatic);
2 years, 11 months
1
0
0
0
[reactos] 01/01: [GDI32_VISTA] Move D3DKMT functions out of gdi32. CORE-17433
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=49bb853b2440c7152f34c…
commit 49bb853b2440c7152f34c216023e88212dafe8f1 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Sat Nov 13 11:43:41 2021 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Sat Jan 1 12:42:04 2022 -0500 [GDI32_VISTA] Move D3DKMT functions out of gdi32. CORE-17433 --- dll/apisets/CMakeLists.txt | 2 +- dll/apisets/api-ms-win-dx-d3dkmt-l1-1-0.spec | 4 ++-- dll/apisets/update.py | 1 + dll/directx/wine/wined3d/CMakeLists.txt | 2 +- modules/rostests/winetests/gdi32/CMakeLists.txt | 2 +- win32ss/CMakeLists.txt | 1 + win32ss/gdi/gdi32/gdi32.spec | 3 --- win32ss/gdi/gdi32/objects/dc.c | 13 ------------- win32ss/gdi/gdi32_vista/CMakeLists.txt | 26 +++++++++++++++++++++++++ win32ss/gdi/gdi32_vista/dc.c | 26 +++++++++++++++++++++++++ win32ss/gdi/gdi32_vista/gdi32_vista.rc | 5 +++++ win32ss/gdi/gdi32_vista/gdi32_vista.spec | 2 ++ 12 files changed, 66 insertions(+), 21 deletions(-) diff --git a/dll/apisets/CMakeLists.txt b/dll/apisets/CMakeLists.txt index 3273531b34a..f101725bf77 100644 --- a/dll/apisets/CMakeLists.txt +++ b/dll/apisets/CMakeLists.txt @@ -200,7 +200,7 @@ add_apiset(api-ms-win-downlevel-shlwapi-l1-1-0 0x611f0000 shlwapi) add_apiset(api-ms-win-downlevel-shlwapi-l2-1-0 0x61200000 shlwapi) add_apiset(api-ms-win-downlevel-user32-l1-1-0 0x61210000 user32) add_apiset(api-ms-win-downlevel-version-l1-1-0 0x61220000 version) -add_apiset(api-ms-win-dx-d3dkmt-l1-1-0 0x61230000 gdi32) +add_apiset(api-ms-win-dx-d3dkmt-l1-1-0 0x61230000 gdi32_vista gdi32) add_apiset(api-ms-win-eventing-classicprovider-l1-1-0 0x61290000 advapi32) add_apiset(api-ms-win-eventing-consumer-l1-1-0 0x612a0000 advapi32) add_apiset(api-ms-win-eventing-controller-l1-1-0 0x612b0000 advapi32) diff --git a/dll/apisets/api-ms-win-dx-d3dkmt-l1-1-0.spec b/dll/apisets/api-ms-win-dx-d3dkmt-l1-1-0.spec index 241a6eab50f..a0ba046c0b6 100644 --- a/dll/apisets/api-ms-win-dx-d3dkmt-l1-1-0.spec +++ b/dll/apisets/api-ms-win-dx-d3dkmt-l1-1-0.spec @@ -14,7 +14,7 @@ @ stub D3DKMTCreateAllocation @ stub D3DKMTCreateAllocation2 @ stub D3DKMTCreateContext -@ stdcall D3DKMTCreateDCFromMemory() gdi32.D3DKMTCreateDCFromMemory +@ stdcall D3DKMTCreateDCFromMemory() gdi32_vista.D3DKMTCreateDCFromMemory @ stub D3DKMTCreateDevice @ stub D3DKMTCreateKeyedMutex @ stub D3DKMTCreateKeyedMutex2 @@ -24,7 +24,7 @@ @ stub D3DKMTCreateSynchronizationObject2 @ stub D3DKMTDestroyAllocation @ stub D3DKMTDestroyContext -@ stdcall D3DKMTDestroyDCFromMemory() gdi32.D3DKMTDestroyDCFromMemory +@ stdcall D3DKMTDestroyDCFromMemory() gdi32_vista.D3DKMTDestroyDCFromMemory @ stub D3DKMTDestroyDevice @ stub D3DKMTDestroyKeyedMutex @ stub D3DKMTDestroyOutputDupl diff --git a/dll/apisets/update.py b/dll/apisets/update.py index c30a8bef7d1..9ff10fe2408 100644 --- a/dll/apisets/update.py +++ b/dll/apisets/update.py @@ -405,6 +405,7 @@ def generate_specnames(dll_dir): yield (os.path.join(dll_dir, 'appcompat', 'apphelp', 'apphelp.spec'), 'apphelp') yield (os.path.join(dll_dir, '..', 'win32ss', 'user', 'user32', 'user32.spec'), 'user32') yield (os.path.join(dll_dir, '..', 'win32ss', 'gdi', 'gdi32', 'gdi32.spec'), 'gdi32') + yield (os.path.join(dll_dir, '..', 'win32ss', 'gdi', 'gdi32_vista', 'gdi32_vista.spec'), 'gdi32_vista') def run(wineroot): global NL_CHAR diff --git a/dll/directx/wine/wined3d/CMakeLists.txt b/dll/directx/wine/wined3d/CMakeLists.txt index 10f144b93e6..58f15cfbc14 100644 --- a/dll/directx/wine/wined3d/CMakeLists.txt +++ b/dll/directx/wine/wined3d/CMakeLists.txt @@ -49,7 +49,7 @@ add_library(d3dwine MODULE set_module_type(d3dwine win32dll) target_link_libraries(d3dwine wine) -add_importlibs(d3dwine user32 opengl32 gdi32 advapi32 msvcrt kernel32 ntdll) +add_importlibs(d3dwine user32 opengl32 gdi32 gdi32_vista advapi32 msvcrt kernel32 ntdll) add_pch(d3dwine precomp.h SOURCE) add_cd_file(TARGET d3dwine DESTINATION reactos/system32 FOR all) diff --git a/modules/rostests/winetests/gdi32/CMakeLists.txt b/modules/rostests/winetests/gdi32/CMakeLists.txt index bd8ec4419d5..3a7abed6b52 100644 --- a/modules/rostests/winetests/gdi32/CMakeLists.txt +++ b/modules/rostests/winetests/gdi32/CMakeLists.txt @@ -31,7 +31,7 @@ if(MSVC AND ARCH STREQUAL "amd64") endif() set_module_type(gdi32_winetest win32cui) -add_importlibs(gdi32_winetest gdi32 user32 advapi32 msvcrt kernel32) +add_importlibs(gdi32_winetest gdi32 gdi32_vista user32 advapi32 msvcrt kernel32) if(MSVC) add_importlibs(gdi32_winetest ntdll) diff --git a/win32ss/CMakeLists.txt b/win32ss/CMakeLists.txt index 727461031cd..51c8ec4c5f4 100644 --- a/win32ss/CMakeLists.txt +++ b/win32ss/CMakeLists.txt @@ -11,6 +11,7 @@ if(USE_DIBLIB) endif() add_subdirectory(gdi/gdi32) +add_subdirectory(gdi/gdi32_vista) add_subdirectory(printing) add_subdirectory(reactx) add_subdirectory(user/user32) diff --git a/win32ss/gdi/gdi32/gdi32.spec b/win32ss/gdi/gdi32/gdi32.spec index 53fd576d31e..0db97d36c0d 100644 --- a/win32ss/gdi/gdi32/gdi32.spec +++ b/win32ss/gdi/gdi32/gdi32.spec @@ -608,6 +608,3 @@ 608 stdcall bMakePathNameW(wstr wstr wstr long) 609 stdcall cGetTTFFromFOT(long long long long long long long) 610 stdcall gdiPlaySpoolStream(long long long long long long) -; FIXME: Wine DX Dlls need these -@ stdcall D3DKMTCreateDCFromMemory(ptr) -@ stdcall D3DKMTDestroyDCFromMemory(ptr) diff --git a/win32ss/gdi/gdi32/objects/dc.c b/win32ss/gdi/gdi32/objects/dc.c index 3f20b9f6392..580776819f9 100644 --- a/win32ss/gdi/gdi32/objects/dc.c +++ b/win32ss/gdi/gdi32/objects/dc.c @@ -1579,16 +1579,3 @@ SelectObject( return NULL; } - -/*********************************************************************** - * D3DKMTCreateDCFromMemory (GDI32.@) - */ -DWORD WINAPI D3DKMTCreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ) -{ - return NtGdiDdDDICreateDCFromMemory( desc ); -} - -DWORD WINAPI D3DKMTDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY *desc ) -{ - return NtGdiDdDDIDestroyDCFromMemory( desc ); -} diff --git a/win32ss/gdi/gdi32_vista/CMakeLists.txt b/win32ss/gdi/gdi32_vista/CMakeLists.txt new file mode 100644 index 00000000000..411e5b403ac --- /dev/null +++ b/win32ss/gdi/gdi32_vista/CMakeLists.txt @@ -0,0 +1,26 @@ + +include_directories( + include + ${REACTOS_SOURCE_DIR}/win32ss/include) + +spec2def(gdi32_vista.dll gdi32_vista.spec ADD_IMPORTLIB) + +list(APPEND SOURCE + dc.c) + +add_library(gdi32_vista MODULE + ${SOURCE} + gdi32_vista.rc + ${CMAKE_CURRENT_BINARY_DIR}/gdi32_vista.def) + +set_module_type(gdi32_vista + win32dll + ENTRYPOINT 0 + UNICODE) + +target_link_libraries(gdi32_vista win32ksys) + +#add_importlibs(gdi32_vista user32 advapi32 kernel32 ntdll) +#add_pch(gdi32_vista include/precomp.h SOURCE) +add_dependencies(gdi32_vista psdk) +add_cd_file(TARGET gdi32_vista DESTINATION reactos/system32 FOR all) diff --git a/win32ss/gdi/gdi32_vista/dc.c b/win32ss/gdi/gdi32_vista/dc.c new file mode 100644 index 00000000000..c985aa22255 --- /dev/null +++ b/win32ss/gdi/gdi32_vista/dc.c @@ -0,0 +1,26 @@ +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H +#define NTOS_MODE_USER +#include <stdarg.h> +#include <windef.h> +#include <winbase.h> +#include <ndk/rtlfuncs.h> +#include <wingdi.h> +#include <winddi.h> +#include <prntfont.h> +#include <ntgdityp.h> +#include <ntgdi.h> + +/*********************************************************************** + * D3DKMTCreateDCFromMemory (GDI32.@) + */ +DWORD WINAPI D3DKMTCreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc ) +{ + return NtGdiDdDDICreateDCFromMemory( desc ); +} + +DWORD WINAPI D3DKMTDestroyDCFromMemory( const D3DKMT_DESTROYDCFROMMEMORY *desc ) +{ + return NtGdiDdDDIDestroyDCFromMemory( desc ); +} diff --git a/win32ss/gdi/gdi32_vista/gdi32_vista.rc b/win32ss/gdi/gdi32_vista/gdi32_vista.rc new file mode 100644 index 00000000000..116013b55e2 --- /dev/null +++ b/win32ss/gdi/gdi32_vista/gdi32_vista.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "GDI Client DLL" +#define REACTOS_STR_INTERNAL_NAME "gdi32_vista" +#define REACTOS_STR_ORIGINAL_FILENAME "gdi32_vista.dll" +#include <reactos/version.rc> diff --git a/win32ss/gdi/gdi32_vista/gdi32_vista.spec b/win32ss/gdi/gdi32_vista/gdi32_vista.spec new file mode 100644 index 00000000000..13ddbd8c7e5 --- /dev/null +++ b/win32ss/gdi/gdi32_vista/gdi32_vista.spec @@ -0,0 +1,2 @@ +@ stdcall D3DKMTCreateDCFromMemory(ptr) +@ stdcall D3DKMTDestroyDCFromMemory(ptr)
2 years, 11 months
1
0
0
0
[reactos] 01/01: [NTUSER] Fix KVM and VBox tests (#4235)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=757bed81b1c96bffa195b…
commit 757bed81b1c96bffa195b1237d6d91125a1650bf Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sun Jan 2 01:40:11 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Sun Jan 2 01:40:11 2022 +0900 [NTUSER] Fix KVM and VBox tests (#4235) KVM and VBox tests was failing since d5deacd - Check NULL at UserFreeInputContext and UserDestroyInputContext functions. - Move UserMarkObjectDestroy into the UserDestroyInputContext function. CORE-11700 --- win32ss/user/ntuser/ime.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/win32ss/user/ntuser/ime.c b/win32ss/user/ntuser/ime.c index c172f28a70c..81c4e330243 100644 --- a/win32ss/user/ntuser/ime.c +++ b/win32ss/user/ntuser/ime.c @@ -224,10 +224,14 @@ AllocInputContextObject(PDESKTOP pDesk, VOID UserFreeInputContext(PVOID Object) { PIMC pIMC = Object, pImc0; - PTHREADINFO pti = pIMC->head.pti; + PTHREADINFO pti; - UserMarkObjectDestroy(Object); + if (!pIMC) + return; + pti = pIMC->head.pti; + + /* Find the IMC in the list and remove it */ for (pImc0 = pti->spDefaultImc; pImc0; pImc0 = pImc0->pImcNext) { if (pImc0->pImcNext == pIMC) @@ -237,7 +241,7 @@ VOID UserFreeInputContext(PVOID Object) } } - UserHeapFree(Object); + UserHeapFree(pIMC); pti->ppi->UserHandleCount--; IntDereferenceThreadInfo(pti); @@ -246,7 +250,11 @@ VOID UserFreeInputContext(PVOID Object) BOOLEAN UserDestroyInputContext(PVOID Object) { PIMC pIMC = Object; - UserDeleteObject(pIMC->head.h, TYPE_INPUTCONTEXT); + if (pIMC) + { + UserMarkObjectDestroy(pIMC); + UserDeleteObject(pIMC->head.h, TYPE_INPUTCONTEXT); + } return TRUE; }
2 years, 11 months
1
0
0
0
[reactos] 01/01: [MSPAINT] Polymorphism on tools (#4210)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ee132a05bafe93fcc6534…
commit ee132a05bafe93fcc6534071120cb51b0b0fc7ac Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sat Jan 1 22:02:36 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Sat Jan 1 22:02:36 2022 +0900 [MSPAINT] Polymorphism on tools (#4210) - Introduce polymorphism on tools and mouse actions. - Implement double-clicking on TOOL_SHAPE. - Fix some bugs about mouse handling. CORE-17931 --- base/applications/mspaint/common.h | 3 + base/applications/mspaint/globalvar.h | 2 - base/applications/mspaint/imgarea.cpp | 136 ++--- base/applications/mspaint/imgarea.h | 8 + base/applications/mspaint/mouse.cpp | 990 +++++++++++++++++-------------- base/applications/mspaint/mouse.h | 23 - base/applications/mspaint/precomp.h | 1 - base/applications/mspaint/scrollbox.cpp | 18 +- base/applications/mspaint/toolbox.cpp | 94 ++- base/applications/mspaint/toolsmodel.cpp | 82 ++- base/applications/mspaint/toolsmodel.h | 53 ++ base/applications/mspaint/winproc.cpp | 7 +- 12 files changed, 786 insertions(+), 631 deletions(-) diff --git a/base/applications/mspaint/common.h b/base/applications/mspaint/common.h index 288bba64be4..af55873145f 100644 --- a/base/applications/mspaint/common.h +++ b/base/applications/mspaint/common.h @@ -30,6 +30,9 @@ BOOL zoomTo(int newZoom, int mouseX, int mouseY); BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1); +void placeSelWin(void); +void updateStartAndLast(LONG x, LONG y); +void updateLast(LONG x, LONG y); static inline int Zoomed(int xy) { diff --git a/base/applications/mspaint/globalvar.h b/base/applications/mspaint/globalvar.h index cd427c86b05..a639f620be1 100644 --- a/base/applications/mspaint/globalvar.h +++ b/base/applications/mspaint/globalvar.h @@ -106,5 +106,3 @@ extern CStretchSkewDialog stretchSkewDialog; /* VARIABLES declared in mouse.cpp **********************************/ -extern POINT pointStack[256]; -extern short pointSP; diff --git a/base/applications/mspaint/imgarea.cpp b/base/applications/mspaint/imgarea.cpp index d521b6f065d..69a6de62984 100644 --- a/base/applications/mspaint/imgarea.cpp +++ b/base/applications/mspaint/imgarea.cpp @@ -159,41 +159,43 @@ LRESULT CImgAreaWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO LRESULT CImgAreaWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - if ((!drawing) || (toolsModel.GetActiveTool() == TOOL_COLOR)) - { - SetCapture(); - drawing = TRUE; - startPaintingL(imageModel.GetDC(), UnZoomed(GET_X_LPARAM(lParam)), UnZoomed(GET_Y_LPARAM(lParam)), - paletteModel.GetFgColor(), paletteModel.GetBgColor()); - } - else - { - SendMessage(WM_LBUTTONUP, wParam, lParam); - imageModel.Undo(); - } + drawing = TRUE; + SetCapture(); + INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + toolsModel.OnButtonDown(TRUE, UnZoomed(x), UnZoomed(y), FALSE); + Invalidate(FALSE); + return 0; +} + +LRESULT CImgAreaWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + drawing = FALSE; + ReleaseCapture(); + INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + toolsModel.OnButtonDown(TRUE, UnZoomed(x), UnZoomed(y), TRUE); + toolsModel.resetTool(); Invalidate(FALSE); - if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() < MAX_ZOOM)) - 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) || (toolsModel.GetActiveTool() == TOOL_COLOR)) - { - SetCapture(); - drawing = TRUE; - startPaintingR(imageModel.GetDC(), UnZoomed(GET_X_LPARAM(lParam)), UnZoomed(GET_Y_LPARAM(lParam)), - paletteModel.GetFgColor(), paletteModel.GetBgColor()); - } - else - { - SendMessage(WM_RBUTTONUP, wParam, lParam); - imageModel.Undo(); - } + drawing = TRUE; + SetCapture(); + INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + toolsModel.OnButtonDown(FALSE, UnZoomed(x), UnZoomed(y), FALSE); + Invalidate(FALSE); + return 0; +} + +LRESULT CImgAreaWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + drawing = FALSE; + ReleaseCapture(); + INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + toolsModel.OnButtonDown(FALSE, UnZoomed(x), UnZoomed(y), TRUE); + toolsModel.resetTool(); Invalidate(FALSE); - if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() > MIN_ZOOM)) - zoomTo(toolsModel.GetZoom() / 2, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; } @@ -201,62 +203,27 @@ LRESULT CImgAreaWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO { if (drawing) { - endPaintingL(imageModel.GetDC(), UnZoomed(GET_X_LPARAM(lParam)), UnZoomed(GET_Y_LPARAM(lParam)), paletteModel.GetFgColor(), - paletteModel.GetBgColor()); + drawing = FALSE; + INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + toolsModel.OnButtonUp(TRUE, UnZoomed(x), UnZoomed(y)); Invalidate(FALSE); - if (toolsModel.GetActiveTool() == TOOL_COLOR) - { - COLORREF tempColor = - GetPixel(imageModel.GetDC(), UnZoomed(GET_X_LPARAM(lParam)), UnZoomed(GET_Y_LPARAM(lParam))); - if (tempColor != CLR_INVALID) - paletteModel.SetFgColor(tempColor); - } SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) ""); } - drawing = FALSE; ReleaseCapture(); return 0; } void CImgAreaWindow::cancelDrawing() { - POINT pt; - switch (toolsModel.GetActiveTool()) - { - case TOOL_FREESEL: case TOOL_RECTSEL: - case TOOL_TEXT: case TOOL_ZOOM: case TOOL_SHAPE: - imageModel.ResetToPrevious(); - selectionModel.ResetPtStack(); - pointSP = 0; - Invalidate(FALSE); - break; - default: - GetCursorPos(&pt); - ScreenToClient(&pt); - // FIXME: dirty hack - if (GetKeyState(VK_LBUTTON) < 0) - { - endPaintingL(imageModel.GetDC(), UnZoomed(pt.x), UnZoomed(pt.y), paletteModel.GetFgColor(), - paletteModel.GetBgColor()); - } - else if (GetKeyState(VK_RBUTTON) < 0) - { - endPaintingR(imageModel.GetDC(), UnZoomed(pt.x), UnZoomed(pt.y), paletteModel.GetFgColor(), - paletteModel.GetBgColor()); - } - imageModel.Undo(); - pointSP = 0; - selectionModel.ResetPtStack(); - } + drawing = FALSE; + toolsModel.OnCancelDraw(); + Invalidate(FALSE); } LRESULT CImgAreaWindow::OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { if (drawing) - { cancelDrawing(); - drawing = FALSE; - } return 0; } @@ -270,14 +237,8 @@ LRESULT CImgAreaWindow::OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& } else { - switch (toolsModel.GetActiveTool()) - { - case TOOL_SHAPE: case TOOL_BEZIER: - cancelDrawing(); - break; - default: - break; - } + if (drawing || ToolBase::pointSP != 0) + cancelDrawing(); } } return 0; @@ -287,19 +248,12 @@ LRESULT CImgAreaWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO { if (drawing) { - endPaintingR(imageModel.GetDC(), UnZoomed(GET_X_LPARAM(lParam)), UnZoomed(GET_Y_LPARAM(lParam)), paletteModel.GetFgColor(), - paletteModel.GetBgColor()); + drawing = FALSE; + INT x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam); + toolsModel.OnButtonUp(FALSE, UnZoomed(x), UnZoomed(y)); Invalidate(FALSE); - if (toolsModel.GetActiveTool() == TOOL_COLOR) - { - COLORREF tempColor = - GetPixel(imageModel.GetDC(), UnZoomed(GET_X_LPARAM(lParam)), UnZoomed(GET_Y_LPARAM(lParam))); - if (tempColor != CLR_INVALID) - paletteModel.SetBgColor(tempColor); - } SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) ""); } - drawing = FALSE; ReleaseCapture(); return 0; } @@ -374,9 +328,9 @@ LRESULT CImgAreaWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO default: break; } - if ((wParam & MK_LBUTTON) != 0) + if (wParam & MK_LBUTTON) { - whilePaintingL(imageModel.GetDC(), xNow, yNow, paletteModel.GetFgColor(), paletteModel.GetBgColor()); + toolsModel.OnMouseMove(TRUE, xNow, yNow); Invalidate(FALSE); if ((toolsModel.GetActiveTool() >= TOOL_TEXT) || (toolsModel.GetActiveTool() == TOOL_RECTSEL) || (toolsModel.GetActiveTool() == TOOL_FREESEL)) { @@ -387,9 +341,9 @@ LRESULT CImgAreaWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize); } } - if ((wParam & MK_RBUTTON) != 0) + if (wParam & MK_RBUTTON) { - whilePaintingR(imageModel.GetDC(), xNow, yNow, paletteModel.GetFgColor(), paletteModel.GetBgColor()); + toolsModel.OnMouseMove(FALSE, xNow, yNow); Invalidate(FALSE); if (toolsModel.GetActiveTool() >= TOOL_TEXT) { diff --git a/base/applications/mspaint/imgarea.h b/base/applications/mspaint/imgarea.h index 184076c965a..4c1a41ec27c 100644 --- a/base/applications/mspaint/imgarea.h +++ b/base/applications/mspaint/imgarea.h @@ -13,6 +13,10 @@ class CImgAreaWindow : public CWindowImpl<CMainWindow> { public: + CImgAreaWindow() : drawing(FALSE) + { + } + DECLARE_WND_CLASS_EX(_T("ImgAreaWindow"), CS_DBLCLKS, COLOR_BTNFACE) BEGIN_MSG_MAP(CImgAreaWindow) @@ -20,7 +24,9 @@ public: MESSAGE_HANDLER(WM_PAINT, OnPaint) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) + MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk) MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown) + MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk) MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp) MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) @@ -39,7 +45,9 @@ private: LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); diff --git a/base/applications/mspaint/mouse.cpp b/base/applications/mspaint/mouse.cpp index 0720a9fde56..e5b50b617ad 100644 --- a/base/applications/mspaint/mouse.cpp +++ b/base/applications/mspaint/mouse.cpp @@ -11,6 +11,9 @@ #include "precomp.h" +INT ToolBase::pointSP = 0; +POINT ToolBase::pointStack[256] = { { 0 } }; + /* FUNCTIONS ********************************************************/ void @@ -58,512 +61,583 @@ BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1) return (abs(x1 - x0) <= cxThreshold) && (abs(y1 - y0) <= cyThreshold); } -POINT pointStack[256]; -short pointSP; +void updateStartAndLast(LONG x, LONG y) +{ + start.x = last.x = x; + start.y = last.y = y; +} -void -startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) +void updateLast(LONG x, LONG y) { - start.x = x; - start.y = y; last.x = x; last.y = y; - switch (toolsModel.GetActiveTool()) +} + +void ToolBase::reset() +{ + pointSP = 0; +} + +void ToolBase::OnCancelDraw() +{ + reset(); +} + +void ToolBase::beginEvent() +{ + m_hdc = imageModel.GetDC(); + m_fg = paletteModel.GetFgColor(); + m_bg = paletteModel.GetBgColor(); +} + +void ToolBase::endEvent() +{ + m_hdc = NULL; +} + +/* TOOLS ********************************************************/ + +// TOOL_FREESEL +struct FreeSelTool : ToolBase +{ + FreeSelTool() : ToolBase(TOOL_FREESEL) { - case TOOL_FREESEL: - selectionWindow.ShowWindow(SW_HIDE); - selectionModel.ResetPtStack(); - selectionModel.PushToPtStack(x, y); - break; - case TOOL_LINE: - case TOOL_RECT: - case TOOL_ELLIPSE: - case TOOL_RRECT: + } + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + imageModel.CopyPrevious(); + selectionWindow.ShowWindow(SW_HIDE); + selectionModel.ResetPtStack(); + selectionModel.PushToPtStack(x, y); + } + + void OnMouseMove(BOOL bLeftButton, LONG x, LONG y) + { + if (selectionModel.PtStackSize() == 1) imageModel.CopyPrevious(); - break; - case TOOL_RECTSEL: - case TOOL_TEXT: + selectionModel.PushToPtStack(max(0, min(x, imageModel.GetWidth())), max(0, min(y, imageModel.GetHeight()))); + imageModel.ResetToPrevious(); + selectionModel.DrawFramePoly(m_hdc); + } + + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) + { + selectionModel.CalculateBoundingBoxAndContents(m_hdc); + if (selectionModel.PtStackSize() > 1) + { + selectionModel.DrawBackgroundPoly(m_hdc, m_bg); + imageModel.CopyPrevious(); + + selectionModel.DrawSelection(m_hdc); + + placeSelWin(); + selectionWindow.ShowWindow(SW_SHOW); + ForceRefreshSelectionContents(); + } + selectionModel.ResetPtStack(); + } + + void OnCancelDraw() + { + imageModel.ResetToPrevious(); + selectionModel.ResetPtStack(); + ToolBase::OnCancelDraw(); + } +}; + +// TOOL_RECTSEL +struct RectSelTool : ToolBase +{ + RectSelTool() : ToolBase(TOOL_RECTSEL) + { + } + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + imageModel.CopyPrevious(); + if (bLeftButton) + { imageModel.CopyPrevious(); selectionWindow.ShowWindow(SW_HIDE); selectionModel.SetSrcRectSizeToZero(); - break; - case TOOL_RUBBER: - imageModel.CopyPrevious(); - Erase(hdc, x, y, x, y, bg, toolsModel.GetRubberRadius()); - break; - case TOOL_FILL: - imageModel.CopyPrevious(); - Fill(hdc, x, y, fg); - break; - case TOOL_PEN: - imageModel.CopyPrevious(); - SetPixel(hdc, x, y, fg); - break; - case TOOL_BRUSH: - imageModel.CopyPrevious(); - Brush(hdc, x, y, x, y, fg, toolsModel.GetBrushStyle()); - break; - case TOOL_AIRBRUSH: - imageModel.CopyPrevious(); - Airbrush(hdc, x, y, fg, toolsModel.GetAirBrushWidth()); - break; - case TOOL_BEZIER: - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - if (pointSP == 0) - { - imageModel.CopyPrevious(); - pointSP++; - } - break; - case TOOL_SHAPE: - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - if (pointSP + 1 >= 2) - Poly(hdc, pointStack, pointSP + 1, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), FALSE, FALSE); - if (pointSP == 0) - { - imageModel.CopyPrevious(); - pointSP++; - } - break; - case TOOL_COLOR: - case TOOL_ZOOM: - break; + } } -} -void -whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) -{ - switch (toolsModel.GetActiveTool()) + void OnMouseMove(BOOL bLeftButton, LONG x, LONG y) { - case TOOL_FREESEL: - if (selectionModel.PtStackSize() == 1) - imageModel.CopyPrevious(); - selectionModel.PushToPtStack(max(0, min(x, imageModel.GetWidth())), max(0, min(y, imageModel.GetHeight()))); - imageModel.ResetToPrevious(); - selectionModel.DrawFramePoly(hdc); - break; - case TOOL_RECTSEL: - case TOOL_TEXT: + POINT temp; + if (bLeftButton) { - POINT temp; imageModel.ResetToPrevious(); temp.x = max(0, min(x, imageModel.GetWidth())); temp.y = max(0, min(y, imageModel.GetHeight())); selectionModel.SetSrcAndDestRectFromPoints(start, temp); - RectSel(hdc, start.x, start.y, temp.x, temp.y); - break; + RectSel(m_hdc, start.x, start.y, temp.x, temp.y); } - case TOOL_RUBBER: - 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, toolsModel.GetBrushStyle()); - break; - case TOOL_AIRBRUSH: - Airbrush(hdc, x, y, fg, toolsModel.GetAirBrushWidth()); - break; - case TOOL_LINE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - roundTo8Directions(start.x, start.y, x, y); - Line(hdc, start.x, start.y, x, y, fg, toolsModel.GetLineWidth()); - break; - case TOOL_BEZIER: - imageModel.ResetToPrevious(); - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - switch (pointSP) - { - case 1: - Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, fg, - toolsModel.GetLineWidth()); - break; - case 2: - 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, toolsModel.GetLineWidth()); - break; - } - break; - case TOOL_RECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Rect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_SHAPE: - imageModel.ResetToPrevious(); - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) - 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, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), FALSE, FALSE); - break; - case TOOL_ELLIPSE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Ellp(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_RRECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - RRect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_FILL: - case TOOL_COLOR: - case TOOL_ZOOM: - break; } - last.x = x; - last.y = y; -} - -void -endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) -{ - switch (toolsModel.GetActiveTool()) + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) { - case TOOL_FREESEL: + if (bLeftButton) { - selectionModel.CalculateBoundingBoxAndContents(hdc); - if (selectionModel.PtStackSize() > 1) + imageModel.ResetToPrevious(); + if (selectionModel.IsSrcRectSizeNonzero()) { - selectionModel.DrawBackgroundPoly(hdc, bg); + selectionModel.CalculateContents(m_hdc); + selectionModel.DrawBackgroundRect(m_hdc, m_bg); imageModel.CopyPrevious(); - selectionModel.DrawSelection(hdc); + selectionModel.DrawSelection(m_hdc); placeSelWin(); selectionWindow.ShowWindow(SW_SHOW); ForceRefreshSelectionContents(); } - selectionModel.ResetPtStack(); - break; } - case TOOL_RECTSEL: - imageModel.ResetToPrevious(); - if (selectionModel.IsSrcRectSizeNonzero()) - { - selectionModel.CalculateContents(hdc); - selectionModel.DrawBackgroundRect(hdc, bg); - imageModel.CopyPrevious(); + } - selectionModel.DrawSelection(hdc); + void OnCancelDraw() + { + imageModel.ResetToPrevious(); + selectionModel.ResetPtStack(); + ToolBase::OnCancelDraw(); + } +}; - placeSelWin(); - selectionWindow.ShowWindow(SW_SHOW); - ForceRefreshSelectionContents(); - } - break; - case TOOL_TEXT: - imageModel.ResetToPrevious(); - if (selectionModel.IsSrcRectSizeNonzero()) - { - imageModel.CopyPrevious(); +struct GenericDrawTool : ToolBase +{ + GenericDrawTool(TOOLTYPE type) : ToolBase(type) + { + } - placeSelWin(); - selectionWindow.ShowWindow(SW_SHOW); - ForceRefreshSelectionContents(); - } - break; - case TOOL_RUBBER: - 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); - SetPixel(hdc, x, y, fg); - break; - case TOOL_LINE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - roundTo8Directions(start.x, start.y, x, y); - Line(hdc, start.x, start.y, x, y, fg, toolsModel.GetLineWidth()); - break; - case TOOL_BEZIER: - pointSP++; - if (pointSP == 4) - pointSP = 0; - break; - case TOOL_RECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Rect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_SHAPE: - imageModel.ResetToPrevious(); - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) - roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, - pointStack[pointSP].x, pointStack[pointSP].y); - pointSP++; - if (pointSP >= 2) - { - if (nearlyEqualPoints(x, y, pointStack[0].x, pointStack[0].y)) - { - Poly(hdc, pointStack, pointSP, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), TRUE, FALSE); - pointSP = 0; - } - else - { - Poly(hdc, pointStack, pointSP, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), FALSE, FALSE); - } - } - if (pointSP == 255) - pointSP--; - break; - case TOOL_ELLIPSE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Ellp(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_RRECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - RRect(hdc, start.x, start.y, x, y, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_FILL: - case TOOL_COLOR: - case TOOL_ZOOM: - case TOOL_BRUSH: - case TOOL_AIRBRUSH: - break; + virtual void draw(BOOL bLeftButton, LONG x, LONG y) = 0; + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + imageModel.CopyPrevious(); + draw(bLeftButton, x, y); } -} -void -startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) + void OnMouseMove(BOOL bLeftButton, LONG x, LONG y) + { + draw(bLeftButton, x, y); + } + + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) + { + draw(bLeftButton, x, y); + } + + void OnCancelDraw() + { + OnButtonUp(FALSE, 0, 0); + imageModel.Undo(); + selectionModel.ResetPtStack(); + ToolBase::OnCancelDraw(); + } +}; + +// TOOL_RUBBER +struct RubberTool : GenericDrawTool { - start.x = x; - start.y = y; - last.x = x; - last.y = y; - switch (toolsModel.GetActiveTool()) - { - case TOOL_FREESEL: - case TOOL_TEXT: - case TOOL_LINE: - case TOOL_RECT: - case TOOL_ELLIPSE: - case TOOL_RRECT: - imageModel.CopyPrevious(); - break; - case TOOL_RUBBER: - imageModel.CopyPrevious(); - Replace(hdc, x, y, x, y, fg, bg, toolsModel.GetRubberRadius()); - break; - case TOOL_FILL: - imageModel.CopyPrevious(); - Fill(hdc, x, y, bg); - break; - case TOOL_PEN: - imageModel.CopyPrevious(); - SetPixel(hdc, x, y, bg); - break; - case TOOL_BRUSH: + RubberTool() : GenericDrawTool(TOOL_RUBBER) + { + } + + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + if (bLeftButton) + Erase(m_hdc, last.x, last.y, x, y, m_bg, toolsModel.GetRubberRadius()); + else + Replace(m_hdc, last.x, last.y, x, y, m_fg, m_bg, toolsModel.GetRubberRadius()); + } +}; + +// TOOL_FILL +struct FillTool : ToolBase +{ + FillTool() : ToolBase(TOOL_FILL) + { + } + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + imageModel.CopyPrevious(); + Fill(m_hdc, x, y, bLeftButton ? m_fg : m_bg); + } +}; + +// TOOL_COLOR +struct ColorTool : ToolBase +{ + ColorTool() : ToolBase(TOOL_COLOR) + { + } + + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) + { + COLORREF tempColor; + + if (0 <= x && x < imageModel.GetWidth() && 0 <= y && y < imageModel.GetHeight()) + tempColor = GetPixel(m_hdc, x, y); + else + tempColor = RGB(255, 255, 255); // Outside is white + + if (bLeftButton) + paletteModel.SetFgColor(tempColor); + else + paletteModel.SetBgColor(tempColor); + + toolsModel.SetActiveTool(toolsModel.GetOldActiveTool()); + } +}; + +// TOOL_ZOOM +struct ZoomTool : ToolBase +{ + ZoomTool() : ToolBase(TOOL_ZOOM) + { + } + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + imageModel.CopyPrevious(); + if (bLeftButton) + { + if (toolsModel.GetZoom() < MAX_ZOOM) + zoomTo(toolsModel.GetZoom() * 2, x, y); + } + else + { + if (toolsModel.GetZoom() > MIN_ZOOM) + zoomTo(toolsModel.GetZoom() / 2, x, y); + } + } +}; + +// TOOL_PEN +struct PenTool : GenericDrawTool +{ + PenTool() : GenericDrawTool(TOOL_PEN) + { + } + + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + COLORREF rgb = bLeftButton ? m_fg : m_bg; + Line(m_hdc, last.x, last.y, x, y, rgb, 1); + SetPixel(m_hdc, x, y, rgb); + } +}; + +// TOOL_BRUSH +struct BrushTool : GenericDrawTool +{ + BrushTool() : GenericDrawTool(TOOL_BRUSH) + { + } + + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + COLORREF rgb = bLeftButton ? m_fg : m_bg; + Brush(m_hdc, last.x, last.y, x, y, rgb, toolsModel.GetBrushStyle()); + } +}; + +// TOOL_AIRBRUSH +struct AirBrushTool : GenericDrawTool +{ + AirBrushTool() : GenericDrawTool(TOOL_AIRBRUSH) + { + } + + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + COLORREF rgb = bLeftButton ? m_fg : m_bg; + Airbrush(m_hdc, x, y, rgb, toolsModel.GetAirBrushWidth()); + } +}; + +// TOOL_TEXT +struct TextTool : ToolBase +{ + TextTool() : ToolBase(TOOL_TEXT) + { + } + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + imageModel.CopyPrevious(); + } + + void OnMouseMove(BOOL bLeftButton, LONG x, LONG y) + { + POINT temp; + imageModel.ResetToPrevious(); + temp.x = max(0, min(x, imageModel.GetWidth())); + temp.y = max(0, min(y, imageModel.GetHeight())); + selectionModel.SetSrcAndDestRectFromPoints(start, temp); + RectSel(m_hdc, start.x, start.y, temp.x, temp.y); + } + + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + if (selectionModel.IsSrcRectSizeNonzero()) + { imageModel.CopyPrevious(); - Brush(hdc, x, y, x, y, bg, toolsModel.GetBrushStyle()); - break; - case TOOL_AIRBRUSH: + + placeSelWin(); + selectionWindow.ShowWindow(SW_SHOW); + ForceRefreshSelectionContents(); + } + } + + void OnCancelDraw() + { + imageModel.ResetToPrevious(); + selectionModel.ResetPtStack(); + ToolBase::OnCancelDraw(); + } +}; + +// TOOL_LINE +struct LineTool : GenericDrawTool +{ + LineTool() : GenericDrawTool(TOOL_LINE) + { + } + + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + if (GetAsyncKeyState(VK_SHIFT) < 0) + roundTo8Directions(start.x, start.y, x, y); + COLORREF rgb = bLeftButton ? m_fg : m_bg; + Line(m_hdc, start.x, start.y, x, y, rgb, toolsModel.GetLineWidth()); + } +}; + +// TOOL_BEZIER +struct BezierTool : ToolBase +{ + BezierTool() : ToolBase(TOOL_BEZIER) + { + } + + void draw(BOOL bLeftButton) + { + COLORREF rgb = (bLeftButton ? m_fg : m_bg); + switch (pointSP) + { + case 1: + Line(m_hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, rgb, + toolsModel.GetLineWidth()); + break; + case 2: + Bezier(m_hdc, pointStack[0], pointStack[2], pointStack[2], pointStack[1], rgb, toolsModel.GetLineWidth()); + break; + case 3: + Bezier(m_hdc, pointStack[0], pointStack[2], pointStack[3], pointStack[1], rgb, toolsModel.GetLineWidth()); + break; + } + } + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + pointStack[pointSP].x = x; + pointStack[pointSP].y = y; + + if (pointSP == 0) + { imageModel.CopyPrevious(); - Airbrush(hdc, x, y, bg, toolsModel.GetAirBrushWidth()); - break; - case TOOL_BEZIER: - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - if (pointSP == 0) - { - imageModel.CopyPrevious(); - pointSP++; - } - break; - case TOOL_SHAPE: - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - if (pointSP + 1 >= 2) - Poly(hdc, pointStack, pointSP + 1, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), FALSE, FALSE); - if (pointSP == 0) - { - imageModel.CopyPrevious(); - pointSP++; - } - break; - case TOOL_RECTSEL: - case TOOL_COLOR: - case TOOL_ZOOM: - break; + pointSP++; + } } -} -void -whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) + void OnMouseMove(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + pointStack[pointSP].x = x; + pointStack[pointSP].y = y; + draw(bLeftButton); + } + + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + draw(bLeftButton); + pointSP++; + if (pointSP == 4) + pointSP = 0; + } + + void OnCancelDraw() + { + OnButtonUp(FALSE, 0, 0); + imageModel.Undo(); + selectionModel.ResetPtStack(); + ToolBase::OnCancelDraw(); + } +}; + +// TOOL_RECT +struct RectTool : GenericDrawTool { - switch (toolsModel.GetActiveTool()) - { - case TOOL_RUBBER: - 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, toolsModel.GetBrushStyle()); - break; - case TOOL_AIRBRUSH: - Airbrush(hdc, x, y, bg, toolsModel.GetAirBrushWidth()); - break; - case TOOL_LINE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - roundTo8Directions(start.x, start.y, x, y); - Line(hdc, start.x, start.y, x, y, bg, toolsModel.GetLineWidth()); - break; - case TOOL_BEZIER: - imageModel.ResetToPrevious(); - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - switch (pointSP) - { - case 1: - Line(hdc, pointStack[0].x, pointStack[0].y, pointStack[1].x, pointStack[1].y, bg, - toolsModel.GetLineWidth()); - break; - case 2: - 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, toolsModel.GetLineWidth()); - break; - } - break; - case TOOL_RECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Rect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_SHAPE: - imageModel.ResetToPrevious(); - pointStack[pointSP].x = x; - pointStack[pointSP].y = y; - if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) - 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, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), FALSE, FALSE); - break; - case TOOL_ELLIPSE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Ellp(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_RRECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - RRect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_FREESEL: - case TOOL_RECTSEL: - case TOOL_FILL: - case TOOL_COLOR: - case TOOL_ZOOM: - case TOOL_TEXT: - break; + RectTool() : GenericDrawTool(TOOL_RECT) + { } - last.x = x; - last.y = y; -} + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + if (GetAsyncKeyState(VK_SHIFT) < 0) + regularize(start.x, start.y, x, y); + if (bLeftButton) + Rect(m_hdc, start.x, start.y, x, y, m_fg, m_bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); + else + Rect(m_hdc, start.x, start.y, x, y, m_bg, m_fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); + } +}; -void -endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) +// TOOL_SHAPE +struct ShapeTool : ToolBase { - switch (toolsModel.GetActiveTool()) - { - case TOOL_RUBBER: - 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); - SetPixel(hdc, x, y, bg); - break; - case TOOL_LINE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - roundTo8Directions(start.x, start.y, x, y); - Line(hdc, start.x, start.y, x, y, bg, toolsModel.GetLineWidth()); - break; - case TOOL_BEZIER: + ShapeTool() : ToolBase(TOOL_SHAPE) + { + } + + void draw(BOOL bLeftButton, LONG x, LONG y, BOOL bClosed = FALSE) + { + if (pointSP + 1 >= 2) + { + if (bLeftButton) + Poly(m_hdc, pointStack, pointSP + 1, m_fg, m_bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), bClosed, FALSE); + else + Poly(m_hdc, pointStack, pointSP + 1, m_bg, m_fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), bClosed, FALSE); + } + } + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + pointStack[pointSP].x = x; + pointStack[pointSP].y = y; + + if (pointSP == 0 && !bDoubleClick) + { + imageModel.CopyPrevious(); + draw(bLeftButton, x, y); + pointSP++; + } + else + { + draw(bLeftButton, x, y, bDoubleClick); + } + } + + void OnMouseMove(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + pointStack[pointSP].x = x; + pointStack[pointSP].y = y; + if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) + roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, x, y); + draw(bLeftButton, x, y, FALSE); + } + + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) + roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, x, y); + + if (nearlyEqualPoints(x, y, pointStack[0].x, pointStack[0].y)) + { + pointSP--; + draw(bLeftButton, x, y, TRUE); + pointSP = 0; + } + else + { pointSP++; - if (pointSP == 4) - pointSP = 0; - break; - case TOOL_RECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Rect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_SHAPE: - imageModel.ResetToPrevious(); pointStack[pointSP].x = x; pointStack[pointSP].y = y; - if ((pointSP > 0) && (GetAsyncKeyState(VK_SHIFT) < 0)) - roundTo8Directions(pointStack[pointSP - 1].x, pointStack[pointSP - 1].y, - pointStack[pointSP].x, pointStack[pointSP].y); - pointSP++; - if (pointSP >= 2) - { - if (nearlyEqualPoints(x, y, pointStack[0].x, pointStack[0].y)) - { - Poly(hdc, pointStack, pointSP, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), TRUE, FALSE); - pointSP = 0; - } - else - { - Poly(hdc, pointStack, pointSP, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), FALSE, FALSE); - } - } - if (pointSP == 255) - pointSP--; - break; - case TOOL_ELLIPSE: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - Ellp(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_RRECT: - imageModel.ResetToPrevious(); - if (GetAsyncKeyState(VK_SHIFT) < 0) - regularize(start.x, start.y, x, y); - RRect(hdc, start.x, start.y, x, y, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); - break; - case TOOL_FREESEL: - case TOOL_RECTSEL: - case TOOL_FILL: - case TOOL_COLOR: - case TOOL_ZOOM: - case TOOL_BRUSH: - case TOOL_AIRBRUSH: - case TOOL_TEXT: - break; + draw(bLeftButton, x, y, FALSE); + } + + if (pointSP == _countof(pointStack)) + pointSP--; + } + + void OnCancelDraw() + { + imageModel.ResetToPrevious(); + selectionModel.ResetPtStack(); + ToolBase::OnCancelDraw(); + } +}; + +// TOOL_ELLIPSE +struct EllipseTool : GenericDrawTool +{ + EllipseTool() : GenericDrawTool(TOOL_ELLIPSE) + { + } + + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + if (GetAsyncKeyState(VK_SHIFT) < 0) + regularize(start.x, start.y, x, y); + if (bLeftButton) + Ellp(m_hdc, start.x, start.y, x, y, m_fg, m_bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); + else + Ellp(m_hdc, start.x, start.y, x, y, m_bg, m_fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); + } +}; + +// TOOL_RRECT +struct RRectTool : GenericDrawTool +{ + RRectTool() : GenericDrawTool(TOOL_RRECT) + { + } + + virtual void draw(BOOL bLeftButton, LONG x, LONG y) + { + imageModel.ResetToPrevious(); + if (GetAsyncKeyState(VK_SHIFT) < 0) + regularize(start.x, start.y, x, y); + if (bLeftButton) + RRect(m_hdc, start.x, start.y, x, y, m_fg, m_bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); + else + RRect(m_hdc, start.x, start.y, x, y, m_bg, m_fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle()); + } +}; + +/*static*/ ToolBase* +ToolBase::createToolObject(TOOLTYPE type) +{ + switch (type) + { + case TOOL_FREESEL: return new FreeSelTool(); + case TOOL_RECTSEL: return new RectSelTool(); + case TOOL_RUBBER: return new RubberTool(); + case TOOL_FILL: return new FillTool(); + case TOOL_COLOR: return new ColorTool(); + case TOOL_ZOOM: return new ZoomTool(); + case TOOL_PEN: return new PenTool(); + case TOOL_BRUSH: return new BrushTool(); + case TOOL_AIRBRUSH: return new AirBrushTool(); + case TOOL_TEXT: return new TextTool(); + case TOOL_LINE: return new LineTool(); + case TOOL_BEZIER: return new BezierTool(); + case TOOL_RECT: return new RectTool(); + case TOOL_SHAPE: return new ShapeTool(); + case TOOL_ELLIPSE: return new EllipseTool(); + case TOOL_RRECT: return new RRectTool(); } + UNREACHABLE; + return NULL; } diff --git a/base/applications/mspaint/mouse.h b/base/applications/mspaint/mouse.h deleted file mode 100644 index 59f13fd7425..00000000000 --- a/base/applications/mspaint/mouse.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * PROJECT: PAINT for ReactOS - * LICENSE: LGPL - * FILE: base/applications/mspaint/mouse.h - * PURPOSE: Things which should not be in the mouse event handler itself - * PROGRAMMERS: Benedikt Freisen - */ - -#pragma once - -void placeSelWin(void); - -void startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg); - -void whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg); - -void endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg); - -void startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg); - -void whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg); - -void endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg); diff --git a/base/applications/mspaint/precomp.h b/base/applications/mspaint/precomp.h index d51eafa85e6..5b5bfa8279d 100644 --- a/base/applications/mspaint/precomp.h +++ b/base/applications/mspaint/precomp.h @@ -38,7 +38,6 @@ #include "history.h" #include "imgarea.h" #include "miniature.h" -#include "mouse.h" #include "palette.h" #include "palettemodel.h" #include "registry.h" diff --git a/base/applications/mspaint/scrollbox.cpp b/base/applications/mspaint/scrollbox.cpp index 32f48e6d490..d2be15f8f18 100644 --- a/base/applications/mspaint/scrollbox.cpp +++ b/base/applications/mspaint/scrollbox.cpp @@ -176,7 +176,23 @@ LRESULT CScrollboxWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO LRESULT CScrollboxWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { selectionWindow.ShowWindow(SW_HIDE); - pointSP = 0; // resets the point-buffer of the polygon and bezier functions + + switch (toolsModel.GetActiveTool()) + { + case TOOL_BEZIER: + case TOOL_SHAPE: + if (ToolBase::pointSP != 0) + { + toolsModel.OnCancelDraw(); + imageArea.Invalidate(); + } + break; + + default: + break; + } + + toolsModel.resetTool(); // resets the point-buffer of the polygon and bezier functions return 0; } diff --git a/base/applications/mspaint/toolbox.cpp b/base/applications/mspaint/toolbox.cpp index 7e0a3aeeafd..d11917b5cac 100644 --- a/base/applications/mspaint/toolbox.cpp +++ b/base/applications/mspaint/toolbox.cpp @@ -71,58 +71,42 @@ LRESULT CToolBox::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL return 0; } +struct COMMAND_TO_TOOL +{ + UINT id; + TOOLTYPE tool; +}; + +static const COMMAND_TO_TOOL CommandToToolMapping[] = +{ + { ID_FREESEL, TOOL_FREESEL }, + { ID_RECTSEL, TOOL_RECTSEL }, + { ID_RUBBER, TOOL_RUBBER }, + { ID_FILL, TOOL_FILL }, + { ID_COLOR, TOOL_COLOR }, + { ID_ZOOM, TOOL_ZOOM }, + { ID_PEN, TOOL_PEN }, + { ID_BRUSH, TOOL_BRUSH }, + { ID_AIRBRUSH, TOOL_AIRBRUSH }, + { ID_TEXT, TOOL_TEXT }, + { ID_LINE, TOOL_LINE }, + { ID_BEZIER, TOOL_BEZIER }, + { ID_RECT, TOOL_RECT }, + { ID_SHAPE, TOOL_SHAPE }, + { ID_ELLIPSE, TOOL_ELLIPSE }, + { ID_RRECT, TOOL_RRECT }, +}; + LRESULT CToolBox::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - switch (LOWORD(wParam)) + UINT id = LOWORD(wParam); + for (size_t i = 0; i < _countof(CommandToToolMapping); ++i) { - case ID_FREESEL: - toolsModel.SetActiveTool(TOOL_FREESEL); - break; - case ID_RECTSEL: - toolsModel.SetActiveTool(TOOL_RECTSEL); - break; - case ID_RUBBER: - toolsModel.SetActiveTool(TOOL_RUBBER); - break; - case ID_FILL: - toolsModel.SetActiveTool(TOOL_FILL); - break; - case ID_COLOR: - toolsModel.SetActiveTool(TOOL_COLOR); - break; - case ID_ZOOM: - toolsModel.SetActiveTool(TOOL_ZOOM); - break; - case ID_PEN: - toolsModel.SetActiveTool(TOOL_PEN); - break; - case ID_BRUSH: - toolsModel.SetActiveTool(TOOL_BRUSH); - break; - case ID_AIRBRUSH: - toolsModel.SetActiveTool(TOOL_AIRBRUSH); - break; - case ID_TEXT: - toolsModel.SetActiveTool(TOOL_TEXT); - break; - case ID_LINE: - toolsModel.SetActiveTool(TOOL_LINE); - break; - case ID_BEZIER: - toolsModel.SetActiveTool(TOOL_BEZIER); - break; - case ID_RECT: - toolsModel.SetActiveTool(TOOL_RECT); - break; - case ID_SHAPE: - toolsModel.SetActiveTool(TOOL_SHAPE); - break; - case ID_ELLIPSE: - toolsModel.SetActiveTool(TOOL_ELLIPSE); - break; - case ID_RRECT: - toolsModel.SetActiveTool(TOOL_RRECT); + if (CommandToToolMapping[i].id == id) + { + toolsModel.SetActiveTool(CommandToToolMapping[i].tool); break; + } } return 0; } @@ -130,6 +114,18 @@ LRESULT CToolBox::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHand 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 + toolsModel.resetTool(); // resets the point-buffer of the polygon and bezier functions + + // Check the toolbar button + TOOLTYPE tool = toolsModel.GetActiveTool(); + for (size_t i = 0; i < _countof(CommandToToolMapping); ++i) + { + if (CommandToToolMapping[i].tool == tool) + { + toolbar.SendMessage(TB_CHECKBUTTON, CommandToToolMapping[i].id, TRUE); + break; + } + } + return 0; } diff --git a/base/applications/mspaint/toolsmodel.cpp b/base/applications/mspaint/toolsmodel.cpp index a0ceaeff1ef..bedf12d4e9a 100644 --- a/base/applications/mspaint/toolsmodel.cpp +++ b/base/applications/mspaint/toolsmodel.cpp @@ -17,11 +17,27 @@ ToolsModel::ToolsModel() m_lineWidth = 1; m_shapeStyle = 0; m_brushStyle = 0; - m_activeTool = TOOL_PEN; + m_oldActiveTool = m_activeTool = TOOL_PEN; m_airBrushWidth = 5; m_rubberRadius = 4; m_transpBg = FALSE; m_zoom = 1000; + ZeroMemory(&m_tools, sizeof(m_tools)); + m_pToolObject = GetOrCreateTool(m_activeTool); +} + +ToolsModel::~ToolsModel() +{ + for (size_t i = 0; i < TOOL_MAX + 1; ++i) + delete m_tools[i]; +} + +ToolBase *ToolsModel::GetOrCreateTool(TOOLTYPE nTool) +{ + if (!m_tools[nTool]) + m_tools[nTool] = ToolBase::createToolObject(nTool); + + return m_tools[nTool]; } int ToolsModel::GetLineWidth() const @@ -62,9 +78,29 @@ TOOLTYPE ToolsModel::GetActiveTool() const return m_activeTool; } +TOOLTYPE ToolsModel::GetOldActiveTool() const +{ + return m_oldActiveTool; +} + void ToolsModel::SetActiveTool(TOOLTYPE nActiveTool) { + switch (m_activeTool) + { + case TOOL_FREESEL: + case TOOL_RECTSEL: + case TOOL_RUBBER: + case TOOL_COLOR: + case TOOL_ZOOM: + case TOOL_TEXT: + break; + default: + m_oldActiveTool = m_activeTool; + break; + } + m_activeTool = nActiveTool; + m_pToolObject = GetOrCreateTool(m_activeTool); NotifyToolChanged(); } @@ -129,3 +165,47 @@ void ToolsModel::NotifyZoomChanged() { toolSettingsWindow.SendMessage(WM_TOOLSMODELZOOMCHANGED); } + +void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) +{ + m_pToolObject->beginEvent(); + updateStartAndLast(x, y); + m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick); + m_pToolObject->endEvent(); +} + +void ToolsModel::OnMouseMove(BOOL bLeftButton, LONG x, LONG y) +{ + m_pToolObject->beginEvent(); + m_pToolObject->OnMouseMove(bLeftButton, x, y); + updateLast(x, y); + m_pToolObject->endEvent(); +} + +void ToolsModel::OnButtonUp(BOOL bLeftButton, LONG x, LONG y) +{ + m_pToolObject->beginEvent(); + m_pToolObject->OnButtonUp(bLeftButton, x, y); + updateLast(x, y); + m_pToolObject->endEvent(); +} + +void ToolsModel::OnCancelDraw() +{ + m_pToolObject->beginEvent(); + m_pToolObject->OnCancelDraw(); + m_pToolObject->endEvent(); +} + +void ToolsModel::resetTool() +{ + m_pToolObject->reset(); +} + +void ToolsModel::selectAll() +{ + SetActiveTool(TOOL_RECTSEL); + OnButtonDown(TRUE, 0, 0, FALSE); + OnMouseMove(TRUE, imageModel.GetWidth(), imageModel.GetHeight()); + OnButtonUp(TRUE, imageModel.GetWidth(), imageModel.GetHeight()); +} diff --git a/base/applications/mspaint/toolsmodel.h b/base/applications/mspaint/toolsmodel.h index 0fff204d626..b8a70dce4a7 100644 --- a/base/applications/mspaint/toolsmodel.h +++ b/base/applications/mspaint/toolsmodel.h @@ -26,10 +26,48 @@ enum TOOLTYPE TOOL_SHAPE = 14, TOOL_ELLIPSE = 15, TOOL_RRECT = 16, + TOOL_MAX = TOOL_RRECT, }; /* CLASSES **********************************************************/ +struct ToolBase +{ + TOOLTYPE m_tool; + HDC m_hdc; + COLORREF m_fg, m_bg; + static INT pointSP; + static POINT pointStack[256]; + + ToolBase(TOOLTYPE tool) : m_tool(tool), m_hdc(NULL) + { + } + + virtual ~ToolBase() + { + } + + virtual void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) + { + } + + virtual void OnMouseMove(BOOL bLeftButton, LONG x, LONG y) + { + } + + virtual void OnButtonUp(BOOL bLeftButton, LONG x, LONG y) + { + } + + virtual void OnCancelDraw(); + + void beginEvent(); + void endEvent(); + void reset(); + + static ToolBase* createToolObject(TOOLTYPE type); +}; + class ToolsModel { private: @@ -37,10 +75,15 @@ private: int m_shapeStyle; int m_brushStyle; TOOLTYPE m_activeTool; + TOOLTYPE m_oldActiveTool; int m_airBrushWidth; int m_rubberRadius; BOOL m_transpBg; int m_zoom; + ToolBase* m_tools[TOOL_MAX + 1]; + ToolBase *m_pToolObject; + + ToolBase *GetOrCreateTool(TOOLTYPE nTool); void NotifyToolChanged(); void NotifyToolSettingsChanged(); @@ -48,6 +91,7 @@ private: public: ToolsModel(); + ~ToolsModel(); int GetLineWidth() const; void SetLineWidth(int nLineWidth); int GetShapeStyle() const; @@ -55,6 +99,7 @@ public: int GetBrushStyle() const; void SetBrushStyle(int nBrushStyle); TOOLTYPE GetActiveTool() const; + TOOLTYPE GetOldActiveTool() const; void SetActiveTool(TOOLTYPE nActiveTool); int GetAirBrushWidth() const; void SetAirBrushWidth(int nAirBrushWidth); @@ -64,4 +109,12 @@ public: void SetBackgroundTransparent(BOOL bTransparent); int GetZoom() const; void SetZoom(int nZoom); + + void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick); + void OnMouseMove(BOOL bLeftButton, LONG x, LONG y); + void OnButtonUp(BOOL bLeftButton, LONG x, LONG y); + void OnCancelDraw(); + + void resetTool(); + void selectAll(); }; diff --git a/base/applications/mspaint/winproc.cpp b/base/applications/mspaint/winproc.cpp index 4ccc7be0cdb..643a914309c 100644 --- a/base/applications/mspaint/winproc.cpp +++ b/base/applications/mspaint/winproc.cpp @@ -559,11 +559,8 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH { HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL); SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0)); - toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL); - //TODO: do this properly - startPaintingL(imageModel.GetDC(), 0, 0, paletteModel.GetFgColor(), paletteModel.GetBgColor()); - whilePaintingL(imageModel.GetDC(), imageModel.GetWidth(), imageModel.GetHeight(), paletteModel.GetFgColor(), paletteModel.GetBgColor()); - endPaintingL(imageModel.GetDC(), imageModel.GetWidth(), imageModel.GetHeight(), paletteModel.GetFgColor(), paletteModel.GetBgColor()); + toolsModel.selectAll(); + imageArea.Invalidate(TRUE); break; } case IDM_EDITCOPYTO:
2 years, 11 months
1
0
0
0
[reactos] 01/01: [BCRYPT] Add ECDSA P256 to known algorithms
by Thomas Csovcsity
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e0a47b7b5ffc7d8dd5b88…
commit e0a47b7b5ffc7d8dd5b883875200b56cec8ef923 Author: Thomas Csovcsity <thc.fr13nd(a)gmail.com> AuthorDate: Thu Dec 30 21:23:49 2021 +0100 Commit: Stanislav Motylkov <x86corez(a)gmail.com> CommitDate: Sat Jan 1 15:18:06 2022 +0300 [BCRYPT] Add ECDSA P256 to known algorithms Add missing structs and handler in BCryptOpenAlgorithmProvider(). Fixes CORE-16741 and similar problems. --- dll/win32/bcrypt/bcrypt_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dll/win32/bcrypt/bcrypt_main.c b/dll/win32/bcrypt/bcrypt_main.c index 14523136440..4b80ac0e94a 100644 --- a/dll/win32/bcrypt/bcrypt_main.c +++ b/dll/win32/bcrypt/bcrypt_main.c @@ -266,7 +266,8 @@ enum alg_id ALG_ID_SHA1, ALG_ID_SHA256, ALG_ID_SHA384, - ALG_ID_SHA512 + ALG_ID_SHA512, + ALG_ID_ECDSA_P256, }; static const struct { @@ -278,7 +279,8 @@ static const struct { /* ALG_ID_SHA1 */ { 20, BCRYPT_SHA1_ALGORITHM }, /* ALG_ID_SHA256 */ { 32, BCRYPT_SHA256_ALGORITHM }, /* ALG_ID_SHA384 */ { 48, BCRYPT_SHA384_ALGORITHM }, - /* ALG_ID_SHA512 */ { 64, BCRYPT_SHA512_ALGORITHM } + /* ALG_ID_SHA512 */ { 64, BCRYPT_SHA512_ALGORITHM }, + /* ALG_ID_ECDSA_P256 */ { 0, BCRYPT_ECDSA_P256_ALGORITHM }, }; struct algorithm @@ -351,6 +353,7 @@ NTSTATUS WINAPI BCryptOpenAlgorithmProvider( BCRYPT_ALG_HANDLE *handle, LPCWSTR else if (!strcmpW( id, BCRYPT_SHA256_ALGORITHM )) alg_id = ALG_ID_SHA256; else if (!strcmpW( id, BCRYPT_SHA384_ALGORITHM )) alg_id = ALG_ID_SHA384; else if (!strcmpW( id, BCRYPT_SHA512_ALGORITHM )) alg_id = ALG_ID_SHA512; + else if (!strcmpW( id, BCRYPT_ECDSA_P256_ALGORITHM )) alg_id = ALG_ID_ECDSA_P256; else { FIXME( "algorithm %s not supported\n", debugstr_w(id) );
2 years, 11 months
1
0
0
0
[reactos] 01/01: [NTUSER] Implement NtUserCreateInputContext (#4230)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d5deacd90305a83d413af…
commit d5deacd90305a83d413af18dca8fa41fe03e61b3 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sat Jan 1 20:59:00 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Sat Jan 1 20:59:00 2022 +0900 [NTUSER] Implement NtUserCreateInputContext (#4230) - Modify NtUserCreateInputContext prototype. - Add UserCreateInputContext helper function. - Implement NtUserCreateInputContext function by using UserCreateInputContext. - Call UserCreateInputContext(0) in InitThreadCallback function to create the default input context. CORE-11700 --- dll/win32/imm32/imm.c | 2 +- win32ss/include/ntuser.h | 2 +- win32ss/user/ntuser/main.c | 6 +++++ win32ss/user/ntuser/ntstubs.c | 57 ++++++++++++++++++++++++++++++++++++++--- win32ss/user/ntuser/userfuncs.h | 1 + 5 files changed, 63 insertions(+), 5 deletions(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index e24806c86d4..e916d44480f 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -597,7 +597,7 @@ HIMC WINAPI ImmCreateContext(void) if (pClientImc == NULL) return NULL; - hIMC = NtUserCreateInputContext(pClientImc); + hIMC = NtUserCreateInputContext((ULONG_PTR)pClientImc); if (hIMC == NULL) { Imm32HeapFree(pClientImc); diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h index 1e6234f84c1..4618c99af76 100644 --- a/win32ss/include/ntuser.h +++ b/win32ss/include/ntuser.h @@ -1937,7 +1937,7 @@ NtUserCreateDesktop( HIMC NTAPI -NtUserCreateInputContext(PCLIENTIMC pClientImc); +NtUserCreateInputContext(ULONG_PTR dwClientImcData); NTSTATUS NTAPI diff --git a/win32ss/user/ntuser/main.c b/win32ss/user/ntuser/main.c index 00a683af61c..8daf15ba95d 100644 --- a/win32ss/user/ntuser/main.c +++ b/win32ss/user/ntuser/main.c @@ -651,6 +651,12 @@ InitThreadCallback(PETHREAD Thread) } ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags; + /* Create the default input context */ + if (IS_IMM_MODE()) + { + UserCreateInputContext(0); + } + /* Last things to do only if we are not a SYSTEM or CSRSS thread */ if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD))) { diff --git a/win32ss/user/ntuser/ntstubs.c b/win32ss/user/ntuser/ntstubs.c index 95a87900242..ddf9ba09381 100644 --- a/win32ss/user/ntuser/ntstubs.c +++ b/win32ss/user/ntuser/ntstubs.c @@ -461,12 +461,63 @@ NtUserYieldTask(VOID) return 0; } +PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData) +{ + PIMC pIMC; + PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); + PDESKTOP pdesk = pti->rpdesk; + + if (!IS_IMM_MODE() || (pti->TIF_flags & TIF_DISABLEIME)) // Disabled? + return NULL; + + if (!pdesk) // No desktop? + return NULL; + + // pti->spDefaultImc should be already set if non-first time. + if (dwClientImcData && !pti->spDefaultImc) + return NULL; + + // Create an input context user object. + pIMC = UserCreateObject(gHandleTable, pdesk, pti, NULL, TYPE_INPUTCONTEXT, sizeof(IMC)); + if (!pIMC) + return NULL; + + if (dwClientImcData) // Non-first time. + { + // Insert pIMC to the second position (non-default) of the list. + pIMC->pImcNext = pti->spDefaultImc->pImcNext; + pti->spDefaultImc->pImcNext = pIMC; + } + else // First time. It's the default IMC. + { + // Add the first one (default) to the list. + pti->spDefaultImc = pIMC; + pIMC->pImcNext = NULL; + } + + pIMC->dwClientImcData = dwClientImcData; // Set it. + return pIMC; +} + HIMC APIENTRY -NtUserCreateInputContext(PCLIENTIMC pClientImc) +NtUserCreateInputContext(ULONG_PTR dwClientImcData) { - STUB; - return NULL; + PIMC pIMC; + HIMC ret = NULL; + + UserEnterExclusive(); + + if (!IS_IMM_MODE() || !dwClientImcData) + goto Quit; + + pIMC = UserCreateInputContext(dwClientImcData); + if (pIMC) + ret = UserHMGetHandle(pIMC); + +Quit: + UserLeave(); + return ret; } DWORD diff --git a/win32ss/user/ntuser/userfuncs.h b/win32ss/user/ntuser/userfuncs.h index 6fb86e64d71..3bae17d5567 100644 --- a/win32ss/user/ntuser/userfuncs.h +++ b/win32ss/user/ntuser/userfuncs.h @@ -165,6 +165,7 @@ BOOL FASTCALL GetLayeredStatus(PWND pWnd); /************** INPUT CONTEXT **************/ +PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData); VOID UserFreeInputContext(PVOID Object); BOOLEAN UserDestroyInputContext(PVOID Object); PVOID AllocInputContextObject(PDESKTOP pDesk, PTHREADINFO pti, SIZE_T Size, PVOID* HandleOwner);
2 years, 11 months
1
0
0
0
[reactos] 01/01: [NTUSER] Implement NtUserUpdateInputContext (#4228)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ba3affe5f7f7f8818cc90…
commit ba3affe5f7f7f8818cc90a884a3ddcf8257d4d85 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Sat Jan 1 20:57:51 2022 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Sat Jan 1 20:57:51 2022 +0900 [NTUSER] Implement NtUserUpdateInputContext (#4228) - Modify NtUserUpdateInputContext prototype. - Implement NtUserUpdateInputContext function. - Add enum UPDATE_INPUT_CONTEXT (UIC_*) to undocuser.h. CORE-11700 --- dll/win32/imm32/imm.c | 2 +- sdk/include/reactos/undocuser.h | 6 +++++ win32ss/include/ntuser.h | 6 ++--- win32ss/user/ntuser/ntstubs.c | 55 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/dll/win32/imm32/imm.c b/dll/win32/imm32/imm.c index 4ac2cdebb6e..e24806c86d4 100644 --- a/dll/win32/imm32/imm.c +++ b/dll/win32/imm32/imm.c @@ -928,7 +928,7 @@ PCLIENTIMC WINAPI ImmLockClientImc(HIMC hImc) // FIXME: NtUserGetThreadState and enum ThreadStateRoutines are broken. pClientImc->unknown = NtUserGetThreadState(13); - if (!NtUserUpdateInputContext(hImc, 0, pClientImc)) + if (!NtUserUpdateInputContext(hImc, UIC_CLIENTIMCDATA, (DWORD_PTR)pClientImc)) { Imm32HeapFree(pClientImc); return NULL; diff --git a/sdk/include/reactos/undocuser.h b/sdk/include/reactos/undocuser.h index ca13a8b0239..3c0ebb3c149 100644 --- a/sdk/include/reactos/undocuser.h +++ b/sdk/include/reactos/undocuser.h @@ -296,6 +296,12 @@ MessageBoxTimeoutW( LPCWSTR WINAPI MB_GetString(IN UINT wBtn); +/* dwType for NtUserUpdateInputContext */ +typedef enum _UPDATE_INPUT_CONTEXT +{ + UIC_CLIENTIMCDATA = 0, + UIC_IMEWINDOW +} UPDATE_INPUT_CONTEXT; // // User api hook diff --git a/win32ss/include/ntuser.h b/win32ss/include/ntuser.h index 0e6d4c3b4d9..1e6234f84c1 100644 --- a/win32ss/include/ntuser.h +++ b/win32ss/include/ntuser.h @@ -3533,12 +3533,12 @@ BOOL NTAPI NtUserUnregisterUserApiHook(VOID); -DWORD +BOOL NTAPI NtUserUpdateInputContext( HIMC hIMC, - DWORD Unknown1, - LPVOID pClientImc); + DWORD dwType, + DWORD_PTR dwValue); DWORD NTAPI diff --git a/win32ss/user/ntuser/ntstubs.c b/win32ss/user/ntuser/ntstubs.c index 1a173714958..95a87900242 100644 --- a/win32ss/user/ntuser/ntstubs.c +++ b/win32ss/user/ntuser/ntstubs.c @@ -346,16 +346,61 @@ NtUserSetSysColors( return Ret; } -DWORD +BOOL FASTCALL UserUpdateInputContext(PIMC pIMC, DWORD dwType, DWORD_PTR dwValue) +{ + PTHREADINFO pti = GetW32ThreadInfo(); + PTHREADINFO ptiIMC = pIMC->head.pti; + + if (pti->ppi != ptiIMC->ppi) // Different process? + return FALSE; + + switch (dwType) + { + case UIC_CLIENTIMCDATA: + if (pIMC->dwClientImcData) + return FALSE; // Already set + + pIMC->dwClientImcData = dwValue; + break; + + case UIC_IMEWINDOW: + if (!ValidateHwndNoErr((HWND)dwValue)) + return FALSE; // Invalid HWND + + pIMC->hImeWnd = (HWND)dwValue; + break; + + default: + return FALSE; + } + + return TRUE; +} + +BOOL APIENTRY NtUserUpdateInputContext( HIMC hIMC, - DWORD Unknown1, - LPVOID pClientImc) + DWORD dwType, + DWORD_PTR dwValue) { - STUB + PIMC pIMC; + BOOL ret = FALSE; - return 0; + UserEnterExclusive(); + + if (!IS_IMM_MODE()) + goto Quit; + + pIMC = UserGetObject(gHandleTable, hIMC, TYPE_INPUTCONTEXT); + if (!pIMC) + goto Quit; + + ret = UserUpdateInputContext(pIMC, dwType, dwValue); + +Quit: + UserLeave(); + return ret; } DWORD
2 years, 11 months
1
0
0
0
← Newer
1
...
14
15
16
17
18
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Results per page:
10
25
50
100
200