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