ReactOS  0.4.15-dev-3748-g6a496c3
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.

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

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

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
#define FALSE
Definition: types.h:117

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().