Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGTextEdit.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_TGTextEdit
0013 #define ROOT_TGTextEdit
0014 
0015 
0016 #include "TGTextView.h"
0017 
0018 class TGPopupMenu;
0019 class TGSearchType;
0020 class TGTextEditHist;
0021 
0022 class TGTextEdit : public TGTextView {
0023 
0024 private:
0025    TGTextEdit(const TGTextEdit&) = delete;
0026    TGTextEdit& operator=(const TGTextEdit&) = delete;
0027 
0028 public:
0029    enum EInsertMode { kInsert, kReplace };
0030    enum {
0031       kM_FILE_NEW, kM_FILE_OPEN, kM_FILE_CLOSE, kM_FILE_SAVE, kM_FILE_SAVEAS,
0032       kM_FILE_PRINT, kM_EDIT_CUT, kM_EDIT_COPY, kM_EDIT_PASTE, kM_EDIT_SELECTALL,
0033       kM_SEARCH_FIND, kM_SEARCH_FINDAGAIN, kM_SEARCH_GOTO
0034    };
0035 
0036 protected:
0037    GContext_t       fCursor0GC;     ///< graphics context for erasing cursor
0038    GContext_t       fCursor1GC;     ///< graphics context for drawing cursor
0039    Int_t            fCursorState;   ///< cursor state (1=drawn, 2=erased)
0040    TViewTimer      *fCurBlink;      ///< cursor blink timer
0041    TGPopupMenu     *fMenu;          ///< popup menu with editor actions
0042    TGSearchType    *fSearch;        ///< structure used by search dialog
0043    TGLongPosition   fCurrent;       ///< current cursor position
0044    EInsertMode      fInsertMode;    ///< *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",kReplace="&Replace")}*
0045    Bool_t           fEnableMenu;    ///< enable context menu with editor actions
0046    TGTextEditHist  *fHistory;       ///< undo manager
0047    Bool_t           fEnableCursorWithoutFocus; ///< enable cursor visibility when focus went out from
0048                                                ///< text editor window (default is kTRUE)
0049 
0050    static TGGC     *fgCursor0GC;
0051    static TGGC     *fgCursor1GC;
0052 
0053    void Init();
0054 
0055    virtual void SetMenuState();
0056    virtual void CursorOn();
0057    virtual void CursorOff();
0058    virtual void DrawCursor(Int_t mode);
0059    virtual void AdjustPos();
0060    void Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); }
0061 
0062    static const TGGC &GetCursor0GC();
0063    static const TGGC &GetCursor1GC();
0064 
0065 public:
0066    TGTextEdit(const TGWindow *parent = nullptr, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
0067               UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
0068    TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
0069               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
0070    TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
0071               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
0072 
0073    ~TGTextEdit() override;
0074 
0075    virtual Bool_t SaveFile(const char *fname, Bool_t saveas = kFALSE);
0076            void   Clear(Option_t * = "") override;
0077            Bool_t Copy() override;
0078    virtual Bool_t Cut();
0079    virtual Bool_t Paste();
0080    virtual void   InsChar(char character);
0081    virtual void   DelChar();
0082    virtual void   BreakLine();
0083    virtual void   PrevChar();
0084    virtual void   NextChar();
0085    virtual void   LineUp();
0086    virtual void   LineDown();
0087    virtual void   ScreenUp();
0088    virtual void   ScreenDown();
0089    virtual void   Home();
0090    virtual void   End();
0091            void   Print(Option_t * = "") const override;
0092            void   Delete(Option_t * = "") override;
0093            Bool_t Search(const char *string, Bool_t direction = kTRUE, Bool_t caseSensitive = kFALSE) override;
0094    virtual void   Search(Bool_t close);
0095    virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText,
0096                           Bool_t direction, Bool_t caseSensitive);
0097    virtual Bool_t Goto(Long_t line, Long_t column = 0);
0098    virtual void   SetInsertMode(EInsertMode mode = kInsert); //*SUBMENU*
0099    EInsertMode    GetInsertMode() const { return fInsertMode; }
0100    TGPopupMenu   *GetMenu() const { return fMenu; }
0101    virtual void   EnableMenu(Bool_t on = kTRUE) { fEnableMenu = on; } //*TOGGLE* *GETTER=IsMenuEnabled
0102    virtual Bool_t IsMenuEnabled() const { return fEnableMenu; }
0103    TList         *GetHistory() const { return (TList *)fHistory; }
0104    virtual void   EnableCursorWithoutFocus(Bool_t on = kTRUE) { fEnableCursorWithoutFocus = on; }
0105    virtual Bool_t IsCursorEnabledithoutFocus() const { return fEnableCursorWithoutFocus; }
0106 
0107            void   DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height) override;
0108            void   ScrollCanvas(Int_t newTop, Int_t direction) override;
0109    virtual void   SetFocus() { RequestFocus(); }
0110 
0111    virtual void   SetCurrent(TGLongPosition new_coord);
0112    TGLongPosition GetCurrentPos() const { return fCurrent; }
0113            Long_t ReturnLongestLineWidth() override;
0114 
0115            Bool_t HandleTimer(TTimer *t) override;
0116            Bool_t HandleSelection (Event_t *event) override;
0117            Bool_t HandleButton(Event_t *event) override;
0118            Bool_t HandleKey(Event_t *event) override;
0119            Bool_t HandleMotion(Event_t *event) override;
0120            Bool_t HandleCrossing(Event_t *event) override;
0121            Bool_t HandleFocusChange(Event_t *event) override;
0122            Bool_t HandleDoubleClick(Event_t *event) override;
0123            Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0124 
0125    virtual void   FindAgain() { Emit("FindAgain()"); }  //*SIGNAL*
0126    virtual void   Closed() { Emit("Closed()"); }        //*SIGNAL*
0127    virtual void   Opened() { Emit("Opened()"); }        //*SIGNAL*
0128    virtual void   Saved() { Emit("Saved()"); }          //*SIGNAL*
0129    virtual void   SavedAs() { Emit("SavedAs()"); }      //*SIGNAL*
0130 
0131    void           SavePrimitive(std::ostream &out, Option_t * = "") override;
0132 
0133    ClassDefOverride(TGTextEdit,0)  // Text edit widget
0134 };
0135 
0136 #endif