ScummVM API documentation
button_object.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_BAGLIB_BUTTON_OBJECT_H
24 #define BAGEL_BAGLIB_BUTTON_OBJECT_H
25 
26 #include "bagel/spacebar/baglib/sprite_object.h"
27 
28 namespace Bagel {
29 namespace SpaceBar {
30 
31 #define SAVE_BTN 0
32 #define CANCEL_BTN 1
33 #define RESTORE_BTN 2
34 #define RESTART_BTN 3
35 #define QUIT_BTN 4
36 
37 #define LINEUP_BTN 10
38 #define LINEDN_BTN 11
39 #define PAGEUP_BTN 12
40 #define PAGEDN_BTN 13
41 
46 public:
47  enum BUTTON_TYPE {
48  BTN_PUSH = 0,
49  BTN_CHECKBOX = 1,
50  BTN_HLEVER = 2,
51  BTN_VLEVER = 3,
52  BTN_DIAL = 4,
53  BTN_SLIDER = 5
54  };
55 
56 private:
57  bool _dragging;
58  CBofRect _slideRect;
59  int _numPos;
60 
61  BUTTON_TYPE _buttonType;
62  bool _activeDown;
63  bool _activeUp;
64  bool _active;
65 
66  CBofPoint _midPoint;
67  BagFuncPtr _callbackFct;
68  void *_callbackInfo; // Data to be passed to the function
69 
70 public:
72  virtual ~CBagButtonObject();
73 
74  ErrorCode attach() override;
75  ErrorCode detach() override;
76 
77  BUTTON_TYPE getButtonType() const {
78  return _buttonType;
79  }
80 
85  ParseCodes setInfo(CBagIfstream &istr) override;
86  bool runObject() override;
87 
88  // Callback function functionality - probably can be phased out
89  void setCallBack(BagFuncPtr func, void *funcInfo) {
90  _callbackFct = func;
91  _callbackInfo = funcInfo;
92  }
93 
94  BagFuncPtr getCallBack() override {
95  return _callbackFct;
96  }
97 
98  void *getCallBackInfo() const {
99  return _callbackInfo;
100  }
101 
102  bool runCallBack() override {
103  if (_callbackFct) {
104  _callbackFct((int)getRefId(), _callbackInfo);
105  return true;
106  }
107 
108  return false;
109  }
110 
111  void onLButtonDown(uint32 /*nFlags*/, CBofPoint *point, void *) override;
112  void onLButtonUp(uint32 flags, CBofPoint *point, void *extraInfo) override;
113  bool onMouseMove(uint32 /*nFlags*/, CBofPoint point, void *extraInfo) override;
114 
115  ErrorCode update(CBofBitmap *bmp, CBofPoint pt, CBofRect *srcRect = nullptr, int maskColor = -1) override;
116 
117  void setSize(const CBofSize &size) override;
118 
119  void setProperty(const CBofString &prop, int val) override;
120  int getProperty(const CBofString &prop) override;
121 };
122 
123 } // namespace SpaceBar
124 } // namespace Bagel
125 
126 #endif
Definition: button_object.h:45
Definition: ifstream.h:32
Definition: size.h:32
Definition: rect.h:35
Definition: string.h:38
Definition: afxwin.h:27
Definition: point.h:32
Definition: sprite_object.h:35
ParseCodes setInfo(CBagIfstream &istr) override
Definition: bitmap.h:57