Warning, file /include/root/TGTextEntry.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_TGTextEntry
0013 #define ROOT_TGTextEntry
0014
0015
0016 #include "TGFrame.h"
0017 #include "TGWidget.h"
0018 #include "TGTextBuffer.h"
0019
0020 class TBlinkTimer;
0021 class TGToolTip;
0022 class TColor;
0023
0024 class TGTextEntry : public TGFrame, public TGWidget {
0025
0026 public:
0027 enum EEchoMode { kNormal, kNoEcho, kPassword };
0028 enum EInsertMode { kInsert, kReplace };
0029
0030 protected:
0031 TGTextBuffer *fText;
0032 Int_t fStartX;
0033 Int_t fEndX;
0034 Int_t fStartIX;
0035 Int_t fEndIX;
0036 Bool_t fSelectionOn;
0037 Int_t fOffset;
0038 Int_t fCursorX;
0039 Int_t fCursorIX;
0040 Bool_t fCursorOn;
0041 FontStruct_t fFontStruct;
0042 TGGC fNormGC;
0043 TGGC fSelGC;
0044 GContext_t fSelbackGC;
0045 Atom_t fClipboard;
0046 TBlinkTimer *fCurBlink;
0047 TGToolTip *fTip;
0048 Int_t fMaxLen;
0049 Bool_t fEdited;
0050 Bool_t fFrameDrawn;
0051 EEchoMode fEchoMode;
0052 EInsertMode fInsertMode;
0053 ETextJustification fAlignment;
0054 Bool_t fHasOwnFont;
0055 UInt_t fDefWidth;
0056 UInt_t fDefHeight;
0057
0058 void CopyText() const;
0059 void DoRedraw() override;
0060 Int_t GetCharacterIndex(Int_t xcoord);
0061 virtual void Init();
0062 virtual Bool_t IsCursorOutOfFrame();
0063 void Paste();
0064 virtual void PastePrimary(Window_t wid, Atom_t property, Bool_t del);
0065 virtual void ScrollByChar();
0066 virtual void UpdateOffset();
0067
0068 static TString *fgClipboardText;
0069 static const TGFont *fgDefaultFont;
0070 static const TGGC *fgDefaultSelectedGC;
0071 static const TGGC *fgDefaultSelectedBackgroundGC;
0072 static const TGGC *fgDefaultGC;
0073
0074 static const TGGC &GetDefaultSelectedGC();
0075 static const TGGC &GetDefaultSelectedBackgroundGC();
0076
0077 private:
0078 TGTextEntry(const TGTextEntry&) = delete;
0079 TGTextEntry& operator=(const TGTextEntry&) = delete;
0080
0081 public:
0082 static FontStruct_t GetDefaultFontStruct();
0083 static const TGGC &GetDefaultGC();
0084
0085 TGTextEntry(const TGWindow *p, TGTextBuffer *text, Int_t id = -1,
0086 GContext_t norm = GetDefaultGC()(),
0087 FontStruct_t font = GetDefaultFontStruct(),
0088 UInt_t option = kSunkenFrame | kDoubleBorder,
0089 Pixel_t back = GetWhitePixel());
0090
0091 TGTextEntry(const TGWindow *parent = nullptr, const char *text = nullptr, Int_t id = -1);
0092 TGTextEntry(const TString &contents, const TGWindow *parent, Int_t id = -1);
0093
0094 ~TGTextEntry() override;
0095
0096 TGDimension GetDefaultSize() const override;
0097 virtual void SetDefaultSize(UInt_t w, UInt_t h);
0098
0099 virtual void AppendText(const char *text);
0100 void Backspace();
0101 void Clear(Option_t *option="") override;
0102 void CursorLeft(Bool_t mark = kFALSE , Int_t steps = 1);
0103 void CursorRight(Bool_t mark = kFALSE , Int_t steps = 1);
0104 void CursorWordForward(Bool_t mark = kFALSE);
0105 void CursorWordBackward(Bool_t mark = kFALSE);
0106 void Cut();
0107 void Del();
0108 void Deselect();
0109 void DrawBorder() override;
0110 void End(Bool_t mark = kFALSE);
0111 ETextJustification GetAlignment() const { return fAlignment; }
0112 TGTextBuffer *GetBuffer() const { return fText; }
0113 Int_t GetCursorPosition() const { return fCursorIX; }
0114 TString GetDisplayText() const;
0115 EEchoMode GetEchoMode() const { return fEchoMode; }
0116 EInsertMode GetInsertMode() const { return fInsertMode; }
0117 TString GetMarkedText() const;
0118 Int_t GetMaxLength() const { return fMaxLen; }
0119 const char *GetText() const { return fText->GetString(); }
0120 virtual TGToolTip *GetToolTip() const { return fTip; }
0121 const char *GetTitle() const override { return GetText(); }
0122 Bool_t HasMarkedText() const { return fSelectionOn && (fStartIX != fEndIX); }
0123 Pixel_t GetTextColor() const { return fNormGC.GetForeground(); }
0124 FontStruct_t GetFontStruct() const { return fFontStruct; }
0125 void Home(Bool_t mark = kFALSE);
0126 virtual void Insert(const char *);
0127 virtual void InsertText(const char *text, Int_t pos);
0128 Bool_t IsFrameDrawn() const { return fFrameDrawn; }
0129 Bool_t IsEdited() const { return fEdited; }
0130 void Layout() override { UpdateOffset(); }
0131 void MarkWord(Int_t pos);
0132 Int_t MaxMark() const { return fStartIX > fEndIX ? fStartIX : fEndIX; }
0133 Int_t MinMark() const { return fStartIX < fEndIX ? fStartIX : fEndIX; }
0134 void NewMark(Int_t pos);
0135 void Remove();
0136 virtual void RemoveText(Int_t start, Int_t end);
0137 virtual void SetFont(TGFont *font, Bool_t local = kTRUE);
0138 virtual void SetFont(FontStruct_t font, Bool_t local = kTRUE);
0139 virtual void SetFont(const char *fontName, Bool_t local = kTRUE);
0140 virtual void SetTextColor(Pixel_t color, Bool_t local = kTRUE);
0141 virtual void SetTextColor(TColor *color, Bool_t local = kTRUE);
0142 virtual void SetText(const char *text, Bool_t emit = kTRUE);
0143 virtual void SetToolTipText(const char *text, Long_t delayms = 500);
0144 virtual void SetMaxLength(Int_t maxlen);
0145 virtual void SelectAll();
0146 virtual void SetAlignment(ETextJustification mode = kTextLeft);
0147 virtual void SetInsertMode(EInsertMode mode = kInsert);
0148 virtual void SetEchoMode(EEchoMode mode = kNormal);
0149 void SetEnabled(Bool_t flag = kTRUE) { SetState( flag ); }
0150 virtual void SetCursorPosition(Int_t pos);
0151 void SetEdited(Bool_t flag = kTRUE) { fEdited = flag; }
0152 virtual void SetFocus();
0153 virtual void SetFrameDrawn(Bool_t flag = kTRUE);
0154 virtual void SetState(Bool_t state);
0155 virtual void SetTitle(const char *label) { SetText(label); }
0156 void SetForegroundColor(Pixel_t fore) override { SetTextColor(fore, kFALSE); }
0157 Pixel_t GetForeground() const override { return fNormGC.GetForeground(); }
0158 Bool_t HasOwnFont() const { return fHasOwnFont; }
0159
0160 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0161
0162 Bool_t HandleButton(Event_t *event) override;
0163 Bool_t HandleDoubleClick(Event_t *event) override;
0164 Bool_t HandleCrossing(Event_t *event) override;
0165 Bool_t HandleMotion(Event_t *event) override;
0166 Bool_t HandleKey(Event_t *event) override;
0167 Bool_t HandleFocusChange(Event_t *event) override;
0168 Bool_t HandleSelection(Event_t *event) override;
0169 Bool_t HandleSelectionClear(Event_t *event) override;
0170 Bool_t HandleSelectionRequest(Event_t *event) override;
0171 Bool_t HandleTimer(TTimer *t) override;
0172 Bool_t HandleConfigureNotify(Event_t *event) override;
0173
0174 virtual void TextChanged(const char *text = nullptr);
0175 virtual void ReturnPressed();
0176 virtual void TabPressed();
0177 virtual void ShiftTabPressed();
0178 virtual void CursorOutLeft();
0179 virtual void CursorOutRight();
0180 virtual void CursorOutUp();
0181 virtual void CursorOutDown();
0182 virtual void DoubleClicked();
0183
0184 ClassDefOverride(TGTextEntry,0)
0185 };
0186
0187 #endif