ScummVM API documentation
scroll_bar.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BOFLIB_GUI_SCROLL_BAR_H
24 #define BAGEL_BOFLIB_GUI_SCROLL_BAR_H
25 
26 #include "bagel/spacebar/boflib/gui/window.h"
27 #include "bagel/spacebar/boflib/gfx/sprite.h"
28 #include "bagel/spacebar/boflib/gfx/text.h"
29 
30 namespace Bagel {
31 namespace SpaceBar {
32 
33 #define BSB_LEFT 800
34 #define BSB_RIGHT 801
35 #define BSB_LINE_LEFT 802
36 #define BSB_LINE_RIGHT 803
37 #define BSB_PAGE_LEFT 804
38 #define BSB_PAGE_RIGHT 805
39 #define BSB_THUMB_POS 806
40 #define BSB_THUMB_TRACK 807
41 
42 #define MAX_TEXT 128
43 
44 class CBofScrollBar : public CBofWindow {
45 public:
46  CBofScrollBar();
47 
48  virtual ~CBofScrollBar();
49 
50  // Implementation
51  //
52 
53  ErrorCode loadBitmaps(const char *pszBack, const char *pszThumb, const char *pszLeftUp = nullptr, const char *pszRightUp = nullptr, const char *pszLeftDown = nullptr, const char *pszRightDown = nullptr);
54 
55  ErrorCode setPos(int nPos, bool bRepaint = true, bool isInitial = false);
56  int getPos() const {
57  return _nPos;
58  }
59 
60  ErrorCode lineLeft() {
61  return setPos(_nPos - _nLineDelta);
62  }
63  ErrorCode lineRight() {
64  return setPos(_nPos + _nLineDelta);
65  }
66  ErrorCode pageLeft() {
67  return setPos(_nPos - _nPageDelta);
68  }
69  ErrorCode pageRight() {
70  return setPos(_nPos + _nPageDelta);
71  }
72 
73  ErrorCode home() {
74  return setPos(_nMin);
75  }
76  ErrorCode end() {
77  return setPos(_nMax);
78  }
79 
80  int getScrollMin() const {
81  return _nMin;
82  }
83  int getScrollMax() const {
84  return _nMax;
85  }
86 
87  void setLineDelta(const int nDelta) {
88  _nLineDelta = nDelta;
89  }
90  int getLineDelta() const {
91  return _nLineDelta;
92  }
93 
94  void setPageDelta(const int nDelta) {
95  _nPageDelta = nDelta;
96  }
97  int getPageDelta() const {
98  return _nPageDelta;
99  }
100 
101  void getScrollRange(int &nMin, int &nMax);
102  void setScrollRange(int nMin, int nMax, bool bRepaint = true);
103 
104  ErrorCode setText(const char *pszText, int nFlags = JUSTIFY_CENTER);
105 
106  void setRepeatTimer(uint32 nMilliSeconds);
107  ErrorCode paint(CBofRect *pRect = nullptr);
108 
109 protected:
110  int pointToPos(CBofPoint *pPoint);
111 
112  void onPaint(CBofRect *pDirtyRect) override;
113  void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
114  void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
115  void onMouseMove(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
116  void onTimer(uint32) override;
117 
118  //
119  // Data members
120  //
121  CBofBitmap *_pLeftBtnUp;
122  CBofBitmap *_pRightBtnUp;
123  CBofBitmap *_pLeftBtnDn;
124  CBofBitmap *_pRightBtnDn;
125  CBofSprite *_pThumb;
126 
127  CBofRect _cLeftBtnRect;
128  CBofRect _cRightBtnRect;
129 
130  int _nMin;
131  int _nMax;
132  int _nPos;
133  int _nLineDelta;
134  int _nPageDelta;
135 
136  CBofText *_pScrollText;
137  char _szScrollText[MAX_TEXT];
138 
139  CBofSize _cThumbSize;
140  CBofSize _cBkSize;
141 
142  int _nOffset;
143  int _nScrollWidth;
144  int _nRange;
145  bool _bMouseCaptured;
146  CBofPoint _cCurPoint;
147  CBofPoint _cThumbPos;
148  int _nScrollState;
149  uint32 _nTimerCount;
150 };
151 
152 } // namespace SpaceBar
153 } // namespace Bagel
154 
155 #endif
Definition: scroll_bar.h:44
Definition: size.h:32
Definition: window.h:53
Definition: rect.h:35
Definition: text.h:125
Definition: sprite.h:39
Definition: afxwin.h:27
Definition: point.h:32
Definition: bitmap.h:57