ReactOS 0.4.15-dev-7897-g78dc504
mouse.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4 * PURPOSE: Things which should not be in the mouse event handler itself
5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6 * Copyright 2021-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7 */
8
9#include "precomp.h"
10#include <atlalloc.h>
11
12static SIZE_T s_cPoints = 0;
14static POINT s_staticPoints[512]; // 512 is enough
18
19/* FUNCTIONS ********************************************************/
20
21void
23{
24 if (labs(x1 - x0) >= labs(y1 - y0))
25 y1 = y0 + (y1 > y0 ? labs(x1 - x0) : -labs(x1 - x0));
26 else
27 x1 = x0 + (x1 > x0 ? labs(y1 - y0) : -labs(y1 - y0));
28}
29
30void
32{
33 if (labs(x1 - x0) >= labs(y1 - y0))
34 {
35 if (labs(y1 - y0) * 5 < labs(x1 - x0) * 2)
36 y1 = y0;
37 else
38 y1 = y0 + (y1 > y0 ? labs(x1 - x0) : -labs(x1 - x0));
39 }
40 else
41 {
42 if (labs(x1 - x0) * 5 < labs(y1 - y0) * 2)
43 x1 = x0;
44 else
45 x1 = x0 + (x1 > x0 ? labs(y1 - y0) : -labs(y1 - y0));
46 }
47}
48
50{
53 return (abs(x1 - x0) <= cxThreshold) && (abs(y1 - y0) <= cyThreshold);
54}
55
56void getBoundaryOfPoints(RECT& rcBoundary, SIZE_T cPoints, const POINT *pPoints)
57{
58 POINT ptMin = { MAXLONG, MAXLONG }, ptMax = { (LONG)MINLONG, (LONG)MINLONG };
59 while (cPoints-- > 0)
60 {
61 LONG x = pPoints->x, y = pPoints->y;
62 ptMin = { min(x, ptMin.x), min(y, ptMin.y) };
63 ptMax = { max(x, ptMax.x), max(y, ptMax.y) };
64 ++pPoints;
65 }
66
67 ptMax.x += 1;
68 ptMax.y += 1;
69
70 CRect rc(ptMin, ptMax);
71 rcBoundary = rc;
72}
73
75{
76 for (SIZE_T i = 0; i < s_cPoints; ++i)
77 {
78 POINT& pt = s_pPoints[i];
79 pt.x += dx;
80 pt.y += dy;
81 }
82}
83
85{
86 CRect rc;
88
89 ShiftPoints(-rc.left, -rc.top);
90
92 HBITMAP hbmMask = ::CreateBitmap(rc.Width(), rc.Height(), 1, 1, NULL);
93 HGDIOBJ hbmOld = ::SelectObject(hdcMem, hbmMask);
98 ::SelectObject(hdcMem, hbrOld);
99 ::SelectObject(hdcMem, hPenOld);
100 ::SelectObject(hdcMem, hbmOld);
102
103 selectionModel.setMask(rc, hbmMask);
104}
105
107{
109 {
110 s_dynamicPoints.Free();
113 }
114
115 s_cPoints = 0;
116 g_ptEnd = g_ptStart = { -1, -1 };
117
119 {
122 }
123}
124
126{
127 reset();
129}
130
132{
136}
137
139{
140 m_hdc = NULL;
141}
142
143static void pushToPoints(LONG x, LONG y)
144{
145 if (s_cPoints + 1 >= s_maxPoints)
146 {
147 SIZE_T newMax = s_maxPoints + 512;
148 SIZE_T cbNew = newMax * sizeof(POINT);
149 if (!s_dynamicPoints.ReallocateBytes(cbNew))
150 {
151 ATLTRACE("%d, %d, %d\n", (INT)s_cPoints, (INT)s_maxPoints, (INT)cbNew);
152 return;
153 }
154
157
159 s_maxPoints = newMax;
160 }
161
162 s_pPoints[s_cPoints++] = { x, y };
163}
164
165/* TOOLS ********************************************************/
166
168{
171
172 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
173 {
174 m_bLeftButton = bLeftButton;
177 }
178
179 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
180 {
182 return TRUE;
183 }
184
185 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
186 {
187 CRect rcPartial(g_ptStart, g_ptEnd);
188 rcPartial.NormalizeRect();
190 rcPartial.InflateRect((size.cx + 1) / 2, (size.cy + 1) / 2);
191 imageModel.PushImageForUndo(rcPartial);
192
196 return TRUE;
197 }
198
199 void OnEndDraw(BOOL bCancel) override
200 {
202 ToolBase::OnEndDraw(bCancel);
203 }
204
205 void OnSpecialTweak(BOOL bMinus) override
206 {
208 }
209};
210
211typedef enum DIRECTION
212{
219
220#define THRESHOULD_DEG 15
221
222static DIRECTION
224{
225 LONG dx = x1 - x0, dy = y1 - y0;
226
227 if (labs(dx) <= 8 && labs(dy) <= 8)
228 return NO_DIRECTION;
229
230 double radian = atan2((double)dy, (double)dx);
231 if (radian < DEG2RAD(-180 + THRESHOULD_DEG))
232 {
233 ATLTRACE("DIRECTION_HORIZONTAL: %ld\n", RAD2DEG(radian));
235 }
236 if (radian < DEG2RAD(-90 - THRESHOULD_DEG))
237 {
238 ATLTRACE("DIRECTION_DIAGONAL_RIGHT_DOWN: %ld\n", RAD2DEG(radian));
240 }
241 if (radian < DEG2RAD(-90 + THRESHOULD_DEG))
242 {
243 ATLTRACE("DIRECTION_VERTICAL: %ld\n", RAD2DEG(radian));
244 return DIRECTION_VERTICAL;
245 }
246 if (radian < DEG2RAD(-THRESHOULD_DEG))
247 {
248 ATLTRACE("DIRECTION_DIAGONAL_RIGHT_UP: %ld\n", RAD2DEG(radian));
250 }
251 if (radian < DEG2RAD(+THRESHOULD_DEG))
252 {
253 ATLTRACE("DIRECTION_HORIZONTAL: %ld\n", RAD2DEG(radian));
255 }
256 if (radian < DEG2RAD(+90 - THRESHOULD_DEG))
257 {
258 ATLTRACE("DIRECTION_DIAGONAL_RIGHT_DOWN: %ld\n", RAD2DEG(radian));
260 }
261 if (radian < DEG2RAD(+90 + THRESHOULD_DEG))
262 {
263 ATLTRACE("DIRECTION_VERTICAL: %ld\n", RAD2DEG(radian));
264 return DIRECTION_VERTICAL;
265 }
266 if (radian < DEG2RAD(+180 - THRESHOULD_DEG))
267 {
268 ATLTRACE("DIRECTION_DIAGONAL_RIGHT_UP: %ld\n", RAD2DEG(radian));
270 }
271 ATLTRACE("DIRECTION_HORIZONTAL: %ld\n", RAD2DEG(radian));
273}
274
275static void
277{
278 switch (dir)
279 {
280 case NO_DIRECTION:
281 default:
282 return;
283
285 y1 = y0;
286 break;
287
289 x1 = x0;
290 break;
291
293 y1 = y0 + (x1 - x0);
294 break;
295
297 x1 = x0 - (y1 - y0);
298 break;
299 }
300}
301
303{
307
308 virtual void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) = 0;
309
310 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
311 {
313 m_bShiftDown = (::GetKeyState(VK_SHIFT) & 0x8000); // Is Shift key pressed?
314 m_bLeftButton = bLeftButton;
315 s_cPoints = 0;
316 pushToPoints(x, y);
317 pushToPoints(x, y); // We have to draw the first point
319 }
320
321 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
322 {
323 if (!m_bShiftDown)
324 {
325 pushToPoints(x, y);
327 return TRUE;
328 }
329
331 {
334 return FALSE;
335 }
336
338 pushToPoints(x, y);
340 return TRUE;
341 }
342
343 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
344 {
347
348 pushToPoints(x, y);
349
350 CRect rcPartial;
352
354 rcPartial.InflateRect((size.cx + 1) / 2, (size.cy + 1) / 2);
355
356 imageModel.PushImageForUndo(rcPartial);
357
361 return TRUE;
362 }
363
365 {
366 for (SIZE_T i = 1; i < s_cPoints; ++i)
367 {
369 }
370 }
371};
372
374{
381
383 {
385 }
386
388 {
390 return;
391
392 if (!m_bNoDrawBack)
394
396 }
397
399 {
402 }
403
404 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
405 {
406 m_bLeftButton = bLeftButton;
411
412 POINT pt = { x, y };
413 if (!m_bLeftButton) // Show context menu on Right-click
414 {
416 canvasWindow.ClientToScreen(&pt);
418 return;
419 }
420
421 POINT ptCanvas = pt;
422 canvasWindow.ImageToCanvas(ptCanvas);
423 HITTEST hit = selectionModel.hitTest(ptCanvas);
424 if (hit != HIT_NONE) // Dragging of selection started?
425 {
426 if (m_bCtrlKey || m_bShiftKey)
427 {
430 }
431 m_hitSelection = hit;
436 return;
437 }
438
441
443 if (isRectSelect())
444 {
446 }
447 else
448 {
449 s_cPoints = 0;
450 pushToPoints(pt.x, pt.y);
451 }
452
454 }
455
456 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
457 {
458 POINT pt = { x, y };
459
460 if (!m_bLeftButton)
461 return TRUE;
462
463 if (m_hitSelection != HIT_NONE) // Now dragging selection?
464 {
465 if (m_bShiftKey)
467
470 return TRUE;
471 }
472
473 if (isRectSelect() && ::GetKeyState(VK_SHIFT) < 0)
475
477
478 if (isRectSelect())
480 else
481 pushToPoints(pt.x, pt.y);
482
484 return TRUE;
485 }
486
487 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
488 {
489 POINT pt = { x, y };
491
492 if (!m_bLeftButton)
493 return TRUE;
494
495 if (m_hitSelection != HIT_NONE) // Dragging of selection ended?
496 {
497 if (m_bShiftKey)
499
503 return TRUE;
504 }
505
506 if (isRectSelect() && ::GetKeyState(VK_SHIFT) < 0)
508
510
511 if (isRectSelect())
512 {
515 }
516 else
517 {
518 if (s_cPoints > 2)
519 {
522 }
523 else
524 {
525 s_cPoints = 0;
527 }
528 }
529
532 return TRUE;
533 }
534
535 void OnEndDraw(BOOL bCancel) override
536 {
537 if (bCancel)
539 else
541
544 ToolBase::OnEndDraw(bCancel);
545 }
546
547 void OnSpecialTweak(BOOL bMinus) override
548 {
550 }
551};
552
553// TOOL_FREESEL
555{
557 {
559
561 {
562 /* Draw the freehand selection inverted/xored */
563 Poly(hdc, s_pPoints, (INT)s_cPoints, 0, 0, 2, 0, FALSE, TRUE);
564 }
565 }
566};
567
568// TOOL_RECTSEL
570{
572 {
574
576 {
578 if (!rc.IsRectEmpty())
579 RectSel(hdc, rc.left, rc.top, rc.right, rc.bottom);
580 }
581 }
582};
583
584// TOOL_RUBBER
586{
587 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
588 {
589 if (bLeftButton)
590 Erase(hdc, pt0.x, pt0.y, pt1.x, pt1.y, m_bg, toolsModel.GetRubberRadius());
591 else
592 Replace(hdc, pt0.x, pt0.y, pt1.x, pt1.y, m_fg, m_bg, toolsModel.GetRubberRadius());
593 }
594
595 void OnSpecialTweak(BOOL bMinus) override
596 {
598 }
599};
600
601// TOOL_FILL
603{
604 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
605 {
607 Fill(m_hdc, x, y, bLeftButton ? m_fg : m_bg);
608 }
609};
610
611// TOOL_COLOR
613{
614 void fetchColor(BOOL bLeftButton, LONG x, LONG y)
615 {
616 COLORREF rgbColor;
617
618 if (0 <= x && x < imageModel.GetWidth() && 0 <= y && y < imageModel.GetHeight())
619 rgbColor = GetPixel(m_hdc, x, y);
620 else
621 rgbColor = RGB(255, 255, 255); // Outside is white
622
623 if (bLeftButton)
624 paletteModel.SetFgColor(rgbColor);
625 else
626 paletteModel.SetBgColor(rgbColor);
627 }
628
629 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
630 {
631 fetchColor(bLeftButton, x, y);
632 return TRUE;
633 }
634
635 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
636 {
637 fetchColor(bLeftButton, x, y);
639 return TRUE;
640 }
641};
642
643// TOOL_ZOOM
645{
647
648 BOOL getNewZoomRect(CRect& rcView, INT newZoom);
649
651 {
652 CRect rcView;
653 INT oldZoom = toolsModel.GetZoom();
654 if (oldZoom < MAX_ZOOM && getNewZoomRect(rcView, oldZoom * 2))
655 DrawXorRect(hdc, &rcView);
656 }
657
658 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
659 {
660 INT newZoom, oldZoom = toolsModel.GetZoom();
661 if (bLeftButton)
662 newZoom = (oldZoom < MAX_ZOOM) ? (oldZoom * 2) : MIN_ZOOM;
663 else
664 newZoom = (oldZoom > MIN_ZOOM) ? (oldZoom / 2) : MAX_ZOOM;
665
667
668 if (oldZoom != newZoom)
669 {
670 CRect rcView;
671 if (getNewZoomRect(rcView, newZoom))
672 {
673 canvasWindow.zoomTo(newZoom, rcView.left, rcView.top);
674 m_bZoomed = TRUE;
675 }
676 }
677 }
678
679 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
680 {
681 if (m_bZoomed)
683
684 return TRUE;
685 }
686};
687
689{
690 CPoint pt;
692 canvasWindow.ScreenToClient(&pt);
693
694 canvasWindow.getNewZoomRect(rcView, newZoom, pt);
695
696 CRect rc;
699
700 return rc.PtInRect(pt);
701}
702
703// TOOL_PEN
705{
706 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
707 {
708 COLORREF rgb = bLeftButton ? m_fg : m_bg;
709 Line(hdc, pt0.x, pt0.y, pt1.x, pt1.y, rgb, toolsModel.GetPenWidth());
710 }
711
712 void OnSpecialTweak(BOOL bMinus) override
713 {
715 }
716};
717
718// TOOL_BRUSH
720{
721 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
722 {
723 COLORREF rgb = bLeftButton ? m_fg : m_bg;
724 Brush(hdc, pt0.x, pt0.y, pt1.x, pt1.y, rgb, toolsModel.GetBrushStyle(),
726 }
727
728 void OnSpecialTweak(BOOL bMinus) override
729 {
731 }
732};
733
734// TOOL_AIRBRUSH
736{
738
739 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
740 {
742 SmoothDrawTool::OnButtonDown(bLeftButton, x, y, bDoubleClick);
743 }
744
746 {
749 }
750
751 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
752 {
753 COLORREF rgb = bLeftButton ? m_fg : m_bg;
755 }
756
757 void OnSpecialTweak(BOOL bMinus) override
758 {
760 }
761};
762
763// TOOL_TEXT
765{
767 {
769 {
771 if (!rc.IsRectEmpty())
772 RectSel(hdc, rc.left, rc.top, rc.right, rc.bottom);
773 }
774 }
775
777 {
778 POINT pt = { x, y };
782 }
783
784 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
785 {
786 if (!textEditWindow.IsWindow())
788
789 UpdatePoint(x, y);
790 }
791
792 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
793 {
794 UpdatePoint(x, y);
795 return TRUE;
796 }
797
799 {
800 CStringW szText;
801 textEditWindow.GetWindowText(szText);
802
803 CRect rc;
806 rc.InflateRect(-GRIP_SIZE / 2, -GRIP_SIZE / 2);
807
808 // Draw the text
810 Text(hdc, rc.left, rc.top, rc.right, rc.bottom, m_fg, m_bg, szText,
812 }
813
814 void quit()
815 {
816 if (textEditWindow.IsWindow())
817 textEditWindow.ShowWindow(SW_HIDE);
819 }
820
821 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
822 {
823 POINT pt = { x, y };
826
827 BOOL bTextBoxShown = ::IsWindowVisible(textEditWindow);
828 if (bTextBoxShown)
829 {
830 if (textEditWindow.GetWindowTextLength() > 0)
831 {
833 draw(m_hdc);
834 }
836 {
837 quit();
838 return TRUE;
839 }
840 }
841
843 {
844 if (!fontsDialog.IsWindow())
845 fontsDialog.Create(mainWindow);
846
847 fontsDialog.ShowWindow(SW_SHOWNOACTIVATE);
848 }
849
851
852 // Enlarge if tool small
855 {
856 rc.SetRect(x, y, x + cxMin, y + cyMin);
857 }
858 else
859 {
860 if (rc.right - rc.left < cxMin)
861 rc.right = rc.left + cxMin;
862 if (rc.bottom - rc.top < cyMin)
863 rc.bottom = rc.top + cyMin;
864 }
865
866 if (!textEditWindow.IsWindow())
868
869 textEditWindow.SetWindowText(NULL);
872 textEditWindow.SetFocus();
873 return TRUE;
874 }
875
876 void OnEndDraw(BOOL bCancel) override
877 {
878 if (!bCancel)
879 {
881 textEditWindow.GetWindowTextLength() > 0)
882 {
884 draw(m_hdc);
885 }
886 }
887 quit();
888 ToolBase::OnEndDraw(bCancel);
889 }
890};
891
892// TOOL_LINE
894{
896 {
897 if (!m_bDrawing)
898 return;
899 if (GetAsyncKeyState(VK_SHIFT) < 0)
903 }
904};
905
906// TOOL_BEZIER
908{
910
912 {
914 switch (s_cPoints)
915 {
916 case 2:
919 break;
920 case 3:
922 break;
923 case 4:
925 break;
926 }
927 }
928
929 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
930 {
931 m_bLeftButton = bLeftButton;
932
933 if (s_cPoints == 0)
934 {
935 pushToPoints(x, y);
936 pushToPoints(x, y);
937 }
938 else
939 {
940 s_pPoints[s_cPoints - 1] = { x, y };
941 }
942
944 }
945
946 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
947 {
948 if (s_cPoints > 0)
949 s_pPoints[s_cPoints - 1] = { x, y };
951 return TRUE;
952 }
953
954 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
955 {
956 if (s_cPoints >= 4)
957 {
959 return TRUE;
960 }
961 pushToPoints(x, y);
963 return TRUE;
964 }
965
966 void OnEndDraw(BOOL bCancel) override
967 {
968 if (!bCancel && s_cPoints > 1)
969 {
970 // FIXME: I couldn't calculate boundary rectangle from Bezier curve
973 }
974 ToolBase::OnEndDraw(bCancel);
975 }
976
977 void OnSpecialTweak(BOOL bMinus) override
978 {
980 }
981};
982
983// TOOL_RECT
985{
987 {
988 if (!m_bDrawing)
989 return;
990 if (GetAsyncKeyState(VK_SHIFT) < 0)
992 if (m_bLeftButton)
994 else
996 }
997};
998
999// TOOL_SHAPE
1001{
1004
1006 {
1007 if (s_cPoints <= 0)
1008 return;
1009
1010 if (m_bLeftButton)
1012 else
1014 }
1015
1016 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
1017 {
1018 m_bLeftButton = bLeftButton;
1019 m_bClosed = FALSE;
1020
1021 if ((s_cPoints > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
1023
1024 pushToPoints(x, y);
1025
1026 if (s_cPoints > 1 && bDoubleClick)
1027 {
1029 return;
1030 }
1031
1032 if (s_cPoints == 1)
1033 pushToPoints(x, y); // We have to draw the first point
1034
1036 }
1037
1038 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
1039 {
1040 if (s_cPoints > 1)
1041 {
1042 if (GetAsyncKeyState(VK_SHIFT) < 0)
1044
1045 s_pPoints[s_cPoints - 1] = { x, y };
1046 }
1047
1049 return TRUE;
1050 }
1051
1052 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
1053 {
1054 if ((s_cPoints > 1) && (GetAsyncKeyState(VK_SHIFT) < 0))
1056
1057 m_bClosed = FALSE;
1058 if (nearlyEqualPoints(x, y, s_pPoints[0].x, s_pPoints[0].y))
1059 {
1061 return TRUE;
1062 }
1063
1064 pushToPoints(x, y);
1066 return TRUE;
1067 }
1068
1069 void OnEndDraw(BOOL bCancel) override
1070 {
1071 if (!bCancel && s_cPoints > 1)
1072 {
1073 CRect rcPartial;
1075
1077 rcPartial.InflateRect((size.cx + 1) / 2, (size.cy + 1) / 2);
1078
1079 imageModel.PushImageForUndo(rcPartial);
1080
1081 m_bClosed = TRUE;
1083 }
1084 m_bClosed = FALSE;
1085 ToolBase::OnEndDraw(bCancel);
1086 }
1087
1088 void OnSpecialTweak(BOOL bMinus) override
1089 {
1091 }
1092};
1093
1094// TOOL_ELLIPSE
1096{
1098 {
1099 if (!m_bDrawing)
1100 return;
1101 if (GetAsyncKeyState(VK_SHIFT) < 0)
1103 if (m_bLeftButton)
1105 else
1107 }
1108};
1109
1110// TOOL_RRECT
1112{
1114 {
1115 if (!m_bDrawing)
1116 return;
1117 if (GetAsyncKeyState(VK_SHIFT) < 0)
1119 if (m_bLeftButton)
1121 else
1123 }
1124};
1125
1126/*static*/ ToolBase*
1128{
1129 switch (type)
1130 {
1131 case TOOL_FREESEL: return new FreeSelTool();
1132 case TOOL_RECTSEL: return new RectSelTool();
1133 case TOOL_RUBBER: return new RubberTool();
1134 case TOOL_FILL: return new FillTool();
1135 case TOOL_COLOR: return new ColorTool();
1136 case TOOL_ZOOM: return new ZoomTool();
1137 case TOOL_PEN: return new PenTool();
1138 case TOOL_BRUSH: return new BrushTool();
1139 case TOOL_AIRBRUSH: return new AirBrushTool();
1140 case TOOL_TEXT: return new TextTool();
1141 case TOOL_LINE: return new LineTool();
1142 case TOOL_BEZIER: return new BezierTool();
1143 case TOOL_RECT: return new RectTool();
1144 case TOOL_SHAPE: return new ShapeTool();
1145 case TOOL_ELLIPSE: return new EllipseTool();
1146 case TOOL_RRECT: return new RRectTool();
1147 }
1149 return NULL;
1150}
1151
1152void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
1153{
1155 g_ptEnd = g_ptStart = { x, y };
1156 m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick);
1158}
1159
1161{
1163 if (m_pToolObject->OnMouseMove(bLeftButton, x, y))
1164 g_ptEnd = { x, y };
1165
1167}
1168
1170{
1172 if (m_pToolObject->OnButtonUp(bLeftButton, x, y))
1173 g_ptEnd = { x, y };
1174
1176}
1177
1179{
1180 ATLTRACE("ToolsModel::OnEndDraw(%d)\n", bCancel);
1182 m_pToolObject->OnEndDraw(bCancel);
1184}
1185
1187{
1189}
1190
1192{
1194}
1195
1197{
1199}
1200
1202{
1203 LONG xRel = pt.x - g_ptStart.x, yRel = pt.y - g_ptStart.y;
1204
1205 switch (m_activeTool)
1206 {
1207 // freesel, rectsel and text tools always show numbers limited to fit into image area
1208 case TOOL_FREESEL:
1209 case TOOL_RECTSEL:
1210 case TOOL_TEXT:
1211 if (xRel < 0)
1212 xRel = (pt.x < 0) ? -g_ptStart.x : xRel;
1213 else if (pt.x > imageModel.GetWidth())
1214 xRel = imageModel.GetWidth() - g_ptStart.x;
1215 if (yRel < 0)
1216 yRel = (pt.y < 0) ? -g_ptStart.y : yRel;
1217 else if (pt.y > imageModel.GetHeight())
1218 yRel = imageModel.GetHeight() - g_ptStart.y;
1219 break;
1220
1221 // while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14
1222 case TOOL_RUBBER:
1223 case TOOL_PEN:
1224 case TOOL_BRUSH:
1225 case TOOL_AIRBRUSH:
1226 case TOOL_SHAPE:
1227 {
1228 CStringW strCoord;
1229 strCoord.Format(L"%ld, %ld", pt.x, pt.y);
1231 break;
1232 }
1233 default:
1234 break;
1235 }
1236
1237 // rectsel and shape tools always show non-negative numbers when drawing
1239 {
1240 xRel = labs(xRel);
1241 yRel = labs(yRel);
1242 }
1243
1244 if (wParam & MK_LBUTTON)
1245 {
1246 OnMouseMove(TRUE, pt.x, pt.y);
1247 canvasWindow.Invalidate(FALSE);
1248 if ((m_activeTool >= TOOL_TEXT) || IsSelection())
1249 {
1250 CStringW strSize;
1252 yRel = xRel;
1253 strSize.Format(L"%ld x %ld", xRel, yRel);
1255 }
1256 }
1257
1258 if (wParam & MK_RBUTTON)
1259 {
1260 OnMouseMove(FALSE, pt.x, pt.y);
1261 canvasWindow.Invalidate(FALSE);
1262 if (m_activeTool >= TOOL_TEXT)
1263 {
1264 CStringW strSize;
1266 yRel = xRel;
1267 strSize.Format(L"%ld x %ld", xRel, yRel);
1269 }
1270 }
1271}
valarray< _Tp > atan2(const valarray< _Tp > &__x, const valarray< _Tp > &__y)
Definition: _valarray.h:928
Arabic default style
Definition: afstyles.h:94
unsigned int dir
Definition: maze.c:112
#define ATLTRACE(format,...)
Definition: atltrace.h:269
CFontsDialog fontsDialog
Definition: dialogs.cpp:16
HWND g_hStatusBar
Definition: main.cpp:23
CMainWindow mainWindow
Definition: main.cpp:25
static POINT g_ptEnd
Definition: mouse.cpp:17
static SIZE_T s_maxPoints
Definition: mouse.cpp:15
void BuildMaskFromPoints()
Definition: mouse.cpp:84
static LPPOINT s_pPoints
Definition: mouse.cpp:16
static POINT s_staticPoints[512]
Definition: mouse.cpp:14
BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1)
Definition: mouse.cpp:49
void regularize(LONG x0, LONG y0, LONG &x1, LONG &y1)
Definition: mouse.cpp:22
#define THRESHOULD_DEG
Definition: mouse.cpp:220
static void RestrictDrawDirection(DIRECTION dir, LONG x0, LONG y0, LONG &x1, LONG &y1)
Definition: mouse.cpp:276
static DIRECTION GetDirection(LONG x0, LONG y0, LONG x1, LONG y1)
Definition: mouse.cpp:223
void ShiftPoints(INT dx, INT dy)
Definition: mouse.cpp:74
DIRECTION
Definition: mouse.cpp:212
@ NO_DIRECTION
Definition: mouse.cpp:213
@ DIRECTION_DIAGONAL_RIGHT_UP
Definition: mouse.cpp:217
@ DIRECTION_HORIZONTAL
Definition: mouse.cpp:214
@ DIRECTION_VERTICAL
Definition: mouse.cpp:215
@ DIRECTION_DIAGONAL_RIGHT_DOWN
Definition: mouse.cpp:216
void getBoundaryOfPoints(RECT &rcBoundary, SIZE_T cPoints, const POINT *pPoints)
Definition: mouse.cpp:56
static CHeapPtr< POINT, CLocalAllocator > s_dynamicPoints
Definition: mouse.cpp:13
static void pushToPoints(LONG x, LONG y)
Definition: mouse.cpp:143
void roundTo8Directions(LONG x0, LONG y0, LONG &x1, LONG &y1)
Definition: mouse.cpp:31
static POINT g_ptStart
Definition: mouse.cpp:17
static SIZE_T s_cPoints
Definition: mouse.cpp:12
ToolsModel toolsModel
Definition: toolsmodel.cpp:10
RegistrySettings registrySettings
Definition: registry.cpp:14
#define GRIP_SIZE
Definition: precomp.h:43
#define MAX_ZOOM
Definition: precomp.h:45
#define MIN_ZOOM
Definition: precomp.h:44
SelectionModel selectionModel
HITTEST
Definition: precomp.h:55
@ HIT_NONE
Definition: precomp.h:56
CTextEditWindow textEditWindow
Definition: textedit.cpp:12
#define RAD2DEG(radian)
Definition: precomp.h:77
#define DEG2RAD(degree)
Definition: precomp.h:76
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
CCanvasWindow canvasWindow
Definition: canvas.cpp:10
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
BOOL m_drawing
Definition: canvas.h:43
VOID ImageToCanvas(POINT &pt)
Definition: canvas.cpp:40
VOID GetImageRect(RECT &rc)
Definition: canvas.cpp:66
VOID getNewZoomRect(CRect &rcView, INT newZoom, CPoint ptTarget)
Definition: canvas.cpp:79
VOID zoomTo(INT newZoom, LONG left=0, LONG top=0)
Definition: canvas.cpp:107
VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu)
Definition: main.cpp:1316
void InflateRect(int x, int y) noexcept
Definition: atltypes.h:323
BOOL PtInRect(POINT point) const noexcept
Definition: atltypes.h:418
void NormalizeRect() noexcept
Definition: atltypes.h:387
void SetRect(int x1, int y1, int x2, int y2) noexcept
Definition: atltypes.h:423
int Width() const noexcept
Definition: atltypes.h:461
int Height() const noexcept
Definition: atltypes.h:318
BOOL IsRectEmpty() const noexcept
Definition: atltypes.h:351
BOOL GetEditRect(LPRECT prc) const
Definition: textedit.cpp:377
void InvalidateEditRect()
Definition: textedit.cpp:281
HWND Create(HWND hwndParent)
Definition: textedit.cpp:224
HFONT GetFont() const
Definition: textedit.h:25
void ValidateEditRect(LPCRECT prc OPTIONAL)
Definition: textedit.cpp:383
int GetWidth() const
Definition: history.cpp:253
void PushImageForUndo()
Definition: history.cpp:127
void NotifyImageChanged()
Definition: history.cpp:23
int GetHeight() const
Definition: history.cpp:258
HDC GetDC()
Definition: history.cpp:271
void Clamp(POINT &pt) const
Definition: history.cpp:314
COLORREF GetBgColor() const
void SetFgColor(COLORREF newColor)
void SetBgColor(COLORREF newColor)
COLORREF GetFgColor() const
DWORD ShowTextTool
Definition: registry.h:41
void DrawBackground(HDC hDCImage, COLORREF crBg)
void DrawSelection(HDC hDCImage, COLORREF crBg, BOOL bBgTransparent, const CRect &rc, HBITMAP hbm)
COLORREF m_rgbBack
void drawFrameOnCanvas(HDC hCanvasDC)
void Dragging(HITTEST hit, POINT pt)
void setMask(const CRect &rc, HBITMAP hbmMask)
HITTEST hitTest(POINT ptCanvas)
BOOL IsLanded() const
void SetRectFromPoints(const POINT &ptFrom, const POINT &ptTo)
void StretchSelection(BOOL bShrink)
void MakeAirBrushThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:100
void OnDrawOverlayOnCanvas(HDC hdc)
Definition: mouse.cpp:1191
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1186
void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:1178
void MakeBrushThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:94
int GetZoom() const
Definition: toolsmodel.cpp:261
int GetLineWidth() const
Definition: toolsmodel.cpp:46
BOOL IsSelection() const
Definition: toolsmodel.cpp:41
int GetShapeStyle() const
Definition: toolsmodel.cpp:112
TOOLTYPE GetOldActiveTool() const
Definition: toolsmodel.cpp:139
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:144
void DrawWithMouseTool(POINT pt, WPARAM wParam)
Definition: mouse.cpp:1201
void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1160
INT GetPenWidth() const
Definition: toolsmodel.cpp:58
BrushStyle GetBrushStyle() const
Definition: toolsmodel.cpp:123
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: mouse.cpp:1152
void MakeRubberThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:106
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:249
TOOLTYPE m_activeTool
Definition: toolsmodel.h:75
int GetRubberRadius() const
Definition: toolsmodel.cpp:194
ToolBase * m_pToolObject
Definition: toolsmodel.h:81
void MakeLineThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:82
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:134
void MakePenThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:88
void SpecialTweak(BOOL bMinus)
Definition: mouse.cpp:1196
INT GetAirBrushRadius() const
Definition: toolsmodel.cpp:183
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1169
INT GetBrushWidth() const
Definition: toolsmodel.cpp:70
SIZE GetToolSize() const
Definition: toolsmodel.cpp:205
WPARAM wParam
Definition: combotst.c:138
char * Text
Definition: combotst.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define pt(x, y)
Definition: drawing.c:79
void RectSel(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2)
Definition: drawing.cpp:233
void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int thickness)
Definition: drawing.cpp:93
void Ellp(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
Definition: drawing.cpp:38
void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed, BOOL inverted)
Definition: drawing.cpp:68
void DrawXorRect(HDC hdc, const RECT *prc)
Definition: drawing.cpp:362
void RRect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
Definition: drawing.cpp:53
void Replace(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius)
Definition: drawing.cpp:132
void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
Definition: drawing.cpp:115
void Airbrush(HDC hdc, LONG x, LONG y, COLORREF color, LONG r)
Definition: drawing.cpp:153
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:107
#define RGB(r, g, b)
Definition: precomp.h:71
static INT cxMin
Definition: eventvwr.c:4312
static INT cyMin
Definition: eventvwr.c:4312
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ImageModel imageModel
Definition: history.cpp:11
_Check_return_ long __cdecl labs(_In_ long x)
void __cdecl srand(_In_ unsigned int _Seed)
GLint dy
Definition: linetemp.h:97
GLint y0
Definition: linetemp.h:96
if(dx< 0)
Definition: linetemp.h:194
GLint x0
Definition: linetemp.h:95
GLint dx
Definition: linetemp.h:97
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define min(a, b)
Definition: monoChain.cc:55
#define UNREACHABLE
#define L(x)
Definition: ntvdm.h:50
PaletteModel paletteModel
long LONG
Definition: pedump.c:60
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
#define SB_SETTEXT
Definition: commctrl.h:1949
#define _countof(array)
Definition: sndvol32.h:68
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:757
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:751
DWORD m_dwTick
Definition: mouse.cpp:737
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:745
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:739
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:966
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:946
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:977
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:929
BOOL m_bLeftButton
Definition: mouse.cpp:909
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:954
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:911
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:721
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:728
void fetchColor(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:614
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:629
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:635
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:1097
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:604
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:556
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:895
Definition: ncftp.h:79
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:712
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:706
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:1113
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:571
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:986
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:595
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:587
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:547
HITTEST m_hitSelection
Definition: mouse.cpp:380
void OnDrawOverlayOnCanvas(HDC hdc) override
Definition: mouse.cpp:398
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:456
BOOL isRectSelect() const
Definition: mouse.cpp:382
BOOL m_bLeftButton
Definition: mouse.cpp:375
BOOL m_bNoDrawBack
Definition: mouse.cpp:379
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:404
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:387
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:487
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:535
BOOL m_bClosed
Definition: mouse.cpp:1003
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1005
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:1038
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:1069
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:1052
BOOL m_bLeftButton
Definition: mouse.cpp:1002
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:1016
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:1088
virtual void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1)=0
BOOL m_bLeftButton
Definition: mouse.cpp:306
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:364
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:310
BOOL m_bShiftDown
Definition: mouse.cpp:305
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:321
DIRECTION m_direction
Definition: mouse.cpp:304
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:343
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:784
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:766
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:821
void quit()
Definition: mouse.cpp:814
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:792
void UpdatePoint(LONG x, LONG y)
Definition: mouse.cpp:776
void draw(HDC hdc)
Definition: mouse.cpp:798
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:876
void endEvent()
Definition: mouse.cpp:138
virtual BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y)
Definition: toolsmodel.h:50
virtual void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: toolsmodel.h:49
HDC m_hdc
Definition: toolsmodel.h:43
virtual void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:125
virtual void OnSpecialTweak(BOOL bMinus)
Definition: toolsmodel.h:56
void reset()
Definition: mouse.cpp:106
static ToolBase * createToolObject(TOOLTYPE type)
Definition: mouse.cpp:1127
COLORREF m_fg
Definition: toolsmodel.h:44
virtual void OnDrawOverlayOnImage(HDC hdc)
Definition: toolsmodel.h:53
void beginEvent()
Definition: mouse.cpp:131
virtual void OnDrawOverlayOnCanvas(HDC hdc)
Definition: toolsmodel.h:54
virtual BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y)
Definition: toolsmodel.h:51
COLORREF m_bg
Definition: toolsmodel.h:44
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:199
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:179
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:205
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:172
BOOL m_bLeftButton
Definition: mouse.cpp:169
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:185
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:658
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:679
void OnDrawOverlayOnCanvas(HDC hdc) override
Definition: mouse.cpp:650
BOOL getNewZoomRect(CRect &rcView, INT newZoom)
Definition: mouse.cpp:688
BOOL m_bZoomed
Definition: mouse.cpp:646
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define max(a, b)
Definition: svc.c:63
#define CY_MINTEXTEDIT
Definition: textedit.h:11
#define CX_MINTEXTEDIT
Definition: textedit.h:10
static int UnZoomed(int xy)
Definition: toolsmodel.h:155
TOOLTYPE
Definition: toolsmodel.h:11
@ TOOL_AIRBRUSH
Definition: toolsmodel.h:20
@ TOOL_COLOR
Definition: toolsmodel.h:16
@ TOOL_SHAPE
Definition: toolsmodel.h:25
@ TOOL_RUBBER
Definition: toolsmodel.h:14
@ TOOL_BRUSH
Definition: toolsmodel.h:19
@ TOOL_RECT
Definition: toolsmodel.h:24
@ TOOL_BEZIER
Definition: toolsmodel.h:23
@ TOOL_FILL
Definition: toolsmodel.h:15
@ TOOL_TEXT
Definition: toolsmodel.h:21
@ TOOL_PEN
Definition: toolsmodel.h:18
@ TOOL_LINE
Definition: toolsmodel.h:22
@ TOOL_FREESEL
Definition: toolsmodel.h:12
@ TOOL_ZOOM
Definition: toolsmodel.h:17
@ TOOL_ELLIPSE
Definition: toolsmodel.h:26
@ TOOL_RRECT
Definition: toolsmodel.h:27
@ TOOL_RECTSEL
Definition: toolsmodel.h:13
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
#define MAXLONG
Definition: umtypes.h:116
#define MINLONG
Definition: umtypes.h:115
HDC hdcMem
Definition: welcome.c:104
#define POINT
Definition: precomp.h:30
#define CopyMemory
Definition: winbase.h:1710
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3521
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define WHITE_BRUSH
Definition: wingdi.h:902
#define NULL_PEN
Definition: wingdi.h:904
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
#define MK_RBUTTON
Definition: winuser.h:2368
#define SW_HIDE
Definition: winuser.h:768
#define SM_CXDRAG
Definition: winuser.h:1028
#define VK_CONTROL
Definition: winuser.h:2203
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2670
#define SW_SHOWNOACTIVATE
Definition: winuser.h:774
#define MK_LBUTTON
Definition: winuser.h:2367
#define VK_SHIFT
Definition: winuser.h:2202
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define SM_CYDRAG
Definition: winuser.h:1029
BOOL WINAPI IsWindowVisible(_In_ HWND)
int WINAPI GetSystemMetrics(_In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SHORT WINAPI GetKeyState(_In_ int)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185