From d9f3b5c5083bc728dddb92833f0e187589a83b57 Mon Sep 17 00:00:00 2001 From: Benedikt Freisen Date: Mon, 13 Jul 2015 14:46:41 +0000 Subject: [PATCH] [MSPAINT_NEW] Pasting a larger-than-current-canvas image now DOES resize the canvas. (adapted from a patch by Gian Sass) CORE-9674 #resolve #comment Fixed in r68398 svn path=/trunk/; revision=68398 --- .../applications/mspaint_new/definitions.h | 1 + .../base/applications/mspaint_new/globalvar.h | 1 + .../applications/mspaint_new/lang/de-DE.rc | 1 + .../applications/mspaint_new/lang/en-GB.rc | 1 + .../applications/mspaint_new/lang/en-US.rc | 1 + .../base/applications/mspaint_new/main.cpp | 1 + .../base/applications/mspaint_new/winproc.cpp | 41 +++++++++++++++++++ 7 files changed, 47 insertions(+) diff --git a/reactos/base/applications/mspaint_new/definitions.h b/reactos/base/applications/mspaint_new/definitions.h index 2155a6d6376..1f673f164af 100644 --- a/reactos/base/applications/mspaint_new/definitions.h +++ b/reactos/base/applications/mspaint_new/definitions.h @@ -220,6 +220,7 @@ #define IDS_ANGLE 932 #define IDS_LOADERRORTEXT 933 +#define IDS_ENLARGEPROMPTTEXT 934 #define WM_TOOLSMODELTOOLCHANGED WM_APP #define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1) diff --git a/reactos/base/applications/mspaint_new/globalvar.h b/reactos/base/applications/mspaint_new/globalvar.h index 7fcc21132cc..9581eadbe6c 100644 --- a/reactos/base/applications/mspaint_new/globalvar.h +++ b/reactos/base/applications/mspaint_new/globalvar.h @@ -31,6 +31,7 @@ extern STRETCHSKEW stretchSkew; class ImageModel; extern ImageModel imageModel; +extern BOOL askBeforeEnlarging; extern POINT start; extern POINT last; diff --git a/reactos/base/applications/mspaint_new/lang/de-DE.rc b/reactos/base/applications/mspaint_new/lang/de-DE.rc index 7de3651b260..8319299ca1b 100644 --- a/reactos/base/applications/mspaint_new/lang/de-DE.rc +++ b/reactos/base/applications/mspaint_new/lang/de-DE.rc @@ -214,4 +214,5 @@ BEGIN IDS_PERCENTAGE "Der Prozentsatz muss zwischen 1 und 500 liegen." IDS_ANGLE "Der Winkel muss zwischen -89 und 89 liegen." IDS_LOADERRORTEXT "Die Datei %s konnte nicht geladen werden." + IDS_ENLARGEPROMPTTEXT "Das Bild in der Zwischenablage ist größer als die Bitmap.\nSoll die Bitmap vergrößert werden?" END diff --git a/reactos/base/applications/mspaint_new/lang/en-GB.rc b/reactos/base/applications/mspaint_new/lang/en-GB.rc index 0636de32309..4bb903287c5 100644 --- a/reactos/base/applications/mspaint_new/lang/en-GB.rc +++ b/reactos/base/applications/mspaint_new/lang/en-GB.rc @@ -214,4 +214,5 @@ BEGIN IDS_PERCENTAGE "The percentage must be between 1 and 500." IDS_ANGLE "The angle must be between -89 and 89." IDS_LOADERRORTEXT "The file %s could not be loaded." + IDS_ENLARGEPROMPTTEXT "The image in the clipboard is larger than the bitmap.\nWould you like the bitmap enlarged?" END diff --git a/reactos/base/applications/mspaint_new/lang/en-US.rc b/reactos/base/applications/mspaint_new/lang/en-US.rc index baa06f0f161..e8af76b89b8 100644 --- a/reactos/base/applications/mspaint_new/lang/en-US.rc +++ b/reactos/base/applications/mspaint_new/lang/en-US.rc @@ -214,4 +214,5 @@ BEGIN IDS_PERCENTAGE "The percentage must be between 1 and 500." IDS_ANGLE "The angle must be between -89 and 89." IDS_LOADERRORTEXT "The file %s could not be loaded." + IDS_ENLARGEPROMPTTEXT "The image in the clipboard is larger than the bitmap.\nWould you like the bitmap enlarged?" END diff --git a/reactos/base/applications/mspaint_new/main.cpp b/reactos/base/applications/mspaint_new/main.cpp index abdfb6b5942..f68136b526f 100644 --- a/reactos/base/applications/mspaint_new/main.cpp +++ b/reactos/base/applications/mspaint_new/main.cpp @@ -24,6 +24,7 @@ int heightSetInDlg; STRETCHSKEW stretchSkew; ImageModel imageModel; +BOOL askBeforeEnlarging = FALSE; // TODO: initialize from registry POINT start; POINT last; diff --git a/reactos/base/applications/mspaint_new/winproc.cpp b/reactos/base/applications/mspaint_new/winproc.cpp index e9c38845d1f..d088e60879d 100644 --- a/reactos/base/applications/mspaint_new/winproc.cpp +++ b/reactos/base/applications/mspaint_new/winproc.cpp @@ -107,6 +107,47 @@ void CMainWindow::UpdateApplicationProperties(HBITMAP bitmap, LPTSTR newfilename void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window) { + int width = GetDIBWidth(bitmap); + int height = GetDIBHeight(bitmap); + int curWidth = imageModel.GetWidth(); + int curHeight = imageModel.GetHeight(); + + if (width > curWidth || height > curHeight) + { + BOOL shouldEnlarge = TRUE; + + if (askBeforeEnlarging) + { + TCHAR programname[20]; + TCHAR shouldEnlargePromptText[100]; + + LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname)); + LoadString(hProgInstance, IDS_ENLARGEPROMPTTEXT, shouldEnlargePromptText, SIZEOF(shouldEnlargePromptText)); + + switch (MessageBox(shouldEnlargePromptText, programname, MB_YESNOCANCEL | MB_ICONQUESTION)) + { + case IDYES: + break; + case IDNO: + shouldEnlarge = FALSE; + break; + case IDCANCEL: + return; + } + } + + if (shouldEnlarge) + { + if (width > curWidth) + curWidth = width; + + if (height > curHeight) + curHeight = height; + + imageModel.Crop(curWidth, curHeight, 0, 0); + } + } + HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL); SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0)); toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL); -- 2.17.1