Logo ROOT  
Reference Guide
No Matches
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 1/7/2000
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 *************************************************************************/
12#ifndef ROOT_TGTextEdit
13#define ROOT_TGTextEdit
17// //
18// TGTextEdit //
19// //
20// A TGTextEdit is a specialization of TGTextView. It provides the //
21// text edit functionality to the static text viewing widget. //
22// For the messages supported by this widget see the TGView class. //
23// //
26#include "TGTextView.h"
28class TGPopupMenu;
29class TGSearchType;
30class TGTextEditHist;
32class TGTextEdit : public TGTextView {
35 TGTextEdit(const TGTextEdit&) = delete;
36 TGTextEdit& operator=(const TGTextEdit&) = delete;
40 enum {
44 };
47 GContext_t fCursor0GC; // graphics context for erasing cursor
48 GContext_t fCursor1GC; // graphics context for drawing cursor
49 Int_t fCursorState; // cursor state (1=drawn, 2=erased)
50 TViewTimer *fCurBlink; // cursor blink timer
51 TGPopupMenu *fMenu; // popup menu with editor actions
52 TGSearchType *fSearch; // structure used by search dialog
53 TGLongPosition fCurrent; // current cursor position
54 EInsertMode fInsertMode; // *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",kReplace="&Replace")}*
55 Bool_t fEnableMenu; // enable context menu with editor actions
56 TGTextEditHist *fHistory; // undo manager
57 Bool_t fEnableCursorWithoutFocus; // enable cursor visibility when focus went out from
58 // text editor window (default is kTRUE)
63 void Init();
65 virtual void SetMenuState();
66 virtual void CursorOn();
67 virtual void CursorOff();
68 virtual void DrawCursor(Int_t mode);
69 virtual void AdjustPos();
70 virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
72 static const TGGC &GetCursor0GC();
73 static const TGGC &GetCursor1GC();
76 TGTextEdit(const TGWindow *parent = nullptr, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
77 UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
78 TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
79 Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
80 TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
81 Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
83 virtual ~TGTextEdit();
85 virtual Bool_t SaveFile(const char *fname, Bool_t saveas = kFALSE);
86 virtual void Clear(Option_t * = "");
87 virtual Bool_t Copy();
88 virtual Bool_t Cut();
89 virtual Bool_t Paste();
90 virtual void InsChar(char character);
91 virtual void DelChar();
92 virtual void BreakLine();
93 virtual void PrevChar();
94 virtual void NextChar();
95 virtual void LineUp();
96 virtual void LineDown();
97 virtual void ScreenUp();
98 virtual void ScreenDown();
99 virtual void Home();
100 virtual void End();
101 virtual void Print(Option_t * = "") const;
102 virtual void Delete(Option_t * = "");
103 virtual Bool_t Search(const char *string, Bool_t direction = kTRUE, Bool_t caseSensitive = kFALSE);
104 virtual void Search(Bool_t close);
105 virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText,
106 Bool_t direction, Bool_t caseSensitive);
107 virtual Bool_t Goto(Long_t line, Long_t column = 0);
108 virtual void SetInsertMode(EInsertMode mode = kInsert); //*SUBMENU*
110 TGPopupMenu *GetMenu() const { return fMenu; }
111 virtual void EnableMenu(Bool_t on = kTRUE) { fEnableMenu = on; } //*TOGGLE* *GETTER=IsMenuEnabled
112 virtual Bool_t IsMenuEnabled() const { return fEnableMenu; }
113 TList *GetHistory() const { return (TList *)fHistory; }
117 virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
118 virtual void ScrollCanvas(Int_t newTop, Int_t direction);
119 virtual void SetFocus() { RequestFocus(); }
121 virtual void SetCurrent(TGLongPosition new_coord);
125 virtual Bool_t HandleTimer(TTimer *t);
126 virtual Bool_t HandleSelection (Event_t *event);
127 virtual Bool_t HandleButton(Event_t *event);
128 virtual Bool_t HandleKey(Event_t *event);
129 virtual Bool_t HandleMotion(Event_t *event);
130 virtual Bool_t HandleCrossing(Event_t *event);
131 virtual Bool_t HandleFocusChange(Event_t *event);
132 virtual Bool_t HandleDoubleClick(Event_t *event);
133 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
135 virtual void FindAgain() { Emit("FindAgain()"); } //*SIGNAL*
136 virtual void Closed() { Emit("Closed()"); } //*SIGNAL*
137 virtual void Opened() { Emit("Opened()"); } //*SIGNAL*
138 virtual void Saved() { Emit("Saved()"); } //*SIGNAL*
139 virtual void SavedAs() { Emit("SavedAs()"); } //*SIGNAL*
141 virtual void SavePrimitive(std::ostream &out, Option_t * = "");
143 ClassDef(TGTextEdit,0) // Text edit widget
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kFALSE
Definition RtypesCore.h:92
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
include TDocParser_001 C image html pict1_TDocParser_001 png width
void MayNotUse(const char *method)
This function can be used in classes that should override a certain function, but in the inherited cl...
Definition TError.cxx:170
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
Definition TGGC.h:31
TGLongPosition fCurrent
Definition TGTextEdit.h:53
TGTextEditHist * fHistory
Definition TGTextEdit.h:56
GContext_t fCursor1GC
Definition TGTextEdit.h:48
virtual void Closed()
Definition TGTextEdit.h:136
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text edit widget.
TGTextEdit(const TGTextEdit &)=delete
virtual Bool_t Goto(Long_t line, Long_t column=0)
Goto the specified line.
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event.
static TGGC * fgCursor0GC
Definition TGTextEdit.h:60
static const TGGC & GetCursor1GC()
Return default graphics context for text cursor.
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process context menu messages.
virtual void Saved()
Definition TGTextEdit.h:138
virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText, Bool_t direction, Bool_t caseSensitive)
Replace text starting at textPos.
virtual void DrawCursor(Int_t mode)
Draw cursor. If mode = 1 draw cursor, if mode = 2 erase cursor.
TGPopupMenu * GetMenu() const
Definition TGTextEdit.h:110
virtual Bool_t Copy()
Copy text.
TList * GetHistory() const
Definition TGTextEdit.h:113
virtual void AdjustPos()
Adjust current position.
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
EInsertMode GetInsertMode() const
Definition TGTextEdit.h:109
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Redraw the text edit widget.
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
virtual void SetMenuState()
Enable/disable menu items in function of what is possible.
virtual Bool_t Cut()
Cut text.
Bool_t fEnableMenu
Definition TGTextEdit.h:55
TGLongPosition GetCurrentPos() const
Definition TGTextEdit.h:122
virtual Long_t ReturnLongestLineWidth()
Return width of longest line in widget.
virtual void Print(Option_t *="") const
Send current buffer to printer.
virtual void DelChar()
Delete a character from the text edit widget.
virtual Bool_t HandleSelection(Event_t *event)
Handle selection notify event.
GContext_t fCursor0GC
Definition TGTextEdit.h:47
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
virtual void SavedAs()
Definition TGTextEdit.h:139
virtual void LineDown()
Move one line down.
virtual void Clear(Option_t *="")
Clear text edit widget.
virtual void ScreenDown()
Move one screen down.
virtual void Delete(Option_t *="")
Delete selection.
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a text edit widget as a C++ statement(s) on output stream out.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in text edit widget.
virtual void LineUp()
Make current position first line in window by scrolling up.
EInsertMode fInsertMode
Definition TGTextEdit.h:54
virtual void CursorOn()
Turn cursor on.
virtual Bool_t IsCursorEnabledithoutFocus() const
Definition TGTextEdit.h:115
virtual void SetCurrent(TGLongPosition new_coord)
Make the specified position the current position.
virtual void NextChar()
Go to next character.
virtual void ScreenUp()
Move one screen up.
virtual void BreakLine()
Break a line.
virtual ~TGTextEdit()
Cleanup text edit widget.
virtual void FindAgain()
Definition TGTextEdit.h:135
virtual void InsChar(char character)
Insert a character in the text edit widget.
virtual void SetInsertMode(EInsertMode mode=kInsert)
Sets the mode how characters are entered.
virtual void CursorOff()
If cursor if on, turn it off.
virtual Bool_t Search(const char *string, Bool_t direction=kTRUE, Bool_t caseSensitive=kFALSE)
Search for string in the specified direction.
Int_t fCursorState
Definition TGTextEdit.h:49
TGSearchType * fSearch
Definition TGTextEdit.h:52
virtual void Opened()
Definition TGTextEdit.h:137
virtual void PrevChar()
Go to the previous character.
virtual Bool_t Paste()
Paste text into widget.
virtual void EnableCursorWithoutFocus(Bool_t on=kTRUE)
Definition TGTextEdit.h:114
virtual Bool_t IsMenuEnabled() const
Definition TGTextEdit.h:112
virtual void SetFocus()
Definition TGTextEdit.h:119
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text edit widget.
TGPopupMenu * fMenu
Definition TGTextEdit.h:51
Definition TGTextEdit.h:43
Definition TGTextEdit.h:42
virtual void Copy(TObject &) const
Copy this to obj.
Definition TGTextEdit.h:70
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
virtual void EnableMenu(Bool_t on=kTRUE)
Definition TGTextEdit.h:111
Bool_t fEnableCursorWithoutFocus
Definition TGTextEdit.h:57
virtual void Home()
Move to beginning of line.
static TGGC * fgCursor1GC
Definition TGTextEdit.h:61
TViewTimer * fCurBlink
Definition TGTextEdit.h:50
virtual void End()
Move to end of line.
void Init()
Initiliaze a text edit widget.
static const TGGC & GetCursor0GC()
Return selection graphics context for text cursor.
virtual Bool_t HandleTimer(TTimer *t)
Handle timer cursor blink timer.
TGTextEdit & operator=(const TGTextEdit &)=delete
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:231
A doubly linked list.
Definition TList.h:44
Mother of all ROOT objects.
Definition TObject.h:37
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
TText * text
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174