]> Shamusworld >> Repos - ttedit/blobdiff - src/editwindow.cpp
Repurposed code in bezier.h/cpp, added middle button scrolling
[ttedit] / src / editwindow.cpp
index 63e8b3f4a9e2e1674a804fdac3b627fbb52b49d4..e16cee9a5be37a6726e562fa1d476b6bcd906817 100755 (executable)
@@ -24,7 +24,7 @@
 #define DEBUGTP                                // Toolpalette debugging...\r
 \r
 #include "editwindow.h"\r
-#include "bezier.h"\r
+#include "graphicprimitives.h"\r
 #include "toolwindow.h"\r
 #include "debug.h"\r
 #include "vector.h"\r
@@ -321,16 +321,33 @@ WriteLogMsg(" --> [# polys: %u, # points: %u]\n", pts.GetNumPolys(), pts.GetNumP
                        return;\r
                }\r
 \r
-           // Extract current point from lParam/calc offset from previous point\r
+               if (e.MiddleIsDown())\r
+               {\r
+                   // Calc offset from previous point\r
+                       pt = e.GetPosition();\r
+                       ptOffset.x = pt.x - ptPrevious.x,\r
+                       ptOffset.y = pt.y - ptPrevious.y;\r
 \r
-               pt = e.GetPosition();\r
-               ptOffset.x = pt.x - ptPrevious.x,\r
-               ptOffset.y = pt.y - ptPrevious.y;\r
+// Then multiply it by the scaling factor. Whee!\r
+                       // This looks wacky because we're using screen coords for the offset...\r
+                       // Otherwise, we would subtract both offsets!\r
+                       offsetX -= ptOffset.x, offsetY += ptOffset.y;\r
+                       Refresh();\r
+\r
+                       return;\r
+               }\r
 \r
 //             if (e.LeftIsDown())\r
 //             {\r
+#if 0\r
                        if (tool == TOOLScroll)\r
                        {\r
+                           // Extract current point from lParam/calc offset from previous point\r
+\r
+                               pt = e.GetPosition();\r
+                               ptOffset.x = pt.x - ptPrevious.x,\r
+                               ptOffset.y = pt.y - ptPrevious.y;\r
+\r
                                // NOTE: OffsetViewportOrg operates in DEVICE UNITS...\r
 \r
 //Seems there's no equivalent for this in wxWidgets...!\r
@@ -348,7 +365,9 @@ WriteLogMsg(" --> [# polys: %u, # points: %u]\n", pts.GetNumPolys(), pts.GetNumP
                                offsetX -= ptOffset.x, offsetY += ptOffset.y;\r
                                Refresh();\r
                        }\r
-                       else if (tool == TOOLAddPt || tool == TOOLAddPoly || tool == TOOLSelect)\r
+                       else\r
+#endif\r
+ if (tool == TOOLAddPt || tool == TOOLAddPoly || tool == TOOLSelect)\r
                        {\r
                                if (tool != TOOLAddPt || pts.GetNumPoints() > 0)//yecch.\r
                                {\r
@@ -504,64 +523,6 @@ wxPoint TTEditWindow::GetAdjustedClientPosition(wxCoord x, wxCoord y)
        return wxPoint(dc.LogicalToDeviceX(x), dc.LogicalToDeviceY(y));\r
 }\r
 \r
-//\r
-// Draw a round dot (5x5, centered on [x, y])\r
-//\r
-void TTEditWindow::DrawRoundDot(wxDC &dc, int32 x, int32 y)\r
-{\r
-       wxPoint pt[8];\r
-\r
-       pt[0].x = x - 1, pt[0].y = y - 2;\r
-       pt[1].x = x + 1, pt[1].y = y - 2;\r
-       pt[2].x = x + 2, pt[2].y = y - 1;\r
-       pt[3].x = x + 2, pt[3].y = y + 1;\r
-       pt[4].x = x + 1, pt[4].y = y + 2;\r
-       pt[5].x = x - 1, pt[5].y = y + 2;\r
-       pt[6].x = x - 2, pt[6].y = y + 1;\r
-       pt[7].x = x - 2, pt[7].y = y - 1;\r
-\r
-       dc.DrawPolygon(8, pt);\r
-}\r
-\r
-//\r
-// Draw a sqaure dot (5x5, centered on [x, y])\r
-//\r
-void TTEditWindow::DrawSquareDot(wxDC &dc, int32 x, int32 y)\r
-{\r
-       wxPoint pt[4];\r
-\r
-       pt[0].x = x - 2, pt[0].y = y - 2;\r
-       pt[1].x = x + 2, pt[1].y = y - 2;\r
-       pt[2].x = x + 2, pt[2].y = y + 2;\r
-       pt[3].x = x - 2, pt[3].y = y + 2;\r
-\r
-       dc.DrawPolygon(4, pt);\r
-}\r
-\r
-//\r
-// Draw a sqaure dot (nxn, centered on [x, y])\r
-//\r
-void TTEditWindow::DrawSquareDotN(wxDC &dc, int32 x, int32 y, uint32 n)\r
-{\r
-       wxPoint pt[4];\r
-       uint32 offset = (n - 1) / 2;\r
-\r
-       pt[0].x = x - offset, pt[0].y = y - offset;\r
-       pt[1].x = x + offset, pt[1].y = y - offset;\r
-       pt[2].x = x + offset, pt[2].y = y + offset;\r
-       pt[3].x = x - offset, pt[3].y = y + offset;\r
-\r
-       dc.DrawPolygon(4, pt);\r
-}\r
-\r
-//\r
-// Draw a round dot (nxn, centered on [x, y])\r
-//\r
-void TTEditWindow::DrawRoundDotN(wxDC &dc, int32 x, int32 y, uint32 n)\r
-{\r
-       dc.DrawCircle(x, y, (n / 2) + 1);\r
-}\r
-\r
 \r
 #if 0\r
 \r