// @(#)root/gl:$Id$
// Author:  Matevz and Alja Tadel  20/02/2009

/*************************************************************************
 * Copyright (C) 1995-2004, 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_TGLAnnotation
#define ROOT_TGLAnnotation

#include "TGLOverlay.h"
#include "TGLUtil.h"
#include "TGLFontManager.h"

class TGLViewer;
class TGLViewerBase;
class TGLFont;
class TGTextEdit;
class TGMainFrame;

class TGLAnnotation : public TGLOverlayElement
{
private:
   TGLAnnotation(const TGLAnnotation&);            // Not implemented
   TGLAnnotation& operator=(const TGLAnnotation&); // Not implemented

protected:
   enum EDrag        { kMove, kResize, kNone };
   enum ENameStack   { kMoveID, kEditID, kDeleteID, kResizeID };

   void MakeEditor();
   Char_t GetLineTransparency() const;

   Float_t           fPosX;           // x position [0, 1]
   Float_t           fPosY;           // y position [0, 1]
   Float_t           fWidth;
   Float_t           fHeight;

   Int_t             fMouseX, fMouseY; //! last mouse position
   EDrag             fDrag;            //!
   Float_t           fDrawW,  fDrawH;  //! width and height when drawing
   Float_t           fTextSizeDrag;    //! text-size at start of drag

   TGLVector3        fPointer;         // picked location in 3D space
   Bool_t            fActive;          // active item identifier

   TGMainFrame      *fMainFrame;       // editors
   TGTextEdit       *fTextEdit;        // editors

   static Color_t    fgBackColor;
   static Color_t    fgTextColor;

   TGLViewer        *fParent;

   TString           fText;           // annotation text
   Float_t           fTextSize;       // relative font size
   TGLFont           fFont;           // font used to render labels
   TGLFont           fMenuFont;       // font used to render menu buttons
   TGLFont::ETextAlignH_e fTextAlign;

   Color_t           fBackColor;      // background color
   Color_t           fTextColor;      // text color
   Char_t            fTransparency;   // transparency of background

   Bool_t            fDrawRefLine;    // draw 3D refrence line
   Bool_t            fUseColorSet;    // use color set from rnrCtx
   Bool_t            fAllowClose;     // allow closing via 'X' button

public:
   TGLAnnotation(TGLViewerBase *parent, const char *text, Float_t posx, Float_t posy);
   TGLAnnotation(TGLViewerBase *parent, const char *text, Float_t posx, Float_t posy, TGLVector3 ref);
   virtual ~TGLAnnotation();

   void  SetText(const TString& x)   { fText = x; }
   const TString& GetText()    const { return fText; }

   void    SetTransparency(Char_t x) { fTransparency = x; }
   Char_t  GetTransparency()   const { return fTransparency; }

   void    SetUseColorSet(Bool_t x)  { fUseColorSet = x; }
   Bool_t  GetUseColorSet()    const { return fUseColorSet; }

   void    SetBackColor(Color_t x)   { fBackColor = x; }
   Color_t GetBackColor()      const { return fBackColor; }

   void    SetTextColor(Color_t x)   { fTextColor = x; }
   Color_t GetTextColor()      const { return fTextColor; }

   void    SetTextSize(Float_t x)    { fTextSize = x; }
   Float_t GetTextSize()       const { return fTextSize; }

   void    SetAllowClose(Bool_t x)   { fAllowClose = x; }
   Bool_t  GetAllowClose()     const { return fAllowClose; }

   TGLFont::ETextAlignH_e GetTextAlign() const { return fTextAlign; }
   void SetTextAlign(TGLFont::ETextAlignH_e a) { fTextAlign = a; }

   virtual Bool_t MouseEnter(TGLOvlSelectRecord& selRec);
   virtual Bool_t Handle(TGLRnrCtx& rnrCtx, TGLOvlSelectRecord& selRec,
                         Event_t* event);
   virtual void   MouseLeave();

   void CloseEditor();

   void UpdateText();

   virtual void   Render(TGLRnrCtx& rnrCtx);

   ClassDef(TGLAnnotation, 0); // GL-annotation.
};

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