Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
18class TGPopupMenu;
19class TGSearchType;
20class TGTextEditHist;
21
22class TGTextEdit : public TGTextView {
23
24private:
25 TGTextEdit(const TGTextEdit&) = delete;
26 TGTextEdit& operator=(const TGTextEdit&) = delete;
27
28public:
30 enum {
34 };
35
36protected:
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
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 void Copy(TObject &) const override { MayNotUse("Copy(TObject &)"); }
61
62 static const TGGC &GetCursor0GC();
63 static const TGGC &GetCursor1GC();
64
65public:
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 void Clear(Option_t * = "") override;
77 Bool_t Copy() override;
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 void Print(Option_t * = "") const override;
92 void Delete(Option_t * = "") override;
93 Bool_t Search(const char *string, Bool_t direction = kTRUE, Bool_t caseSensitive = kFALSE) override;
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 void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height) override;
108 void ScrollCanvas(Int_t newTop, Int_t direction) override;
109 virtual void SetFocus() { RequestFocus(); }
110
111 virtual void SetCurrent(TGLongPosition new_coord);
114
115 Bool_t HandleTimer(TTimer *t) override;
117 Bool_t HandleButton(Event_t *event) override;
118 Bool_t HandleKey(Event_t *event) override;
119 Bool_t HandleMotion(Event_t *event) override;
123 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
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 void SavePrimitive(std::ostream &out, Option_t * = "") override;
132
133 ClassDefOverride(TGTextEdit,0) // Text edit widget
134};
135
136#endif
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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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:180
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char text
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
This class creates a popup menu object.
Definition TGMenu.h:110
A TGTextEdit is a specialization of TGTextView.
Definition TGTextEdit.h:22
TGLongPosition fCurrent
current cursor position
Definition TGTextEdit.h:43
TGTextEditHist * fHistory
undo manager
Definition TGTextEdit.h:46
GContext_t fCursor1GC
graphics context for drawing cursor
Definition TGTextEdit.h:38
virtual void Closed()
Definition TGTextEdit.h:126
TGTextEdit(const TGTextEdit &)=delete
virtual Bool_t Goto(Long_t line, Long_t column=0)
Goto the specified line.
static TGGC * fgCursor0GC
Definition TGTextEdit.h:50
static const TGGC & GetCursor1GC()
Return default graphics context for text cursor.
virtual void Saved()
Definition TGTextEdit.h:128
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:100
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in text edit widget.
TList * GetHistory() const
Definition TGTextEdit.h:103
virtual void AdjustPos()
Adjust current position.
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click event.
EInsertMode GetInsertMode() const
Definition TGTextEdit.h:99
void Delete(Option_t *="") override
Delete selection.
void ScrollCanvas(Int_t newTop, Int_t direction) override
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a text edit widget as a C++ statement(s) on output stream out.
virtual void SetMenuState()
Enable/disable menu items in function of what is possible.
virtual Bool_t Cut()
Cut text.
Bool_t fEnableMenu
enable context menu with editor actions
Definition TGTextEdit.h:45
@ kM_SEARCH_FINDAGAIN
Definition TGTextEdit.h:33
@ kM_EDIT_SELECTALL
Definition TGTextEdit.h:32
TGLongPosition GetCurrentPos() const
Definition TGTextEdit.h:112
void Clear(Option_t *="") override
Clear text edit widget.
virtual void DelChar()
Delete a character from the text edit widget.
Bool_t HandleFocusChange(Event_t *event) override
Handle focus change event in text edit widget.
GContext_t fCursor0GC
graphics context for erasing cursor
Definition TGTextEdit.h:37
virtual void SavedAs()
Definition TGTextEdit.h:129
virtual void LineDown()
Move one line down.
virtual void ScreenDown()
Move one screen down.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process context menu messages.
Bool_t Copy() override
Copy text.
void Copy(TObject &) const override
Copy this to obj.
Definition TGTextEdit.h:60
virtual void LineUp()
Make current position first line in window by scrolling up.
EInsertMode fInsertMode
OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",...
Definition TGTextEdit.h:44
virtual void CursorOn()
Turn cursor on.
virtual Bool_t IsCursorEnabledithoutFocus() const
Definition TGTextEdit.h:105
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.
void Print(Option_t *="") const override
Send current buffer to printer.
virtual void FindAgain()
Definition TGTextEdit.h:125
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.
Int_t fCursorState
cursor state (1=drawn, 2=erased)
Definition TGTextEdit.h:39
TGSearchType * fSearch
structure used by search dialog
Definition TGTextEdit.h:42
virtual void Opened()
Definition TGTextEdit.h:127
Bool_t Search(const char *string, Bool_t direction=kTRUE, Bool_t caseSensitive=kFALSE) override
Search for string in the specified direction.
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:104
virtual Bool_t IsMenuEnabled() const
Definition TGTextEdit.h:102
Bool_t HandleKey(Event_t *event) override
The key press event handler converts a key press to some line editor action.
virtual void SetFocus()
Definition TGTextEdit.h:109
void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height) override
Redraw the text edit widget.
TGPopupMenu * fMenu
popup menu with editor actions
Definition TGTextEdit.h:41
Bool_t HandleSelection(Event_t *event) override
Handle selection notify event.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in text edit widget.
Bool_t HandleTimer(TTimer *t) override
Handle timer cursor blink timer.
virtual void EnableMenu(Bool_t on=kTRUE)
Definition TGTextEdit.h:101
Long_t ReturnLongestLineWidth() override
Return width of longest line in widget.
Bool_t fEnableCursorWithoutFocus
enable cursor visibility when focus went out from text editor window (default is kTRUE)
Definition TGTextEdit.h:47
virtual void Home()
Move to beginning of line.
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
static TGGC * fgCursor1GC
Definition TGTextEdit.h:51
TViewTimer * fCurBlink
cursor blink timer
Definition TGTextEdit.h:40
virtual void End()
Move to end of line.
void Init()
Initialize a text edit widget.
static const TGGC & GetCursor0GC()
Return selection graphics context for text cursor.
TGTextEdit & operator=(const TGTextEdit &)=delete
A TGTextView is a text viewer widget.
Definition TGTextView.h:22
A TGText is a multi line text buffer.
Definition TGText.h:57
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:232
A doubly linked list.
Definition TList.h:38
Mother of all ROOT objects.
Definition TObject.h:41
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
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174