ReactOS  0.4.12-dev-18-gf469aca
winproc.cpp File Reference
#include "precomp.h"
#include "dialogs.h"
Include dependency graph for winproc.cpp:

Go to the source code of this file.

Functions

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.

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

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();
38 
39  toolsModel.SetZoom(newZoom);
40 
41  selectionWindow.ShowWindow(SW_HIDE);
43  scrollboxWindow.Invalidate(TRUE);
45 
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:949
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define SW_HIDE
Definition: winuser.h:762
LONG right
Definition: windef.h:298
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
int GetZoom()
Definition: toolsmodel.cpp:104
INT INT y
Definition: msvc.h:62
CImgAreaWindow imageArea
Definition: main.cpp:71
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:498
#define SB_THUMBPOSITION
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
INT x
Definition: msvc.h:62
#define min(a, b)
Definition: monoChain.cc:55
#define WM_HSCROLL
Definition: winuser.h:1719
CScrollboxWindow scrollboxWindow
Definition: main.cpp:68
BOOL Invalidate(BOOL bErase=TRUE)
Definition: atlwin.h:819
LONG bottom
Definition: windef.h:299
CSelectionWindow selectionWindow
Definition: main.cpp:70
#define WM_VSCROLL
Definition: winuser.h:1720