ROOT logo
// @(#)root/gui:$Id: TGDockableFrame.h 23256 2008-04-16 14:13:50Z antcheva $
// Author: Abdelhalim Ssadik   07/07/04

/*************************************************************************
 * 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_TGDockableFrame
#define ROOT_TGDockableFrame


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// A TGDockableFrame is a frame with handles that allow it to be        //
// undocked (i.e. put in a transient frame of its own) and to be docked //
// again or hidden and shown again. It uses the TGDockButton, which is  //
// a button with two vertical bars (||) and TGDockHideButton, which is  //
// a button with a small triangle. The TGUndockedFrame is a transient   //
// frame that on closure will put the frame back in the dock.           //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif

#ifndef ROOT_TGWidget
#include "TGWidget.h"
#endif

#ifndef ROOT_TGButton
#include "TGButton.h"
#endif

#ifndef ROOT_TGWindow
#include "TGWindow.h"
#endif


class TGDockableFrame;


class TGDockButton : public TGButton {
protected:
   Bool_t     fMouseOn;    // true when mouse on button
   ULong_t    fNormBg;     // normal background color
   ULong_t    fHiBg;       // highlighted background color

   virtual void DrawBorder();
   virtual void DoRedraw();

public:
   TGDockButton(const TGCompositeFrame *p = 0, Int_t id = 1);
   virtual ~TGDockButton();

   virtual Bool_t HandleCrossing(Event_t *event);

   ClassDef(TGDockButton,0)  // Dock button
};


class TGDockHideButton : public TGDockButton {
protected:
   Int_t     fAspectRatio;   // triangle orientation

   virtual void DoRedraw();

public:
   TGDockHideButton(const TGCompositeFrame *p = 0);

   void SetAspectRatio(Int_t a) { fAspectRatio = a; DoRedraw(); }

   ClassDef(TGDockHideButton,0)  // Hide dock button
};


class TGUndockedFrame : public TGTransientFrame {

private:
   TGUndockedFrame(const TGUndockedFrame&); // Not implemented
   TGUndockedFrame& operator=(const TGUndockedFrame&); // Not implemented

protected:
   TGDockableFrame    *fDockable;   // orignal dockable frame

public:
   TGUndockedFrame(const TGWindow *p = 0, TGDockableFrame *dockable = 0);
   virtual ~TGUndockedFrame();

   void FixSize();
   void CloseWindow();

   ClassDef(TGUndockedFrame,0)  // Undocked frame
};


class TGDockableFrame : public TGCompositeFrame, public TGWidget {
friend class TGUndockedFrame;

private:
   TGDockableFrame(const TGDockableFrame&); // Not implemented
   TGDockableFrame& operator=(const TGDockableFrame&); // Not implemented

protected:
   Bool_t            fHidden;        // if frame is hidden
   Bool_t            fEnableHide;    // if frame can be hidden
   Bool_t            fEnableUndock;  // if frame can be undocked
   Bool_t            fDeleted;       // kTRUE if it is being deleted
   Bool_t            fFixedSize;     // kTRUE if fixed size when undocked
   TString           fDockName;      // name of frame
   TGCompositeFrame *fContainer;     // container containing dockable frame
   TGCompositeFrame *fButtons;       // container containing dock and hide buttons
   TGDockButton     *fDockButton;    // dock button
   TGDockHideButton *fHideButton;    // hide button
   TGUndockedFrame  *fFrame;         // undocked frame
   TGLayoutHints    *fCl, *fHints;   // layout hints
   TGLayoutHints    *fLb, *fLc;      // layout hints

public:
   TGDockableFrame(const TGWindow *p = 0, Int_t id = -1,
                   UInt_t options = kHorizontalFrame);
   virtual ~TGDockableFrame();

   virtual void AddFrame(TGFrame *f, TGLayoutHints *hints);

   virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t);
   virtual void Docked() { Emit("Docked()"); }        //*SIGNAL*
   virtual void Undocked() { Emit("Undocked()"); }    //*SIGNAL*

   void UndockContainer();
   void DockContainer(Int_t del = kTRUE);

   void HideContainer();
   void ShowContainer();

   void   EnableUndock(Bool_t onoff);
   Bool_t EnableUndock() const { return fEnableUndock; }
   void   EnableHide(Bool_t onoff);
   Bool_t EnableHide() const { return fEnableHide; }

   void SetWindowName(const char *name);

   Bool_t IsUndocked() const { return (fFrame != 0); }
   Bool_t IsHidden() const { return fHidden; }

   Bool_t IsFixedSize() const { return  fFixedSize; }
   void   SetFixedSize(Bool_t fixed) { fFixedSize = fixed; }

   TGCompositeFrame *GetContainer() const { return fContainer; }
   TGUndockedFrame  *GetUndocked() const { return fFrame; }

   virtual void      SavePrimitive(ostream &out, Option_t *option = "");

   ClassDef(TGDockableFrame,0)  // Dockable widget
};

#endif
 TGDockableFrame.h:1
 TGDockableFrame.h:2
 TGDockableFrame.h:3
 TGDockableFrame.h:4
 TGDockableFrame.h:5
 TGDockableFrame.h:6
 TGDockableFrame.h:7
 TGDockableFrame.h:8
 TGDockableFrame.h:9
 TGDockableFrame.h:10
 TGDockableFrame.h:11
 TGDockableFrame.h:12
 TGDockableFrame.h:13
 TGDockableFrame.h:14
 TGDockableFrame.h:15
 TGDockableFrame.h:16
 TGDockableFrame.h:17
 TGDockableFrame.h:18
 TGDockableFrame.h:19
 TGDockableFrame.h:20
 TGDockableFrame.h:21
 TGDockableFrame.h:22
 TGDockableFrame.h:23
 TGDockableFrame.h:24
 TGDockableFrame.h:25
 TGDockableFrame.h:26
 TGDockableFrame.h:27
 TGDockableFrame.h:28
 TGDockableFrame.h:29
 TGDockableFrame.h:30
 TGDockableFrame.h:31
 TGDockableFrame.h:32
 TGDockableFrame.h:33
 TGDockableFrame.h:34
 TGDockableFrame.h:35
 TGDockableFrame.h:36
 TGDockableFrame.h:37
 TGDockableFrame.h:38
 TGDockableFrame.h:39
 TGDockableFrame.h:40
 TGDockableFrame.h:41
 TGDockableFrame.h:42
 TGDockableFrame.h:43
 TGDockableFrame.h:44
 TGDockableFrame.h:45
 TGDockableFrame.h:46
 TGDockableFrame.h:47
 TGDockableFrame.h:48
 TGDockableFrame.h:49
 TGDockableFrame.h:50
 TGDockableFrame.h:51
 TGDockableFrame.h:52
 TGDockableFrame.h:53
 TGDockableFrame.h:54
 TGDockableFrame.h:55
 TGDockableFrame.h:56
 TGDockableFrame.h:57
 TGDockableFrame.h:58
 TGDockableFrame.h:59
 TGDockableFrame.h:60
 TGDockableFrame.h:61
 TGDockableFrame.h:62
 TGDockableFrame.h:63
 TGDockableFrame.h:64
 TGDockableFrame.h:65
 TGDockableFrame.h:66
 TGDockableFrame.h:67
 TGDockableFrame.h:68
 TGDockableFrame.h:69
 TGDockableFrame.h:70
 TGDockableFrame.h:71
 TGDockableFrame.h:72
 TGDockableFrame.h:73
 TGDockableFrame.h:74
 TGDockableFrame.h:75
 TGDockableFrame.h:76
 TGDockableFrame.h:77
 TGDockableFrame.h:78
 TGDockableFrame.h:79
 TGDockableFrame.h:80
 TGDockableFrame.h:81
 TGDockableFrame.h:82
 TGDockableFrame.h:83
 TGDockableFrame.h:84
 TGDockableFrame.h:85
 TGDockableFrame.h:86
 TGDockableFrame.h:87
 TGDockableFrame.h:88
 TGDockableFrame.h:89
 TGDockableFrame.h:90
 TGDockableFrame.h:91
 TGDockableFrame.h:92
 TGDockableFrame.h:93
 TGDockableFrame.h:94
 TGDockableFrame.h:95
 TGDockableFrame.h:96
 TGDockableFrame.h:97
 TGDockableFrame.h:98
 TGDockableFrame.h:99
 TGDockableFrame.h:100
 TGDockableFrame.h:101
 TGDockableFrame.h:102
 TGDockableFrame.h:103
 TGDockableFrame.h:104
 TGDockableFrame.h:105
 TGDockableFrame.h:106
 TGDockableFrame.h:107
 TGDockableFrame.h:108
 TGDockableFrame.h:109
 TGDockableFrame.h:110
 TGDockableFrame.h:111
 TGDockableFrame.h:112
 TGDockableFrame.h:113
 TGDockableFrame.h:114
 TGDockableFrame.h:115
 TGDockableFrame.h:116
 TGDockableFrame.h:117
 TGDockableFrame.h:118
 TGDockableFrame.h:119
 TGDockableFrame.h:120
 TGDockableFrame.h:121
 TGDockableFrame.h:122
 TGDockableFrame.h:123
 TGDockableFrame.h:124
 TGDockableFrame.h:125
 TGDockableFrame.h:126
 TGDockableFrame.h:127
 TGDockableFrame.h:128
 TGDockableFrame.h:129
 TGDockableFrame.h:130
 TGDockableFrame.h:131
 TGDockableFrame.h:132
 TGDockableFrame.h:133
 TGDockableFrame.h:134
 TGDockableFrame.h:135
 TGDockableFrame.h:136
 TGDockableFrame.h:137
 TGDockableFrame.h:138
 TGDockableFrame.h:139
 TGDockableFrame.h:140
 TGDockableFrame.h:141
 TGDockableFrame.h:142
 TGDockableFrame.h:143
 TGDockableFrame.h:144
 TGDockableFrame.h:145
 TGDockableFrame.h:146
 TGDockableFrame.h:147
 TGDockableFrame.h:148
 TGDockableFrame.h:149
 TGDockableFrame.h:150
 TGDockableFrame.h:151
 TGDockableFrame.h:152
 TGDockableFrame.h:153
 TGDockableFrame.h:154
 TGDockableFrame.h:155
 TGDockableFrame.h:156
 TGDockableFrame.h:157
 TGDockableFrame.h:158
 TGDockableFrame.h:159
 TGDockableFrame.h:160
 TGDockableFrame.h:161