OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
scroller.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of class TScroller.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_SCROLLER_H)
10#define OWL_SCROLLER_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/objstrm.h>
18#include <owl/window.h>
19
20namespace owl {
21
22#include <owl/preclass.h>
23
24#if !defined(OWL_GEOMETRY_H)
25 class _OWLCLASS TRect;
26#endif
27class _OWLCLASS TDC;
28
29//
30/// \class TScroller
31// ~~~~~ ~~~~~~~~~
32/// Class TScroller implements the actual scroller object. All functions
33/// are inline or virtual to avoid pulling in code when no scrollers have
34/// been constructed.
35//
36/// TScroller supports an automatic window-scrolling mechanism (referred to as
37/// autoscrolling) that works in conjunction with horizontal or vertical window
38/// scroll bars. (It also works if there are no scroll bars.) When autoscrolling is
39/// activated, the window automatically scrolls when the mouse is dragged from
40/// inside the client area of the window to outside that area. If the AutoMode data
41/// member is true, TScroller performs autoscrolling.
42///
43/// To use TScroller, set the Scroller member of your TWindow descendant to a
44/// TScroller object instantiated in the constructor of your TWindow descendant.
45//
47 public:
48 TScroller(TWindow* window,
49 int xUnit, int yUnit,
50 long xRange, long yRange);
51 virtual ~TScroller();
52
53 virtual void SetWindow(TWindow* win);
54 virtual void SetUnits(int xUnit, int yUnit);
55 virtual void SetPageSize();
56 virtual void SetSBarRange();
57 virtual void SetRange(long xRange, long yRange);
58 virtual void SetTotalRangeOfUnits(long xTotalUnits, long yTotalUnits);
59
60 virtual void BeginView(TDC& dc, TRect& rect);
61 virtual void EndView();
62 virtual void VScroll(uint scrollEvent, int thumbPos);
63 virtual void HScroll(uint scrollEvent, int thumbPos);
64 virtual void ScrollTo(long x, long y);
65
66 virtual bool EnableScrollBar(uint flags=SB_BOTH, uint arrow=ESB_ENABLE_BOTH);
67 virtual void ShowScrollBar(int code, bool show=true);
68
69 /// Scrolls to a position calculated using the passed delta values
70 //
71 void ScrollBy(long dx, long dy);
72
73 virtual bool IsAutoMode();
74 virtual void AutoScroll();
75
76 /// Returns a bool value indicating whether or not the passed
77 /// area (in units) is currently visible
78 //
79 bool IsVisibleRect(long x, long y, int xExt, int yExt);
80
81 protected:
82 virtual void SetScrollPage(int bar, int page, bool redraw = true);
83 virtual int GetScrollPage(int bar) const;
84 virtual void GetScrollRange(int bar, int& minPos, int& maxPos) const;
85 virtual void SetScrollRange(int bar, int minPos, int maxPos, bool redraw = true);
86 virtual int GetScrollPos(int bar) const;
87 virtual int SetScrollPos(int bar, int pos, bool redraw = true);
88 virtual int GetScrollTrackPos(int bar) const;
89
90 public:
91 TWindow* Window; ///< Points to the window whose client area scroller is to be managed.
92 long XPos; ///< Specifies the current position of the rectangle in horizontal scroll units.
93 long YPos; ///< Specifies the current position of the rectangle in vertical scroll units.
94 long XRange; ///< Specifies the number of horizontal scroll units.
95 long YRange; ///< Specifies the number of vertical scroll units.
96 long XTotalUnits; ///< Total number of horizontal scroll units
97 long YTotalUnits; ///< Total number of vertical scroll units
98 int XUnit; ///< Specifies the amount (in logical device units) to scroll the rectangle in the horizontal (X) direction.
99 ///< The rectangle is scrolled right if XUnit is positive and left if XUnit is negative.
100 int YUnit; ///< Specifies the amount (in logical device units) to scroll the rectangle in the vertical (Y) direction.
101 ///< The rectangle is scrolled down if YUnit is positive and up if YUnit is negative.
102 int XLine; ///< Specifies the number of logical device units per line to scroll the rectangle in the horizontal (X) direction.
103 int YLine; ///< Specifies the number of logical device units per line to scroll the rectangle in the vertical (Y) direction.
104 int XPage; ///< Specifies the number of logical device units per page to scroll the rectangle in the horizontal (X) direction.
105 int YPage; ///< Specifies the number of logical device units per page to scroll the rectangle in the vertical (Y) direction.
106 bool AutoMode; ///< Is true if automatic scrolling is activated.
107 bool TrackMode; ///< Is true if track scrolling is activated.
108 bool AutoOrg; ///< Is true if scroller offsets origin.
109 bool HasHScrollBar; ///< Is true if scroller has horizontal scroll.
110 bool HasVScrollBar; ///< Is true if scroller has vertical scroll.
111
113};
114
116
117#include <owl/posclass.h>
118
119
120//----------------------------------------------------------------------------
121// Inline implementations
122//
123
124//
125/// Sets the owning window to win.
127 Window = win;
128}
129
130//
131/// Scrolls to a position calculated using the passed delta values (dx and dy). A
132/// positive delta position moves the thumb position down or right. A negative delta
133/// position moves the thumb up or left.
134inline void TScroller::ScrollBy(long dx, long dy){
136}
137
138//
139/// Is true if the rectangle (x, y, xExt, and yExt) is visible.
140inline bool TScroller::IsVisibleRect(long x, long y, int xExt, int yExt){
141 return (x + xExt > XPos) && (y + yExt > YPos) &&
142 (x <= XPos + XPage + 1) && (y <= YPos + YPage + 1);
143}
144
145//
146inline void TScroller::SetScrollPage(int bar, int page, bool redraw){
148}
149
150//
151inline int TScroller::GetScrollPage(int bar) const {
152 return Window->GetScrollPage(bar);
153}
154
155//
156inline void TScroller::GetScrollRange(int bar, int& minPos, int& maxPos) const{
158}
159
160//
164
165//
167 return Window->EnableScrollBar(index, arrow);
168}
169
170//
171inline void TScroller::ShowScrollBar(int code, bool show){
173}
174
175//
176inline int TScroller::GetScrollPos(int bar) const{
177 return Window->GetScrollPos(bar);
178}
179
180//
181inline int TScroller::SetScrollPos(int bar, int pos, bool redraw){
182 return Window->SetScrollPos(bar, pos, redraw);
183}
184
185//
186inline int TScroller::GetScrollTrackPos(int bar) const {
188}
189
190} // OWL namespace
191
192#endif // OWL_SCROLLER_H
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
Class TScroller implements the actual scroller object.
Definition scroller.h:46
virtual void SetWindow(TWindow *win)
Sets the owning window to win.
Definition scroller.h:126
virtual void ShowScrollBar(int code, bool show=true)
Definition scroller.h:171
int XUnit
Specifies the amount (in logical device units) to scroll the rectangle in the horizontal (X) directio...
Definition scroller.h:98
int YUnit
Specifies the amount (in logical device units) to scroll the rectangle in the vertical (Y) direction.
Definition scroller.h:100
long YTotalUnits
Total number of vertical scroll units.
Definition scroller.h:97
bool HasHScrollBar
Is true if scroller has horizontal scroll.
Definition scroller.h:109
int YPage
Specifies the number of logical device units per page to scroll the rectangle in the vertical (Y) dir...
Definition scroller.h:105
bool IsVisibleRect(long x, long y, int xExt, int yExt)
Returns a bool value indicating whether or not the passed area (in units) is currently visible.
Definition scroller.h:140
long YPos
Specifies the current position of the rectangle in vertical scroll units.
Definition scroller.h:93
virtual int SetScrollPos(int bar, int pos, bool redraw=true)
Definition scroller.h:181
long XPos
Specifies the current position of the rectangle in horizontal scroll units.
Definition scroller.h:92
virtual void SetScrollPage(int bar, int page, bool redraw=true)
Definition scroller.h:146
virtual bool EnableScrollBar(uint flags=SB_BOTH, uint arrow=ESB_ENABLE_BOTH)
Definition scroller.h:166
long YRange
Specifies the number of vertical scroll units.
Definition scroller.h:95
bool AutoOrg
Is true if scroller offsets origin.
Definition scroller.h:108
int XLine
Specifies the number of logical device units per line to scroll the rectangle in the horizontal (X) d...
Definition scroller.h:102
virtual int GetScrollPos(int bar) const
Definition scroller.h:176
TWindow * Window
Points to the window whose client area scroller is to be managed.
Definition scroller.h:91
virtual int GetScrollPage(int bar) const
Definition scroller.h:151
bool TrackMode
Is true if track scrolling is activated.
Definition scroller.h:107
void ScrollBy(long dx, long dy)
Scrolls to a position calculated using the passed delta values.
Definition scroller.h:134
virtual void ScrollTo(long x, long y)
Scrolls the rectangle to the position specified in x and y after checking boundary conditions.
Definition scroller.cpp:311
virtual int GetScrollTrackPos(int bar) const
Definition scroller.h:186
long XRange
Specifies the number of horizontal scroll units.
Definition scroller.h:94
virtual void GetScrollRange(int bar, int &minPos, int &maxPos) const
Definition scroller.h:156
bool HasVScrollBar
Is true if scroller has vertical scroll.
Definition scroller.h:110
long XTotalUnits
Total number of horizontal scroll units.
Definition scroller.h:96
bool AutoMode
Is true if automatic scrolling is activated.
Definition scroller.h:106
virtual void SetScrollRange(int bar, int minPos, int maxPos, bool redraw=true)
Definition scroller.h:161
int YLine
Specifies the number of logical device units per line to scroll the rectangle in the vertical (Y) dir...
Definition scroller.h:103
int XPage
Specifies the number of logical device units per page to scroll the rectangle in the horizontal (X) d...
Definition scroller.h:104
Classes that inherit from TStreamableBase are known as streamable classes (their objects can be writt...
Definition objstrm.h:108
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
void ShowScrollBar(int bar, bool show=true)
Displays or hides the scroll bar.
Definition window.h:3043
int GetScrollTrackPos(int bar) const
Returns the thumb track position in the scroll bar.
Definition window.cpp:4104
bool EnableScrollBar(uint sbFlags=SB_BOTH, uint arrowFlags=ESB_ENABLE_BOTH)
Disables or enables one or both of the scroll bar arrows on the scroll bars associated with this wind...
Definition window.h:3029
void GetScrollRange(int bar, int &minPos, int &maxPos) const
Returns the minimum and maximum positions in the scroll bar.
Definition window.cpp:4118
void SetScrollRange(int bar, int minPos, int maxPos, bool redraw=true)
Sets the thumb position in the scroll bar.
Definition window.cpp:4142
void SetScrollPage(int bar, int page, bool redraw=true)
Sets the page property (SCROLLINFO::nPage) of the given scroll bar.
Definition window.cpp:4170
int GetScrollPos(int bar) const
Returns the thumb position in the scroll bar.
Definition window.cpp:4080
int SetScrollPos(int bar, int pos, bool redraw=true)
Sets the thumb position in the scroll bar.
Definition window.cpp:4092
int GetScrollPage(int bar) const
Returns the page property (SCROLLINFO::nPage) of the given scroll bar.
Definition window.cpp:4161
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned int uint
Definition number.h:25
#define _OWLCLASS
Definition defs.h:338
Base window class TWindow definition, including HWND encapsulation.