ReactOS 0.4.17-dev-357-ga8f14ff
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{
615 {
616 if (0 <= x && x < imageModel.GetWidth() && 0 <= y && y < imageModel.GetHeight())
617 return GetPixel(m_hdc, x, y);
618 return RGB(255, 255, 255); // Outside is white
619 }
620
621 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
622 {
623 COLORREF rgbColor = fetchColor(x, y);
624 toolSettingsWindow.SendMessage(WM_TOOLSMODELCOLORPICKED, rgbColor, 0);
625 }
626
627 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
628 {
629 COLORREF rgbColor = fetchColor(x, y);
630 toolSettingsWindow.SendMessage(WM_TOOLSMODELCOLORPICKED, rgbColor, 0);
631 return TRUE;
632 }
633
634 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
635 {
636 COLORREF rgbColor = fetchColor(x, y);
637 if (bLeftButton)
638 paletteModel.SetFgColor(rgbColor);
639 else
640 paletteModel.SetBgColor(rgbColor);
641
643 return TRUE;
644 }
645};
646
647// TOOL_ZOOM
649{
651
652 BOOL getNewZoomRect(CRect& rcView, INT newZoom);
653
655 {
656 CRect rcView;
657 INT oldZoom = toolsModel.GetZoom();
658 if (oldZoom < MAX_ZOOM && getNewZoomRect(rcView, oldZoom * 2))
659 DrawXorRect(hdc, &rcView);
660 }
661
662 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
663 {
664 INT newZoom, oldZoom = toolsModel.GetZoom();
665 if (bLeftButton)
666 newZoom = (oldZoom < MAX_ZOOM) ? (oldZoom * 2) : MIN_ZOOM;
667 else
668 newZoom = (oldZoom > MIN_ZOOM) ? (oldZoom / 2) : MAX_ZOOM;
669
671
672 if (oldZoom != newZoom)
673 {
674 CRect rcView;
675 if (getNewZoomRect(rcView, newZoom))
676 {
677 canvasWindow.zoomTo(newZoom, rcView.left, rcView.top);
678 m_bZoomed = TRUE;
679 }
680 }
681 }
682
683 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
684 {
685 if (m_bZoomed)
687
688 return TRUE;
689 }
690};
691
693{
694 CPoint pt;
696 canvasWindow.ScreenToClient(&pt);
697
698 canvasWindow.getNewZoomRect(rcView, newZoom, pt);
699
700 CRect rc;
703
704 return rc.PtInRect(pt);
705}
706
707// TOOL_PEN
709{
710 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
711 {
712 COLORREF rgb = bLeftButton ? m_fg : m_bg;
713 Line(hdc, pt0.x, pt0.y, pt1.x, pt1.y, rgb, toolsModel.GetPenWidth());
714 }
715
716 void OnSpecialTweak(BOOL bMinus) override
717 {
719 }
720};
721
722// TOOL_BRUSH
724{
725 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
726 {
727 COLORREF rgb = bLeftButton ? m_fg : m_bg;
728 Brush(hdc, pt0.x, pt0.y, pt1.x, pt1.y, rgb, toolsModel.GetBrushStyle(),
730 }
731
732 void OnSpecialTweak(BOOL bMinus) override
733 {
735 }
736};
737
738// TOOL_AIRBRUSH
740{
742
743 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
744 {
746 SmoothDrawTool::OnButtonDown(bLeftButton, x, y, bDoubleClick);
747 }
748
750 {
753 }
754
755 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
756 {
757 COLORREF rgb = bLeftButton ? m_fg : m_bg;
759 }
760
761 void OnSpecialTweak(BOOL bMinus) override
762 {
764 }
765};
766
767// TOOL_TEXT
769{
771 {
773 {
775 if (!rc.IsRectEmpty())
776 RectSel(hdc, rc.left, rc.top, rc.right, rc.bottom);
777 }
778 }
779
781 {
782 POINT pt = { x, y };
786 }
787
788 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
789 {
790 if (!textEditWindow.IsWindow())
792
793 UpdatePoint(x, y);
794 }
795
796 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
797 {
798 UpdatePoint(x, y);
799 return TRUE;
800 }
801
803 {
804 CStringW szText;
805 textEditWindow.GetWindowText(szText);
806
807 CRect rc;
810 rc.InflateRect(-GRIP_SIZE / 2, -GRIP_SIZE / 2);
811
812 // Draw the text
814 Text(hdc, rc.left, rc.top, rc.right, rc.bottom, m_fg, m_bg, szText,
816 }
817
818 void quit()
819 {
820 if (textEditWindow.IsWindow())
821 textEditWindow.ShowWindow(SW_HIDE);
823 }
824
825 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
826 {
827 POINT pt = { x, y };
830
831 BOOL bTextBoxShown = ::IsWindowVisible(textEditWindow);
832 if (bTextBoxShown)
833 {
834 if (textEditWindow.GetWindowTextLength() > 0)
835 {
837 draw(m_hdc);
838 }
840 {
841 quit();
842 return TRUE;
843 }
844 }
845
847 {
848 if (!fontsDialog.IsWindow())
849 fontsDialog.Create(mainWindow);
850
851 fontsDialog.ShowWindow(SW_SHOWNOACTIVATE);
852 }
853
855
856 // Enlarge if tool small
859 {
860 rc.SetRect(x, y, x + cxMin, y + cyMin);
861 }
862 else
863 {
864 if (rc.right - rc.left < cxMin)
865 rc.right = rc.left + cxMin;
866 if (rc.bottom - rc.top < cyMin)
867 rc.bottom = rc.top + cyMin;
868 }
869
870 if (!textEditWindow.IsWindow())
872
873 textEditWindow.SetWindowText(NULL);
876 textEditWindow.SetFocus();
877 return TRUE;
878 }
879
880 void OnEndDraw(BOOL bCancel) override
881 {
882 if (!bCancel)
883 {
885 textEditWindow.GetWindowTextLength() > 0)
886 {
888 draw(m_hdc);
889 }
890 }
891 quit();
892 ToolBase::OnEndDraw(bCancel);
893 }
894};
895
896// TOOL_LINE
898{
900 {
901 if (!m_bDrawing)
902 return;
903 if (GetAsyncKeyState(VK_SHIFT) < 0)
907 }
908};
909
910// TOOL_BEZIER
912{
914
916 {
918 switch (s_cPoints)
919 {
920 case 2:
923 break;
924 case 3:
926 break;
927 case 4:
929 break;
930 }
931 }
932
933 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
934 {
935 m_bLeftButton = bLeftButton;
936
937 if (s_cPoints == 0)
938 {
939 pushToPoints(x, y);
940 pushToPoints(x, y);
941 }
942 else
943 {
944 s_pPoints[s_cPoints - 1] = { x, y };
945 }
946
948 }
949
950 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
951 {
952 if (s_cPoints > 0)
953 s_pPoints[s_cPoints - 1] = { x, y };
955 return TRUE;
956 }
957
958 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
959 {
960 if (s_cPoints >= 4)
961 {
963 return TRUE;
964 }
965 pushToPoints(x, y);
967 return TRUE;
968 }
969
970 void OnEndDraw(BOOL bCancel) override
971 {
972 if (!bCancel && s_cPoints > 1)
973 {
974 // FIXME: I couldn't calculate boundary rectangle from Bezier curve
977 }
978 ToolBase::OnEndDraw(bCancel);
979 }
980
981 void OnSpecialTweak(BOOL bMinus) override
982 {
984 }
985};
986
987// TOOL_RECT
989{
991 {
992 if (!m_bDrawing)
993 return;
994 if (GetAsyncKeyState(VK_SHIFT) < 0)
996 if (m_bLeftButton)
998 else
1000 }
1001};
1002
1003// TOOL_SHAPE
1005{
1008
1010 {
1011 if (s_cPoints <= 0)
1012 return;
1013
1014 if (m_bLeftButton)
1016 else
1018 }
1019
1020 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
1021 {
1022 m_bLeftButton = bLeftButton;
1023 m_bClosed = FALSE;
1024
1025 if ((s_cPoints > 0) && (GetAsyncKeyState(VK_SHIFT) < 0))
1027
1028 pushToPoints(x, y);
1029
1030 if (s_cPoints > 1 && bDoubleClick)
1031 {
1033 return;
1034 }
1035
1036 if (s_cPoints == 1)
1037 pushToPoints(x, y); // We have to draw the first point
1038
1040 }
1041
1042 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
1043 {
1044 if (s_cPoints > 1)
1045 {
1046 if (GetAsyncKeyState(VK_SHIFT) < 0)
1048
1049 s_pPoints[s_cPoints - 1] = { x, y };
1050 }
1051
1053 return TRUE;
1054 }
1055
1056 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
1057 {
1058 if ((s_cPoints > 1) && (GetAsyncKeyState(VK_SHIFT) < 0))
1060
1061 m_bClosed = FALSE;
1062 if (nearlyEqualPoints(x, y, s_pPoints[0].x, s_pPoints[0].y))
1063 {
1065 return TRUE;
1066 }
1067
1068 pushToPoints(x, y);
1070 return TRUE;
1071 }
1072
1073 void OnEndDraw(BOOL bCancel) override
1074 {
1075 if (!bCancel && s_cPoints > 1)
1076 {
1077 CRect rcPartial;
1079
1081 rcPartial.InflateRect((size.cx + 1) / 2, (size.cy + 1) / 2);
1082
1083 imageModel.PushImageForUndo(rcPartial);
1084
1085 m_bClosed = TRUE;
1087 }
1088 m_bClosed = FALSE;
1089 ToolBase::OnEndDraw(bCancel);
1090 }
1091
1092 void OnSpecialTweak(BOOL bMinus) override
1093 {
1095 }
1096};
1097
1098// TOOL_ELLIPSE
1100{
1102 {
1103 if (!m_bDrawing)
1104 return;
1105 if (GetAsyncKeyState(VK_SHIFT) < 0)
1107 if (m_bLeftButton)
1109 else
1111 }
1112};
1113
1114// TOOL_RRECT
1116{
1118 {
1119 if (!m_bDrawing)
1120 return;
1121 if (GetAsyncKeyState(VK_SHIFT) < 0)
1123 if (m_bLeftButton)
1125 else
1127 }
1128};
1129
1130/*static*/ ToolBase*
1132{
1133 switch (type)
1134 {
1135 case TOOL_FREESEL: return new FreeSelTool();
1136 case TOOL_RECTSEL: return new RectSelTool();
1137 case TOOL_RUBBER: return new RubberTool();
1138 case TOOL_FILL: return new FillTool();
1139 case TOOL_COLOR: return new ColorTool();
1140 case TOOL_ZOOM: return new ZoomTool();
1141 case TOOL_PEN: return new PenTool();
1142 case TOOL_BRUSH: return new BrushTool();
1143 case TOOL_AIRBRUSH: return new AirBrushTool();
1144 case TOOL_TEXT: return new TextTool();
1145 case TOOL_LINE: return new LineTool();
1146 case TOOL_BEZIER: return new BezierTool();
1147 case TOOL_RECT: return new RectTool();
1148 case TOOL_SHAPE: return new ShapeTool();
1149 case TOOL_ELLIPSE: return new EllipseTool();
1150 case TOOL_RRECT: return new RRectTool();
1151 }
1153 return NULL;
1154}
1155
1156void ToolsModel::OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
1157{
1159 g_ptEnd = g_ptStart = { x, y };
1160 m_pToolObject->OnButtonDown(bLeftButton, x, y, bDoubleClick);
1162}
1163
1165{
1167 if (m_pToolObject->OnMouseMove(bLeftButton, x, y))
1168 g_ptEnd = { x, y };
1169
1171}
1172
1174{
1176 if (m_pToolObject->OnButtonUp(bLeftButton, x, y))
1177 g_ptEnd = { x, y };
1178
1180}
1181
1183{
1184 ATLTRACE("ToolsModel::OnEndDraw(%d)\n", bCancel);
1186 m_pToolObject->OnEndDraw(bCancel);
1188}
1189
1191{
1193}
1194
1196{
1198}
1199
1201{
1203}
1204
1206{
1207 LONG xRel = pt.x - g_ptStart.x, yRel = pt.y - g_ptStart.y;
1208
1209 switch (m_activeTool)
1210 {
1211 // freesel, rectsel and text tools always show numbers limited to fit into image area
1212 case TOOL_FREESEL:
1213 case TOOL_RECTSEL:
1214 case TOOL_TEXT:
1215 if (xRel < 0)
1216 xRel = (pt.x < 0) ? -g_ptStart.x : xRel;
1217 else if (pt.x > imageModel.GetWidth())
1218 xRel = imageModel.GetWidth() - g_ptStart.x;
1219 if (yRel < 0)
1220 yRel = (pt.y < 0) ? -g_ptStart.y : yRel;
1221 else if (pt.y > imageModel.GetHeight())
1222 yRel = imageModel.GetHeight() - g_ptStart.y;
1223 break;
1224
1225 // while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14
1226 case TOOL_RUBBER:
1227 case TOOL_PEN:
1228 case TOOL_BRUSH:
1229 case TOOL_AIRBRUSH:
1230 case TOOL_SHAPE:
1231 {
1232 CStringW strCoord;
1233 strCoord.Format(L"%ld, %ld", pt.x, pt.y);
1235 break;
1236 }
1237 default:
1238 break;
1239 }
1240
1241 // rectsel and shape tools always show non-negative numbers when drawing
1243 {
1244 xRel = labs(xRel);
1245 yRel = labs(yRel);
1246 }
1247
1248 if (wParam & MK_LBUTTON)
1249 {
1250 OnMouseMove(TRUE, pt.x, pt.y);
1251 canvasWindow.Invalidate(FALSE);
1252 if ((m_activeTool >= TOOL_TEXT) || IsSelection())
1253 {
1254 CStringW strSize;
1256 yRel = xRel;
1257 strSize.Format(L"%ld x %ld", xRel, yRel);
1259 }
1260 }
1261
1262 if (wParam & MK_RBUTTON)
1263 {
1264 OnMouseMove(FALSE, pt.x, pt.y);
1265 canvasWindow.Invalidate(FALSE);
1266 if (m_activeTool >= TOOL_TEXT)
1267 {
1268 CStringW strSize;
1270 yRel = xRel;
1271 strSize.Format(L"%ld x %ld", xRel, yRel);
1273 }
1274 }
1275}
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:57
@ HIT_NONE
Definition: precomp.h:58
#define WM_TOOLSMODELCOLORPICKED
Definition: precomp.h:52
CTextEditWindow textEditWindow
Definition: textedit.cpp:12
CToolSettingsWindow toolSettingsWindow
#define RAD2DEG(radian)
Definition: precomp.h:79
#define DEG2RAD(degree)
Definition: precomp.h:78
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
CCanvasWindow canvasWindow
Definition: canvas.cpp:11
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
BOOL m_drawing
Definition: canvas.h:76
VOID ImageToCanvas(POINT &pt)
Definition: canvas.cpp:186
VOID GetImageRect(RECT &rc)
Definition: canvas.cpp:212
VOID getNewZoomRect(CRect &rcView, INT newZoom, CPoint ptTarget)
Definition: canvas.cpp:225
VOID zoomTo(INT newZoom, LONG left=0, LONG top=0)
Definition: canvas.cpp:253
VOID TrackPopupMenu(POINT ptScreen, INT iSubMenu)
Definition: main.cpp:1330
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:254
void PushImageForUndo()
Definition: history.cpp:125
void NotifyImageChanged()
Definition: history.cpp:23
int GetHeight() const
Definition: history.cpp:259
HDC GetDC()
Definition: history.cpp:272
void Clamp(POINT &pt) const
Definition: history.cpp:315
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:107
void OnDrawOverlayOnCanvas(HDC hdc)
Definition: mouse.cpp:1195
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1190
void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:1182
void MakeBrushThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:101
int GetZoom() const
Definition: toolsmodel.cpp:270
int GetLineWidth() const
Definition: toolsmodel.cpp:46
BOOL IsSelection() const
Definition: toolsmodel.cpp:41
int GetShapeStyle() const
Definition: toolsmodel.cpp:119
TOOLTYPE GetOldActiveTool() const
Definition: toolsmodel.cpp:147
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:152
void DrawWithMouseTool(POINT pt, WPARAM wParam)
Definition: mouse.cpp:1205
void OnMouseMove(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1164
INT GetPenWidth() const
Definition: toolsmodel.cpp:58
BrushStyle GetBrushStyle() const
Definition: toolsmodel.cpp:130
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: mouse.cpp:1156
void MakeRubberThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:113
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:258
TOOLTYPE m_activeTool
Definition: toolsmodel.h:75
int GetRubberRadius() const
Definition: toolsmodel.cpp:202
ToolBase * m_pToolObject
Definition: toolsmodel.h:81
void MakeLineThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:89
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:142
void MakePenThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:95
void SpecialTweak(BOOL bMinus)
Definition: mouse.cpp:1200
INT GetAirBrushRadius() const
Definition: toolsmodel.cpp:191
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1173
INT GetBrushWidth() const
Definition: toolsmodel.cpp:70
SIZE GetToolSize() const
Definition: toolsmodel.cpp:214
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
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
_ACRTIMP double __cdecl atan2(double, double)
Definition: atan2.c:52
_ACRTIMP __msvcrt_long __cdecl labs(__msvcrt_long)
Definition: math.c:680
_ACRTIMP void __cdecl srand(unsigned int)
Definition: misc.c:50
#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:67
#define L(x)
Definition: resources.c:13
static INT cxMin
Definition: eventvwr.c:4340
static INT cyMin
Definition: eventvwr.c:4340
#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
GLint dy
Definition: linetemp.h:97
if(dx< 0)
Definition: linetemp.h:194
GLint x0
Definition: linetemp.h:95
GLint y0
Definition: linetemp.h:96
GLint dx
Definition: linetemp.h:97
#define CopyMemory
Definition: minwinbase.h:29
LONG_PTR LPARAM
Definition: minwindef.h:175
UINT_PTR WPARAM
Definition: minwindef.h:174
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
#define min(a, b)
Definition: monoChain.cc:55
#define UNREACHABLE
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:1954
#define _countof(array)
Definition: sndvol32.h:70
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:761
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:755
DWORD m_dwTick
Definition: mouse.cpp:741
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:749
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:743
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:970
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:950
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:981
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:933
BOOL m_bLeftButton
Definition: mouse.cpp:913
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:958
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:915
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:725
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:732
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:627
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:621
COLORREF fetchColor(LONG x, LONG y)
Definition: mouse.cpp:614
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:634
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:1101
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:899
Definition: ncftp.h:79
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:716
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:710
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:1117
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:571
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:990
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:1007
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1009
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:1042
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:1073
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:1056
BOOL m_bLeftButton
Definition: mouse.cpp:1006
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:1020
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:1092
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:788
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:770
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:825
void quit()
Definition: mouse.cpp:818
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:796
void UpdatePoint(LONG x, LONG y)
Definition: mouse.cpp:780
void draw(HDC hdc)
Definition: mouse.cpp:802
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:880
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:1131
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:662
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:683
void OnDrawOverlayOnCanvas(HDC hdc) override
Definition: mouse.cpp:654
BOOL getNewZoomRect(CRect &rcView, INT newZoom)
Definition: mouse.cpp:692
BOOL m_bZoomed
Definition: mouse.cpp:650
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
#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:156
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
const uint16_t * LPCWSTR
Definition: typedefs.h:57
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
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3521
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
DWORD COLORREF
Definition: windef.h:100
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:1546
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:2404
#define SW_HIDE
Definition: winuser.h:779
#define SM_CXDRAG
Definition: winuser.h:1039
#define VK_CONTROL
Definition: winuser.h:2239
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:3064
#define SW_SHOWNOACTIVATE
Definition: winuser.h:785
#define MK_LBUTTON
Definition: winuser.h:2403
#define VK_SHIFT
Definition: winuser.h:2238
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define SM_CYDRAG
Definition: winuser.h:1040
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)