OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
fscroll.cpp
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1998 by Yura Bidus, All Rights Reserved
4//
5/// \file
6/// Implementation of class TFlatScroller.
7//------------------------------------------------------------------------------
8#include <owl/pch.h>
9#include <owl/fscroll.h>
10#include <owl/window.h>
11
12namespace owl {
13
15
16namespace
17{
18
19 SCROLLINFO FlatSB_GetScrollInfo_(const TWindow* w, int bar, uint mask = SIF_ALL)
20 {
21 PRECONDITION(w && w->GetHandle());
22 SCROLLINFO i = {sizeof(SCROLLINFO), mask};
23 bool r = FlatSB_GetScrollInfo(w->GetHandle(), bar, &i);
24 CHECK(r); InUse(r);
25 return i;
26 }
27
28 int FlatSB_SetScrollInfo_(const TWindow* w, int bar, SCROLLINFO& i, bool redraw)
29 {
30 PRECONDITION(w && w->GetHandle());
31 return FlatSB_SetScrollInfo(w->GetHandle(), bar, &i, redraw);
32 }
33
34} // namespace
35
36//
37// constructs a TScroller object
38//
40 int xUnit,
41 int yUnit,
42 long xRange,
43 long yRange)
44:
45 TScroller(window,xUnit,yUnit,xRange,yRange)
46{
47}
48
49//
50// destructs a TFlatScroller object
51//
55
56
57void
58TFlatScroller::SetScrollPage(int bar, int page, bool redraw)
59{
60 SCROLLINFO i = {sizeof(SCROLLINFO), SIF_PAGE | SIF_DISABLENOSCROLL, 0, 0, static_cast<UINT>(page)};
61 FlatSB_SetScrollInfo_(Window, bar, i, redraw);
62}
63
64
65int
67{
68 return FlatSB_GetScrollInfo_(Window, bar, SIF_PAGE).nPage;
69}
70
71
72//
73void
74TFlatScroller::GetScrollRange(int bar, int& minPos, int& maxPos) const
75{
76 SCROLLINFO i = FlatSB_GetScrollInfo_(Window, bar, SIF_RANGE);
77 minPos = i.nMin;
78 maxPos = i.nMax;
79}
80
81
82//
83void
84TFlatScroller::SetScrollRange(int bar, int minPos, int maxPos, bool redraw)
85{
86 SCROLLINFO i = {sizeof(SCROLLINFO), SIF_RANGE | SIF_DISABLENOSCROLL, minPos, maxPos};
87 FlatSB_SetScrollInfo_(Window, bar, i, redraw);
88}
89
90
91//
92int
94{
95 return FlatSB_GetScrollInfo_(Window, bar, SIF_POS).nPos;
96}
97
98
99//
100int
101TFlatScroller::SetScrollPos(int bar, int pos, bool redraw)
102{
103 SCROLLINFO i = {sizeof(SCROLLINFO), SIF_POS | SIF_DISABLENOSCROLL, 0, 0, 0, pos};
104 return FlatSB_SetScrollInfo_(Window, bar, i, redraw);
105}
106
107//
108int
110{
111 return FlatSB_GetScrollInfo_(Window, bar, SIF_TRACKPOS).nTrackPos;
112}
113
114
116
117#if OWL_PERSISTENT_STREAMS
118
119//
120// reads an instance of TFlatScroller from the passed ipstream
121//
122void*
123TFlatScroller::Streamer::Read(ipstream& is, uint32 /*version*/) const
124{
125 ReadBaseObject((TScroller*)GetObject(), is);
126
127 return GetObject();
128}
129
130//
131// writes the TFlatScroller to the passed opstream
132//
133void
134TFlatScroller::Streamer::Write(opstream& os) const
135{
136 WriteBaseObject((TScroller*)GetObject(), os);
137}
138
139#endif
140
141} // OWL namespace
142/* ========================================================================== */
143
#define CHECK(condition)
Definition checks.h:239
#define PRECONDITION(condition)
Definition checks.h:227
Class TFlatScroller implements the actual scroller object.
Definition fscroll.h:32
virtual void GetScrollRange(int bar, int &minPos, int &maxPos) const
Definition fscroll.cpp:74
virtual void SetScrollRange(int bar, int minPos, int maxPos, bool redraw=true)
Definition fscroll.cpp:84
virtual ~TFlatScroller()
Definition fscroll.cpp:52
TFlatScroller(TWindow *window, int xUnit, int yUnit, long xRange, long yRange)
Definition fscroll.cpp:39
virtual int GetScrollPage(int bar) const
Definition fscroll.cpp:66
virtual int SetScrollPos(int bar, int pos, bool redraw=true)
Definition fscroll.cpp:101
virtual int GetScrollPos(int bar) const
Definition fscroll.cpp:93
virtual int GetScrollTrackPos(int bar) const
Definition fscroll.cpp:109
virtual void SetScrollPage(int bar, int page, bool redraw=true)
Definition fscroll.cpp:58
Class TScroller implements the actual scroller object.
Definition scroller.h:46
TScroller(TWindow *window, int xUnit, int yUnit, long xRange, long yRange)
Constructs a TScroller object with window as the owner window, and xUnit, yUnit, xRange,...
Definition scroller.cpp:113
TWindow * Window
Points to the window whose client area scroller is to be managed.
Definition scroller.h:91
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
Definition of class TFlatScroller.
void ReadBaseObject(Base *base, ipstream &in)
Definition objstrm.h:1159
void WriteBaseObject(Base *base, opstream &out)
Definition objstrm.h:1150
Object Windows Library (OWLNext Core).
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
void InUse(const T &arg)
Handy utility to avoid compiler warnings about unused parameters.
Definition defs.h:299
OWL_DIAGINFO
Definition animctrl.cpp:14
unsigned int uint
Definition number.h:25
IMPLEMENT_STREAMABLE1(TApplication, TModule)
Base window class TWindow definition, including HWND encapsulation.