Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGSplitFrame.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/gui:$Id$
0002 // Author: Bertrand Bellenot 23/01/2008
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGSplitFrame
0013 #define ROOT_TGSplitFrame
0014 
0015 #include "TGFrame.h"
0016 
0017 #include "TMap.h"
0018 
0019 class TGSplitter;
0020 class TContextMenu;
0021 
0022 class TGRectMap : public TObject {
0023 
0024 private:
0025    TGRectMap(const TGRectMap&) = delete;
0026    TGRectMap& operator=(const TGRectMap&) = delete;
0027 
0028 public:
0029    Int_t         fX;    ///< x position
0030    Int_t         fY;    ///< y position
0031    UInt_t        fW;    ///< width
0032    UInt_t        fH;    ///< height
0033 
0034    // constructors
0035    TGRectMap(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
0036              fX(rx), fY(ry), fW(rw), fH(rh) {}
0037    ~TGRectMap() override {}
0038 
0039    // methods
0040    Bool_t Contains(Int_t px, Int_t py) const
0041                 { return ((px >= fX) && (px < fX + (Int_t) fW) &&
0042                           (py >= fY) && (py < fY + (Int_t) fH)); }
0043 
0044    ClassDefOverride(TGRectMap, 0)  // Rectangle used in TMap
0045 };
0046 
0047 class TGSplitTool : public TGCompositeFrame {
0048 
0049 private:
0050    const TGFrame     *fWindow;      ///< frame to which tool tip is associated
0051    TGGC               fRectGC;      ///< rectangles drawing context
0052    TMap               fMap;         ///< map of rectangles/subframes
0053    TContextMenu      *fContextMenu; ///< Context menu for the splitter
0054    Int_t              fX;           ///< X position in fWindow where to popup
0055    Int_t              fY;           ///< Y position in fWindow where to popup
0056 
0057    TGSplitTool(const TGSplitTool&) = delete;
0058    TGSplitTool& operator=(const TGSplitTool&) = delete;
0059 
0060 public:
0061    TGSplitTool(const TGWindow *p = nullptr, const TGFrame *f = nullptr);
0062    ~TGSplitTool() override;
0063 
0064    void   AddRectangle(TGFrame *frm, Int_t x, Int_t y, Int_t w, Int_t h);
0065    void   DoRedraw() override;
0066    void   DrawBorder() override;
0067    Bool_t HandleButton(Event_t *event) override;
0068    Bool_t HandleMotion(Event_t *event) override;
0069    void   Show(Int_t x, Int_t y);
0070    void   Hide();
0071    void   Reset();
0072    void   SetPosition(Int_t x, Int_t y);
0073 
0074    ClassDefOverride(TGSplitTool, 0)  // Split frame tool utility
0075 };
0076 
0077 class TGSplitFrame : public TGCompositeFrame {
0078 
0079 private:
0080    TGSplitFrame(const TGSplitFrame&) = delete;
0081    TGSplitFrame& operator=(const TGSplitFrame&) = delete;
0082 
0083 protected:
0084    TGFrame          *fFrame;       ///< Pointer to the embedded frame (if any)
0085    TGTransientFrame *fUndocked;    ///< Main frame used when "undocking" frame
0086    TGSplitter       *fSplitter;    ///< Pointer to the (H/V) Splitter (if any)
0087    TGSplitFrame     *fFirst;       ///< Pointer to the first child (if any)
0088    TGSplitFrame     *fSecond;      ///< Pointer to the second child (if any)
0089    TGSplitTool      *fSplitTool;   ///< SplitFrame Tool
0090    Float_t           fWRatio;      ///< Width ratio between the first child and this
0091    Float_t           fHRatio;      ///< Height ratio between the first child and this
0092 
0093 public:
0094    TGSplitFrame(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0095                 UInt_t options = 0);
0096    ~TGSplitFrame() override;
0097 
0098    void           AddFrame(TGFrame *f, TGLayoutHints *l = nullptr) override;
0099    void           Cleanup() override;
0100    Bool_t         HandleConfigureNotify(Event_t *) override;
0101    virtual void   HSplit(UInt_t h = 0);
0102    virtual void   VSplit(UInt_t w = 0);
0103    void           RemoveFrame(TGFrame *f) override;
0104 
0105    TGSplitFrame  *GetFirst() const { return fFirst; }
0106    TGFrame       *GetFrame() const { return fFrame; }
0107    TGSplitFrame  *GetSecond() const { return fSecond; }
0108    TGSplitter    *GetSplitter() const { return fSplitter; }
0109    TGSplitTool   *GetSplitTool() const { return fSplitTool; }
0110    TGSplitFrame  *GetTopFrame();
0111    TGFrame       *GetUndocked() const { return fUndocked; }
0112    Float_t        GetHRatio() const { return fHRatio; }
0113    Float_t        GetWRatio() const { return fWRatio; }
0114    void           MapToSPlitTool(TGSplitFrame *top);
0115    void           OnSplitterClicked(Event_t *event);
0116    void           SetHRatio(Float_t r) { fHRatio = r; }
0117    void           SetWRatio(Float_t r) { fWRatio = r; }
0118    void           SplitHorizontal(const char *side = "top");
0119    void           SplitVertical(const char *side = "left");
0120    void           UnSplit(const char *which);
0121 
0122    // methods accessible via context menu
0123 
0124    void           Close();             // *MENU*
0125    void           CloseAndCollapse();  // *MENU*
0126    void           ExtractFrame();      // *MENU*
0127    void           SwallowBack();       // *MENU*
0128    void           SwitchToMain();      // *MENU*
0129    void           SplitHor();          // *MENU*
0130    void           SplitVer();          // *MENU*
0131 
0132    void           Docked(TGFrame* frame);    //*SIGNAL*
0133    void           Undocked(TGFrame* frame);  //*SIGNAL*
0134 
0135    static  void   SwitchFrames(TGFrame *frame, TGCompositeFrame *dest,
0136                                TGFrame *prev);
0137    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0138 
0139    ClassDefOverride(TGSplitFrame, 0) // Splittable composite frame
0140 };
0141 
0142 #endif