The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
combo_drag.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by David White <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 #ifndef COMBO_DRAG_H_INCLUDED
15 #define COMBO_DRAG_H_INCLUDED
16 
17 #include "widgets/combo.hpp"
18 #include "widgets/drop_target.hpp"
19 
20 class CVideo;
21 
22 namespace gui {
23 
24  class combo_drag;
26 
27  class combo_drag : public combo, public drop_target, public events::pump_monitor
28  {
29  public:
30  combo_drag(CVideo& v, const std::vector<std::string>& items, const drop_group_manager_ptr group);
31 
32  /**
33  * used to query if this object was dropped to a target
34  * @return: -1 if not dropped and other the id of target object
35  **/
36  int get_drop_target();
37  /**
38  * Implements return after drop
39  **/
40  virtual void process(events::pump_info& /*info*/);
41  protected:
42  virtual void process_event();
43  virtual void mouse_motion(const SDL_MouseMotionEvent& event);
44  virtual void mouse_down(const SDL_MouseButtonEvent& event);
45  virtual void mouse_up(const SDL_MouseButtonEvent& event);
46  private:
47 
48  void handle_move(const SDL_MouseMotionEvent& event);
49  void handle_drop();
51  SDL_Rect old_location_;
53  enum drag_state {
60  };
62  static const float MIN_DRAG_DISTANCE;
63  static const float RETURN_SPEED;
64  }; //end class combo
65 
66 }
67 
68 #endif
static const float MIN_DRAG_DISTANCE
Definition: combo_drag.hpp:62
virtual void mouse_motion(const SDL_MouseMotionEvent &event)
Definition: combo_drag.cpp:116
Definition: video.hpp:58
SDL_Rect old_location_
Definition: combo_drag.hpp:51
boost::shared_ptr< combo_drag > combo_drag_ptr
Definition: combo_drag.hpp:24
General purpose widgets.
static const float RETURN_SPEED
Definition: combo_drag.hpp:63
const std::vector< std::string > items
virtual void mouse_down(const SDL_MouseButtonEvent &event)
Definition: combo_drag.cpp:150
drag_state drag_
Definition: combo_drag.hpp:61
virtual void process_event()
Definition: combo_drag.cpp:161
const GLdouble * v
Definition: glew.h:1359
combo_drag(CVideo &v, const std::vector< std::string > &items, const drop_group_manager_ptr group)
Definition: combo_drag.cpp:28
int get_drop_target()
used to query if this object was dropped to a target
Definition: combo_drag.cpp:42
void handle_move(const SDL_MouseMotionEvent &event)
Definition: combo_drag.cpp:49
GLboolean GLuint group
Definition: glew.h:2589
virtual void mouse_up(const SDL_MouseButtonEvent &event)
Definition: combo_drag.cpp:128
cl_event event
Definition: glew.h:3070
virtual void process(events::pump_info &)
Implements return after drop.
Definition: combo_drag.cpp:88
Handles droping for drag able ui items.
Definition: drop_target.hpp:38