1 /*
2  *  drag.cc - Dragging objects in Game_window.
3  *
4  *  Copyright (C) 2000-2013  The Exult Team
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef INCL_DRAG_H
22 #define INCL_DRAG_H
23 
24 #include "mouse.h"
25 #include "objs.h"
26 #include "rect.h"
27 #include "singles.h"
28 #include "tiles.h"
29 
30 class Gump;
31 class Gump_button;
32 class Image_buffer;
33 
34 /*
35  *  Data needed when dragging an object.
36  */
37 class Dragging_info : public Game_singletons {
38 	Game_object_shared obj; // What's being dragged.
39 	bool is_new;            // Object was newly created.
40 	Gump *gump;
41 	Gump_button *button;
42 	Tile_coord old_pos;     // Original pos. of object if it wasn't
43 	//   in a container.
44 	TileRect old_foot;     // Original footprint.
45 	int old_lift;           // Lift of obj OR its owner.
46 	int quantity;           // Amount of object being moved.
47 	int readied_index;      // If it was a 'readied' item.
48 	// Last mouse, paint positions:
49 	int mousex, mousey, paintx, painty;
50 	Mouse::Mouse_shapes mouse_shape;// Save starting mouse shape.
51 	TileRect rect;         // Rectangle to repaint.
52 	bool okay;          // True if drag constructed okay.
53 	bool possible_theft;        // Moved enough to be 'theft'.
54 
55 	bool start(int x, int y);   // First motion.
56 	void put_back();        // Put back object.
57 	bool drop_on_gump(int x, int y, Game_object *to_drop, Gump *gump);
58 	bool drop_on_map(int x, int y, Game_object *to_drop);
59 public:
60 	friend class Game_window;
61 	// Create for dropping new object.
62 	Dragging_info(Game_object_shared newobj);
63 	Dragging_info(int x, int y);    // Create for given mouse position.
64 	bool moved(int x, int y);   // Mouse moved.
65 	void paint();           // Paint object being dragged.
66 	bool drop(int x, int y);    // Drop obj. at given position.
67 	// Mouse button released.
68 	bool drop(int x, int y, bool moved);
69 };
70 
71 #endif  /* INCL_DRAG_H */
72