Logo ROOT   6.16/01
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-2000, 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//////////////////////////////////////////////////////////////////////////
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// //
24//////////////////////////////////////////////////////////////////////////
25
26#include "TGTextView.h"
27
28class TGPopupMenu;
29class TGSearchType;
30class TGTextEditHist;
31
32class TGTextEdit : public TGTextView {
33
34private:
35 TGTextEdit(const TGTextEdit&); // Not implemented
36 TGTextEdit& operator=(const TGTextEdit&); // Not implemented
37
38public:
40 enum {
44 };
45
46protected:
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)
59
62
63 void Init();
64
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 &)"); }
71
72 static const TGGC &GetCursor0GC();
73 static const TGGC &GetCursor1GC();
74
75public:
76 TGTextEdit(const TGWindow *parent = 0, 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());
82
83 virtual ~TGTextEdit();
84
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; }
116
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(); }
120
121 virtual void SetCurrent(TGLongPosition new_coord);
124
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);
134
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*
140
141 virtual void SavePrimitive(std::ostream &out, Option_t * = "");
142
143 ClassDef(TGTextEdit,0) // Text edit widget
144};
145
146#endif
Handle_t GContext_t
Definition: GuiTypes.h:37
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
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.
virtual Bool_t Goto(Long_t line, Long_t column=0)
Goto the specified line.
Definition: TGTextEdit.cxx:737
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.
Definition: TGTextEdit.cxx:695
virtual void DrawCursor(Int_t mode)
Draw cursor. If mode = 1 draw cursor, if mode = 2 erase cursor.
Definition: TGTextEdit.cxx:823
TGPopupMenu * GetMenu() const
Definition: TGTextEdit.h:110
virtual Bool_t Copy()
Copy text.
Definition: TGTextEdit.cxx:415
TList * GetHistory() const
Definition: TGTextEdit.h:113
virtual void AdjustPos()
Adjust current position.
Definition: TGTextEdit.cxx:900
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Definition: TGTextEdit.cxx:387
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.
Definition: TGTextEdit.cxx:326
virtual Bool_t Cut()
Cut text.
Definition: TGTextEdit.cxx:441
Bool_t fEnableMenu
Definition: TGTextEdit.h:55
TGLongPosition GetCurrentPos() const
Definition: TGTextEdit.h:122
@ kM_SEARCH_GOTO
Definition: TGTextEdit.h:43
@ kM_FILE_SAVEAS
Definition: TGTextEdit.h:41
@ kM_SEARCH_FINDAGAIN
Definition: TGTextEdit.h:43
@ kM_FILE_PRINT
Definition: TGTextEdit.h:42
@ kM_EDIT_SELECTALL
Definition: TGTextEdit.h:42
@ kM_FILE_OPEN
Definition: TGTextEdit.h:41
@ kM_FILE_SAVE
Definition: TGTextEdit.h:41
@ kM_EDIT_COPY
Definition: TGTextEdit.h:42
@ kM_SEARCH_FIND
Definition: TGTextEdit.h:43
@ kM_FILE_CLOSE
Definition: TGTextEdit.h:41
@ kM_EDIT_PASTE
Definition: TGTextEdit.h:42
virtual Long_t ReturnLongestLineWidth()
Return width of longest line in widget.
Definition: TGTextEdit.cxx:365
virtual void Print(Option_t *="") const
Send current buffer to printer.
Definition: TGTextEdit.cxx:476
virtual void DelChar()
Delete a character from the text edit widget.
virtual Bool_t HandleSelection(Event_t *event)
Handle selection notify event.
Definition: TGTextEdit.cxx:945
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.
Definition: TGTextEdit.cxx:375
virtual void ScreenDown()
Move one screen down.
virtual void Delete(Option_t *="")
Delete selection.
Definition: TGTextEdit.cxx:531
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.
Definition: TGTextEdit.cxx:794
virtual Bool_t IsCursorEnabledithoutFocus() const
Definition: TGTextEdit.h:115
virtual void SetCurrent(TGLongPosition new_coord)
Make the specified position the current position.
Definition: TGTextEdit.cxx:807
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.
Definition: TGTextEdit.cxx:271
TGTextEdit(const TGTextEdit &)
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.
Definition: TGTextEdit.cxx:773
virtual void CursorOff()
If cursor if on, turn it off.
Definition: TGTextEdit.cxx:783
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:633
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.
Definition: TGTextEdit.cxx:454
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
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.
Definition: TGTextEdit.cxx:284
static const TGGC & GetCursor0GC()
Return selection graphics context for text cursor.
virtual Bool_t HandleTimer(TTimer *t)
Handle timer cursor blink timer.
Definition: TGTextEdit.cxx:924
TGTextEdit & operator=(const TGTextEdit &)
Definition: TGText.h:67
virtual void RequestFocus()
Definition: TGWindow.h:98
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
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:933
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
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