ReactOS  0.4.14-dev-583-g2a1ba2c
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 215 of file imgarea.cpp.

216 {
217  POINT pt;
218  switch (toolsModel.GetActiveTool())
219  {
220  case TOOL_FREESEL: case TOOL_RECTSEL:
221  case TOOL_TEXT: case TOOL_ZOOM: case TOOL_SHAPE:
224  pointSP = 0;
225  Invalidate(FALSE);
226  break;
227  default:
228  GetCursorPos(&pt);
229  ScreenToClient(&pt);
230  // FIXME: dirty hack
231  if (GetKeyState(VK_LBUTTON) < 0)
232  {
235  }
236  else if (GetKeyState(VK_RBUTTON) < 0)
237  {
240  }
241  imageModel.Undo();
242  pointSP = 0;
244  }
245 }
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:219
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 31 of file imgarea.cpp.

32 {
33  HDC hdc;
34  HPEN oldPen;
35  HBRUSH oldBrush;
36  LOGBRUSH logbrush;
37  int rop;
38 
39  RECT clientRectScrollbox;
40  RECT clientRectImageArea;
41  int x, y, w, h;
42  scrollboxWindow.GetClientRect(&clientRectScrollbox);
43  GetClientRect(&clientRectImageArea);
44  w = clientRectImageArea.right * 2;
45  h = clientRectImageArea.bottom * 2;
46  if (!w || !h)
47  {
48  return;
49  }
50  w = clientRectImageArea.right * clientRectScrollbox.right / w;
51  h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
52  x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
53  y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));
54 
55  hdc = GetDC();
56  oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 0, 0));
57  logbrush.lbStyle = BS_HOLLOW;
58  oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
59  rop = SetROP2(hdc, R2_NOT);
60  Rectangle(hdc, x, y, x + w, y + h);
61  SetROP2(hdc, rop);
62  DeleteObject(SelectObject(hdc, oldBrush));
63  DeleteObject(SelectObject(hdc, oldPen));
64  ReleaseDC(hdc);
65 }
#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:68
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 247 of file imgarea.cpp.

248 {
249  if (drawing)
250  {
251  cancelDrawing();
252  drawing = FALSE;
253  }
254  return 0;
255 }
BOOL drawing
Definition: imgarea.h:34
void cancelDrawing()
Definition: imgarea.cpp:215

◆ OnImageModelDimensionsChanged()

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

Definition at line 405 of file imgarea.cpp.

406 {
408  return 0;
409 }
void updateCanvasAndScrollbars()
Definition: imgarea.cpp:20

◆ OnImageModelImageChanged()

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

Definition at line 411 of file imgarea.cpp.

412 {
413  Invalidate(FALSE);
414  return 0;
415 }
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 257 of file imgarea.cpp.

258 {
259  if (wParam == VK_ESCAPE)
260  {
261  if (GetCapture() == m_hWnd)
262  {
263  ReleaseCapture();
264  }
265  else
266  {
267  switch (toolsModel.GetActiveTool())
268  {
269  case TOOL_SHAPE: case TOOL_BEZIER:
270  cancelDrawing();
271  break;
272  }
273  }
274  }
275  return 0;
276 }
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:2879
HWND m_hWnd
Definition: atlwin.h:268
int GetActiveTool()
Definition: toolsmodel.cpp:60
void cancelDrawing()
Definition: imgarea.cpp:215
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888

◆ OnLButtonDown()

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

Definition at line 154 of file imgarea.cpp.

155 {
156  if ((!drawing) || (toolsModel.GetActiveTool() == TOOL_COLOR))
157  {
158  SetCapture();
159  drawing = TRUE;
162  }
163  else
164  {
166  imageModel.Undo();
167  }
168  Invalidate(FALSE);
169  if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() < 8000))
171  return 0;
172 }
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:219
#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 194 of file imgarea.cpp.

195 {
196  if (drawing)
197  {
200  Invalidate(FALSE);
202  {
203  COLORREF tempColor =
205  if (tempColor != CLR_INVALID)
206  paletteModel.SetFgColor(tempColor);
207  }
209  }
210  drawing = FALSE;
211  ReleaseCapture();
212  return 0;
213 }
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:219
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:2888
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 397 of file imgarea.cpp.

398 {
401  Invalidate(FALSE);
402  return 0;
403 }
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 299 of file imgarea.cpp.

300 {
301  LONG xNow = GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom();
302  LONG yNow = GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom();
304  {
305  TRACKMOUSEEVENT tme;
306 
308  {
309  Invalidate(FALSE);
310  UpdateWindow();
312  }
313 
314  tme.cbSize = sizeof(TRACKMOUSEEVENT);
315  tme.dwFlags = TME_LEAVE;
316  tme.hwndTrack = m_hWnd;
317  tme.dwHoverTime = 0;
318  TrackMouseEvent(&tme);
319 
320  if (!drawing)
321  {
322  CString strCoord;
323  strCoord.Format(_T("%ld, %ld"), xNow, yNow);
324  SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
325  }
326  }
327  if (drawing)
328  {
329  /* values displayed in statusbar */
330  LONG xRel = xNow - start.x;
331  LONG yRel = yNow - start.y;
332  /* freesel, rectsel and text tools always show numbers limited to fit into image area */
334  {
335  if (xRel < 0)
336  xRel = (xNow < 0) ? -start.x : xRel;
337  else if (xNow > imageModel.GetWidth())
338  xRel = imageModel.GetWidth() - start.x;
339  if (yRel < 0)
340  yRel = (yNow < 0) ? -start.y : yRel;
341  else if (yNow > imageModel.GetHeight())
342  yRel = imageModel.GetHeight() - start.y;
343  }
344  /* rectsel and shape tools always show non-negative numbers when drawing */
346  {
347  if (xRel < 0)
348  xRel = -xRel;
349  if (yRel < 0)
350  yRel = -yRel;
351  }
352  /* while drawing, update cursor coordinates only for tools 3, 7, 8, 9, 14 */
353  switch(toolsModel.GetActiveTool())
354  {
355  case TOOL_RUBBER:
356  case TOOL_PEN:
357  case TOOL_BRUSH:
358  case TOOL_AIRBRUSH:
359  case TOOL_SHAPE:
360  {
361  CString strCoord;
362  strCoord.Format(_T("%ld, %ld"), xNow, yNow);
363  SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM) (LPCTSTR) strCoord);
364  break;
365  }
366  }
367  if ((wParam & MK_LBUTTON) != 0)
368  {
370  Invalidate(FALSE);
372  {
373  CString strSize;
375  yRel = xRel;
376  strSize.Format(_T("%ld x %ld"), xRel, yRel);
377  SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
378  }
379  }
380  if ((wParam & MK_RBUTTON) != 0)
381  {
383  Invalidate(FALSE);
385  {
386  CString strSize;
388  yRel = xRel;
389  strSize.Format(_T("%ld x %ld"), xRel, yRel);
390  SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) (LPCTSTR) strSize);
391  }
392  }
393  }
394  return 0;
395 }
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:31
#define TOOL_RUBBER
Definition: definitions.h:137
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:668
#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:219
#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:195
int GetHeight()
Definition: history.cpp:200
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 99 of file imgarea.cpp.

100 {
102  HDC hdc = GetDC();
103  int imgXRes = imageModel.GetWidth();
104  int imgYRes = imageModel.GetHeight();
105  StretchBlt(hdc, 0, 0, imgXRes * toolsModel.GetZoom() / 1000, imgYRes * toolsModel.GetZoom() / 1000, imageModel.GetDC(), 0, 0, imgXRes,
106  imgYRes, SRCCOPY);
107  if (showGrid && (toolsModel.GetZoom() >= 4000))
108  {
109  HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 1, 0x00a0a0a0));
110  int counter;
111  for(counter = 0; counter <= imgYRes; counter++)
112  {
113  MoveToEx(hdc, 0, counter * toolsModel.GetZoom() / 1000, NULL);
114  LineTo(hdc, imgXRes * toolsModel.GetZoom() / 1000, counter * toolsModel.GetZoom() / 1000);
115  }
116  for(counter = 0; counter <= imgXRes; counter++)
117  {
118  MoveToEx(hdc, counter * toolsModel.GetZoom() / 1000, 0, NULL);
119  LineTo(hdc, counter * toolsModel.GetZoom() / 1000, imgYRes * toolsModel.GetZoom() / 1000);
120  }
121  DeleteObject(SelectObject(hdc, oldPen));
122  }
123  ReleaseDC(hdc);
124  selectionWindow.Invalidate(FALSE);
125  miniature.Invalidate(FALSE);
126  return 0;
127 }
ToolsModel toolsModel
Definition: main.cpp:18
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL showGrid
Definition: main.cpp:59
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:1521
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:219
CMiniatureWindow miniature
Definition: main.cpp:64
smooth NULL
Definition: ftsmooth.c:416
GLuint counter
Definition: glext.h:11116
#define WM_PAINT
Definition: winuser.h:1602
int GetWidth()
Definition: history.cpp:195
int GetHeight()
Definition: history.cpp:200
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:70

◆ OnRButtonDown()

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

Definition at line 174 of file imgarea.cpp.

175 {
176  if ((!drawing) || (toolsModel.GetActiveTool() == TOOL_COLOR))
177  {
178  SetCapture();
179  drawing = TRUE;
182  }
183  else
184  {
186  imageModel.Undo();
187  }
188  Invalidate(FALSE);
189  if ((toolsModel.GetActiveTool() == TOOL_ZOOM) && (toolsModel.GetZoom() > 125))
191  return 0;
192 }
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:219
#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 278 of file imgarea.cpp.

279 {
280  if (drawing)
281  {
284  Invalidate(FALSE);
286  {
287  COLORREF tempColor =
289  if (tempColor != CLR_INVALID)
290  paletteModel.SetBgColor(tempColor);
291  }
293  }
294  drawing = FALSE;
295  ReleaseCapture();
296  return 0;
297 }
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:219
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:2888
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 129 of file imgarea.cpp.

130 {
131  switch (toolsModel.GetActiveTool())
132  {
133  case TOOL_FILL:
135  break;
136  case TOOL_COLOR:
138  break;
139  case TOOL_ZOOM:
141  break;
142  case TOOL_PEN:
144  break;
145  case TOOL_AIRBRUSH:
147  break;
148  default:
150  }
151  return 0;
152 }
#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 67 of file imgarea.cpp.

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

Member Data Documentation

◆ drawing

BOOL CImgAreaWindow::drawing

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