OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
scrollba.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 TScrollBar. This defines the basic behavior of all
7/// scrollbar controls.
8//----------------------------------------------------------------------------
9
10#if !defined(OWL_SCROLLBAR_H)
11#define OWL_SCROLLBAR_H
12
13#include <owl/private/defs.h>
14#if defined(BI_HAS_PRAGMA_ONCE)
15# pragma once
16#endif
17
18#include <owl/control.h>
19
20namespace owl {
21
23
24#include <owl/preclass.h>
25
26//
27/// \class TScrollBar
28/// TScrollBar objects represent standalone vertical and horizontal scroll bar
29/// controls. Most of TScrollBar's member functions manage the scroll bar's sliding
30/// box (thumb) position and range.
31///
32/// One special feature of TScrollBar is the notify-based set of member functions
33/// that automatically adjust the scroll bar's thumb position in response to scroll
34/// bar messages.
35///
36/// Never place TScrollBar objects in windows that have either the WS_HSCROLL or
37/// WS_VSCROLL styles in their attributes.
38//
40 : public TControl
41{
42 public:
43
44 TScrollBar(TWindow* parent, int id, int x, int y, int w, int h, bool isHScrollBar, TModule* module = 0);
45 TScrollBar(TWindow* parent, int resourceId, TModule* module = 0);
46 TScrollBar(THandle hWnd, TModule* module = 0);
47
48 int GetLineMagnitude() const;
49 void SetLineMagnitude(int linemagnitude);
50
51 int GetPageMagnitude() const;
52 void SetPageMagnitude(int pagemagnitude);
53
54 /// \name Virtual functions to interface to scrollbars & derived
55 /// @{
56 virtual void GetRange(int& minValue, int& maxValue) const;
57 virtual int GetPosition() const;
58 virtual void SetRange(int minValue, int maxValue, bool redraw = true);
59 virtual void SetPosition(int thumbPos, bool redraw = true);
60 virtual int DeltaPos(int delta);
61 virtual void GetScrollInfo(SCROLLINFO* info) const;
62 virtual void SetScrollInfo(SCROLLINFO* info, bool redraw = true);
63 /// @}
64
65 /// \name Called by EvHScroll and EvVScroll response table handlers
66 /// These routines all end up calling SetPosition()
67 /// @{
68 virtual void SBLineUp();
69 virtual void SBLineDown();
70 virtual void SBPageUp();
71 virtual void SBPageDown();
72 virtual void SBThumbPosition(int thumbPos);
73 virtual void SBThumbTrack(int thumbPos);
74 virtual void SBTop();
75 virtual void SBBottom();
76 virtual void SBEndScroll();
77 /// @}
78
79 /// \name Response table handlers that call above virtual functions in
80 /// response to messages sent by to us by TWindow::DispatchScroll()
81 /// @{
82 void EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
83 void EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
84 /// @}
85
86 /// Safe overload
87 //
88 void Transfer(TScrollBarData& data, TTransferDirection direction) {Transfer(&data, direction);}
89
90 protected:
91
92 // Override TWindow virtual member functions
93 //
94 auto Transfer(void* buffer, TTransferDirection) -> uint override;
95 auto GetWindowClassName() -> TWindowClassName override;
96 void SetupWindow() override;
97
99
100 /// The number of range units to scroll the scroll bar when the user requests a
101 /// small movement by clicking on the scroll bar's arrows. TScrollBar's constructor
102 /// sets LineMagnitude to 1 by default. (The scroll range is 0-100 by default.)
103 //
104 int LineMagnitude;
105
106 /// The number of range units to scroll the scroll bar when the user requests a
107 /// large movement by clicking in the scroll bar's scrolling area. TScrollBar's
108 /// constructor sets PageMagnitude to 10 by default. (The scroll range is 0-100 by
109 /// default.)
110 //
111 int PageMagnitude;
112
113 private:
114
115 // Hidden to prevent accidental copying or assignment
116 //
117 TScrollBar(const TScrollBar&);
118 TScrollBar& operator=(const TScrollBar&);
119
122};
123
125
126//
127// Scroll bar notification macros. methods are: void method()
128//
129// EV_SB_LINEDOWN(id, method)
130// EV_SB_LINEUP(id, method)
131// EV_SB_PAGEDOWN(id, method)
132// EV_SB_PAGEUP(id, method)
133// EV_SB_TOP(id, method)
134// EV_SB_BOTTOM(id, method)
135// EV_SB_THUMBPOSITION(id, method)
136// EV_SB_ENDSCROLL(id, method)
137// EV_SB_BEGINTRACK(id, method)
138
139//
140/// \struct TScrollBarData
141/// The TScrollBarData structure contains integer values that represent a range of
142/// thumb positions on the scroll bar. TScrollBar's function GetRange calls
143/// TScrollBarData to obtain the highest and lowest thumb positions on the scroll
144/// bar. GetPosition calls TScrollBarData to obtain the current thumb position on
145/// the scroll bar.
146//
148{
149 int LowValue; ///< Contains the lowest value of thumb position in the scroll bar's range.
150 int HighValue; ///< Contains the highest value of the thumb position in the scroll bar's range.
151 int Position; ///< Contains the scroll bar's thumb position.
152};
153
154#include <owl/posclass.h>
155
156//----------------------------------------------------------------------------
157// Inline implementation
158//
159
160//
161/// Returns the current delta to move the thumb when line up/line down is received.
162//
164{
165 return LineMagnitude;
166}
167
168//
169/// Sets the delta to move the thumb when line up/line down is received.
170//
171inline void TScrollBar::SetLineMagnitude(int linemagnitude)
172{
173 LineMagnitude = linemagnitude;
174}
175
176
177} // OWL namespace
178
179
180#endif // OWL_SCROLLBAR_H
TControl(TWindow *parent, int id, LPCTSTR title, int x, int y, int w, int h, TModule *module=nullptr)
Invokes TWindow's constructor, passing it parent (parent window), title (caption text),...
Definition control.cpp:43
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:78
TScrollBar objects represent standalone vertical and horizontal scroll bar controls.
Definition scrollba.h:41
void SetPageMagnitude(int pagemagnitude)
Sets the delta to move the thumb when page up/page down is received.
Definition scrollba.cpp:214
virtual void SBLineUp()
Calls SetPosition to move the thumb up or left (by LineMagnitude units).
Definition scrollba.cpp:279
int GetPageMagnitude() const
Returns the current delta to move the thumb when page up/page down is received.
Definition scrollba.cpp:205
virtual void SetScrollInfo(SCROLLINFO *info, bool redraw=true)
Sets scrollbar info.
Definition scrollba.cpp:140
virtual void SBLineDown()
Calls SetPosition to move the thumb down or right (by LineMagnitude units).
Definition scrollba.cpp:290
void Transfer(TScrollBarData &data, TTransferDirection direction)
Safe overload.
Definition scrollba.h:88
virtual void SetPosition(int thumbPos, bool redraw=true)
Moves the thumb to the position specified in thumbPos.
Definition scrollba.cpp:177
TScrollBar(TWindow *parent, int id, int x, int y, int w, int h, bool isHScrollBar, TModule *module=0)
Constructs and initializes a TScrollBar object with the given parent window (parent),...
Definition scrollba.cpp:31
virtual void SBBottom()
Calls SetPosition to move the thumb to the bottom or right of the scroll bar.
Definition scrollba.cpp:355
virtual void SBThumbPosition(int thumbPos)
Calls SetPosition to move the thumb.
Definition scrollba.cpp:322
virtual void SBThumbTrack(int thumbPos)
Calls SetPosition to move the thumb as it is being dragged to a new position.
Definition scrollba.cpp:331
virtual void SBEndScroll()
User released the mouse after scrolling.
Definition scrollba.cpp:366
virtual void GetRange(int &minValue, int &maxValue) const
Returns the end values of the present range of scroll bar thumb positions in minValue and maxValue.
Definition scrollba.cpp:230
virtual int GetPosition() const
Returns the scroll bar's current thumb position.
Definition scrollba.cpp:160
void SetLineMagnitude(int linemagnitude)
Sets the delta to move the thumb when line up/line down is received.
Definition scrollba.h:171
virtual void GetScrollInfo(SCROLLINFO *info) const
Retrieves the scroll info.
Definition scrollba.cpp:150
virtual void SBPageDown()
Calls SetPosition to move the thumb down or right (by PageMagnitude units).
Definition scrollba.cpp:312
virtual void SBTop()
Calls SetPosition to move the thumb to the top or right of the scroll bar.
Definition scrollba.cpp:342
virtual void SetRange(int minValue, int maxValue, bool redraw=true)
Sets the scroll bar to the range between min and max.
Definition scrollba.cpp:246
virtual int DeltaPos(int delta)
Calls SetPosition to change the scroll bar's thumb position by the value supplied in delta.
Definition scrollba.cpp:265
void EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl)
Response table handler that calls the virtual function (SBBottom, SBLineDown and so on) in response t...
Definition scrollba.cpp:375
int GetLineMagnitude() const
Returns the current delta to move the thumb when line up/line down is received.
Definition scrollba.h:163
void EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl)
Response table handler that calls the virtual function (SBBottom, SBLineDown and so on) in response t...
Definition scrollba.cpp:412
virtual void SBPageUp()
Calls SetPosition to move the thumb up or left (by PageMagnitude units).
Definition scrollba.cpp:301
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:50
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
Definition of class TControl.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Definition window.h:92
Object Windows Library (OWLNext Core).
Definition animctrl.h:22
unsigned int uint
Definition number.h:25
#define public_data
Definition defs.h:207
#define _OWLCLASS
Definition defs.h:338
The TScrollBarData structure contains integer values that represent a range of thumb positions on the...
Definition scrollba.h:148
int HighValue
Contains the highest value of the thumb position in the scroll bar's range.
Definition scrollba.h:150
int LowValue
Contains the lowest value of thumb position in the scroll bar's range.
Definition scrollba.h:149
int Position
Contains the scroll bar's thumb position.
Definition scrollba.h:151