ScummVM API documentation
container_gump.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef ULTIMA8_GUMPS_CONTAINERGUMP_H
23 #define ULTIMA8_GUMPS_CONTAINERGUMP_H
24 
25 #include "ultima/ultima8/gumps/item_relative_gump.h"
26 #include "ultima/ultima8/misc/classtype.h"
27 
28 namespace Ultima {
29 namespace Ultima8 {
30 
31 class Shape;
32 class Container;
33 
38 public:
39  ENABLE_RUNTIME_CLASSTYPE()
40 
41  ContainerGump();
42  ContainerGump(const Shape *shape, uint32 frameNum, uint16 owner,
43  uint32 flags = FLAG_DRAGGABLE, int32 layer = LAYER_NORMAL);
44  ~ContainerGump() override;
45 
46  void setItemArea(Rect *itemArea) {
47  _itemArea = *itemArea;
48  }
49 
50  // Close the gump
51  void Close(bool no_del = false) override;
52 
53  // Init the gump, call after construction
54  void InitGump(Gump *newparent, bool take_focus = true) override;
55 
56  void run() override;
57 
58  // Paint the Gump
59  void PaintThis(RenderSurface *, int32 lerp_factor, bool scaled) override;
60 
61  // Trace a click, and return ObjId
62  uint16 TraceObjId(int32 mx, int32 my) override;
63 
64  // Get the location of an item in the gump (coords relative to this).
65  // Returns false on failure.
66  bool GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy,
67  int32 lerp_factor = 256) override;
68 
69 
70  bool StartDraggingItem(Item *item, int mx, int my) override;
71  bool DraggingItem(Item *item, int mx, int my) override;
72  void DraggingItemLeftGump(Item *item) override;
73  void StopDraggingItem(Item *item, bool moved) override;
74  void DropItem(Item *item, int mx, int my) override;
75 
76  Gump *onMouseDown(int button, int32 mx, int32 my) override;
77  void onMouseClick(int button, int32 mx, int32 my) override;
78  void onMouseDouble(int button, int32 mx, int32 my) override;
79 
80  bool loadData(Common::ReadStream *rs, uint32 version);
81  void saveData(Common::WriteStream *ws) override;
82 
83 protected:
84  void GetItemLocation(int32 lerp_factor) override;
85 
86  virtual Container *getTargetContainer(Item *item, int mx, int my);
87 
88  void getItemCoords(Item *item, int32 &itemx, int32 &itemy);
89 
90  Rect _itemArea;
91 
92  bool _displayDragging;
93  uint32 _draggingShape;
94  uint32 _draggingFrame;
95  uint32 _draggingFlags;
96  int32 _draggingX, _draggingY;
97 };
98 
99 } // End of namespace Ultima8
100 } // End of namespace Ultima
101 
102 #endif
void Close(bool no_del=false) override
Definition: stream.h:77
Definition: container_gump.h:37
bool GetLocationOfItem(uint16 itemid, int32 &gx, int32 &gy, int32 lerp_factor=256) override
Definition: rect.h:32
Definition: item.h:42
Definition: render_surface.h:40
uint16 TraceObjId(int32 mx, int32 my) override
Trace a click, and return ObjId.
void PaintThis(RenderSurface *, int32 lerp_factor, bool scaled) override
Overloadable method to Paint just this Gump (RenderSurface is relative to this)
Definition: gump.h:47
bool DraggingItem(Item *item, int mx, int my) override
void DraggingItemLeftGump(Item *item) override
Called when an item that was being dragged over the gump left the gump.
Definition: detection.h:27
bool StartDraggingItem(Item *item, int mx, int my) override
Definition: item_relative_gump.h:34
Definition: container.h:36
void DropItem(Item *item, int mx, int my) override
Definition: stream.h:385
void StopDraggingItem(Item *item, bool moved) override
void run() override
Run the gump.
Definition: shape.h:38
void InitGump(Gump *newparent, bool take_focus=true) override