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