// @(#)root/gl:$Id$
// Author: Bertrand Bellenot   29/01/2008

/*************************************************************************
 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGLEventHandler
#define ROOT_TGLEventHandler

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGLEventHandler                                                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGEventHandler
#include "TGEventHandler.h"
#endif
#ifndef ROOT_TPoint
#include "TPoint.h"
#endif

class TGToolTip;

class TGLViewer;
class TGLPhysicalShape;

class TGLEventHandler : public TGEventHandler
{
protected:
   TGLViewer        *fGLViewer;
   TTimer           *fMouseTimer;     // mouse delay timer
   TPoint            fButtonPushPos;
   TPoint            fLastPos;
   TPoint            fLastMouseOverPos;
   TGLPhysicalShape *fLastMouseOverShape;
   TGToolTip        *fTooltip;        // tooltip for highlight
   TPoint            fLastGlobalPos;
   TPoint            fTooltipPos;
   UInt_t            fActiveButtonID;
   UInt_t            fLastEventState;
   Bool_t            fIgnoreButtonUp;
   Bool_t            fInPointerGrab;
   Bool_t            fMouseTimerRunning;
   Bool_t            fTooltipShown;
   Bool_t            fArcBall;
   Int_t             fTooltipPixelTolerance;
   Int_t             fSecSelType; // secondary selection type
   Bool_t            fDoInternalSelection;
   Bool_t            fViewerCentricControls;
   Float_t           fArrowKeyFactor;
   Float_t           fMouseDragFactor;
   Float_t           fMouseWheelFactor;

   virtual Bool_t Rotate(Int_t xDelta, Int_t yDelta, Bool_t mod1, Bool_t mod2);

   virtual void   GrabMouse();
   virtual void   UnGrabMouse();

   virtual void   SelectForClicked(Event_t *event);
   virtual void   SelectForMouseOver();

   Int_t ControlValue(Int_t v) { return fViewerCentricControls ? -v : v; }

public:
   TGLEventHandler(TGWindow *w, TObject *obj);
   virtual ~TGLEventHandler();

   virtual void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
   virtual Bool_t HandleEvent(Event_t *event);
   virtual Bool_t HandleExpose(Event_t * event);
   virtual Bool_t HandleFocusChange(Event_t *event);
   virtual Bool_t HandleCrossing(Event_t *event);
   virtual Bool_t HandleButton(Event_t * event);
   virtual Bool_t HandleDoubleClick(Event_t *event);
   virtual Bool_t HandleConfigureNotify(Event_t *event);
   virtual Bool_t HandleKey(Event_t *event);
   virtual Bool_t HandleMotion(Event_t * event);
   virtual Bool_t HandleTimer(TTimer *t);
   virtual void   StartMouseTimer();
   virtual void   StopMouseTimer();
   virtual void   ClearMouseOver();
   virtual void   Repaint();

   virtual void   PopupContextMenu(TGLPhysicalShape* pshp, Event_t *event, Int_t gx, Int_t gy);

   virtual void   TriggerTooltip(const char* text);
   virtual void   RemoveTooltip();

   void  SetMouseOverSelectDelay(Int_t ms);
   void  SetMouseOverTooltipDelay(Int_t ms);

   Int_t GetTooltipPixelTolerance()  const { return fTooltipPixelTolerance; }
   void  SetTooltipPixelTolerance(Int_t t) { fTooltipPixelTolerance = t; }

   Int_t GetSecSelType()  const { return fSecSelType; }
   void  SetSecSelType(Int_t t) { fSecSelType = t; }

   Bool_t GetDoInternalSelection() const { return fDoInternalSelection; }
   void   SetDoInternalSelection(Bool_t x) { fDoInternalSelection = x; }

   Bool_t GetArcBall() const   { return fArcBall; }
   void   SetArcBall(Bool_t a) { fArcBall = a;    }

   ClassDef(TGLEventHandler, 0); // Base-class and default implementation of event-handler for TGLViewer.
};

#endif

 TGLEventHandler.h:1
 TGLEventHandler.h:2
 TGLEventHandler.h:3
 TGLEventHandler.h:4
 TGLEventHandler.h:5
 TGLEventHandler.h:6
 TGLEventHandler.h:7
 TGLEventHandler.h:8
 TGLEventHandler.h:9
 TGLEventHandler.h:10
 TGLEventHandler.h:11
 TGLEventHandler.h:12
 TGLEventHandler.h:13
 TGLEventHandler.h:14
 TGLEventHandler.h:15
 TGLEventHandler.h:16
 TGLEventHandler.h:17
 TGLEventHandler.h:18
 TGLEventHandler.h:19
 TGLEventHandler.h:20
 TGLEventHandler.h:21
 TGLEventHandler.h:22
 TGLEventHandler.h:23
 TGLEventHandler.h:24
 TGLEventHandler.h:25
 TGLEventHandler.h:26
 TGLEventHandler.h:27
 TGLEventHandler.h:28
 TGLEventHandler.h:29
 TGLEventHandler.h:30
 TGLEventHandler.h:31
 TGLEventHandler.h:32
 TGLEventHandler.h:33
 TGLEventHandler.h:34
 TGLEventHandler.h:35
 TGLEventHandler.h:36
 TGLEventHandler.h:37
 TGLEventHandler.h:38
 TGLEventHandler.h:39
 TGLEventHandler.h:40
 TGLEventHandler.h:41
 TGLEventHandler.h:42
 TGLEventHandler.h:43
 TGLEventHandler.h:44
 TGLEventHandler.h:45
 TGLEventHandler.h:46
 TGLEventHandler.h:47
 TGLEventHandler.h:48
 TGLEventHandler.h:49
 TGLEventHandler.h:50
 TGLEventHandler.h:51
 TGLEventHandler.h:52
 TGLEventHandler.h:53
 TGLEventHandler.h:54
 TGLEventHandler.h:55
 TGLEventHandler.h:56
 TGLEventHandler.h:57
 TGLEventHandler.h:58
 TGLEventHandler.h:59
 TGLEventHandler.h:60
 TGLEventHandler.h:61
 TGLEventHandler.h:62
 TGLEventHandler.h:63
 TGLEventHandler.h:64
 TGLEventHandler.h:65
 TGLEventHandler.h:66
 TGLEventHandler.h:67
 TGLEventHandler.h:68
 TGLEventHandler.h:69
 TGLEventHandler.h:70
 TGLEventHandler.h:71
 TGLEventHandler.h:72
 TGLEventHandler.h:73
 TGLEventHandler.h:74
 TGLEventHandler.h:75
 TGLEventHandler.h:76
 TGLEventHandler.h:77
 TGLEventHandler.h:78
 TGLEventHandler.h:79
 TGLEventHandler.h:80
 TGLEventHandler.h:81
 TGLEventHandler.h:82
 TGLEventHandler.h:83
 TGLEventHandler.h:84
 TGLEventHandler.h:85
 TGLEventHandler.h:86
 TGLEventHandler.h:87
 TGLEventHandler.h:88
 TGLEventHandler.h:89
 TGLEventHandler.h:90
 TGLEventHandler.h:91
 TGLEventHandler.h:92
 TGLEventHandler.h:93
 TGLEventHandler.h:94
 TGLEventHandler.h:95
 TGLEventHandler.h:96
 TGLEventHandler.h:97
 TGLEventHandler.h:98
 TGLEventHandler.h:99
 TGLEventHandler.h:100
 TGLEventHandler.h:101
 TGLEventHandler.h:102
 TGLEventHandler.h:103
 TGLEventHandler.h:104
 TGLEventHandler.h:105
 TGLEventHandler.h:106
 TGLEventHandler.h:107
 TGLEventHandler.h:108
 TGLEventHandler.h:109
 TGLEventHandler.h:110
 TGLEventHandler.h:111
 TGLEventHandler.h:112
 TGLEventHandler.h:113
 TGLEventHandler.h:114