ScummVM API documentation
cursor.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_CURSOR_H
24 #define BAGEL_BAGLIB_CURSOR_H
25 
26 #include "bagel/boflib/gfx/bitmap.h"
27 #include "bagel/boflib/error.h"
28 
29 namespace Bagel {
30 
31 class CSystemCursor;
32 
33 class CBagCursor : public CBofObject, public CBofError {
34 private:
35  char _fileName[MAX_FNAME];
36  CBofBitmap *_bitmap;
37  int _x;
38  int _y;
39  bool _sharedPalFl;
40  bool _wieldCursorFl;
41 
42 protected:
43  static CBagCursor *_currentCursor;
44  static CSystemCursor *_systemCursor;
45 
46 public:
47  CBagCursor();
48  CBagCursor(CBofBitmap *bmp);
49  CBagCursor(const char *fileName, bool sharedPalFl = false);
50  static void initialize();
51  static void shutdown();
52  static void showSystemCursor();
53  static void hideSystemCursor() {
54  _currentCursor = nullptr;
55  }
56 
57  ~CBagCursor();
58 
59  void setHotspot(int x, int y);
60 
61  CBofPoint getHotspot() const;
62 
63  int getX() const {
64  return _x;
65  }
66  int getY() const {
67  return _y;
68  }
69 
70  ErrorCode load() {
71  return load(_fileName);
72  }
73  ErrorCode load(CBofBitmap *bmp);
74  ErrorCode load(const char *fileName, CBofPalette *pal = nullptr);
75 
76  void unLoad();
77 
78  CBofBitmap *getImage() const {
79  return _bitmap;
80  }
81  ErrorCode setImage(CBofBitmap *bmp) {
82  return load(bmp);
83  }
84 
85  static CBagCursor *getCurrent() {
86  return _currentCursor;
87  }
88 
89  static bool isSystemCursorVisible() {
90  return _currentCursor && _currentCursor->isSystemCursor();
91  }
92 
96  void setWieldCursor(bool b) {
97  _wieldCursorFl = b;
98  }
99  bool IsWieldCursor() const {
100  return _wieldCursorFl;
101  }
102 
103  void show() {
104  setCurrent();
105  }
106  void hide() {
107  _currentCursor = nullptr;
108  }
109 
110  virtual void setCurrent();
111  virtual bool isSystemCursor() const {
112  return false;
113  }
114 };
115 
116 class CSystemCursor : public CBagCursor {
117 public:
118  CSystemCursor() : CBagCursor() {
119  }
120 
121  void setCurrent() override;
122  bool isSystemCursor() const override {
123  return true;
124  }
125 };
126 
127 } // namespace Bagel
128 
129 #endif
Definition: object.h:28
Definition: bitmap.h:55
Definition: cursor.h:33
Definition: error.h:50
void setWieldCursor(bool b)
Definition: cursor.h:96
Definition: cursor.h:116
Definition: bagel.h:31
Definition: point.h:34
Definition: palette.h:69