Logo ROOT   6.14/05
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 
28 class TGPopupMenu;
29 class TGSearchType;
30 class TGTextEditHist;
31 
32 class TGTextEdit : public TGTextView {
33 
34 private:
35  TGTextEdit(const TGTextEdit&); // Not implemented
36  TGTextEdit& operator=(const TGTextEdit&); // Not implemented
37 
38 public:
40  enum {
44  };
45 
46 protected:
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 
60  static TGGC *fgCursor0GC;
61  static TGGC *fgCursor1GC;
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 
75 public:
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; }
114  virtual void EnableCursorWithoutFocus(Bool_t on = kTRUE) { fEnableCursorWithoutFocus = on; }
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);
123  virtual Long_t ReturnLongestLineWidth();
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
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:111
virtual void Print(Option_t *="") const
Send current buffer to printer.
Definition: TGTextEdit.cxx:476
virtual ~TGTextEdit()
Cleanup text edit widget.
Definition: TGTextEdit.cxx:271
GContext_t fCursor1GC
Definition: TGTextEdit.h:48
TGLongPosition fCurrent
Definition: TGTextEdit.h:53
virtual void CursorOff()
If cursor if on, turn it off.
Definition: TGTextEdit.cxx:783
static TGGC * fgCursor1GC
Definition: TGTextEdit.h:61
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
Definition: TGText.h:67
void Init()
Initiliaze a text edit widget.
Definition: TGTextEdit.cxx:284
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2551
virtual void LineUp()
Make current position first line in window by scrolling up.
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
EInsertMode fInsertMode
Definition: TGTextEdit.h:54
TGTextEdit & operator=(const TGTextEdit &)
Handle_t GContext_t
Definition: GuiTypes.h:37
EInsertMode GetInsertMode() const
Definition: TGTextEdit.h:109
virtual Long_t ReturnLongestLineWidth()
Return width of longest line in widget.
Definition: TGTextEdit.cxx:365
TList * GetHistory() const
Definition: TGTextEdit.h:113
int Int_t
Definition: RtypesCore.h:41
virtual void AdjustPos()
Adjust current position.
Definition: TGTextEdit.cxx:900
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fEnableMenu
Definition: TGTextEdit.h:55
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:52
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
TGLongPosition GetCurrentPos() const
Definition: TGTextEdit.h:122
TGTextEditHist * fHistory
Definition: TGTextEdit.h:56
Int_t fCursorState
Definition: TGTextEdit.h:49
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:320
ULong_t Pixel_t
Definition: GuiTypes.h:39
virtual void Opened()
Definition: TGTextEdit.h:137
TGTextEdit(const TGTextEdit &)
virtual void EnableCursorWithoutFocus(Bool_t on=kTRUE)
Definition: TGTextEdit.h:114
Bool_t fEnableCursorWithoutFocus
Definition: TGTextEdit.h:57
virtual void CursorOn()
Turn cursor on.
Definition: TGTextEdit.cxx:794
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
virtual void End()
Move to end of line.
TGPopupMenu * fMenu
Definition: TGTextEdit.h:51
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:98
virtual void SetMenuState()
Enable/disable menu items in function of what is possible.
Definition: TGTextEdit.cxx:326
A doubly linked list.
Definition: TList.h:44
virtual void DrawCursor(Int_t mode)
Draw cursor. If mode = 1 draw cursor, if mode = 2 erase cursor.
Definition: TGTextEdit.cxx:823
virtual void NextChar()
Go to next character.
virtual void Home()
Move to beginning of line.
virtual void Saved()
Definition: TGTextEdit.h:138
GContext_t fCursor0GC
Definition: TGTextEdit.h:47
virtual void SavedAs()
Definition: TGTextEdit.h:139
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 void FindAgain()
Definition: TGTextEdit.h:135
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
virtual void DelChar()
Delete a character from the text edit widget.
virtual void Clear(Option_t *="")
Clear text edit widget.
Definition: TGTextEdit.cxx:375
#define h(i)
Definition: RSha256.hxx:106
virtual Bool_t IsMenuEnabled() const
Definition: TGTextEdit.h:112
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void Closed()
Definition: TGTextEdit.h:136
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:119
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.
TGPopupMenu * GetMenu() const
Definition: TGTextEdit.h:110
virtual void LineDown()
Move one line down.
TText * text
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:50
virtual void PrevChar()
Go to the previous character.
static TGGC * fgCursor0GC
Definition: TGTextEdit.h:60
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.
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t Cut()
Cut text.
Definition: TGTextEdit.cxx:441
virtual Bool_t IsCursorEnabledithoutFocus() const
Definition: TGTextEdit.h:115
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.
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
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Definition: TGTextEdit.cxx:387
const Bool_t kTRUE
Definition: RtypesCore.h:87
Definition: TGGC.h:31