widgets/combo_drag.hpp

Go to the documentation of this file.
00001 /* $Id: combo_drag.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 #ifndef COMBO_DRAG_H_INCLUDED
00016 #define COMBO_DRAG_H_INCLUDED
00017 
00018 #include "widgets/combo.hpp"
00019 #include "widgets/drop_target.hpp"
00020 
00021 class display;
00022 
00023 namespace gui {
00024 
00025     class combo_drag;
00026     typedef boost::shared_ptr<combo_drag> combo_drag_ptr;
00027 
00028     class combo_drag : public combo, public drop_target, public events::pump_monitor
00029     {
00030         public:
00031             combo_drag(display& disp, const std::vector<std::string>& items, const drop_group_manager_ptr group);
00032 
00033             /**
00034              * used to query if this object was dropped to a target
00035              * @return: -1 if not dropped and other the id of target object
00036              **/
00037             int get_drop_target();
00038             /**
00039              * Implements return after drop
00040              **/
00041             virtual void process(events::pump_info& /*info*/);
00042         protected:
00043             virtual void process_event();
00044             virtual void mouse_motion(const SDL_MouseMotionEvent& event);
00045             virtual void mouse_down(const SDL_MouseButtonEvent& event);
00046             virtual void mouse_up(const SDL_MouseButtonEvent& event);
00047         private:
00048 
00049             void handle_move(const SDL_MouseMotionEvent& event);
00050             void handle_drop();
00051             int drag_target_, old_drag_target_;
00052             SDL_Rect old_location_;
00053             int mouse_x_, mouse_y_;
00054             enum drag_state {
00055                 NONE,
00056                 PRESSED,
00057                 PRESSED_MOVE,
00058                 MOVED,
00059                 RETURN,
00060                 DROP_DOWN
00061             };
00062             drag_state drag_;
00063             static const float MIN_DRAG_DISTANCE;
00064             static const float RETURN_SPEED;
00065     }; //end class combo
00066 
00067 }
00068 
00069 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:58 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs