core/vgui/vgui_drag_mixin.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_drag_mixin.h
00002 #ifndef vgui_drag_mixin_h_
00003 #define vgui_drag_mixin_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief  Simplifies the handling of drag events.
00010 // \author Philip C. Pritchett, Robotics Research Group, University of Oxford
00011 // \date   11 Sep 99
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //   11-SEP-1999 P.Pritchett - Initial version.
00016 //   26-APR-2002 K.Y.McGaul - Converted to doxygen style comments.
00017 // \endverbatim
00018 
00019 #include "vgui_event.h"
00020 #include "vgui_tableau.h"
00021 
00022 //: Simplifies the handling of drag events.
00023 //
00024 //  A drag event occurs when the user moves the mouse with one of the
00025 //  mouse buttons pressed down.  In VGUI there is no vgui_DRAG event (there
00026 //  is only vgui_MOTION for when the mouse is moving).  So if you want to
00027 //  capture drag events you may find this class handy.
00028 //
00029 //  The drag_mixin records the last mouse button to be pressed and will
00030 //  send vgui_MOTION events to the function mouse_drag() if the mouse is being
00031 //  moved  with a button depressed.
00032 //
00033 //  An easy way to use vgui_drag_mixin is to derive your tableau from
00034 //  vgui_drag_tableau. You would then be able to implement mouse_drag and
00035 //  all the other function like key_press, mouse_down in vgui_tableau to
00036 //  handle events.
00037 class vgui_drag_mixin
00038 {
00039   //: Mouse button the user is pressing (vgui_BUTTON_NULL if none is pressed).
00040   vgui_button last_down_button_;
00041 
00042  public:
00043   //: Constructor - create a default vgui_drag_mixin.
00044   vgui_drag_mixin(void);
00045 
00046   //: Destructor.
00047   virtual ~vgui_drag_mixin(void);
00048 
00049   //: Look for drag events and pass them to mouse_drag().
00050   virtual bool handle(vgui_event const&);
00051 
00052   //: Called when the user is dragging the mouse.
00053   virtual bool mouse_drag(int, int, vgui_button, vgui_modifier);
00054 };
00055 
00056 #endif // vgui_drag_mixin_h_