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
0002
0003
0004
0005
0006
0007
0008
0009
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;
0026 TGText *fClipText;
0027 FontStruct_t fFont;
0028 Int_t fMaxAscent;
0029 Int_t fMaxDescent;
0030 Int_t fMaxWidth;
0031 TGGC fNormGC;
0032 TGGC fSelGC;
0033 TGGC fSelbackGC;
0034 Bool_t fMarkedFromX;
0035 Bool_t fMarkedFromY;
0036 Bool_t fIsMarked;
0037 Bool_t fIsMarking;
0038 Bool_t fIsSaved;
0039 Bool_t fReadOnly;
0040 TGLongPosition fMarkedStart;
0041 TGLongPosition fMarkedEnd;
0042 TViewTimer *fScrollTimer;
0043 Atom_t *fDNDTypeList;
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; }
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()"); }
0136 virtual void DataDropped(const char *fname) { Emit("DataDropped(char *)", fname); }
0137 virtual void Marked(Bool_t mark) { Emit("Marked(Bool_t)", mark); }
0138 virtual void Clicked(const char *word) { Emit("Clicked(char *)", word); }
0139 virtual void DoubleClicked(const char *word) { Emit("DoubleClicked(char *)", word); }
0140
0141 ClassDefOverride(TGTextView,0)
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