ROOT  6.06/09
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 #ifndef ROOT_TGTextView
27 #include "TGTextView.h"
28 #endif
29 
30 class TGPopupMenu;
31 class TGSearchType;
32 class TGTextEditHist;
33 
34 class TGTextEdit : public TGTextView {
35 
36 private:
37  TGTextEdit(const TGTextEdit&); // Not implemented
38  TGTextEdit& operator=(const TGTextEdit&); // Not implemented
39 
40 public:
42  enum {
46  };
47 
48 protected:
49  GContext_t fCursor0GC; // graphics context for erasing cursor
50  GContext_t fCursor1GC; // graphics context for drawing cursor
51  Int_t fCursorState; // cursor state (1=drawn, 2=erased)
52  TViewTimer *fCurBlink; // cursor blink timer
53  TGPopupMenu *fMenu; // popup menu with editor actions
54  TGSearchType *fSearch; // structure used by search dialog
55  TGLongPosition fCurrent; // current cursor position
56  EInsertMode fInsertMode; // *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",kReplace="&Replace")}*
57  Bool_t fEnableMenu; // enable context menu with editor actions
58  TGTextEditHist *fHistory; // undo manager
59  Bool_t fEnableCursorWithoutFocus; // enable cursor visibility when focus went out from
60  // text editor window (default is kTRUE)
61 
62  static TGGC *fgCursor0GC;
63  static TGGC *fgCursor1GC;
64 
65  void Init();
66 
67  virtual void SetMenuState();
68  virtual void CursorOn();
69  virtual void CursorOff();
70  virtual void DrawCursor(Int_t mode);
71  virtual void AdjustPos();
72  virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
73 
74  static const TGGC &GetCursor0GC();
75  static const TGGC &GetCursor1GC();
76 
77 public:
78  TGTextEdit(const TGWindow *parent = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
79  UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
80  TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
81  Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
82  TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
83  Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
84 
85  virtual ~TGTextEdit();
86 
87  virtual Bool_t SaveFile(const char *fname, Bool_t saveas = kFALSE);
88  virtual void Clear(Option_t * = "");
89  virtual Bool_t Copy();
90  virtual Bool_t Cut();
91  virtual Bool_t Paste();
92  virtual void InsChar(char character);
93  virtual void DelChar();
94  virtual void BreakLine();
95  virtual void PrevChar();
96  virtual void NextChar();
97  virtual void LineUp();
98  virtual void LineDown();
99  virtual void ScreenUp();
100  virtual void ScreenDown();
101  virtual void Home();
102  virtual void End();
103  virtual void Print(Option_t * = "") const;
104  virtual void Delete(Option_t * = "");
105  virtual Bool_t Search(const char *string, Bool_t direction = kTRUE, Bool_t caseSensitive = kFALSE);
106  virtual void Search(Bool_t close);
107  virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText,
108  Bool_t direction, Bool_t caseSensitive);
109  virtual Bool_t Goto(Long_t line, Long_t column = 0);
110  virtual void SetInsertMode(EInsertMode mode = kInsert); //*SUBMENU*
112  TGPopupMenu *GetMenu() const { return fMenu; }
113  virtual void EnableMenu(Bool_t on = kTRUE) { fEnableMenu = on; } //*TOGGLE* *GETTER=IsMenuEnabled
114  virtual Bool_t IsMenuEnabled() const { return fEnableMenu; }
115  TList *GetHistory() const { return (TList *)fHistory; }
116  virtual void EnableCursorWithoutFocus(Bool_t on = kTRUE) { fEnableCursorWithoutFocus = on; }
118 
119  virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
120  virtual void ScrollCanvas(Int_t newTop, Int_t direction);
121  virtual void SetFocus() { RequestFocus(); }
122 
123  virtual void SetCurrent(TGLongPosition new_coord);
125  virtual Long_t ReturnLongestLineWidth();
126 
127  virtual Bool_t HandleTimer(TTimer *t);
128  virtual Bool_t HandleSelection (Event_t *event);
129  virtual Bool_t HandleButton(Event_t *event);
130  virtual Bool_t HandleKey(Event_t *event);
131  virtual Bool_t HandleMotion(Event_t *event);
132  virtual Bool_t HandleCrossing(Event_t *event);
133  virtual Bool_t HandleFocusChange(Event_t *event);
134  virtual Bool_t HandleDoubleClick(Event_t *event);
135  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
136 
137  virtual void FindAgain() { Emit("FindAgain()"); } //*SIGNAL*
138  virtual void Closed() { Emit("Closed()"); } //*SIGNAL*
139  virtual void Opened() { Emit("Opened()"); } //*SIGNAL*
140  virtual void Saved() { Emit("Saved()"); } //*SIGNAL*
141  virtual void SavedAs() { Emit("SavedAs()"); } //*SIGNAL*
142 
143  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
144 
145  ClassDef(TGTextEdit,0) // Text edit widget
146 };
147 
148 #endif
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
static const TGGC & GetCursor1GC()
Return default graphics context for text cursor.
virtual void EnableMenu(Bool_t on=kTRUE)
Definition: TGTextEdit.h:113
virtual ~TGTextEdit()
Cleanup text edit widget.
Definition: TGTextEdit.cxx:271
GContext_t fCursor1GC
Definition: TGTextEdit.h:50
TGLongPosition fCurrent
Definition: TGTextEdit.h:55
virtual void CursorOff()
If cursor if on, turn it off.
Definition: TGTextEdit.cxx:783
static TGGC * fgCursor1GC
Definition: TGTextEdit.h:63
TLine * line
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process context menu messages.
const char Option_t
Definition: RtypesCore.h:62
EInsertMode GetInsertMode() const
Definition: TGTextEdit.h:111
Definition: TGText.h:71
void Init()
Initiliaze a text edit widget.
Definition: TGTextEdit.cxx:284
virtual void LineUp()
Make current position first line in window by scrolling up.
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:971
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
EInsertMode fInsertMode
Definition: TGTextEdit.h:56
TGTextEdit & operator=(const TGTextEdit &)
Handle_t GContext_t
Definition: GuiTypes.h:39
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
int Int_t
Definition: RtypesCore.h:41
virtual void AdjustPos()
Adjust current position.
Definition: TGTextEdit.cxx:900
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Bool_t fEnableMenu
Definition: TGTextEdit.h:57
virtual void Delete(Option_t *="")
Delete selection.
Definition: TGTextEdit.cxx:531
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in text edit widget.
TGSearchType * fSearch
Definition: TGTextEdit.h:54
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 Copy()
Copy text.
Definition: TGTextEdit.cxx:415
TGTextEditHist * fHistory
Definition: TGTextEdit.h:58
Int_t fCursorState
Definition: TGTextEdit.h:51
virtual void ScreenDown()
Move one screen down.
virtual void ScreenUp()
Move one screen up.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
virtual void Opened()
Definition: TGTextEdit.h:139
TGTextEdit(const TGTextEdit &)
virtual void EnableCursorWithoutFocus(Bool_t on=kTRUE)
Definition: TGTextEdit.h:116
Bool_t fEnableCursorWithoutFocus
Definition: TGTextEdit.h:59
virtual void CursorOn()
Turn cursor on.
Definition: TGTextEdit.cxx:794
virtual void End()
Move to end of line.
TGPopupMenu * fMenu
Definition: TGTextEdit.h:53
virtual void SetCurrent(TGLongPosition new_coord)
Make the specified position the current position.
Definition: TGTextEdit.cxx:807
static const TGGC & GetCursor0GC()
Return selection graphics context for text cursor.
virtual void RequestFocus()
Definition: TGWindow.h:100
char * out
Definition: TBase64.cxx:29
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
virtual void SetMenuState()
Enable/disable menu items in function of what is possible.
Definition: TGTextEdit.cxx:326
A doubly linked list.
Definition: TList.h:47
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:112
virtual void NextChar()
Go to next character.
virtual void Home()
Move to beginning of line.
virtual void Saved()
Definition: TGTextEdit.h:140
GContext_t fCursor0GC
Definition: TGTextEdit.h:49
virtual void SavedAs()
Definition: TGTextEdit.h:141
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text edit widget.
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text edit widget.
virtual Bool_t IsMenuEnabled() const
Definition: TGTextEdit.h:114
virtual void FindAgain()
Definition: TGTextEdit.h:137
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
virtual void DelChar()
Delete a character from the text edit widget.
virtual void Clear(Option_t *="")
Clear text edit widget.
Definition: TGTextEdit.cxx:375
virtual void Closed()
Definition: TGTextEdit.h:138
long Long_t
Definition: RtypesCore.h:50
virtual Bool_t HandleSelection(Event_t *event)
Handle selection notify event.
Definition: TGTextEdit.cxx:945
virtual void SetFocus()
Definition: TGTextEdit.h:121
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 InsChar(char character)
Insert a character in the text edit widget.
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
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event.
virtual void LineDown()
Move one line down.
virtual void SetInsertMode(EInsertMode mode=kInsert)
Sets the mode how characters are entered.
Definition: TGTextEdit.cxx:773
virtual Bool_t HandleTimer(TTimer *t)
Handle timer cursor blink timer.
Definition: TGTextEdit.cxx:924
Double_t y[n]
Definition: legend1.C:17
TViewTimer * fCurBlink
Definition: TGTextEdit.h:52
TGLongPosition GetCurrentPos() const
Definition: TGTextEdit.h:124
virtual void PrevChar()
Go to the previous character.
static TGGC * fgCursor0GC
Definition: TGTextEdit.h:62
virtual void Copy(TObject &) const
Copy this to obj.
Definition: TGTextEdit.h:72
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
Mother of all ROOT objects.
Definition: TObject.h:58
virtual Bool_t Cut()
Cut text.
Definition: TGTextEdit.cxx:441
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Redraw the text edit widget.
virtual void BreakLine()
Break a line.
TList * GetHistory() const
Definition: TGTextEdit.h:115
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
virtual Bool_t Paste()
Paste text into widget.
Definition: TGTextEdit.cxx:454
virtual Bool_t Goto(Long_t line, Long_t column=0)
Goto the specified line.
Definition: TGTextEdit.cxx:737
virtual Bool_t IsCursorEnabledithoutFocus() const
Definition: TGTextEdit.h:117
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Definition: TGTextEdit.cxx:387
const Bool_t kTRUE
Definition: Rtypes.h:91
Definition: TGGC.h:35