Logo ROOT  
Reference Guide
TGTextEdit.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 1/7/2000
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGTextEdit
13 #define ROOT_TGTextEdit
14 
15 
16 #include "TGTextView.h"
17 
18 class TGPopupMenu;
19 class TGSearchType;
20 class TGTextEditHist;
21 
22 class TGTextEdit : public TGTextView {
23 
24 private:
25  TGTextEdit(const TGTextEdit&) = delete;
26  TGTextEdit& operator=(const TGTextEdit&) = delete;
27 
28 public:
30  enum {
34  };
35 
36 protected:
37  GContext_t fCursor0GC; ///< graphics context for erasing cursor
38  GContext_t fCursor1GC; ///< graphics context for drawing cursor
39  Int_t fCursorState; ///< cursor state (1=drawn, 2=erased)
40  TViewTimer *fCurBlink; ///< cursor blink timer
41  TGPopupMenu *fMenu; ///< popup menu with editor actions
42  TGSearchType *fSearch; ///< structure used by search dialog
43  TGLongPosition fCurrent; ///< current cursor position
44  EInsertMode fInsertMode; ///< *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",kReplace="&Replace")}*
45  Bool_t fEnableMenu; ///< enable context menu with editor actions
46  TGTextEditHist *fHistory; ///< undo manager
47  Bool_t fEnableCursorWithoutFocus; ///< enable cursor visibility when focus went out from
48  ///< text editor window (default is kTRUE)
49 
50  static TGGC *fgCursor0GC;
51  static TGGC *fgCursor1GC;
52 
53  void Init();
54 
55  virtual void SetMenuState();
56  virtual void CursorOn();
57  virtual void CursorOff();
58  virtual void DrawCursor(Int_t mode);
59  virtual void AdjustPos();
60  virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
61 
62  static const TGGC &GetCursor0GC();
63  static const TGGC &GetCursor1GC();
64 
65 public:
66  TGTextEdit(const TGWindow *parent = nullptr, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
67  UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
68  TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
69  Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
70  TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
71  Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
72 
73  virtual ~TGTextEdit();
74 
75  virtual Bool_t SaveFile(const char *fname, Bool_t saveas = kFALSE);
76  virtual void Clear(Option_t * = "");
77  virtual Bool_t Copy();
78  virtual Bool_t Cut();
79  virtual Bool_t Paste();
80  virtual void InsChar(char character);
81  virtual void DelChar();
82  virtual void BreakLine();
83  virtual void PrevChar();
84  virtual void NextChar();
85  virtual void LineUp();
86  virtual void LineDown();
87  virtual void ScreenUp();
88  virtual void ScreenDown();
89  virtual void Home();
90  virtual void End();
91  virtual void Print(Option_t * = "") const;
92  virtual void Delete(Option_t * = "");
93  virtual Bool_t Search(const char *string, Bool_t direction = kTRUE, Bool_t caseSensitive = kFALSE);
94  virtual void Search(Bool_t close);
95  virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText,
96  Bool_t direction, Bool_t caseSensitive);
97  virtual Bool_t Goto(Long_t line, Long_t column = 0);
98  virtual void SetInsertMode(EInsertMode mode = kInsert); //*SUBMENU*
100  TGPopupMenu *GetMenu() const { return fMenu; }
101  virtual void EnableMenu(Bool_t on = kTRUE) { fEnableMenu = on; } //*TOGGLE* *GETTER=IsMenuEnabled
102  virtual Bool_t IsMenuEnabled() const { return fEnableMenu; }
103  TList *GetHistory() const { return (TList *)fHistory; }
106 
107  virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
108  virtual void ScrollCanvas(Int_t newTop, Int_t direction);
109  virtual void SetFocus() { RequestFocus(); }
110 
111  virtual void SetCurrent(TGLongPosition new_coord);
113  virtual Long_t ReturnLongestLineWidth();
114 
115  virtual Bool_t HandleTimer(TTimer *t);
116  virtual Bool_t HandleSelection (Event_t *event);
117  virtual Bool_t HandleButton(Event_t *event);
118  virtual Bool_t HandleKey(Event_t *event);
119  virtual Bool_t HandleMotion(Event_t *event);
120  virtual Bool_t HandleCrossing(Event_t *event);
121  virtual Bool_t HandleFocusChange(Event_t *event);
122  virtual Bool_t HandleDoubleClick(Event_t *event);
123  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
124 
125  virtual void FindAgain() { Emit("FindAgain()"); } //*SIGNAL*
126  virtual void Closed() { Emit("Closed()"); } //*SIGNAL*
127  virtual void Opened() { Emit("Opened()"); } //*SIGNAL*
128  virtual void Saved() { Emit("Saved()"); } //*SIGNAL*
129  virtual void SavedAs() { Emit("SavedAs()"); } //*SIGNAL*
130 
131  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
132 
133  ClassDef(TGTextEdit,0) // Text edit widget
134 };
135 
136 #endif
TGTextEdit::TGTextEdit
TGTextEdit(const TGTextEdit &)=delete
TGTextEdit::GetCursor0GC
static const TGGC & GetCursor0GC()
Return selection graphics context for text cursor.
Definition: TGTextEdit.cxx:2177
TGTextEdit::fgCursor0GC
static TGGC * fgCursor0GC
Definition: TGTextEdit.h:50
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TGTextEdit::kM_SEARCH_FIND
@ kM_SEARCH_FIND
Definition: TGTextEdit.h:33
TGTextEdit::CursorOff
virtual void CursorOff()
If cursor if on, turn it off.
Definition: TGTextEdit.cxx:784
TViewTimer
Definition: TGTextView.h:145
TGTextEdit::kM_FILE_SAVE
@ kM_FILE_SAVE
Definition: TGTextEdit.h:31
TGTextEdit::DrawCursor
virtual void DrawCursor(Int_t mode)
Draw cursor. If mode = 1 draw cursor, if mode = 2 erase cursor.
Definition: TGTextEdit.cxx:824
TGTextEdit::Init
void Init()
Initialize a text edit widget.
Definition: TGTextEdit.cxx:285
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGTextEdit::EnableMenu
virtual void EnableMenu(Bool_t on=kTRUE)
Definition: TGTextEdit.h:101
TGTextEdit::fEnableCursorWithoutFocus
Bool_t fEnableCursorWithoutFocus
enable cursor visibility when focus went out from text editor window (default is kTRUE)
Definition: TGTextEdit.h:47
TGWindow::RequestFocus
virtual void RequestFocus()
request focus
Definition: TGWindow.cxx:232
TGTextEdit::GetCurrentPos
TGLongPosition GetCurrentPos() const
Definition: TGTextEdit.h:112
TGTextEdit::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
Definition: TGTextEdit.cxx:1498
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGTextEdit::Opened
virtual void Opened()
Definition: TGTextEdit.h:127
TGTextEdit::fCursorState
Int_t fCursorState
cursor state (1=drawn, 2=erased)
Definition: TGTextEdit.h:39
TGTextEdit::LineUp
virtual void LineUp()
Make current position first line in window by scrolling up.
Definition: TGTextEdit.cxx:2044
TGTextEdit::kM_FILE_PRINT
@ kM_FILE_PRINT
Definition: TGTextEdit.h:32
TGTextEdit::kM_EDIT_COPY
@ kM_EDIT_COPY
Definition: TGTextEdit.h:32
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
Int_t
int Int_t
Definition: RtypesCore.h:45
TGTextEdit::SetFocus
virtual void SetFocus()
Definition: TGTextEdit.h:109
TGTextEdit::Print
virtual void Print(Option_t *="") const
Send current buffer to printer.
Definition: TGTextEdit.cxx:477
x
Double_t x[n]
Definition: legend1.C:17
TGTextEdit::IsMenuEnabled
virtual Bool_t IsMenuEnabled() const
Definition: TGTextEdit.h:102
TGTextEdit::Copy
virtual void Copy(TObject &) const
Copy this to obj.
Definition: TGTextEdit.h:60
TGText
A TGText is a multi line text buffer.
Definition: TGText.h:57
TObject::MayNotUse
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition: TObject.cxx:946
TGTextEdit::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text edit widget.
Definition: TGTextEdit.cxx:1032
TGTextEdit::fInsertMode
EInsertMode fInsertMode
OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",...
Definition: TGTextEdit.h:44
TGTextEdit::EnableCursorWithoutFocus
virtual void EnableCursorWithoutFocus(Bool_t on=kTRUE)
Definition: TGTextEdit.h:104
TGTextEdit::GetHistory
TList * GetHistory() const
Definition: TGTextEdit.h:103
TGTextEdit::fCurrent
TGLongPosition fCurrent
current cursor position
Definition: TGTextEdit.h:43
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGTextEdit::HandleSelection
virtual Bool_t HandleSelection(Event_t *event)
Handle selection notify event.
Definition: TGTextEdit.cxx:946
TGTextEdit::kM_EDIT_PASTE
@ kM_EDIT_PASTE
Definition: TGTextEdit.h:32
text
TText * text
Definition: entrylist_figure1.C:10
bool
TGTextEdit::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a text edit widget as a C++ statement(s) on output stream out.
Definition: TGTextEdit.cxx:2201
GContext_t
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
TGTextEdit::LineDown
virtual void LineDown()
Move one line down.
Definition: TGTextEdit.cxx:2078
TGTextEdit::Closed
virtual void Closed()
Definition: TGTextEdit.h:126
TGTextEdit::kM_FILE_CLOSE
@ kM_FILE_CLOSE
Definition: TGTextEdit.h:31
TGTextEdit::CursorOn
virtual void CursorOn()
Turn cursor on.
Definition: TGTextEdit.cxx:795
TGTextEdit::kReplace
@ kReplace
Definition: TGTextEdit.h:29
TTimer
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TGTextEdit
A TGTextEdit is a specialization of TGTextView.
Definition: TGTextEdit.h:22
TGTextEdit::HandleFocusChange
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text edit widget.
Definition: TGTextEdit.cxx:1530
TGTextEdit::InsChar
virtual void InsChar(char character)
Insert a character in the text edit widget.
Definition: TGTextEdit.cxx:1718
TGTextEdit::End
virtual void End()
Move to end of line.
Definition: TGTextEdit.cxx:2163
TGTextEdit::SetCurrent
virtual void SetCurrent(TGLongPosition new_coord)
Make the specified position the current position.
Definition: TGTextEdit.cxx:808
TGTextEdit::Clear
virtual void Clear(Option_t *="")
Clear text edit widget.
Definition: TGTextEdit.cxx:376
TGTextEdit::SaveFile
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Definition: TGTextEdit.cxx:388
h
#define h(i)
Definition: RSha256.hxx:106
TGTextEdit::~TGTextEdit
virtual ~TGTextEdit()
Cleanup text edit widget.
Definition: TGTextEdit.cxx:272
TGGC
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
TGTextEdit::ScreenUp
virtual void ScreenUp()
Move one screen up.
Definition: TGTextEdit.cxx:2111
TGTextEdit::operator=
TGTextEdit & operator=(const TGTextEdit &)=delete
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
TGTextEdit::fHistory
TGTextEditHist * fHistory
undo manager
Definition: TGTextEdit.h:46
TGTextEdit::fCurBlink
TViewTimer * fCurBlink
cursor blink timer
Definition: TGTextEdit.h:40
Long_t
long Long_t
Definition: RtypesCore.h:54
TGTextEdit::Cut
virtual Bool_t Cut()
Cut text.
Definition: TGTextEdit.cxx:442
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGTextEdit::Replace
virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText, Bool_t direction, Bool_t caseSensitive)
Replace text starting at textPos.
Definition: TGTextEdit.cxx:696
TGTextEdit::SetMenuState
virtual void SetMenuState()
Enable/disable menu items in function of what is possible.
Definition: TGTextEdit.cxx:327
y
Double_t y[n]
Definition: legend1.C:17
TGTextEdit::DelChar
virtual void DelChar()
Delete a character from the text edit widget.
Definition: TGTextEdit.cxx:1814
TGTextEdit::ReturnLongestLineWidth
virtual Long_t ReturnLongestLineWidth()
Return width of longest line in widget.
Definition: TGTextEdit.cxx:366
TGTextEdit::kInsert
@ kInsert
Definition: TGTextEdit.h:29
TGTextEdit::kM_SEARCH_GOTO
@ kM_SEARCH_GOTO
Definition: TGTextEdit.h:33
line
TLine * line
Definition: entrylistblock_figure1.C:235
TGTextEdit::ScreenDown
virtual void ScreenDown()
Move one screen down.
Definition: TGTextEdit.cxx:2131
TGTextEdit::GetCursor1GC
static const TGGC & GetCursor1GC()
Return default graphics context for text cursor.
Definition: TGTextEdit.cxx:2189
TGTextEdit::Home
virtual void Home()
Move to beginning of line.
Definition: TGTextEdit.cxx:2151
TGTextEdit::HandleTimer
virtual Bool_t HandleTimer(TTimer *t)
Handle timer cursor blink timer.
Definition: TGTextEdit.cxx:925
TGLongPosition
Definition: TGDimension.h:54
TGTextEdit::Delete
virtual void Delete(Option_t *="")
Delete selection.
Definition: TGTextEdit.cxx:532
ROOT::Math::detail::close
@ close
Definition: GenVectorIO.h:35
TGTextView.h
TGTextEdit::Saved
virtual void Saved()
Definition: TGTextEdit.h:128
TGTextEdit::EInsertMode
EInsertMode
Definition: TGTextEdit.h:29
TGTextEdit::kM_FILE_NEW
@ kM_FILE_NEW
Definition: TGTextEdit.h:31
TGTextEdit::Goto
virtual Bool_t Goto(Long_t line, Long_t column=0)
Goto the specified line.
Definition: TGTextEdit.cxx:738
TGTextEdit::ScrollCanvas
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
Definition: TGTextEdit.cxx:1938
TGTextEdit::fSearch
TGSearchType * fSearch
structure used by search dialog
Definition: TGTextEdit.h:42
TGTextEdit::kM_EDIT_SELECTALL
@ kM_EDIT_SELECTALL
Definition: TGTextEdit.h:32
TGTextEdit::FindAgain
virtual void FindAgain()
Definition: TGTextEdit.h:125
TGTextEdit::IsCursorEnabledithoutFocus
virtual Bool_t IsCursorEnabledithoutFocus() const
Definition: TGTextEdit.h:105
TGTextEdit::NextChar
virtual void NextChar()
Go to next character.
Definition: TGTextEdit.cxx:2007
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGTextEdit::kM_FILE_OPEN
@ kM_FILE_OPEN
Definition: TGTextEdit.h:31
TGTextView
A TGTextView is a text viewer widget.
Definition: TGTextView.h:22
TGTextEdit::DrawRegion
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Redraw the text edit widget.
Definition: TGTextEdit.cxx:1950
TGPopupMenu
This class creates a popup menu object.
Definition: TGMenu.h:110
Event_t
Event structure.
Definition: GuiTypes.h:174
TGTextEdit::SavedAs
virtual void SavedAs()
Definition: TGTextEdit.h:129
TGTextEdit::kM_FILE_SAVEAS
@ kM_FILE_SAVEAS
Definition: TGTextEdit.h:31
TGFrame::GetWhitePixel
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:709
TGTextEdit::PrevChar
virtual void PrevChar()
Go to the previous character.
Definition: TGTextEdit.cxx:1962
TGTextEdit::fgCursor1GC
static TGGC * fgCursor1GC
Definition: TGTextEdit.h:51
TGTextEdit::kM_SEARCH_FINDAGAIN
@ kM_SEARCH_FINDAGAIN
Definition: TGTextEdit.h:33
TGTextEdit::HandleDoubleClick
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event.
Definition: TGTextEdit.cxx:1091
TGTextEdit::Copy
virtual Bool_t Copy()
Copy text.
Definition: TGTextEdit.cxx:416
TGTextEdit::GetMenu
TGPopupMenu * GetMenu() const
Definition: TGTextEdit.h:100
TGTextEdit::AdjustPos
virtual void AdjustPos()
Adjust current position.
Definition: TGTextEdit.cxx:901
TGTextEdit::GetInsertMode
EInsertMode GetInsertMode() const
Definition: TGTextEdit.h:99
TGTextEdit::BreakLine
virtual void BreakLine()
Break a line.
Definition: TGTextEdit.cxx:1900
TGTextEdit::ProcessMessage
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process context menu messages.
Definition: TGTextEdit.cxx:1586
TGTextEdit::Search
virtual Bool_t Search(const char *string, Bool_t direction=kTRUE, Bool_t caseSensitive=kFALSE)
Search for string in the specified direction.
Definition: TGTextEdit.cxx:634
TGTextEdit::fCursor0GC
GContext_t fCursor0GC
graphics context for erasing cursor
Definition: TGTextEdit.h:37
TGTextEdit::kM_EDIT_CUT
@ kM_EDIT_CUT
Definition: TGTextEdit.h:32
TGTextEdit::fCursor1GC
GContext_t fCursor1GC
graphics context for drawing cursor
Definition: TGTextEdit.h:38
TGTextEdit::Paste
virtual Bool_t Paste()
Paste text into widget.
Definition: TGTextEdit.cxx:455
TGTextEdit::fEnableMenu
Bool_t fEnableMenu
enable context menu with editor actions
Definition: TGTextEdit.h:45
TGTextEdit::HandleKey
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
Definition: TGTextEdit.cxx:1262
TGTextEdit::fMenu
TGPopupMenu * fMenu
popup menu with editor actions
Definition: TGTextEdit.h:41
TList
A doubly linked list.
Definition: TList.h:44
TQObject::Emit
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
TGSearchType
Definition: TGTextEditDialogs.h:19
TGTextEdit::HandleMotion
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in text edit widget.
Definition: TGTextEdit.cxx:1222
int
TGTextEdit::SetInsertMode
virtual void SetInsertMode(EInsertMode mode=kInsert)
Sets the mode how characters are entered.
Definition: TGTextEdit.cxx:774