Paint: Added cropping via attributes dialog and setting desktop wallpaper (both not...
authorBenedikt Freisen <b.freisen@gmx.net>
Fri, 29 May 2009 19:36:35 +0000 (19:36 +0000)
committerBenedikt Freisen <b.freisen@gmx.net>
Fri, 29 May 2009 19:36:35 +0000 (19:36 +0000)
svn path=/trunk/; revision=41200

reactos/base/applications/paint/dialogs.c
reactos/base/applications/paint/history.c
reactos/base/applications/paint/paint.rbuild
reactos/base/applications/paint/registry.c [new file with mode: 0644]
reactos/base/applications/paint/registry.h [new file with mode: 0644]
reactos/base/applications/paint/winproc.c

index a5592dc..310a6ea 100644 (file)
@@ -84,11 +84,17 @@ LRESULT CALLBACK ATTDlgWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l
             switch (LOWORD(wParam))
             {
                 case IDOK:
-                    EndDialog(hwnd, 1);
+                    EndDialog(hwnd, GetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, NULL, FALSE) | (GetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, NULL, FALSE)<<16));
                     break;
                 case IDCANCEL:
                     EndDialog(hwnd, 0);
                     break;
+                case IDD_ATTRIBUTESSTANDARD:
+                    CheckDlgButton(hwnd, IDD_ATTRIBUTESRB3, BST_CHECKED);
+                    CheckDlgButton(hwnd, IDD_ATTRIBUTESRB5, BST_CHECKED);
+                    SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT1, imgXRes, FALSE);
+                    SetDlgItemInt(hwnd, IDD_ATTRIBUTESEDIT2, imgYRes, FALSE);
+                    break;
             }
             break;
         default:
index 70057b2..a8a8664 100644 (file)
@@ -91,7 +91,7 @@ void insertReversible(HBITMAP hbm)
     setImgXYRes(GetDIBWidth(hBms[currInd]), GetDIBHeight(hBms[currInd]));
 }
 
-void cropReversible(int x, int y)
+void cropReversible(int x, int y)//FIXME: This function is broken
 {
     SelectObject(hDrawingDC, hBms[currInd]);
     DeleteObject(hBms[(currInd+1)%4]);
index 8025cf9..3c48bf8 100644 (file)
@@ -16,6 +16,7 @@
        <file>main.c</file>
        <file>mouse.c</file>
        <file>palette.c</file>
+       <file>registry.c</file>
        <file>selection.c</file>
        <file>toolsettings.c</file>
        <file>winproc.c</file>
diff --git a/reactos/base/applications/paint/registry.c b/reactos/base/applications/paint/registry.c
new file mode 100644 (file)
index 0000000..e423d0d
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * PROJECT:     PAINT for ReactOS
+ * LICENSE:     LGPL
+ * FILE:        registry.c
+ * PURPOSE:     Offering functions dealing with registry values
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+/* INCLUDES *********************************************************/
+
+#include <windows.h>
+
+/* FUNCTIONS ********************************************************/
+
+void setWallpaper(char fname[], int style)
+{
+    HKEY hkeycontrolpanel;
+    HKEY hkeydesktop;
+    RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel", 0, 0, hkeycontrolpanel);
+    RegOpenKeyEx(hkeycontrolpanel, "Desktop", 0, KEY_SET_VALUE, hkeydesktop);
+    RegSetValueEx(hkeydesktop, "Wallpaper", 0, REG_SZ, fname, sizeof(fname));
+    switch (style)
+    {
+        case 0:
+            RegSetValueEx(hkeydesktop, "WallpaperStyle", 0, REG_SZ, "2", 2);
+            RegSetValueEx(hkeydesktop, "TileWallpaper", 0, REG_SZ, "0", 2);
+            break;
+        case 1:
+            RegSetValueEx(hkeydesktop, "WallpaperStyle", 0, REG_SZ, "1", 2);
+            RegSetValueEx(hkeydesktop, "TileWallpaper", 0, REG_SZ, "0", 2);
+            break;
+        case 2:
+            RegSetValueEx(hkeydesktop, "WallpaperStyle", 0, REG_SZ, "1", 2);
+            RegSetValueEx(hkeydesktop, "TileWallpaper", 0, REG_SZ, "1", 2);
+            break;
+    }
+    RegCloseKey(hkeydesktop);
+    RegCloseKey(hkeycontrolpanel);
+}
diff --git a/reactos/base/applications/paint/registry.h b/reactos/base/applications/paint/registry.h
new file mode 100644 (file)
index 0000000..035d15c
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * PROJECT:     PAINT for ReactOS
+ * LICENSE:     LGPL
+ * FILE:        registry.h
+ * PURPOSE:     Offering functions dealing with registry values
+ * PROGRAMMERS: Benedikt Freisen
+ */
+
+void setWallpaper(char fname[], int style);
index 96fe59d..2f4a316 100644 (file)
@@ -21,6 +21,7 @@
 #include "drawing.h"
 #include "history.h"
 #include "mouse.h"
+#include "registry.h"
 
 /* FUNCTIONS ********************************************************/
 
@@ -87,7 +88,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
             switch (lParam)
             {
                 case 0:
-                    if (FALSE)
+                    if (isAFile)
                     {
                         EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERPLANE, MF_ENABLED | MF_BYCOMMAND);
                         EnableMenuItem(GetMenu(hMainWnd), IDM_FILEASWALLPAPERCENTERED, MF_ENABLED | MF_BYCOMMAND);
@@ -421,6 +422,15 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
                         isAFile = TRUE;
                     }
                     break;
+                case IDM_FILEASWALLPAPERPLANE:
+                    setWallpaper(filepathname, 2);
+                    break;
+                case IDM_FILEASWALLPAPERCENTERED:
+                    setWallpaper(filepathname, 1);
+                    break;
+                case IDM_FILEASWALLPAPERSTRETCHED:
+                    setWallpaper(filepathname, 0);
+                    break;
                 case IDM_EDITUNDO:
                     undo();
                     SendMessage(hImageArea, WM_PAINT, 0, 0);
@@ -507,10 +517,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
                     break;
                 case IDM_IMAGEATTRIBUTES:
                     {
-                        //int attrdata[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-                        attributesDlg();
-                        //cropReversible(640, 200);
-                        //ZoomTo(zoom);
+                        int retVal = attributesDlg();
+                        if ((LOWORD(retVal)!=0)&&(HIWORD(retVal)!=0))
+                        {
+                            // cropReversible broken, dirty hack:
+                            // insertReversible(CopyImage(hBms[currInd], IMAGE_BITMAP, LOWORD(retVal), HIWORD(retVal), 0));
+                            cropReversible(LOWORD(retVal), HIWORD(retVal));
+                            updateCanvasAndScrollbars();
+                        }
                     }
                     break;
                 case IDM_IMAGECHANGESIZE: