TGDockableFrame.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGDockableFrame.h 23256 2008-04-16 14:13:50Z antcheva $
00002 // Author: Abdelhalim Ssadik   07/07/04
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGDockableFrame
00013 #define ROOT_TGDockableFrame
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // A TGDockableFrame is a frame with handles that allow it to be        //
00019 // undocked (i.e. put in a transient frame of its own) and to be docked //
00020 // again or hidden and shown again. It uses the TGDockButton, which is  //
00021 // a button with two vertical bars (||) and TGDockHideButton, which is  //
00022 // a button with a small triangle. The TGUndockedFrame is a transient   //
00023 // frame that on closure will put the frame back in the dock.           //
00024 //                                                                      //
00025 //////////////////////////////////////////////////////////////////////////
00026 
00027 #ifndef ROOT_TGFrame
00028 #include "TGFrame.h"
00029 #endif
00030 
00031 #ifndef ROOT_TGWidget
00032 #include "TGWidget.h"
00033 #endif
00034 
00035 #ifndef ROOT_TGButton
00036 #include "TGButton.h"
00037 #endif
00038 
00039 #ifndef ROOT_TGWindow
00040 #include "TGWindow.h"
00041 #endif
00042 
00043 
00044 class TGDockableFrame;
00045 
00046 
00047 class TGDockButton : public TGButton {
00048 protected:
00049    Bool_t     fMouseOn;    // true when mouse on button
00050    ULong_t    fNormBg;     // normal background color
00051    ULong_t    fHiBg;       // highlighted background color
00052 
00053    virtual void DrawBorder();
00054    virtual void DoRedraw();
00055 
00056 public:
00057    TGDockButton(const TGCompositeFrame *p = 0, Int_t id = 1);
00058    virtual ~TGDockButton();
00059 
00060    virtual Bool_t HandleCrossing(Event_t *event);
00061 
00062    ClassDef(TGDockButton,0)  // Dock button
00063 };
00064 
00065 
00066 class TGDockHideButton : public TGDockButton {
00067 protected:
00068    Int_t     fAspectRatio;   // triangle orientation
00069 
00070    virtual void DoRedraw();
00071 
00072 public:
00073    TGDockHideButton(const TGCompositeFrame *p = 0);
00074 
00075    void SetAspectRatio(Int_t a) { fAspectRatio = a; DoRedraw(); }
00076 
00077    ClassDef(TGDockHideButton,0)  // Hide dock button
00078 };
00079 
00080 
00081 class TGUndockedFrame : public TGTransientFrame {
00082 
00083 private:
00084    TGUndockedFrame(const TGUndockedFrame&); // Not implemented
00085    TGUndockedFrame& operator=(const TGUndockedFrame&); // Not implemented
00086 
00087 protected:
00088    TGDockableFrame    *fDockable;   // orignal dockable frame
00089 
00090 public:
00091    TGUndockedFrame(const TGWindow *p = 0, TGDockableFrame *dockable = 0);
00092    virtual ~TGUndockedFrame();
00093 
00094    void FixSize();
00095    void CloseWindow();
00096 
00097    ClassDef(TGUndockedFrame,0)  // Undocked frame
00098 };
00099 
00100 
00101 class TGDockableFrame : public TGCompositeFrame, public TGWidget {
00102 friend class TGUndockedFrame;
00103 
00104 private:
00105    TGDockableFrame(const TGDockableFrame&); // Not implemented
00106    TGDockableFrame& operator=(const TGDockableFrame&); // Not implemented
00107 
00108 protected:
00109    Bool_t            fHidden;        // if frame is hidden
00110    Bool_t            fEnableHide;    // if frame can be hidden
00111    Bool_t            fEnableUndock;  // if frame can be undocked
00112    Bool_t            fDeleted;       // kTRUE if it is being deleted
00113    Bool_t            fFixedSize;     // kTRUE if fixed size when undocked
00114    TString           fDockName;      // name of frame
00115    TGCompositeFrame *fContainer;     // container containing dockable frame
00116    TGCompositeFrame *fButtons;       // container containing dock and hide buttons
00117    TGDockButton     *fDockButton;    // dock button
00118    TGDockHideButton *fHideButton;    // hide button
00119    TGUndockedFrame  *fFrame;         // undocked frame
00120    TGLayoutHints    *fCl, *fHints;   // layout hints
00121    TGLayoutHints    *fLb, *fLc;      // layout hints
00122 
00123 public:
00124    TGDockableFrame(const TGWindow *p = 0, Int_t id = -1,
00125                    UInt_t options = kHorizontalFrame);
00126    virtual ~TGDockableFrame();
00127 
00128    virtual void AddFrame(TGFrame *f, TGLayoutHints *hints);
00129 
00130    virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t);
00131    virtual void Docked() { Emit("Docked()"); }        //*SIGNAL*
00132    virtual void Undocked() { Emit("Undocked()"); }    //*SIGNAL*
00133 
00134    void UndockContainer();
00135    void DockContainer(Int_t del = kTRUE);
00136 
00137    void HideContainer();
00138    void ShowContainer();
00139 
00140    void   EnableUndock(Bool_t onoff);
00141    Bool_t EnableUndock() const { return fEnableUndock; }
00142    void   EnableHide(Bool_t onoff);
00143    Bool_t EnableHide() const { return fEnableHide; }
00144 
00145    void SetWindowName(const char *name);
00146 
00147    Bool_t IsUndocked() const { return (fFrame != 0); }
00148    Bool_t IsHidden() const { return fHidden; }
00149 
00150    Bool_t IsFixedSize() const { return  fFixedSize; }
00151    void   SetFixedSize(Bool_t fixed) { fFixedSize = fixed; }
00152 
00153    TGCompositeFrame *GetContainer() const { return fContainer; }
00154    TGUndockedFrame  *GetUndocked() const { return fFrame; }
00155 
00156    virtual void      SavePrimitive(ostream &out, Option_t *option = "");
00157 
00158    ClassDef(TGDockableFrame,0)  // Dockable widget
00159 };
00160 
00161 #endif

Generated on Tue Jul 5 14:19:54 2011 for ROOT_528-00b_version by  doxygen 1.5.1