[MSPAINT_NEW]
authorBenedikt Freisen <b.freisen@gmx.net>
Mon, 13 Jul 2015 14:46:41 +0000 (14:46 +0000)
committerBenedikt Freisen <b.freisen@gmx.net>
Mon, 13 Jul 2015 14:46:41 +0000 (14:46 +0000)
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

reactos/base/applications/mspaint_new/definitions.h
reactos/base/applications/mspaint_new/globalvar.h
reactos/base/applications/mspaint_new/lang/de-DE.rc
reactos/base/applications/mspaint_new/lang/en-GB.rc
reactos/base/applications/mspaint_new/lang/en-US.rc
reactos/base/applications/mspaint_new/main.cpp
reactos/base/applications/mspaint_new/winproc.cpp

index 2155a6d..1f673f1 100644 (file)
 #define IDS_ANGLE      932
 
 #define IDS_LOADERRORTEXT 933
+#define IDS_ENLARGEPROMPTTEXT 934
 
 #define WM_TOOLSMODELTOOLCHANGED WM_APP
 #define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1)
index 7fcc211..9581ead 100644 (file)
@@ -31,6 +31,7 @@ extern STRETCHSKEW stretchSkew;
 
 class ImageModel;
 extern ImageModel imageModel;
+extern BOOL askBeforeEnlarging;
 
 extern POINT start;
 extern POINT last;
index 7de3651..8319299 100644 (file)
@@ -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
index 0636de3..4bb9032 100644 (file)
@@ -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
index baa06f0..e8af76b 100644 (file)
@@ -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
index abdfb6b..f68136b 100644 (file)
@@ -24,6 +24,7 @@ int heightSetInDlg;
 STRETCHSKEW stretchSkew;
 
 ImageModel imageModel;
+BOOL askBeforeEnlarging = FALSE;  // TODO: initialize from registry
 
 POINT start;
 POINT last;
index e9c3884..d088e60 100644 (file)
@@ -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);