Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGTextView.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: Fons Rademakers   1/7/2000
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_TGTextView
0013 #define ROOT_TGTextView
0014 
0015 
0016 #include "TGView.h"
0017 #include "TGText.h"
0018 #include "TTimer.h"
0019 
0020 class TViewTimer;
0021 
0022 class TGTextView : public TGView {
0023 
0024 protected:
0025    TGText         *fText;         ///< text buffer
0026    TGText         *fClipText;     ///< clipboard text buffer
0027    FontStruct_t    fFont;         ///< text font
0028    Int_t           fMaxAscent;    ///< maximum ascent in font
0029    Int_t           fMaxDescent;   ///< maximum descent in font
0030    Int_t           fMaxWidth;     ///< maximum width of character in font
0031    TGGC            fNormGC;       ///< graphics context for drawing text
0032    TGGC            fSelGC;        ///< graphics context for drawing marked text
0033    TGGC            fSelbackGC;    ///< graphics context for drawing marked background
0034    Bool_t          fMarkedFromX;  ///< true if text is marked from x
0035    Bool_t          fMarkedFromY;  ///< true if text is marker from y
0036    Bool_t          fIsMarked;     ///< true if text is marked/selected
0037    Bool_t          fIsMarking;    ///< true if in marking mode
0038    Bool_t          fIsSaved;      ///< true is content is saved
0039    Bool_t          fReadOnly;     ///< text cannot be edited
0040    TGLongPosition  fMarkedStart;  ///< start position of marked text
0041    TGLongPosition  fMarkedEnd;    ///< end position of marked text
0042    TViewTimer     *fScrollTimer;  ///< scrollbar timer
0043    Atom_t         *fDNDTypeList;  ///< handles DND types
0044 
0045    static const TGFont *fgDefaultFont;
0046    static TGGC         *fgDefaultGC;
0047    static TGGC         *fgDefaultSelectedGC;
0048    static const TGGC   *fgDefaultSelectedBackgroundGC;
0049 
0050    void Init(Pixel_t bg);
0051    void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h) override;
0052    virtual void Mark(Long_t xPos, Long_t yPos);
0053    virtual void UnMark();
0054    void Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); }
0055    virtual void HLayout();
0056    virtual void VLayout();
0057 
0058    static FontStruct_t  GetDefaultFontStruct();
0059    static const TGGC   &GetDefaultGC();
0060    static const TGGC   &GetDefaultSelectedGC();
0061    static const TGGC   &GetDefaultSelectedBackgroundGC();
0062 
0063 private:
0064    TGTextView(const TGTextView&) = delete;
0065    TGTextView& operator=(const TGTextView&) = delete;
0066 
0067 public:
0068    TGTextView(const TGWindow *parent = nullptr, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
0069               UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
0070    TGTextView(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
0071               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
0072    TGTextView(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
0073               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
0074 
0075    ~TGTextView() override;
0076 
0077    virtual Bool_t IsSaved() { fIsSaved = fText->IsSaved(); return fIsSaved;}
0078    virtual Long_t ToObjXCoord(Long_t xCoord, Long_t line);
0079    virtual Long_t ToObjYCoord(Long_t yCoord);
0080    virtual Long_t ToScrXCoord(Long_t xCoord, Long_t line);
0081    virtual Long_t ToScrYCoord(Long_t yCoord);
0082    virtual void   AdjustWidth();
0083    virtual Bool_t LoadFile(const char *fname, long startpos = 0, long length = -1);
0084    virtual Bool_t LoadBuffer(const char *txtbuf);
0085            void   Clear(Option_t * = "") override;
0086    virtual Bool_t Copy();
0087    virtual Bool_t SelectAll();
0088    virtual Bool_t Search(const char *string, Bool_t direction, Bool_t caseSensitive);
0089    virtual void   SetFont(FontStruct_t font);
0090    virtual Long_t ReturnHeighestColHeight() { return fText->RowCount()*fScrollVal.fY; }
0091    virtual Long_t ReturnLongestLineWidth();
0092    virtual Long_t ReturnLineLength(Long_t line) { return fText->GetLineLength(line); }
0093    virtual Long_t ReturnLongestLine() { return fText->GetLongestLine(); }
0094    virtual Long_t ReturnLineCount() { return fText->RowCount(); }
0095 
0096    virtual void   SetSBRange(Int_t direction);
0097    virtual void   SetHsbPosition(Long_t newPos);
0098    virtual void   SetVsbPosition(Long_t newPos);
0099    virtual void   ShowBottom();
0100    virtual void   ShowTop();
0101 
0102            void   SavePrimitive(std::ostream &out, Option_t * = "") override;
0103    virtual void   SetText(TGText *text);
0104    virtual void   AddText(TGText *text);
0105    virtual void   AddLine(const char *string);
0106    virtual void   AddLineFast(const char *string);
0107    virtual void   Update();
0108            void   Layout() override;
0109 
0110    virtual void   SetBackground(Pixel_t p);
0111    virtual void   SetSelectBack(Pixel_t p);
0112    virtual void   SetSelectFore(Pixel_t p);
0113            void   SetForegroundColor(Pixel_t) override;
0114 
0115          TGText  *GetText() const { return fText; }
0116 
0117    virtual void   SetReadOnly(Bool_t on = kTRUE) { fReadOnly = on; } //*TOGGLE* *GETTER=IsReadOnly
0118            Bool_t IsReadOnly() const { return fReadOnly; }
0119            Bool_t IsMarked() const { return fIsMarked; }
0120 
0121            Bool_t HandleDNDDrop(TDNDData *data) override;
0122            Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action,
0123                                     Int_t xroot, Int_t yroot) override;
0124            Atom_t HandleDNDEnter(Atom_t * typelist) override;
0125            Bool_t HandleDNDLeave() override;
0126 
0127            Bool_t HandleButton(Event_t *event) override;
0128            Bool_t HandleDoubleClick(Event_t *event) override;
0129            Bool_t HandleSelectionClear(Event_t *event) override;
0130            Bool_t HandleSelectionRequest(Event_t *event) override;
0131            Bool_t HandleMotion(Event_t *event) override;
0132            Bool_t HandleTimer(TTimer *t) override;
0133            Bool_t HandleCrossing(Event_t *event) override;
0134 
0135    virtual void DataChanged() { Emit("DataChanged()"); }  //*SIGNAL*
0136    virtual void DataDropped(const char *fname) { Emit("DataDropped(char *)", fname); }  //*SIGNAL*
0137    virtual void Marked(Bool_t mark) { Emit("Marked(Bool_t)", mark); } // *SIGNAL*
0138    virtual void Clicked(const char *word) { Emit("Clicked(char *)", word); }  //*SIGNAL*
0139    virtual void DoubleClicked(const char *word) { Emit("DoubleClicked(char *)", word); }  //*SIGNAL*
0140 
0141    ClassDefOverride(TGTextView,0)  // Non-editable text viewer widget
0142 };
0143 
0144 
0145 class TViewTimer : public TTimer {
0146 private:
0147    TGView   *fView;
0148 
0149    TViewTimer(const TViewTimer&) = delete;
0150    TViewTimer& operator=(const TViewTimer&) = delete;
0151 
0152 public:
0153    TViewTimer(TGView *t, Long_t ms) : TTimer(ms, kTRUE), fView(t) { }
0154    Bool_t Notify() override;
0155 };
0156 
0157 
0158 #endif