ReactOS  0.4.13-dev-257-gfabbd7c
winproc.cpp File Reference
#include "precomp.h"
#include "dialogs.h"
Include dependency graph for winproc.cpp:

Go to the source code of this file.


BOOL zoomTo (int newZoom, int mouseX, int mouseY)

Function Documentation

◆ zoomTo()

BOOL zoomTo ( int  newZoom,
int  mouseX,
int  mouseY 

Definition at line 21 of file winproc.cpp.

22 {
23  RECT clientRectScrollbox;
24  RECT clientRectImageArea;
25  int x, y, w, h;
26  scrollboxWindow.GetClientRect(&clientRectScrollbox);
27  imageArea.GetClientRect(&clientRectImageArea);
28  w = clientRectImageArea.right * newZoom / toolsModel.GetZoom();
29  h = clientRectImageArea.bottom * newZoom / toolsModel.GetZoom();
30  if (!w || !h)
31  {
32  return FALSE;
33  }
34  w = clientRectImageArea.right * clientRectScrollbox.right / w;
35  h = clientRectImageArea.bottom * clientRectScrollbox.bottom / h;
36  x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2)) * newZoom / toolsModel.GetZoom();
37  y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2)) * newZoom / toolsModel.GetZoom();
39  toolsModel.SetZoom(newZoom);
41  selectionWindow.ShowWindow(SW_HIDE);
43  scrollboxWindow.Invalidate(TRUE);
48  return TRUE;
49 }
ToolsModel toolsModel
Definition: main.cpp:18
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3916
BOOL MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint=TRUE)
Definition: atlwin.h:958
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define SW_HIDE
Definition: winuser.h:762
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG right
Definition: windef.h:293
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
int GetZoom()
Definition: toolsmodel.cpp:104
CImgAreaWindow imageArea
Definition: main.cpp:71
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:507
Definition: winuser.h:572
int GetWidth()
Definition: history.cpp:195
int GetHeight()
Definition: history.cpp:200
ImageModel imageModel
Definition: main.cpp:32
void SetZoom(int nZoom)
Definition: toolsmodel.cpp:109
#define min(a, b)
#define WM_HSCROLL
Definition: winuser.h:1719
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
CScrollboxWindow scrollboxWindow
Definition: main.cpp:68
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:828
LONG bottom
Definition: windef.h:294
CSelectionWindow selectionWindow
Definition: main.cpp:70
#define WM_VSCROLL
Definition: winuser.h:1720

Referenced by CMainWindow::OnCommand(), CImgAreaWindow::OnLButtonDown(), CImgAreaWindow::OnRButtonDown(), and CToolSettingsWindow::OnVScroll().