ReactOS  0.4.15-dev-425-gc40b086
CImgAreaWindow Class Reference

#include <imgarea.h>

Inheritance diagram for CImgAreaWindow:
Collaboration diagram for CImgAreaWindow:

Public Attributes

BOOL drawing
 
- Public Attributes inherited from ATL::CWindowImplBaseT< CWindow, CControlWinTraits >
WNDPROC m_pfnSuperWindowProc
 
- Public Attributes inherited from ATL::CWindowImplRoot< CWindow >
CWndProcThunk m_thunk
 
const _ATL_MSGm_pCurrentMsg
 
DWORD m_dwState
 
- Public Attributes inherited from ATL::CWindow
HWND m_hWnd
 

Private Member Functions

LRESULT OnSize (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnPaint (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSetCursor (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnRButtonDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnLButtonUp (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnRButtonUp (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMouseMove (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMouseLeave (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnImageModelDimensionsChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnImageModelImageChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnCaptureChanged (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnKeyDown (UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
void drawZoomFrame (int mouseX, int mouseY)
 
void cancelDrawing ()
 

Additional Inherited Members

- Public Types inherited from ATL::CWindowImplRoot< CWindow >
enum  
 
- Public Member Functions inherited from ATL::CWindowImpl< CMainWindow >
HWND Create (HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
 
- Public Member Functions inherited from ATL::CWindowImplBaseT< CWindow, CControlWinTraits >
 CWindowImplBaseT ()
 
virtual void OnFinalMessage (HWND)
 
BOOL SubclassWindow (HWND hWnd)
 
virtual WNDPROC GetWindowProc ()
 
LRESULT DefWindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam)
 
HWND Create (HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName, DWORD dwStyle, DWORD dwExStyle, _U_MENUorID MenuOrID, ATOM atom, LPVOID lpCreateParam)
 
- Public Member Functions inherited from ATL::CWindowImplRoot< CWindow >
 CWindowImplRoot ()
 
virtual ~CWindowImplRoot ()
 
- Public Member Functions inherited from ATL::CWindow
 CWindow (HWND hWnd=NULL)
 
 operator HWND () const
 
UINT ArrangeIconicWindows ()
 
void Attach (HWND hWndNew)
 
HDC BeginPaint (LPPAINTSTRUCT lpPaint)
 
BOOL BringWindowToTop ()
 
BOOL CenterWindow (HWND hWndCenter=NULL)
 
BOOL ChangeClipboardChain (HWND hWndNewNext)
 
BOOL CheckDlgButton (int nIDButton, UINT nCheck)
 
BOOL CheckRadioButton (int nIDFirstButton, int nIDLastButton, int nIDCheckButton)
 
HWND ChildWindowFromPoint (POINT point) const
 
HWND ChildWindowFromPointEx (POINT point, UINT uFlags) const
 
BOOL ClientToScreen (LPPOINT lpPoint) const
 
BOOL ClientToScreen (LPRECT lpRect) const
 
HWND Create (LPCTSTR lpstrWndClass, HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
 
BOOL CreateCaret (HBITMAP pBitmap)
 
BOOL CreateGrayCaret (int nWidth, int nHeight)
 
BOOL CreateSolidCaret (int nWidth, int nHeight)
 
HDWP DeferWindowPos (HDWP hWinPosInfo, HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT uFlags)
 
BOOL DestroyWindow ()
 
HWND Detach ()
 
int DlgDirList (LPTSTR lpPathSpec, int nIDListBox, int nIDStaticPath, UINT nFileType)
 
int DlgDirListComboBox (LPTSTR lpPathSpec, int nIDComboBox, int nIDStaticPath, UINT nFileType)
 
BOOL DlgDirSelect (LPTSTR lpString, int nCount, int nIDListBox)
 
BOOL DlgDirSelectComboBox (LPTSTR lpString, int nCount, int nIDComboBox)
 
void DragAcceptFiles (BOOL bAccept=TRUE)
 
BOOL DrawMenuBar ()
 
BOOL EnableScrollBar (UINT uSBFlags, UINT uArrowFlags=ESB_ENABLE_BOTH)
 
BOOL EnableWindow (BOOL bEnable=TRUE)
 
void EndPaint (LPPAINTSTRUCT lpPaint)
 
BOOL FlashWindow (BOOL bInvert)
 
BOOL GetClientRect (LPRECT lpRect) const
 
HDC GetDC ()
 
HDC GetDCEx (HRGN hRgnClip, DWORD flags)
 
HWND GetDescendantWindow (int nID) const
 
HRESULT GetDlgControl (int nID, REFIID iid, void **ppCtrl)
 
int GetDlgCtrlID () const
 
HRESULT GetDlgHost (int nID, REFIID iid, void **ppHost)
 
HWND GetDlgItem (int nID)
 
UINT GetDlgItemInt (int nID, BOOL *lpTrans=NULL, BOOL bSigned=TRUE) const
 
UINT GetDlgItemText (int nID, LPTSTR lpStr, int nMaxCount) const
 
BOOL GetDlgItemText (int nID, BSTR &bstrText) const
 
DWORD GetExStyle () const
 
HFONT GetFont () const
 
DWORD GetHotKey () const
 
HICON GetIcon (BOOL bBigIcon=TRUE) const
 
HWND GetLastActivePopup () const
 
HMENU GetMenu () const
 
HWND GetNextDlgGroupItem (HWND hWndCtl, BOOL bPrevious=FALSE) const
 
HWND GetNextDlgTabItem (HWND hWndCtl, BOOL bPrevious=FALSE) const
 
CWindow GetParent () const
 
BOOL GetScrollInfo (int nBar, LPSCROLLINFO lpScrollInfo)
 
BOOL GetScrollPos (int nBar)
 
BOOL GetScrollRange (int nBar, LPINT lpMinPos, LPINT lpMaxPos) const
 
DWORD GetStyle () const
 
HMENU GetSystemMenu (BOOL bRevert)
 
HWND GetTopLevelParent () const
 
HWND GetTopLevelWindow () const
 
HWND GetTopWindow () const
 
BOOL GetUpdateRect (LPRECT lpRect, BOOL bErase=FALSE)
 
int GetUpdateRgn (HRGN hRgn, BOOL bErase=FALSE)
 
HWND GetWindow (UINT nCmd) const
 
DWORD GetWindowContextHelpId () const
 
HDC GetWindowDC ()
 
LONG GetWindowLong (int nIndex) const
 
LONG_PTR GetWindowLongPtr (int nIndex) const
 
BOOL GetWindowPlacement (WINDOWPLACEMENT *lpwndpl) const
 
DWORD GetWindowProcessID ()
 
BOOL GetWindowRect (LPRECT lpRect) const
 
int GetWindowRgn (HRGN hRgn)
 
int GetWindowText (LPTSTR lpszStringBuf, int nMaxCount) const
 
BOOL GetWindowText (BSTR &bstrText)
 
int GetWindowTextLength () const
 
DWORD GetWindowThreadID ()
 
WORD GetWindowWord (int nIndex) const
 
void GotoDlgCtrl (HWND hWndCtrl) const
 
BOOL HideCaret ()
 
BOOL HiliteMenuItem (HMENU hMenu, UINT uHiliteItem, UINT uHilite)
 
BOOL Invalidate (BOOL bErase=TRUE)
 
BOOL InvalidateRect (LPCRECT lpRect, BOOL bErase=TRUE)
 
void InvalidateRgn (HRGN hRgn, BOOL bErase=TRUE)
 
BOOL IsChild (const HWND hWnd) const
 
BOOL IsDialogMessage (LPMSG lpMsg)
 
UINT IsDlgButtonChecked (int nIDButton) const
 
BOOL IsIconic () const
 
BOOL IsParentDialog ()
 
BOOL IsWindow () const
 
BOOL IsWindowEnabled () const
 
BOOL IsWindowVisible () const
 
BOOL IsWindowUnicode ()
 
BOOL IsZoomed () const
 
BOOL KillTimer (UINT_PTR nIDEvent)
 
BOOL LockWindowUpdate (BOOL bLock=TRUE)
 
int MapWindowPoints (HWND hWndTo, LPPOINT lpPoint, UINT nCount) const
 
int MapWindowPoints (HWND hWndTo, LPRECT lpRect) const
 
int MessageBox (LPCTSTR lpszText, LPCTSTR lpszCaption=NULL, UINT nType=MB_OK)
 
BOOL ModifyStyle (DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
 
BOOL ModifyStyleEx (DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
 
BOOL MoveWindow (int x, int y, int nWidth, int nHeight, BOOL bRepaint=TRUE)
 
void NextDlgCtrl () const
 
BOOL OpenClipboard ()
 
BOOL PostMessage (UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
void PrevDlgCtrl () const
 
void Print (HDC hDC, DWORD dwFlags) const
 
void PrintClient (HDC hDC, DWORD dwFlags) const
 
BOOL RedrawWindow (LPCRECT lpRectUpdate=NULL, HRGN hRgnUpdate=NULL, UINT flags=RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE)
 
int ReleaseDC (HDC hDC)
 
BOOL ResizeClient (int nWidth, int nHeight, BOOL bRedraw=FALSE)
 
BOOL ScreenToClient (LPPOINT lpPoint) const
 
BOOL ScrollWindow (int xAmount, int yAmount, LPCRECT lpRect=NULL, LPCRECT lpClipRect=NULL)
 
int ScrollWindowEx (int dx, int dy, LPCRECT lpRectScroll, LPCRECT lpRectClip, HRGN hRgnUpdate, LPRECT lpRectUpdate, UINT flags)
 
LRESULT SendDlgItemMessage (int nID, UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
LRESULT SendMessage (UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
void SendMessageToDescendants (UINT message, WPARAM wParam=0, LPARAM lParam=0, BOOL bDeep=TRUE)
 
BOOL SendNotifyMessage (UINT message, WPARAM wParam=0, LPARAM lParam=0)
 
HWND SetActiveWindow ()
 
HWND SetCapture ()
 
HWND SetClipboardViewer ()
 
int SetDlgCtrlID (int nID)
 
BOOL SetDlgItemInt (int nID, UINT nValue, BOOL bSigned=TRUE)
 
BOOL SetDlgItemText (int nID, LPCTSTR lpszString)
 
HWND SetFocus ()
 
void SetFont (HFONT hFont, BOOL bRedraw=TRUE)
 
int SetHotKey (WORD wVirtualKeyCode, WORD wModifiers)
 
HICON SetIcon (HICON hIcon, BOOL bBigIcon=TRUE)
 
BOOL SetMenu (HMENU hMenu)
 
HWND SetParent (HWND hWndNewParent)
 
void SetRedraw (BOOL bRedraw=TRUE)
 
int SetScrollInfo (int nBar, LPSCROLLINFO lpScrollInfo, BOOL bRedraw=TRUE)
 
int SetScrollPos (int nBar, int nPos, BOOL bRedraw=TRUE)
 
BOOL SetScrollRange (int nBar, int nMinPos, int nMaxPos, BOOL bRedraw=TRUE)
 
UINT_PTR SetTimer (UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD)=NULL)
 
BOOL SetWindowContextHelpId (DWORD dwContextHelpId)
 
LONG SetWindowLong (int nIndex, LONG dwNewLong)
 
LONG_PTR SetWindowLongPtr (int nIndex, LONG_PTR dwNewLong)
 
BOOL SetWindowPlacement (const WINDOWPLACEMENT *lpwndpl)
 
BOOL SetWindowPos (HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags)
 
int SetWindowRgn (HRGN hRgn, BOOL bRedraw=FALSE)
 
BOOL SetWindowText (LPCTSTR lpszString)
 
WORD SetWindowWord (int nIndex, WORD wNewWord)
 
BOOL ShowCaret ()
 
BOOL ShowOwnedPopups (BOOL bShow=TRUE)
 
BOOL ShowScrollBar (UINT nBar, BOOL bShow=TRUE)
 
BOOL ShowWindow (int nCmdShow)
 
BOOL ShowWindowAsync (int nCmdShow)
 
BOOL UpdateWindow ()
 
BOOL ValidateRect (LPCRECT lpRect)
 
BOOL ValidateRgn (HRGN hRgn)
 
BOOL WinHelp (LPCTSTR lpszHelp, UINT nCmd=HELP_CONTEXT, DWORD dwData=0)
 
- Public Member Functions inherited from ATL::CMessageMap
virtual BOOL ProcessWindowMessage (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult, DWORD dwMsgMapID)=0
 
- Static Public Member Functions inherited from ATL::CWindowImpl< CMainWindow >
static LPCTSTR GetWndCaption ()
 
- Static Public Member Functions inherited from ATL::CWindowImplBaseT< CWindow, CControlWinTraits >
static DWORD GetWndStyle (DWORD dwStyle)
 
static DWORD GetWndExStyle (DWORD dwExStyle)
 
static LRESULT CALLBACK StartWindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
- Static Public Member Functions inherited from ATL::CWindow
static LPCTSTR GetWndClassName ()
 
static LRESULT SendMessage (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
- Static Public Attributes inherited from ATL::CWindow
static RECT rcDefault
 

Detailed Description

Definition at line 13 of file imgarea.h.

Member Function Documentation

◆ cancelDrawing()

void CImgAreaWindow::cancelDrawing ( )
private

Definition at line 219 of file imgarea.cpp.

220 {
221  POINT pt;
222  switch (toolsModel.GetActiveTool())
223  {
224  case TOOL_FREESEL: case TOOL_RECTSEL:
225  case TOOL_TEXT: case TOOL_ZOOM: case TOOL_SHAPE:
228  pointSP = 0;
229  Invalidate(FALSE);
230  break;
231  default:
232  GetCursorPos(&pt);
233  ScreenToClient(&pt);
234  // FIXME: dirty hack
235  if (GetKeyState(VK_LBUTTON) < 0)
236  {
239  }
240  else if (GetKeyState(VK_RBUTTON) < 0)
241  {
244  }
245  imageModel.Undo();
246  pointSP = 0;
248  }
249 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TOOL_TEXT
Definition: definitions.h:144
#define VK_LBUTTON
Definition: winuser.h:2165
#define pt(x, y)
Definition: drawing.c:79
void endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:218
#define TOOL_SHAPE
Definition: definitions.h:148
SelectionModel selectionModel
Definition: main.cpp:20
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
int GetZoom()
Definition: toolsmodel.cpp:104
#define VK_RBUTTON
Definition: winuser.h:2166
HDC GetDC()
Definition: history.cpp:218
SHORT WINAPI GetKeyState(_In_ int)
short pointSP
Definition: mouse.cpp:53
BOOL ScreenToClient(LPPOINT lpPoint) const
Definition: atlwin.h:1024
ImageModel imageModel
Definition: main.cpp:32
#define TOOL_FREESEL
Definition: definitions.h:135
#define TOOL_RECTSEL
Definition: definitions.h:136
PaletteModel paletteModel
Definition: main.cpp:28
#define TOOL_ZOOM
Definition: definitions.h:140
int GetActiveTool()
Definition: toolsmodel.cpp:60
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
void Undo(void)
Definition: history.cpp:57
void endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:464
void ResetToPrevious(void)
Definition: history.cpp:93

Referenced by OnCaptureChanged(), and OnKeyDown().

◆ drawZoomFrame()

void CImgAreaWindow::drawZoomFrame ( int  mouseX,
int  mouseY 
)
private

Definition at line 35 of file imgarea.cpp.

36 {
37  HDC hdc;
38  HPEN oldPen;
39  HBRUSH oldBrush;
40  LOGBRUSH logbrush;
41  int rop;
42 
43  RECT clientRectScrollbox;
44  RECT clientRectImageArea;
45  int x, y, w, h;
46  scrollboxWindow.GetClientRect(&clientRectScrollbox);
47  GetClientRect(&clientRectImageArea);
48  w = clientRectImageArea.right * 2;
49  h = clientRectImageArea.bottom * 2;
50  if (!w || !h)
51  {
52  return;
53  }
54  w = clientRectImageArea.right * clientRectScrollbox.right / w;
55  h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
56  x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
57  y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));
58 
59  hdc = GetDC();
60  oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 0, 0));
61  logbrush.lbStyle = BS_HOLLOW;
62  oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
63  rop = SetROP2(hdc, R2_NOT);
64  Rectangle(hdc, x, y, x + w, y + h);
65  SetROP2(hdc, rop);
66  DeleteObject(SelectObject(hdc, oldBrush));
67  DeleteObject(SelectObject(hdc, oldPen));
68  ReleaseDC(hdc);
69 }
#define max(a, b)
Definition: svc.c:63
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define R2_NOT
Definition: wingdi.h:346
UINT lbStyle
Definition: wingdi.h:1746
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG right
Definition: windef.h:308
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define PS_SOLID
Definition: wingdi.h:585
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1083
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
#define BS_HOLLOW
Definition: wingdi.h:1087
HDC hdc
Definition: main.c:9
HBRUSH WINAPI CreateBrushIndirect(_In_ const LOGBRUSH *plb)
int ReleaseDC(HDC hDC)
Definition: atlwin.h:1006
#define min(a, b)
Definition: monoChain.cc:55
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
CScrollboxWindow scrollboxWindow
Definition: main.cpp:69
LONG bottom
Definition: windef.h:309
HDC GetDC()
Definition: atlwin.h:513

Referenced by OnMouseMove().

◆ OnCaptureChanged()

LRESULT CImgAreaWindow::OnCaptureChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 251 of file imgarea.cpp.

252 {
253  if (drawing)
254  {
255  cancelDrawing();
256  drawing = FALSE;
257  }
258  return 0;
259 }
BOOL drawing
Definition: imgarea.h:34
void cancelDrawing()
Definition: imgarea.cpp:219

◆ OnImageModelDimensionsChanged()

LRESULT CImgAreaWindow::OnImageModelDimensionsChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 409 of file imgarea.cpp.

410 {
412  return 0;
413 }
void updateCanvasAndScrollbars()
Definition: imgarea.cpp:20

◆ OnImageModelImageChanged()

LRESULT CImgAreaWindow::OnImageModelImageChanged ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 415 of file imgarea.cpp.

416 {
417  Invalidate(FALSE);
418  return 0;
419 }
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828

◆ OnKeyDown()

LRESULT CImgAreaWindow::OnKeyDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 261 of file imgarea.cpp.

262 {
263  if (wParam == VK_ESCAPE)
264  {
265  if (GetCapture() == m_hWnd)
266  {
267  ReleaseCapture();
268  }
269  else
270  {
271  switch (toolsModel.GetActiveTool())
272  {
273  case TOOL_SHAPE: case TOOL_BEZIER:
274  cancelDrawing();
275  break;
276  }
277  }
278  }
279  return 0;
280 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TOOL_SHAPE
Definition: definitions.h:148
#define VK_ESCAPE
Definition: winuser.h:2189
WPARAM wParam
Definition: combotst.c:138
#define TOOL_BEZIER
Definition: definitions.h:146
HWND WINAPI GetCapture(void)
Definition: message.c:2880
HWND m_hWnd
Definition: atlwin.h:268
int GetActiveTool()
Definition: toolsmodel.cpp:60
void cancelDrawing()
Definition: imgarea.cpp:219
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889

◆ OnLButtonDown()

LRESULT CImgAreaWindow::OnLButtonDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 158 of file imgarea.cpp.

159 {
160  if ((!drawing) || (toolsModel.GetActiveTool() == TOOL_COLOR))
161  {
162  SetCapture();
163  drawing = TRUE;
166  }
167  else
168  {
170  imageModel.Undo();
171  }
172  Invalidate(FALSE);
173  if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() < 8000))
175  return 0;
176 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TRUE
Definition: types.h:120
BOOL zoomTo(int, int, int)
Definition: winproc.cpp:21
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
WPARAM wParam
Definition: combotst.c:138
int GetZoom()
Definition: toolsmodel.cpp:104
void startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:56
HDC GetDC()
Definition: history.cpp:218
#define TOOL_COLOR
Definition: definitions.h:139
ImageModel imageModel
Definition: main.cpp:32
PaletteModel paletteModel
Definition: main.cpp:28
#define TOOL_ZOOM
Definition: definitions.h:140
int GetActiveTool()
Definition: toolsmodel.cpp:60
#define WM_LBUTTONUP
Definition: winuser.h:1759
BOOL drawing
Definition: imgarea.h:34
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
void Undo(void)
Definition: history.cpp:57
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
LPARAM lParam
Definition: combotst.c:139
HWND SetCapture()
Definition: atlwin.h:1100

◆ OnLButtonUp()

LRESULT CImgAreaWindow::OnLButtonUp ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 198 of file imgarea.cpp.

199 {
200  if (drawing)
201  {
204  Invalidate(FALSE);
206  {
207  COLORREF tempColor =
209  if (tempColor != CLR_INVALID)
210  paletteModel.SetFgColor(tempColor);
211  }
213  }
214  drawing = FALSE;
215  ReleaseCapture();
216  return 0;
217 }
ToolsModel toolsModel
Definition: main.cpp:18
void endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:218
#define CLR_INVALID
Definition: wingdi.h:882
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
int GetZoom()
Definition: toolsmodel.cpp:104
HDC GetDC()
Definition: history.cpp:218
LONG_PTR LPARAM
Definition: windef.h:208
DWORD COLORREF
Definition: windef.h:300
HWND hStatusBar
Definition: main.cpp:35
#define TOOL_COLOR
Definition: definitions.h:139
#define SB_SETTEXT
Definition: commctrl.h:1945
void SetFgColor(int newColor)
ImageModel imageModel
Definition: main.cpp:32
PaletteModel paletteModel
Definition: main.cpp:28
int GetActiveTool()
Definition: toolsmodel.cpp:60
BOOL drawing
Definition: imgarea.h:34
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
LPARAM lParam
Definition: combotst.c:139

◆ OnMouseLeave()

LRESULT CImgAreaWindow::OnMouseLeave ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 401 of file imgarea.cpp.

402 {
405  Invalidate(FALSE);
406  return 0;
407 }
ToolsModel toolsModel
Definition: main.cpp:18
LONG_PTR LPARAM
Definition: windef.h:208
#define _T(x)
Definition: vfdio.h:22
HWND hStatusBar
Definition: main.cpp:35
#define SB_SETTEXT
Definition: commctrl.h:1945
#define TOOL_ZOOM
Definition: definitions.h:140
int GetActiveTool()
Definition: toolsmodel.cpp:60
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048

◆ OnMouseMove()

LRESULT CImgAreaWindow::OnMouseMove ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 303 of file imgarea.cpp.

304 {
305  LONG xNow = GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom();
306  LONG yNow = GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom();
308  {
309  TRACKMOUSEEVENT tme;
310 
312  {
313  Invalidate(FALSE);
314  UpdateWindow();
316  }
317 
318  tme.cbSize = sizeof(TRACKMOUSEEVENT);
319  tme.dwFlags = TME_LEAVE;
320  tme.hwndTrack = m_hWnd;
321  tme.dwHoverTime = 0;
322  TrackMouseEvent(&tme);
323 
324  if (!drawing)
325  {
326  CString strCoord;
327  strCoord.Format(_T("%ld, %ld"), xNow, yNow);
328  SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
329  }
330  }
331  if (drawing)
332  {
333  /* values displayed in statusbar */
334  LONG xRel = xNow - start.x;
335  LONG yRel = yNow - start.y;
336  /* freesel, rectsel and text tools always show numbers limited to fit into image area */
338  {
339  if (xRel < 0)
340  xRel = (xNow < 0) ? -start.x : xRel;
341  else if (xNow > imageModel.GetWidth())
342  xRel = imageModel.GetWidth() - start.x;
343  if (yRel < 0)
344  yRel = (yNow < 0) ? -start.y : yRel;
345  else if (yNow > imageModel.GetHeight())
346  yRel = imageModel.GetHeight() - start.y;
347  }
348  /* rectsel and shape tools always show non-negative numbers when drawing */
350  {
351  if (xRel < 0)
352  xRel = -xRel;
353  if (yRel < 0)
354  yRel = -yRel;
355  }
356  /* while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14 */
357  switch(toolsModel.GetActiveTool())
358  {
359  case TOOL_RUBBER:
360  case TOOL_PEN:
361  case TOOL_BRUSH:
362  case TOOL_AIRBRUSH:
363  case TOOL_SHAPE:
364  {
365  CString strCoord;
366  strCoord.Format(_T("%ld, %ld"), xNow, yNow);
367  SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
368  break;
369  }
370  }
371  if ((wParam & MK_LBUTTON) != 0)
372  {
374  Invalidate(FALSE);
376  {
377  CString strSize;
379  yRel = xRel;
380  strSize.Format(_T("%ld x %ld"), xRel, yRel);
381  SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
382  }
383  }
384  if ((wParam & MK_RBUTTON) != 0)
385  {
387  Invalidate(FALSE);
389  {
390  CString strSize;
392  yRel = xRel;
393  strSize.Format(_T("%ld x %ld"), xRel, yRel);
394  SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
395  }
396  }
397  }
398  return 0;
399 }
ToolsModel toolsModel
Definition: main.cpp:18
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define TOOL_TEXT
Definition: definitions.h:144
#define MK_LBUTTON
Definition: winuser.h:2342
#define TOOL_LINE
Definition: definitions.h:145
void drawZoomFrame(int mouseX, int mouseY)
Definition: imgarea.cpp:35
#define TOOL_RUBBER
Definition: definitions.h:137
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:688
#define TOOL_SHAPE
Definition: definitions.h:148
WPARAM wParam
Definition: combotst.c:138
#define TOOL_PEN
Definition: definitions.h:141
void whilePaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:125
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
int GetZoom()
Definition: toolsmodel.cpp:104
long LONG
Definition: pedump.c:60
HDC GetDC()
Definition: history.cpp:218
#define VK_SHIFT
Definition: winuser.h:2177
#define TOOL_AIRBRUSH
Definition: definitions.h:143
LONG_PTR LPARAM
Definition: windef.h:208
#define MK_RBUTTON
Definition: winuser.h:2343
#define _T(x)
Definition: vfdio.h:22
if(!(yy_init))
Definition: macro.lex.yy.c:714
BOOL UpdateWindow()
Definition: atlwin.h:1277
HWND hStatusBar
Definition: main.cpp:35
int GetWidth()
Definition: history.cpp:194
int GetHeight()
Definition: history.cpp:199
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
#define SB_SETTEXT
Definition: commctrl.h:1945
SHORT WINAPI GetAsyncKeyState(_In_ int)
ImageModel imageModel
Definition: main.cpp:32
#define TOOL_FREESEL
Definition: definitions.h:135
HWND m_hWnd
Definition: atlwin.h:268
#define TOOL_BRUSH
Definition: definitions.h:142
#define TOOL_RECTSEL
Definition: definitions.h:136
PaletteModel paletteModel
Definition: main.cpp:28
#define TOOL_ZOOM
Definition: definitions.h:140
GLuint start
Definition: gl.h:1545
int GetActiveTool()
Definition: toolsmodel.cpp:60
#define TME_LEAVE
Definition: commctrl.h:4977
BOOL drawing
Definition: imgarea.h:34
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
LPARAM lParam
Definition: combotst.c:139
void whilePaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:389

◆ OnPaint()

LRESULT CImgAreaWindow::OnPaint ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 103 of file imgarea.cpp.

104 {
106  HDC hdc = GetDC();
107  int imgXRes = imageModel.GetWidth();
108  int imgYRes = imageModel.GetHeight();
109  StretchBlt(hdc, 0, 0, imgXRes * toolsModel.GetZoom() / 1000, imgYRes * toolsModel.GetZoom() / 1000, imageModel.GetDC(), 0, 0, imgXRes,
110  imgYRes, SRCCOPY);
111  if (showGrid && (toolsModel.GetZoom() >= 4000))
112  {
113  HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00a0a0a0));
114  int counter;
115  for(counter = 0; counter <= imgYRes; counter++)
116  {
117  MoveToEx(hdc, 0, counter * toolsModel.GetZoom() / 1000, NULL);
118  LineTo(hdc, imgXRes * toolsModel.GetZoom() / 1000, counter * toolsModel.GetZoom() / 1000);
119  }
120  for(counter = 0; counter <= imgXRes; counter++)
121  {
122  MoveToEx(hdc, counter * toolsModel.GetZoom() / 1000, 0, NULL);
123  LineTo(hdc, counter * toolsModel.GetZoom() / 1000, imgYRes * toolsModel.GetZoom() / 1000);
124  }
125  DeleteObject(SelectObject(hdc, oldPen));
126  }
127  ReleaseDC(hdc);
128  selectionWindow.Invalidate(FALSE);
129  miniature.Invalidate(FALSE);
130  return 0;
131 }
ToolsModel toolsModel
Definition: main.cpp:18
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL showGrid
Definition: main.cpp:60
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
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)
WPARAM wParam
Definition: combotst.c:138
LRESULT DefWindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: atlwin.h:1522
int GetZoom()
Definition: toolsmodel.cpp:104
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PS_SOLID
Definition: wingdi.h:585
HDC GetDC()
Definition: history.cpp:218
CMiniatureWindow miniature
Definition: main.cpp:65
smooth NULL
Definition: ftsmooth.c:416
GLuint counter
Definition: glext.h:11116
#define WM_PAINT
Definition: winuser.h:1602
int GetWidth()
Definition: history.cpp:194
int GetHeight()
Definition: history.cpp:199
HDC hdc
Definition: main.c:9
ImageModel imageModel
Definition: main.cpp:32
int ReleaseDC(HDC hDC)
Definition: atlwin.h:1006
LPARAM lParam
Definition: combotst.c:139
HDC GetDC()
Definition: atlwin.h:513
#define SRCCOPY
Definition: wingdi.h:332
CSelectionWindow selectionWindow
Definition: main.cpp:71

◆ OnRButtonDown()

LRESULT CImgAreaWindow::OnRButtonDown ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 178 of file imgarea.cpp.

179 {
180  if ((!drawing) || (toolsModel.GetActiveTool() == TOOL_COLOR))
181  {
182  SetCapture();
183  drawing = TRUE;
186  }
187  else
188  {
190  imageModel.Undo();
191  }
192  Invalidate(FALSE);
193  if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() > 125))
195  return 0;
196 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TRUE
Definition: types.h:120
BOOL zoomTo(int, int, int)
Definition: winproc.cpp:21
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
WPARAM wParam
Definition: combotst.c:138
int GetZoom()
Definition: toolsmodel.cpp:104
HDC GetDC()
Definition: history.cpp:218
#define WM_RBUTTONUP
Definition: winuser.h:1762
#define TOOL_COLOR
Definition: definitions.h:139
ImageModel imageModel
Definition: main.cpp:32
PaletteModel paletteModel
Definition: main.cpp:28
#define TOOL_ZOOM
Definition: definitions.h:140
int GetActiveTool()
Definition: toolsmodel.cpp:60
BOOL drawing
Definition: imgarea.h:34
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
void Undo(void)
Definition: history.cpp:57
void startPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:329
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
LPARAM lParam
Definition: combotst.c:139
HWND SetCapture()
Definition: atlwin.h:1100

◆ OnRButtonUp()

LRESULT CImgAreaWindow::OnRButtonUp ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 282 of file imgarea.cpp.

283 {
284  if (drawing)
285  {
288  Invalidate(FALSE);
290  {
291  COLORREF tempColor =
293  if (tempColor != CLR_INVALID)
294  paletteModel.SetBgColor(tempColor);
295  }
297  }
298  drawing = FALSE;
299  ReleaseCapture();
300  return 0;
301 }
ToolsModel toolsModel
Definition: main.cpp:18
#define CLR_INVALID
Definition: wingdi.h:882
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
void SetBgColor(int newColor)
int GetZoom()
Definition: toolsmodel.cpp:104
HDC GetDC()
Definition: history.cpp:218
LONG_PTR LPARAM
Definition: windef.h:208
DWORD COLORREF
Definition: windef.h:300
HWND hStatusBar
Definition: main.cpp:35
#define TOOL_COLOR
Definition: definitions.h:139
#define SB_SETTEXT
Definition: commctrl.h:1945
ImageModel imageModel
Definition: main.cpp:32
PaletteModel paletteModel
Definition: main.cpp:28
int GetActiveTool()
Definition: toolsmodel.cpp:60
BOOL drawing
Definition: imgarea.h:34
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
void endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
Definition: mouse.cpp:464
LPARAM lParam
Definition: combotst.c:139

◆ OnSetCursor()

LRESULT CImgAreaWindow::OnSetCursor ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 133 of file imgarea.cpp.

134 {
135  switch (toolsModel.GetActiveTool())
136  {
137  case TOOL_FILL:
139  break;
140  case TOOL_COLOR:
142  break;
143  case TOOL_ZOOM:
145  break;
146  case TOOL_PEN:
148  break;
149  case TOOL_AIRBRUSH:
151  break;
152  default:
154  }
155  return 0;
156 }
#define TOOL_FILL
Definition: definitions.h:138
HCURSOR hCurFill
Definition: main.cpp:42
ToolsModel toolsModel
Definition: main.cpp:18
#define TOOL_PEN
Definition: definitions.h:141
HCURSOR hCurPen
Definition: main.cpp:45
HCURSOR hCurAirbrush
Definition: main.cpp:46
#define TOOL_AIRBRUSH
Definition: definitions.h:143
smooth NULL
Definition: ftsmooth.c:416
HCURSOR hCurZoom
Definition: main.cpp:44
#define TOOL_COLOR
Definition: definitions.h:139
#define LoadCursor
Definition: winuser.h:5787
#define IDC_CROSS
Definition: winuser.h:685
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define TOOL_ZOOM
Definition: definitions.h:140
int GetActiveTool()
Definition: toolsmodel.cpp:60
HCURSOR hCurColor
Definition: main.cpp:43

◆ OnSize()

LRESULT CImgAreaWindow::OnSize ( UINT  nMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
private

Definition at line 71 of file imgarea.cpp.

72 {
73  int imgXRes = imageModel.GetWidth();
74  int imgYRes = imageModel.GetHeight();
75  sizeboxLeftTop.MoveWindow(
76  0,
77  0, 3, 3, TRUE);
78  sizeboxCenterTop.MoveWindow(
79  imgXRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4,
80  0, 3, 3, TRUE);
81  sizeboxRightTop.MoveWindow(
82  imgXRes * toolsModel.GetZoom() / 1000 + 3,
83  0, 3, 3, TRUE);
84  sizeboxLeftCenter.MoveWindow(
85  0,
86  imgYRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4, 3, 3, TRUE);
87  sizeboxRightCenter.MoveWindow(
88  imgXRes * toolsModel.GetZoom() / 1000 + 3,
89  imgYRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4, 3, 3, TRUE);
90  sizeboxLeftBottom.MoveWindow(
91  0,
92  imgYRes * toolsModel.GetZoom() / 1000 + 3, 3, 3, TRUE);
93  sizeboxCenterBottom.MoveWindow(
94  imgXRes * toolsModel.GetZoom() / 2000 + 3 * 3 / 4,
95  imgYRes * toolsModel.GetZoom() / 1000 + 3, 3, 3, TRUE);
96  sizeboxRightBottom.MoveWindow(
97  imgXRes * toolsModel.GetZoom() / 1000 + 3,
98  imgYRes * toolsModel.GetZoom() / 1000 + 3, 3, 3, TRUE);
100  return 0;
101 }
ToolsModel toolsModel
Definition: main.cpp:18
#define TRUE
Definition: types.h:120
CSizeboxWindow sizeboxRightCenter
Definition: main.cpp:77
int GetZoom()
Definition: toolsmodel.cpp:104
CSizeboxWindow sizeboxCenterTop
Definition: main.cpp:74
CSizeboxWindow sizeboxRightTop
Definition: main.cpp:75
CSizeboxWindow sizeboxCenterBottom
Definition: main.cpp:79
CSizeboxWindow sizeboxRightBottom
Definition: main.cpp:80
int GetWidth()
Definition: history.cpp:194
int GetHeight()
Definition: history.cpp:199
CSizeboxWindow sizeboxLeftCenter
Definition: main.cpp:76
ImageModel imageModel
Definition: main.cpp:32
CSizeboxWindow sizeboxLeftBottom
Definition: main.cpp:78
void UpdateScrollbox()
Definition: scrollbox.cpp:53
CSizeboxWindow sizeboxLeftTop
Definition: main.cpp:73

Member Data Documentation

◆ drawing

BOOL CImgAreaWindow::drawing

The documentation for this class was generated from the following files: