ReactOS 0.4.17-dev-470-gf9e3448
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 */
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, toolsModel.GetBgBrush(), toolsModel.GetRubberRadius());
591 else
592 Replace(hdc, pt0.x, pt0.y, pt1.x, pt1.y, m_fg, toolsModel.GetBgBrush(), 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 HBRUSH hBrush = (bLeftButton ? toolsModel.GetFgBrush() : toolsModel.GetBgBrush());
608 Fill(m_hdc, x, y, hBrush);
609 }
610};
611
612// TOOL_COLOR
614{
616 {
617 if (0 <= x && x < imageModel.GetWidth() && 0 <= y && y < imageModel.GetHeight())
618 return GetPixel(m_hdc, x, y);
619 return RGB(255, 255, 255); // Outside is white
620 }
621
622 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
623 {
624 COLORREF rgbColor = fetchColor(x, y);
625 toolSettingsWindow.SendMessage(WM_TOOLSMODELCOLORPICKED, rgbColor, 0);
626 }
627
628 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
629 {
630 COLORREF rgbColor = fetchColor(x, y);
631 toolSettingsWindow.SendMessage(WM_TOOLSMODELCOLORPICKED, rgbColor, 0);
632 return TRUE;
633 }
634
635 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
636 {
637 COLORREF rgbColor = fetchColor(x, y);
638 if (bLeftButton)
639 paletteModel.SetFgColor(rgbColor);
640 else
641 paletteModel.SetBgColor(rgbColor);
642
644 return TRUE;
645 }
646};
647
648// TOOL_ZOOM
650{
652
653 BOOL getNewZoomRect(CRect& rcView, INT newZoom);
654
656 {
657 CRect rcView;
658 INT oldZoom = toolsModel.GetZoom();
659 if (oldZoom < MAX_ZOOM && getNewZoomRect(rcView, oldZoom * 2))
660 DrawXorRect(hdc, &rcView);
661 }
662
663 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
664 {
665 INT newZoom, oldZoom = toolsModel.GetZoom();
666 if (bLeftButton)
667 newZoom = (oldZoom < MAX_ZOOM) ? (oldZoom * 2) : MIN_ZOOM;
668 else
669 newZoom = (oldZoom > MIN_ZOOM) ? (oldZoom / 2) : MAX_ZOOM;
670
672
673 if (oldZoom != newZoom)
674 {
675 CRect rcView;
676 if (getNewZoomRect(rcView, newZoom))
677 {
678 canvasWindow.zoomTo(newZoom, rcView.left, rcView.top);
679 m_bZoomed = TRUE;
680 }
681 }
682 }
683
684 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
685 {
686 if (m_bZoomed)
688
689 return TRUE;
690 }
691};
692
694{
695 CPoint pt;
697 canvasWindow.ScreenToClient(&pt);
698
699 canvasWindow.getNewZoomRect(rcView, newZoom, pt);
700
701 CRect rc;
704
705 return rc.PtInRect(pt);
706}
707
708// TOOL_PEN
710{
711 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
712 {
713 HBRUSH hBrush = (bLeftButton ? toolsModel.GetFgBrush() : toolsModel.GetBgBrush());
714 Line(hdc, pt0.x, pt0.y, pt1.x, pt1.y, hBrush, toolsModel.GetPenWidth());
715 }
716
717 void OnSpecialTweak(BOOL bMinus) override
718 {
720 }
721};
722
723// TOOL_BRUSH
725{
726 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
727 {
728 HBRUSH hBrush = (bLeftButton ? toolsModel.GetFgBrush() : toolsModel.GetBgBrush());
729 Brush(hdc, pt0.x, pt0.y, pt1.x, pt1.y, hBrush, toolsModel.GetBrushStyle(),
731 }
732
733 void OnSpecialTweak(BOOL bMinus) override
734 {
736 }
737};
738
739// TOOL_AIRBRUSH
741{
743
744 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
745 {
747 SmoothDrawTool::OnButtonDown(bLeftButton, x, y, bDoubleClick);
748 }
749
751 {
754 }
755
756 void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
757 {
758 HBRUSH hBrush = (bLeftButton ? toolsModel.GetFgBrush() : toolsModel.GetBgBrush());
759 Airbrush(hdc, pt1.x, pt1.y, hBrush, toolsModel.GetAirBrushRadius());
760 }
761
762 void OnSpecialTweak(BOOL bMinus) override
763 {
765 }
766};
767
768// TOOL_TEXT
770{
772 {
774 {
776 if (!rc.IsRectEmpty())
777 RectSel(hdc, rc.left, rc.top, rc.right, rc.bottom);
778 }
779 }
780
782 {
783 POINT pt = { x, y };
787 }
788
789 void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
790 {
791 if (!textEditWindow.IsWindow())
793
794 UpdatePoint(x, y);
795 }
796
797 BOOL OnMouseMove(BOOL bLeftButton, LONG& x, LONG& y) override
798 {
799 UpdatePoint(x, y);
800 return TRUE;
801 }
802
804 {
805 CStringW szText;
806 textEditWindow.GetWindowText(szText);
807
808 CRect rc;
811 rc.InflateRect(-GRIP_SIZE / 2, -GRIP_SIZE / 2);
812
813 // Draw the text
815 Text(hdc, rc.left, rc.top, rc.right, rc.bottom, toolsModel.GetFgBrush(), toolsModel.GetBgBrush(), szText,
817 }
818
819 void quit()
820 {
821 if (textEditWindow.IsWindow())
822 textEditWindow.ShowWindow(SW_HIDE);
824 }
825
826 BOOL OnButtonUp(BOOL bLeftButton, LONG& x, LONG& y) override
827 {
828 POINT pt = { x, y };
831
832 BOOL bTextBoxShown = ::IsWindowVisible(textEditWindow);
833 if (bTextBoxShown)
834 {
835 if (textEditWindow.GetWindowTextLength() > 0)
836 {
838 draw(m_hdc);
839 }
841 {
842 quit();
843 return TRUE;
844 }
845 }
846
848 {
849 if (!fontsDialog.IsWindow())
850 fontsDialog.Create(mainWindow);
851
852 fontsDialog.ShowWindow(SW_SHOWNOACTIVATE);
853 }
854
856
857 // Enlarge if tool small
860 {
861 rc.SetRect(x, y, x + cxMin, y + cyMin);
862 }
863 else
864 {
865 if (rc.right - rc.left < cxMin)
866 rc.right = rc.left + cxMin;
867 if (rc.bottom - rc.top < cyMin)
868 rc.bottom = rc.top + cyMin;
869 }
870
871 if (!textEditWindow.IsWindow())
873
874 textEditWindow.SetWindowText(NULL);
877 textEditWindow.SetFocus();
878 return TRUE;
879 }
880
881 void OnEndDraw(BOOL bCancel) override
882 {
883 if (!bCancel)
884 {
886 textEditWindow.GetWindowTextLength() > 0)
887 {
889 draw(m_hdc);
890 }
891 }
892 quit();
893 ToolBase::OnEndDraw(bCancel);
894 }
895};
896
897// TOOL_LINE
899{
901 {
902 if (!m_bDrawing)
903 return;
904 if (GetAsyncKeyState(VK_SHIFT) < 0)
906 HBRUSH hBrush = (m_bLeftButton ? toolsModel.GetFgBrush() : toolsModel.GetBgBrush());
908 }
909};
910
911// TOOL_BEZIER
913{
915
917 {
918 HBRUSH hBrush = (m_bLeftButton ? toolsModel.GetFgBrush() : toolsModel.GetBgBrush());
919 switch (s_cPoints)
920 {
921 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:131
void OnDrawOverlayOnCanvas(HDC hdc)
Definition: mouse.cpp:1195
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1190
void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:1182
HBRUSH GetFgBrush()
Definition: toolsmodel.cpp:357
void MakeBrushThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:125
int GetZoom() const
Definition: toolsmodel.cpp:294
int GetLineWidth() const
Definition: toolsmodel.cpp:70
HBRUSH GetBgBrush()
Definition: toolsmodel.cpp:362
BOOL IsSelection() const
Definition: toolsmodel.cpp:65
int GetShapeStyle() const
Definition: toolsmodel.cpp:143
TOOLTYPE GetOldActiveTool() const
Definition: toolsmodel.cpp:171
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:176
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:82
BrushStyle GetBrushStyle() const
Definition: toolsmodel.cpp:154
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: mouse.cpp:1156
void MakeRubberThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:137
BOOL IsBackgroundTransparent() const
Definition: toolsmodel.cpp:282
TOOLTYPE m_activeTool
Definition: toolsmodel.h:88
int GetRubberRadius() const
Definition: toolsmodel.cpp:226
ToolBase * m_pToolObject
Definition: toolsmodel.h:94
void MakeLineThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:113
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:166
void MakePenThickerOrThinner(BOOL bThinner)
Definition: toolsmodel.cpp:119
void SpecialTweak(BOOL bMinus)
Definition: mouse.cpp:1200
INT GetAirBrushRadius() const
Definition: toolsmodel.cpp:215
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1173
INT GetBrushWidth() const
Definition: toolsmodel.cpp:94
SIZE GetToolSize() const
Definition: toolsmodel.cpp:238
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:481
void Bezier(HDC hdc, POINT p1, POINT p2, POINT p3, POINT p4, COLORREF color, int thickness)
Definition: drawing.cpp:249
void Ellp(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
Definition: drawing.cpp:98
void Poly(HDC hdc, POINT *lpPoints, int nCount, COLORREF fg, COLORREF bg, int thickness, int style, BOOL closed, BOOL inverted)
Definition: drawing.cpp:184
void DrawXorRect(HDC hdc, const RECT *prc)
Definition: drawing.cpp:639
void RRect(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, int thickness, int style)
Definition: drawing.cpp:141
void Replace(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius)
Definition: drawing.cpp:324
void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
Definition: drawing.cpp:302
void Airbrush(HDC hdc, LONG x, LONG y, COLORREF color, LONG r)
Definition: drawing.cpp:369
void Fill(HDC hdc, LONG x, LONG y, COLORREF color)
Definition: drawing.cpp:286
#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:762
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:756
DWORD m_dwTick
Definition: mouse.cpp:742
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:750
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:744
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:914
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:958
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:916
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:726
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:733
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:628
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick) override
Definition: mouse.cpp:622
COLORREF fetchColor(LONG x, LONG y)
Definition: mouse.cpp:615
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:635
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:900
Definition: ncftp.h:79
void OnSpecialTweak(BOOL bMinus) override
Definition: mouse.cpp:717
void OnDraw(HDC hdc, BOOL bLeftButton, POINT pt0, POINT pt1) override
Definition: mouse.cpp:711
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:789
void OnDrawOverlayOnImage(HDC hdc) override
Definition: mouse.cpp:771
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:826
void quit()
Definition: mouse.cpp:819
BOOL OnMouseMove(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:797
void UpdatePoint(LONG x, LONG y)
Definition: mouse.cpp:781
void draw(HDC hdc)
Definition: mouse.cpp:803
void OnEndDraw(BOOL bCancel) override
Definition: mouse.cpp:881
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:663
BOOL OnButtonUp(BOOL bLeftButton, LONG &x, LONG &y) override
Definition: mouse.cpp:684
void OnDrawOverlayOnCanvas(HDC hdc) override
Definition: mouse.cpp:655
BOOL getNewZoomRect(CRect &rcView, INT newZoom)
Definition: mouse.cpp:693
BOOL m_bZoomed
Definition: mouse.cpp:651
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, BOOL bRound=FALSE)
Definition: toolsmodel.h:175
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_ 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)