Back to home page

EIC code displayed by LXR

 
 

    


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 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   08/01/98
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_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;              ///< text buffer
0032    Int_t             fStartX;            ///< selection begin in pixels
0033    Int_t             fEndX;              ///< selection end in pixels
0034    Int_t             fStartIX;           ///< selection begin in characters
0035    Int_t             fEndIX;             ///< selection end in characters
0036    Bool_t            fSelectionOn;       ///< selection status (on/off)
0037    Int_t             fOffset;            ///< start position of text (in pixels)
0038    Int_t             fCursorX;           ///< cursor position in pixels
0039    Int_t             fCursorIX;          ///< cursor position in characters
0040    Bool_t            fCursorOn;          ///< cursor status (on/off)
0041    FontStruct_t      fFontStruct;        ///< text font
0042    TGGC              fNormGC;            ///< normal drawing context
0043    TGGC              fSelGC;             ///< selected text drawing context
0044    GContext_t        fSelbackGC;         ///< selected background drawing context
0045    Atom_t            fClipboard;         ///< clipboard property
0046    TBlinkTimer      *fCurBlink;          ///< cursor blink timer
0047    TGToolTip        *fTip;               ///< associated tooltip
0048    Int_t             fMaxLen;            ///< maximum length of text
0049    Bool_t            fEdited;            ///< kFALSE, if the line edit's contents have not been changed since the construction
0050    Bool_t            fFrameDrawn;        ///< kTRUE draw itself inside a two-pixel frame, kFALSE draw without any frame
0051    EEchoMode         fEchoMode;          ///< *OPTION={GetMethod="GetEchoMode";SetMethod="SetEchoMode";Items=(kNormal="Normal",kNoEcho="No Echo",kPassword="Password")}*
0052    EInsertMode       fInsertMode;        ///< *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="Insert",kReplace="Replace")}*
0053    ETextJustification fAlignment;        ///< *OPTION={GetMethod="GetAlignment";SetMethod="SetAlignment";Items=(kTextLeft="Left",kTextCenterX="Center",kTextRight="Right")}*
0054    Bool_t            fHasOwnFont;        ///< kTRUE - font defined locally,  kFALSE - globally
0055    UInt_t            fDefWidth;          ///< default width
0056    UInt_t            fDefHeight;         ///< default height
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; ///< application clipboard text
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);          //*MENU*
0143    virtual  void        SetToolTipText(const char *text, Long_t delayms = 500);  //*MENU*
0144    virtual  void        SetMaxLength(Int_t maxlen);                              //*MENU*
0145    virtual  void        SelectAll();
0146    virtual  void        SetAlignment(ETextJustification mode = kTextLeft);       //*SUBMENU*
0147    virtual  void        SetInsertMode(EInsertMode mode = kInsert);               //*SUBMENU*
0148    virtual  void        SetEchoMode(EEchoMode mode = kNormal);                   //*SUBMENU*
0149             void        SetEnabled(Bool_t flag = kTRUE) { SetState( flag ); }    //*TOGGLE* *GETTER=IsEnabled
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);//*SIGNAL*
0175    virtual  void        ReturnPressed();                        //*SIGNAL*
0176    virtual  void        TabPressed();                           //*SIGNAL*
0177    virtual  void        ShiftTabPressed();                      //*SIGNAL*
0178    virtual  void        CursorOutLeft();                        //*SIGNAL*
0179    virtual  void        CursorOutRight();                       //*SIGNAL*
0180    virtual  void        CursorOutUp();                          //*SIGNAL*
0181    virtual  void        CursorOutDown();                        //*SIGNAL*
0182    virtual  void        DoubleClicked();                        //*SIGNAL*
0183 
0184    ClassDefOverride(TGTextEntry,0) // The TGTextEntry widget is a simple line editor for inputting text
0185 };
0186 
0187 #endif