Logo ROOT   6.12/07
Reference Guide
TGTextEditor.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot 20/06/06
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_TGTextEditor
13 #define ROOT_TGTextEditor
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGTextEditor //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "TGFrame.h"
23 #include "TGTextEdit.h"
24 
25 class TGComboBox;
26 class TGLabel;
27 class TGLayoutHints;
28 class TGMenuBar;
29 class TGPopupMenu;
30 class TGStatusBar;
31 class TGText;
32 class TGTextBuffer;
33 class TGTextEntry;
34 class TGToolBar;
35 class TMacro;
36 class TString;
37 class TTimer;
38 
39 class TGTextEditor : public TGMainFrame {
40 
41 protected:
42 
43  TTimer *fTimer; // for statusbar and toolbar update
44  TGStatusBar *fStatusBar; // for file name, line and col number
45  TGToolBar *fToolBar; // toolbar with common tool buttons
46  TGTextEdit *fTextEdit; // text edit widget
47  TGLabel *fLabel; // "command" label
48  TGComboBox *fComboCmd; // commands combobox
49  TGTextEntry *fCommand; // command text entry widget
50  TGTextBuffer *fCommandBuf; // command text buffer
51  TGLayoutHints *fMenuBarLayout; // used for the menubar
52  TGLayoutHints *fMenuBarItemLayout; // used for for menubar items
53  TGMenuBar *fMenuBar; // editor's menu bar
54  TGPopupMenu *fMenuFile; // "File" menu entry
55  TGPopupMenu *fMenuEdit; // "Edit" menu entry
56  TGPopupMenu *fMenuSearch; // "Search" menu entry
57  TGPopupMenu *fMenuTools; // "Tools" menu entry
58  TGPopupMenu *fMenuHelp; // "Help" menu entry
59  Bool_t fExiting; // true if editor is closing
60  Bool_t fTextChanged; // true if text has changed
61  TString fFilename; // name of the opened file
62  TMacro *fMacro; // pointer on the opened macro
63  virtual void Build();
64 
65 public:
66  TGTextEditor(const char *filename = 0, const TGWindow *p = 0,
67  UInt_t w = 900, UInt_t h = 600);
68  TGTextEditor(TMacro *macro, const TGWindow *p = 0, UInt_t w = 0,
69  UInt_t h = 0);
70  virtual ~TGTextEditor();
71 
72  void ClearText();
73  Bool_t LoadBuffer(const char *buf) { return fTextEdit->LoadBuffer(buf); }
74  void LoadFile(const char *fname = 0);
75  void SaveFile(const char *fname);
77  void PrintText();
78  void Search(Bool_t ret);
79  void Goto();
80  void About();
81  void DataChanged();
82  void DataDropped(char *fname);
83  Int_t IsSaved();
84  void CompileMacro();
85  void ExecuteMacro();
86  void InterruptMacro();
87  void SetText(TGText *text) { fTextEdit->SetText(text); }
88  void AddText(TGText *text) { fTextEdit->AddText(text); }
89  void AddLine(const char *string) { fTextEdit->AddLine(string); }
90  void AddLineFast(const char *string) { fTextEdit->AddLineFast(string); }
91  TGText *GetText() const { return fTextEdit->GetText(); }
92 
93  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
94  virtual Bool_t HandleKey(Event_t *event);
95  virtual Bool_t HandleTimer(TTimer *t);
96  virtual void CloseWindow();
97  virtual void DeleteWindow();
98 
99  ClassDef(TGTextEditor,0) // Simple text editor using TGTextEdit widget
100 };
101 
102 #endif
TGToolBar * fToolBar
Definition: TGTextEditor.h:45
void Search(Bool_t ret)
Invokes search dialog, or just search previous string if again is true.
TGPopupMenu * fMenuFile
Definition: TGTextEditor.h:54
void Goto()
Invokes goto dialog, and go to the specified line.
void CompileMacro()
Save the edited text in a temporary macro, then compile it.
virtual Bool_t LoadBuffer(const char *txtbuf)
Load text from a text buffer. Return false in case of failure.
Definition: TGTextView.cxx:469
void ClearText()
Clear text edit widget.
Definition: TGText.h:67
virtual void CloseWindow()
Close TGTextEditor window.
TTimer * fTimer
Definition: TGTextEditor.h:43
virtual Bool_t HandleTimer(TTimer *t)
Handle timer event.
TH1 * h
Definition: legend2.C:5
TGLabel * fLabel
Definition: TGTextEditor.h:47
virtual Bool_t HandleKey(Event_t *event)
Keyboard event handler.
void AddLine(const char *string)
Definition: TGTextEditor.h:89
virtual void AddLineFast(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:249
void AddText(TGText *text)
Definition: TGTextEditor.h:88
TGTextBuffer * fCommandBuf
Definition: TGTextEditor.h:50
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:31
Basic string class.
Definition: TString.h:125
TGMenuBar * fMenuBar
Definition: TGTextEditor.h:53
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fTextChanged
Definition: TGTextEditor.h:60
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other command generated by the user.
TGText * GetText() const
Definition: TGTextView.h:126
void DataChanged()
Slot setting the fTextChanged flag to true when the text has been modified in fTextEdit.
TGLayoutHints * fMenuBarLayout
Definition: TGTextEditor.h:51
Bool_t LoadBuffer(const char *buf)
Definition: TGTextEditor.h:73
TGPopupMenu * fMenuSearch
Definition: TGTextEditor.h:56
void SetText(TGText *text)
Definition: TGTextEditor.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void AddLine(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:227
void ExecuteMacro()
Save the edited text in a temporary macro, execute it, and then delete the temporary file...
Bool_t fExiting
Definition: TGTextEditor.h:59
void AddLineFast(const char *string)
Definition: TGTextEditor.h:90
void About()
Display ROOT splash screen.
virtual void Build()
Build TGTextEditor widget.
void LoadFile(const char *fname=0)
Load a file into the editor. If fname is 0, a TGFileDialog will popup.
unsigned int UInt_t
Definition: RtypesCore.h:42
TGStatusBar * fStatusBar
Definition: TGTextEditor.h:44
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TMacro * fMacro
Definition: TGTextEditor.h:62
void SaveFile(const char *fname)
Save the edited text in the file "fname".
Bool_t SaveFileAs()
Save the edited text in a file selected with TGFileDialog.
virtual void AddText(TGText *text)
Add text to the view widget.
Definition: TGTextView.cxx:206
TGText * GetText() const
Definition: TGTextEditor.h:91
long Long_t
Definition: RtypesCore.h:50
TGPopupMenu * fMenuTools
Definition: TGTextEditor.h:57
TGTextEntry * fCommand
Definition: TGTextEditor.h:49
TGLayoutHints * fMenuBarItemLayout
Definition: TGTextEditor.h:52
TText * text
TGComboBox * fComboCmd
Definition: TGTextEditor.h:48
TString fFilename
Definition: TGTextEditor.h:61
void PrintText()
Open the print dialog and send current buffer to printer.
virtual void SetText(TGText *text)
Adopt a new text buffer. The text will be deleted by this object.
Definition: TGTextView.cxx:195
TGTextEdit * fTextEdit
Definition: TGTextEditor.h:46
TGTextEditor(const char *filename=0, const TGWindow *p=0, UInt_t w=900, UInt_t h=600)
TGTextEditor constructor with file name as first argument.
Int_t IsSaved()
Check if file has to be saved in case of modifications.
TGPopupMenu * fMenuEdit
Definition: TGTextEditor.h:55
void InterruptMacro()
Interrupt execution of a macro.
virtual void DeleteWindow()
Delete TGTextEditor Window.
virtual ~TGTextEditor()
TGTextEditor destructor.
void DataDropped(char *fname)
Update file information when receiving the signal DataDropped from TGTextEdit widget.
TGPopupMenu * fMenuHelp
Definition: TGTextEditor.h:58