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/boflib/gui/window.h"
27 #include "bagel/boflib/gfx/sprite.h"
28 #include "bagel/boflib/gfx/text.h"
29 
30 namespace Bagel {
31 
32 #define BSB_LEFT 800
33 #define BSB_RIGHT 801
34 #define BSB_LINE_LEFT 802
35 #define BSB_LINE_RIGHT 803
36 #define BSB_PAGE_LEFT 804
37 #define BSB_PAGE_RIGHT 805
38 #define BSB_THUMB_POS 806
39 #define BSB_THUMB_TRACK 807
40 
41 #define MAX_TEXT 128
42 
43 class CBofScrollBar : public CBofWindow {
44 public:
45  CBofScrollBar();
46 
47  virtual ~CBofScrollBar();
48 
49  // Implementation
50  //
51 
52  ErrorCode loadBitmaps(const char *pszBack, const char *pszThumb, const char *pszLeftUp = nullptr, const char *pszRightUp = nullptr, const char *pszLeftDown = nullptr, const char *pszRightDown = nullptr);
53 
54  ErrorCode setPos(int nPos, bool bRepaint = true, bool isInitial = false);
55  int getPos() const {
56  return _nPos;
57  }
58 
59  ErrorCode lineLeft() {
60  return setPos(_nPos - _nLineDelta);
61  }
62  ErrorCode lineRight() {
63  return setPos(_nPos + _nLineDelta);
64  }
65  ErrorCode pageLeft() {
66  return setPos(_nPos - _nPageDelta);
67  }
68  ErrorCode pageRight() {
69  return setPos(_nPos + _nPageDelta);
70  }
71 
72  ErrorCode home() {
73  return setPos(_nMin);
74  }
75  ErrorCode end() {
76  return setPos(_nMax);
77  }
78 
79  int getScrollMin() const {
80  return _nMin;
81  }
82  int getScrollMax() const {
83  return _nMax;
84  }
85 
86  void setLineDelta(const int nDelta) {
87  _nLineDelta = nDelta;
88  }
89  int getLineDelta() const {
90  return _nLineDelta;
91  }
92 
93  void setPageDelta(const int nDelta) {
94  _nPageDelta = nDelta;
95  }
96  int getPageDelta() const {
97  return _nPageDelta;
98  }
99 
100  void getScrollRange(int &nMin, int &nMax);
101  void setScrollRange(int nMin, int nMax, bool bRepaint = true);
102 
103  ErrorCode setText(const char *pszText, int nFlags = JUSTIFY_CENTER);
104 
105  void setRepeatTimer(uint32 nMilliSeconds);
106  ErrorCode paint(CBofRect *pRect = nullptr);
107 
108 protected:
109  int pointToPos(CBofPoint *pPoint);
110 
111  void onPaint(CBofRect *pDirtyRect) override;
112  void onLButtonDown(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
113  void onLButtonUp(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
114  void onMouseMove(uint32 nFlags, CBofPoint *pPoint, void * = nullptr) override;
115  void onTimer(uint32) override;
116 
117  //
118  // Data members
119  //
120  CBofBitmap *_pLeftBtnUp;
121  CBofBitmap *_pRightBtnUp;
122  CBofBitmap *_pLeftBtnDn;
123  CBofBitmap *_pRightBtnDn;
124  CBofSprite *_pThumb;
125 
126  CBofRect _cLeftBtnRect;
127  CBofRect _cRightBtnRect;
128 
129  int _nMin;
130  int _nMax;
131  int _nPos;
132  int _nLineDelta;
133  int _nPageDelta;
134 
135  CBofText *_pScrollText;
136  char _szScrollText[MAX_TEXT];
137 
138  CBofSize _cThumbSize;
139  CBofSize _cBkSize;
140 
141  int _nOffset;
142  int _nScrollWidth;
143  int _nRange;
144  bool _bMouseCaptured;
145  CBofPoint _cCurPoint;
146  CBofPoint _cThumbPos;
147  int _nScrollState;
148  uint32 _nTimerCount;
149 };
150 
151 } // namespace Bagel
152 
153 #endif
Definition: window.h:50
Definition: scroll_bar.h:43
Definition: size.h:31
Definition: bitmap.h:55
Definition: sprite.h:38
Definition: rect.h:36
Definition: bagel.h:31
Definition: point.h:34
Definition: text.h:122