ReactOS  0.4.12-dev-75-g00dd17e
scrollbox.cpp File Reference
#include "precomp.h"
#include <atltypes.h>
Include dependency graph for scrollbox.cpp:

Go to the source code of this file.

Classes

struct  ScrollbarPresence
 

Functions

void UpdateScrollbox ()
 

Variables

CONST ScrollbarPresence sp_mx [3][3]
 
CONST INT HSCROLL_WIDTH = ::GetSystemMetrics(SM_CYHSCROLL)
 
CONST INT VSCROLL_WIDTH = ::GetSystemMetrics(SM_CXVSCROLL)
 

Function Documentation

◆ UpdateScrollbox()

void UpdateScrollbox ( )

Definition at line 53 of file scrollbox.cpp.

Referenced by CScrollboxWindow::OnSize(), and CImgAreaWindow::OnSize().

54 {
55  CONST INT EXTRASIZE = 5; /* 3 px of selection markers + 2 px of border */
56 
57  CRect tempRect;
58  CSize sizeImageArea;
59  CSize sizeScrollBox;
60  INT vmode, hmode;
61  SCROLLINFO si;
62 
63  scrollboxWindow.GetWindowRect(&tempRect);
64  sizeScrollBox = CSize(tempRect.Width(), tempRect.Height());
65 
66  imageArea.GetClientRect(&tempRect);
67  sizeImageArea = CSize(tempRect.Width(), tempRect.Height());
68  sizeImageArea += CSize(EXTRASIZE * 2, EXTRASIZE * 2);
69 
70  /* show/hide the scrollbars */
71  vmode = (sizeScrollBox.cy < sizeImageArea.cy ? 0 :
72  (sizeScrollBox.cy < sizeImageArea.cy + HSCROLL_WIDTH ? 1 : 2));
73  hmode = (sizeScrollBox.cx < sizeImageArea.cx ? 0 :
74  (sizeScrollBox.cx < sizeImageArea.cx + VSCROLL_WIDTH ? 1 : 2));
75  scrollboxWindow.ShowScrollBar(SB_VERT, sp_mx[vmode][hmode].bVert);
76  scrollboxWindow.ShowScrollBar(SB_HORZ, sp_mx[vmode][hmode].bHoriz);
77 
78  si.cbSize = sizeof(SCROLLINFO);
79  si.fMask = SIF_PAGE | SIF_RANGE;
80  si.nMin = 0;
81 
82  si.nMax = sizeImageArea.cx +
83  (sp_mx[vmode][hmode].bVert == TRUE ? HSCROLL_WIDTH : 0);
84  si.nPage = sizeScrollBox.cx;
85  scrollboxWindow.SetScrollInfo(SB_HORZ, &si);
86 
87  si.nMax = sizeImageArea.cy +
88  (sp_mx[vmode][hmode].bHoriz == TRUE ? VSCROLL_WIDTH : 0);
89  si.nPage = sizeScrollBox.cy;
90  scrollboxWindow.SetScrollInfo(SB_VERT, &si);
91 
92  scrlClientWindow.MoveWindow(-scrollboxWindow.GetScrollPos(SB_HORZ),
93  -scrollboxWindow.GetScrollPos(SB_VERT),
94  sizeImageArea.cx, sizeImageArea.cy, TRUE);
95 }
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
int Width() const
Definition: atltypes.h:404
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
CONST INT HSCROLL_WIDTH
Definition: scrollbox.cpp:46
int32_t INT
Definition: typedefs.h:56
#define SIF_PAGE
Definition: winuser.h:1219
CImgAreaWindow imageArea
Definition: main.cpp:71
CONST INT VSCROLL_WIDTH
Definition: scrollbox.cpp:47
BOOL GetClientRect(LPRECT lpRect) const
Definition: atlwin.h:498
LONG cx
Definition: windef.h:324
#define CONST
Definition: compiler.h:170
int Height() const
Definition: atltypes.h:318
struct tagSCROLLINFO SCROLLINFO
CScrollboxWindow scrlClientWindow
Definition: main.cpp:69
CONST ScrollbarPresence sp_mx[3][3]
Definition: scrollbox.cpp:39
CScrollboxWindow scrollboxWindow
Definition: main.cpp:68
LONG cy
Definition: windef.h:325

Variable Documentation

◆ HSCROLL_WIDTH

CONST INT HSCROLL_WIDTH = ::GetSystemMetrics(SM_CYHSCROLL)

Definition at line 46 of file scrollbox.cpp.

Referenced by UpdateScrollbox().

◆ sp_mx

CONST ScrollbarPresence sp_mx[3][3]
Initial value:
=
{
{ { TRUE,TRUE }, { TRUE,TRUE }, { TRUE,FALSE } },
{ { TRUE,TRUE }, { FALSE,FALSE }, { FALSE,FALSE } },
{ { FALSE,TRUE }, { FALSE,FALSE }, { FALSE,FALSE } }
}
#define TRUE
Definition: types.h:120

Definition at line 39 of file scrollbox.cpp.

Referenced by UpdateScrollbox().

◆ VSCROLL_WIDTH

CONST INT VSCROLL_WIDTH = ::GetSystemMetrics(SM_CXVSCROLL)

Definition at line 47 of file scrollbox.cpp.

Referenced by UpdateScrollbox().