Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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:
39  enum EInsertMode { kInsert, kReplace };
40  enum {
41  kM_FILE_NEW, kM_FILE_OPEN, kM_FILE_CLOSE, kM_FILE_SAVE, kM_FILE_SAVEAS,
42  kM_FILE_PRINT, kM_EDIT_CUT, kM_EDIT_COPY, kM_EDIT_PASTE, kM_EDIT_SELECTALL,
43  kM_SEARCH_FIND, kM_SEARCH_FINDAGAIN, kM_SEARCH_GOTO
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*
109  EInsertMode GetInsertMode() const { return fInsertMode; }
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; }
115  virtual Bool_t IsCursorEnabledithoutFocus() const { return fEnableCursorWithoutFocus; }
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);
122  TGLongPosition GetCurrentPos() const { return fCurrent; }
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