ReactOS 0.4.15-dev-8236-g99f0937
canvas.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: Providing the canvas window class
5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6 */
7
8#include "precomp.h"
9
11
12/* FUNCTIONS ********************************************************/
13
14CCanvasWindow::CCanvasWindow()
15 : m_drawing(FALSE)
16 , m_hitCanvasSizeBox(HIT_NONE)
17 , m_ptOrig { -1, -1 }
18{
19 m_ahbmCached[0] = m_ahbmCached[1] = NULL;
20 m_rcResizing.SetRectEmpty();
21}
22
24{
25 if (m_ahbmCached[0])
27 if (m_ahbmCached[1])
29}
30
32{
33 CRect rcBase;
34 GetImageRect(rcBase);
35 ImageToCanvas(rcBase);
37 return rcBase;
38}
39
41{
42 Zoomed(pt);
45}
46
48{
49 Zoomed(rc);
51}
52
54{
57 UnZoomed(pt);
58}
59
61{
63 UnZoomed(rc);
64}
65
67{
68 rc = { 0, 0, imageModel.GetWidth(), imageModel.GetHeight() };
69}
70
72{
74 return HIT_INNER;
75 RECT rcBase = GetBaseRect();
76 return getSizeBoxHitTest(pt, &rcBase);
77}
78
80{
81 CRect rcImage;
82 GetImageRect(rcImage);
83 ImageToCanvas(rcImage);
84
85 // Calculate the zoom rectangle
86 INT oldZoom = toolsModel.GetZoom();
87 GetClientRect(rcView);
88 LONG cxView = rcView.right * oldZoom / newZoom, cyView = rcView.bottom * oldZoom / newZoom;
89 rcView.SetRect(ptTarget.x - cxView / 2, ptTarget.y - cyView / 2,
90 ptTarget.x + cxView / 2, ptTarget.y + cyView / 2);
91
92 // Shift the rectangle if necessary
93 INT dx = 0, dy = 0;
94 if (rcView.left < rcImage.left)
95 dx = rcImage.left - rcView.left;
96 else if (rcImage.right < rcView.right)
97 dx = rcImage.right - rcView.right;
98 if (rcView.top < rcImage.top)
99 dy = rcImage.top - rcView.top;
100 else if (rcImage.bottom < rcView.bottom)
101 dy = rcImage.bottom - rcView.bottom;
102 rcView.OffsetRect(dx, dy);
103
104 rcView.IntersectRect(&rcView, &rcImage);
105}
106
108{
109 POINT pt = { left, top };
111
112 toolsModel.SetZoom(newZoom);
114 pt.x += GetScrollPos(SB_HORZ);
115 pt.y += GetScrollPos(SB_VERT);
116
118 updateScrollPos(pt.x, pt.y);
119 Invalidate(TRUE);
120}
121
123{
124 // This is the target area we have to draw on
125 CRect rcCanvasDraw;
126 rcCanvasDraw.IntersectRect(&rcClient, &rcPaint);
127
128 // We use a memory bitmap to reduce flickering
129 HDC hdcMem0 = ::CreateCompatibleDC(hDC);
130 m_ahbmCached[0] = CachedBufferDIB(m_ahbmCached[0], rcClient.right, rcClient.bottom);
131 HGDIOBJ hbm0Old = ::SelectObject(hdcMem0, m_ahbmCached[0]);
132
133 // Fill the background on hdcMem0
134 ::FillRect(hdcMem0, &rcCanvasDraw, (HBRUSH)(COLOR_APPWORKSPACE + 1));
135
136 // Draw the sizeboxes if necessary
137 RECT rcBase = GetBaseRect();
139 drawSizeBoxes(hdcMem0, &rcBase, FALSE, &rcCanvasDraw);
140
141 // Calculate image size
142 CRect rcImage;
143 GetImageRect(rcImage);
144 SIZE sizeImage = { imageModel.GetWidth(), imageModel.GetHeight() };
145
146 // Calculate the target area on the image
147 CRect rcImageDraw = rcCanvasDraw;
148 CanvasToImage(rcImageDraw);
149 rcImageDraw.IntersectRect(&rcImageDraw, &rcImage);
150
151 // Consider rounding down by zooming
152 rcImageDraw.right += 1;
153 rcImageDraw.bottom += 1;
154
155 // hdcMem1 <-- imageModel
156 HDC hdcMem1 = ::CreateCompatibleDC(hDC);
157 m_ahbmCached[1] = CachedBufferDIB(m_ahbmCached[1], sizeImage.cx, sizeImage.cy);
158 HGDIOBJ hbm1Old = ::SelectObject(hdcMem1, m_ahbmCached[1]);
159 ::BitBlt(hdcMem1, rcImageDraw.left, rcImageDraw.top, rcImageDraw.Width(), rcImageDraw.Height(),
160 imageModel.GetDC(), rcImageDraw.left, rcImageDraw.top, SRCCOPY);
161
162 // Draw overlay #1 on hdcMem1
164
165 // Transfer the bits with stretch (hdcMem0 <-- hdcMem1)
166 ImageToCanvas(rcImage);
167 ::StretchBlt(hdcMem0, rcImage.left, rcImage.top, rcImage.Width(), rcImage.Height(),
168 hdcMem1, 0, 0, sizeImage.cx, sizeImage.cy, SRCCOPY);
169
170 // Clean up hdcMem1
171 ::SelectObject(hdcMem1, hbm1Old);
172 ::DeleteDC(hdcMem1);
173
174 // Draw the grid on hdcMem0
175 if (g_showGrid && toolsModel.GetZoom() >= 4000)
176 {
177 HPEN oldPen = (HPEN) ::SelectObject(hdcMem0, ::CreatePen(PS_SOLID, 1, RGB(160, 160, 160)));
178 for (INT counter = 0; counter < sizeImage.cy; counter++)
179 {
180 POINT pt0 = { 0, counter }, pt1 = { sizeImage.cx, counter };
181 ImageToCanvas(pt0);
182 ImageToCanvas(pt1);
183 ::MoveToEx(hdcMem0, pt0.x, pt0.y, NULL);
184 ::LineTo(hdcMem0, pt1.x, pt1.y);
185 }
186 for (INT counter = 0; counter < sizeImage.cx; counter++)
187 {
188 POINT pt0 = { counter, 0 }, pt1 = { counter, sizeImage.cy };
189 ImageToCanvas(pt0);
190 ImageToCanvas(pt1);
191 ::MoveToEx(hdcMem0, pt0.x, pt0.y, NULL);
192 ::LineTo(hdcMem0, pt1.x, pt1.y);
193 }
194 ::DeleteObject(::SelectObject(hdcMem0, oldPen));
195 }
196
197 // Draw overlay #2 on hdcMem0
199
200 // Draw new frame on hdcMem0 if any
202 DrawXorRect(hdcMem0, &m_rcResizing);
203
204 // Transfer the bits (hDC <-- hdcMem0)
205 ::BitBlt(hDC, rcCanvasDraw.left, rcCanvasDraw.top, rcCanvasDraw.Width(), rcCanvasDraw.Height(),
206 hdcMem0, rcCanvasDraw.left, rcCanvasDraw.top, SRCCOPY);
207
208 // Clean up hdcMem0
209 ::SelectObject(hdcMem0, hbm0Old);
210 ::DeleteDC(hdcMem0);
211}
212
214{
215 CRect rcClient;
216 GetClientRect(&rcClient);
217
218 CSize sizePage(rcClient.right, rcClient.bottom);
219 CSize sizeZoomed = { Zoomed(imageModel.GetWidth()), Zoomed(imageModel.GetHeight()) };
220 CSize sizeWhole = { sizeZoomed.cx + (GRIP_SIZE * 2), sizeZoomed.cy + (GRIP_SIZE * 2) };
221
222 // show/hide the scrollbars
223 ShowScrollBar(SB_HORZ, sizePage.cx < sizeWhole.cx);
224 ShowScrollBar(SB_VERT, sizePage.cy < sizeWhole.cy);
225
226 if (sizePage.cx < sizeWhole.cx || sizePage.cy < sizeWhole.cy)
227 {
228 GetClientRect(&rcClient); // Scrollbars might change, get client rectangle again
229 sizePage = CSize(rcClient.right, rcClient.bottom);
230 }
231
232 SCROLLINFO si = { sizeof(si), SIF_PAGE | SIF_RANGE };
233 si.nMin = 0;
234
235 si.nMax = sizeWhole.cx;
236 si.nPage = sizePage.cx;
238
239 si.nMax = sizeWhole.cy;
240 si.nPage = sizePage.cy;
242}
243
245{
248}
249
251{
252 if (m_hWnd)
254
255 return 0;
256}
257
259{
260 SCROLLINFO si;
261 si.cbSize = sizeof(SCROLLINFO);
262 si.fMask = SIF_ALL;
263 GetScrollInfo(fnBar, &si);
264 switch (LOWORD(wParam))
265 {
266 case SB_THUMBTRACK:
267 case SB_THUMBPOSITION:
268 si.nPos = (SHORT)HIWORD(wParam);
269 break;
270 case SB_LINELEFT:
271 si.nPos -= 5;
272 break;
273 case SB_LINERIGHT:
274 si.nPos += 5;
275 break;
276 case SB_PAGELEFT:
277 si.nPos -= si.nPage;
278 break;
279 case SB_PAGERIGHT:
280 si.nPos += si.nPage;
281 break;
282 }
283 si.nPos = max(min(si.nPos, si.nMax), si.nMin);
284 SetScrollInfo(fnBar, &si);
285 Invalidate();
286}
287
289{
291 return 0;
292}
293
295{
297 return 0;
298}
299
301{
303
304 m_nMouseDownMsg = nMsg;
305 BOOL bLeftButton = (nMsg == WM_LBUTTONDOWN);
306
307 if (nMsg == WM_MBUTTONDOWN)
308 {
309 m_ptOrig = pt;
310 SetCapture();
312 return 0;
313 }
314
315 HITTEST hitSelection = selectionModel.hitTest(pt);
316 if (hitSelection != HIT_NONE)
317 {
318 m_drawing = TRUE;
320 SetCapture();
321 toolsModel.OnButtonDown(bLeftButton, pt.x, pt.y, FALSE);
322 Invalidate();
323 return 0;
324 }
325
326 HITTEST hit = CanvasHitTest(pt);
327 if (hit == HIT_NONE || hit == HIT_BORDER)
328 {
329 switch (toolsModel.GetActiveTool())
330 {
331 case TOOL_BEZIER:
332 case TOOL_SHAPE:
334 Invalidate();
335 break;
336
337 case TOOL_FREESEL:
338 case TOOL_RECTSEL:
340 Invalidate();
341 break;
342
343 default:
344 break;
345 }
346
347 toolsModel.resetTool(); // resets the point-buffer of the polygon and bezier functions
348 return 0;
349 }
350
352
353 if (hit == HIT_INNER)
354 {
355 m_drawing = TRUE;
356 SetCapture();
357 toolsModel.OnButtonDown(bLeftButton, pt.x, pt.y, FALSE);
358 Invalidate();
359 return 0;
360 }
361
362 if (bLeftButton)
363 {
364 m_hitCanvasSizeBox = hit;
365 m_ptOrig = pt;
366 SetCapture();
367 }
368
369 return 0;
370}
371
373{
376
379 m_nMouseDownMsg = 0;
380
383 Invalidate();
384 return 0;
385}
386
388{
390
392 {
393 INT x = GetScrollPos(SB_HORZ) - (pt.x - m_ptOrig.x);
394 INT y = GetScrollPos(SB_VERT) - (pt.y - m_ptOrig.y);
397 m_ptOrig = pt;
398 return 0;
399 }
400
402
404 Invalidate();
405
407 {
408 TRACKMOUSEEVENT tme = { sizeof(tme) };
409 tme.dwFlags = TME_LEAVE;
410 tme.hwndTrack = m_hWnd;
411 tme.dwHoverTime = 0;
412 ::TrackMouseEvent(&tme);
413
414 if (!m_drawing)
415 {
416 CRect rcImage;
417 GetImageRect(rcImage);
418
419 CStringW strCoord;
420 if (rcImage.PtInRect(pt))
421 strCoord.Format(L"%ld, %ld", pt.x, pt.y);
423 }
424 }
425
427 {
429 return 0;
430 }
431
432 if (m_hitCanvasSizeBox == HIT_NONE || ::GetCapture() != m_hWnd)
433 return 0;
434
435 // Dragging now... Calculate the new size
436 INT cxImage = imageModel.GetWidth(), cyImage = imageModel.GetHeight();
437 INT cxDelta = pt.x - m_ptOrig.x;
438 INT cyDelta = pt.y - m_ptOrig.y;
439 switch (m_hitCanvasSizeBox)
440 {
441 case HIT_UPPER_LEFT:
442 cxImage -= cxDelta;
443 cyImage -= cyDelta;
444 break;
445 case HIT_UPPER_CENTER:
446 cyImage -= cyDelta;
447 break;
448 case HIT_UPPER_RIGHT:
449 cxImage += cxDelta;
450 cyImage -= cyDelta;
451 break;
452 case HIT_MIDDLE_LEFT:
453 cxImage -= cxDelta;
454 break;
455 case HIT_MIDDLE_RIGHT:
456 cxImage += cxDelta;
457 break;
458 case HIT_LOWER_LEFT:
459 cxImage -= cxDelta;
460 cyImage += cyDelta;
461 break;
462 case HIT_LOWER_CENTER:
463 cyImage += cyDelta;
464 break;
465 case HIT_LOWER_RIGHT:
466 cxImage += cxDelta;
467 cyImage += cyDelta;
468 break;
469 default:
470 return 0;
471 }
472
473 // Limit bitmap size
474 cxImage = max(1, cxImage);
475 cyImage = max(1, cyImage);
476 cxImage = min(MAXWORD, cxImage);
477 cyImage = min(MAXWORD, cyImage);
478
479 // Display new size
480 CStringW strSize;
481 strSize.Format(L"%d x %d", cxImage, cyImage);
483
484 // Dragging now... Fix the position...
485 CRect rcResizing = { 0, 0, cxImage, cyImage };
486 switch (m_hitCanvasSizeBox)
487 {
488 case HIT_UPPER_LEFT:
489 rcResizing.OffsetRect(cxDelta, cyDelta);
490 break;
491 case HIT_UPPER_CENTER:
492 rcResizing.OffsetRect(0, cyDelta);
493 break;
494 case HIT_UPPER_RIGHT:
495 rcResizing.OffsetRect(0, cyDelta);
496 break;
497 case HIT_MIDDLE_LEFT:
498 rcResizing.OffsetRect(cxDelta, 0);
499 break;
500 case HIT_LOWER_LEFT:
501 rcResizing.OffsetRect(cxDelta, 0);
502 break;
503 default:
504 break;
505 }
506 ImageToCanvas(rcResizing);
507 m_rcResizing = rcResizing;
508 Invalidate(TRUE);
509
510 return 0;
511}
512
514{
517
519
520 BOOL bLeftButton = (m_nMouseDownMsg == WM_LBUTTONDOWN);
521 m_nMouseDownMsg = 0;
522
523 if (m_drawing)
524 {
526 toolsModel.OnButtonUp(bLeftButton, pt.x, pt.y);
527 Invalidate(FALSE);
529 return 0;
530 }
531
532 if (m_hitCanvasSizeBox == HIT_NONE || !bLeftButton)
533 return 0;
534
535 // Resize the image
536 INT cxImage = imageModel.GetWidth(), cyImage = imageModel.GetHeight();
537 INT cxDelta = pt.x - m_ptOrig.x;
538 INT cyDelta = pt.y - m_ptOrig.y;
539 switch (m_hitCanvasSizeBox)
540 {
541 case HIT_UPPER_LEFT:
542 imageModel.Crop(cxImage - cxDelta, cyImage - cyDelta, cxDelta, cyDelta);
543 break;
544 case HIT_UPPER_CENTER:
545 imageModel.Crop(cxImage, cyImage - cyDelta, 0, cyDelta);
546 break;
547 case HIT_UPPER_RIGHT:
548 imageModel.Crop(cxImage + cxDelta, cyImage - cyDelta, 0, cyDelta);
549 break;
550 case HIT_MIDDLE_LEFT:
551 imageModel.Crop(cxImage - cxDelta, cyImage, cxDelta, 0);
552 break;
553 case HIT_MIDDLE_RIGHT:
554 imageModel.Crop(cxImage + cxDelta, cyImage, 0, 0);
555 break;
556 case HIT_LOWER_LEFT:
557 imageModel.Crop(cxImage - cxDelta, cyImage + cyDelta, cxDelta, 0);
558 break;
559 case HIT_LOWER_CENTER:
560 imageModel.Crop(cxImage, cyImage + cyDelta, 0, 0);
561 break;
562 case HIT_LOWER_RIGHT:
563 imageModel.Crop(cxImage + cxDelta, cyImage + cyDelta, 0, 0);
564 break;
565 default:
566 break;
567 }
569
571
573 toolsModel.resetTool(); // resets the point-buffer of the polygon and bezier functions
575 Invalidate(TRUE);
576 return 0;
577}
578
580{
582 {
583 bHandled = FALSE;
584 return 0;
585 }
586
588 {
590 return 0;
591 }
592
593 POINT pt;
596
597 CRect rcClient;
598 GetClientRect(&rcClient);
599
600 if (!rcClient.PtInRect(pt))
601 {
602 bHandled = FALSE;
603 return 0;
604 }
605
606 HITTEST hitSelection = selectionModel.hitTest(pt);
607 if (hitSelection != HIT_NONE)
608 {
609 if (!setCursorOnSizeBox(hitSelection))
611 return 0;
612 }
613
614 CRect rcImage;
615 GetImageRect(rcImage);
616 ImageToCanvas(rcImage);
617
618 if (rcImage.PtInRect(pt))
619 {
620 switch (toolsModel.GetActiveTool())
621 {
622 case TOOL_FILL:
624 break;
625 case TOOL_COLOR:
627 break;
628 case TOOL_ZOOM:
630 break;
631 case TOOL_PEN:
633 break;
634 case TOOL_AIRBRUSH:
636 break;
637 default:
639 }
640 return 0;
641 }
642
644 bHandled = FALSE;
645
646 return 0;
647}
648
650{
651 if (wParam == VK_ESCAPE)
652 {
655 m_nMouseDownMsg = 0;
658 Invalidate(TRUE);
659 }
660
661 return 0;
662}
663
665{
666 // Cancel dragging
669 Invalidate(TRUE);
670 return 0;
671}
672
674{
675 return ::SendMessageW(GetParent(), nMsg, wParam, lParam);
676}
677
679{
681 return 0;
682}
683
685{
686 return TRUE; // do nothing => transparent background
687}
688
690{
691 RECT rcClient;
692 GetClientRect(&rcClient);
693
694 PAINTSTRUCT ps;
695 HDC hDC = BeginPaint(&ps);
696 DoDraw(hDC, rcClient, ps.rcPaint);
697 EndPaint(&ps);
698 return 0;
699}
700
702{
704 toolsModel.OnEndDraw(bCancel);
705 Invalidate(FALSE);
706}
707
709{
713}
714
716{
718 return 0;
719}
static HDC hDC
Definition: 3dtext.c:33
#define IDC_ZOOM
Definition: resource.h:16
HWND g_hStatusBar
Definition: main.cpp:23
BOOL g_imageSaved
Definition: main.cpp:21
BOOL g_showGrid
Definition: main.cpp:22
HINSTANCE g_hinstExe
Definition: main.cpp:17
ToolsModel toolsModel
Definition: toolsmodel.cpp:10
#define GRIP_SIZE
Definition: precomp.h:43
SelectionModel selectionModel
HITTEST
Definition: precomp.h:55
@ HIT_NONE
Definition: precomp.h:56
@ HIT_BORDER
Definition: precomp.h:65
@ HIT_LOWER_RIGHT
Definition: precomp.h:64
@ HIT_LOWER_CENTER
Definition: precomp.h:63
@ HIT_UPPER_LEFT
Definition: precomp.h:57
@ HIT_INNER
Definition: precomp.h:66
@ HIT_LOWER_LEFT
Definition: precomp.h:62
@ HIT_UPPER_CENTER
Definition: precomp.h:58
@ HIT_UPPER_RIGHT
Definition: precomp.h:59
@ HIT_MIDDLE_RIGHT
Definition: precomp.h:61
@ HIT_MIDDLE_LEFT
Definition: precomp.h:60
CTextEditWindow textEditWindow
Definition: textedit.cpp:12
#define IDC_FILL
Definition: resource.h:20
#define IDC_PEN
Definition: resource.h:23
#define IDC_COLOR
Definition: resource.h:21
#define IDC_AIRBRUSH
Definition: resource.h:24
#define IDC_HANDDRAG
Definition: resource.h:25
CCanvasWindow canvasWindow
Definition: canvas.cpp:10
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
VOID OnHVScroll(WPARAM wParam, INT fnBar)
Definition: canvas.cpp:258
VOID DoDraw(HDC hDC, RECT &rcClient, RECT &rcPaint)
Definition: canvas.cpp:122
BOOL m_drawing
Definition: canvas.h:43
VOID OnEndDraw(BOOL bCancel)
Definition: canvas.cpp:701
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:684
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:649
LRESULT OnCaptureChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:678
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:294
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:579
HITTEST m_hitCanvasSizeBox
Definition: canvas.h:58
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:715
VOID ImageToCanvas(POINT &pt)
Definition: canvas.cpp:40
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:250
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:689
LRESULT OnCancelMode(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:664
VOID CanvasToImage(POINT &pt)
Definition: canvas.cpp:53
VOID updateScrollPos(INT x=0, INT y=0)
Definition: canvas.cpp:244
CRect m_rcResizing
Definition: canvas.h:61
UINT m_nMouseDownMsg
Definition: canvas.h:82
virtual ~CCanvasWindow()
Definition: canvas.cpp:23
HBITMAP m_ahbmCached[2]
Definition: canvas.h:60
HITTEST CanvasHitTest(POINT pt)
Definition: canvas.cpp:71
LRESULT OnButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:513
LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:288
LRESULT OnButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:372
VOID GetImageRect(RECT &rc)
Definition: canvas.cpp:66
POINT m_ptOrig
Definition: canvas.h:59
VOID updateScrollRange()
Definition: canvas.cpp:213
LRESULT OnButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:300
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:387
VOID getNewZoomRect(CRect &rcView, INT newZoom, CPoint ptTarget)
Definition: canvas.cpp:79
RECT GetBaseRect()
Definition: canvas.cpp:31
LRESULT OnCtlColorEdit(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:708
VOID zoomTo(INT newZoom, LONG left=0, LONG top=0)
Definition: canvas.cpp:107
LRESULT OnMouseWheel(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: canvas.cpp:673
void SetRectEmpty() noexcept
Definition: atltypes.h:431
BOOL IntersectRect(LPCRECT lpRect1, LPCRECT lpRect2) noexcept
Definition: atltypes.h:346
void InflateRect(int x, int y) noexcept
Definition: atltypes.h:323
void OffsetRect(int x, int y) noexcept
Definition: atltypes.h:403
BOOL PtInRect(POINT point) const noexcept
Definition: atltypes.h:418
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
static BOOL IsWaiting()
Definition: CWaitCursor.h:40
int GetWidth() const
Definition: history.cpp:253
void NotifyImageChanged()
Definition: history.cpp:23
void Crop(int nWidth, int nHeight, int nOffsetX=0, int nOffsetY=0)
Definition: history.cpp:191
int GetHeight() const
Definition: history.cpp:258
HDC GetDC()
Definition: history.cpp:271
COLORREF GetFgColor() const
HITTEST hitTest(POINT ptCanvas)
void OnDrawOverlayOnCanvas(HDC hdc)
Definition: mouse.cpp:1191
void OnDrawOverlayOnImage(HDC hdc)
Definition: mouse.cpp:1186
void OnEndDraw(BOOL bCancel)
Definition: mouse.cpp:1178
int GetZoom() const
Definition: toolsmodel.cpp:261
BOOL IsSelection() const
Definition: toolsmodel.cpp:41
void resetTool()
Definition: toolsmodel.cpp:302
void DrawWithMouseTool(POINT pt, WPARAM wParam)
Definition: mouse.cpp:1201
void OnButtonDown(BOOL bLeftButton, LONG x, LONG y, BOOL bDoubleClick)
Definition: mouse.cpp:1152
void SetZoom(int nZoom)
Definition: toolsmodel.cpp:266
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:134
void OnButtonUp(BOOL bLeftButton, LONG x, LONG y)
Definition: mouse.cpp:1169
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HBITMAP CachedBufferDIB(HBITMAP hbm, int minimalWidth, int minimalHeight)
Definition: dib.cpp:115
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define pt(x, y)
Definition: drawing.c:79
void DrawXorRect(HDC hdc, const RECT *prc)
Definition: drawing.cpp:362
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
ImageModel imageModel
Definition: history.cpp:11
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
static HDC
Definition: imagelist.c:92
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define MAXWORD
#define L(x)
Definition: ntvdm.h:50
PaletteModel paletteModel
#define LOWORD(l)
Definition: pedump.c:82
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
#define TME_LEAVE
Definition: commctrl.h:4981
#define SB_SETTEXT
Definition: commctrl.h:1949
BOOL setCursorOnSizeBox(HITTEST hit)
Definition: sizebox.cpp:20
VOID drawSizeBoxes(HDC hdc, LPCRECT prcBase, BOOL bDrawFrame, LPCRECT prcPaint)
Definition: sizebox.cpp:103
HITTEST getSizeBoxHitTest(POINT pt, LPCRECT prcBase)
Definition: sizebox.cpp:80
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
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
LONG cx
Definition: windef.h:334
LONG cy
Definition: windef.h:335
#define max(a, b)
Definition: svc.c:63
static int UnZoomed(int xy)
Definition: toolsmodel.h:155
@ TOOL_AIRBRUSH
Definition: toolsmodel.h:20
@ TOOL_COLOR
Definition: toolsmodel.h:16
@ TOOL_SHAPE
Definition: toolsmodel.h:25
@ TOOL_BEZIER
Definition: toolsmodel.h:23
@ TOOL_FILL
Definition: toolsmodel.h:15
@ TOOL_PEN
Definition: toolsmodel.h:18
@ TOOL_FREESEL
Definition: toolsmodel.h:12
@ TOOL_ZOOM
Definition: toolsmodel.h:17
@ TOOL_RECTSEL
Definition: toolsmodel.h:13
static int Zoomed(int xy)
Definition: toolsmodel.h:150
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define TRANSPARENT
Definition: wingdi.h:950
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
#define NULL_BRUSH
Definition: wingdi.h:901
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define PS_SOLID
Definition: wingdi.h:586
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define SB_THUMBTRACK
Definition: winuser.h:573
#define WM_HSCROLL
Definition: winuser.h:1743
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
struct tagSCROLLINFO SCROLLINFO
#define WM_VSCROLL
Definition: winuser.h:1744
#define SIF_RANGE
Definition: winuser.h:1235
#define SB_PAGERIGHT
Definition: winuser.h:571
#define SB_VERT
Definition: winuser.h:553
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1778
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2701
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define SIF_PAGE
Definition: winuser.h:1233
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define IDC_SIZEALL
Definition: winuser.h:696
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
#define SB_LINERIGHT
Definition: winuser.h:567
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define IDC_CROSS
Definition: winuser.h:690
#define SB_LINELEFT
Definition: winuser.h:566
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define COLOR_APPWORKSPACE
Definition: winuser.h:925
#define SIF_ALL
Definition: winuser.h:1232
#define SendMessage
Definition: winuser.h:5852
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define VK_ESCAPE
Definition: winuser.h:2214
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define WM_MBUTTONDOWN
Definition: winuser.h:1782
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_HORZ
Definition: winuser.h:552
#define SB_PAGELEFT
Definition: winuser.h:570
#define SB_THUMBPOSITION
Definition: winuser.h:572
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185