ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TGFrame
23 #include "TGFrame.h"
24 #endif
25 #ifndef ROOT_TGTextEdit
26 #include "TGTextEdit.h"
27 #endif
28 
29 class TGComboBox;
30 class TGLabel;
31 class TGLayoutHints;
32 class TGMenuBar;
33 class TGPopupMenu;
34 class TGStatusBar;
35 class TGText;
36 class TGTextBuffer;
37 class TGTextEntry;
38 class TGToolBar;
39 class TMacro;
40 class TString;
41 class TTimer;
42 
43 class TGTextEditor : public TGMainFrame {
44 
45 protected:
46 
47  TTimer *fTimer; // for statusbar and toolbar update
48  TGStatusBar *fStatusBar; // for file name, line and col number
49  TGToolBar *fToolBar; // toolbar with common tool buttons
50  TGTextEdit *fTextEdit; // text edit widget
51  TGLabel *fLabel; // "command" label
52  TGComboBox *fComboCmd; // commands combobox
53  TGTextEntry *fCommand; // command text entry widget
54  TGTextBuffer *fCommandBuf; // command text buffer
55  TGLayoutHints *fMenuBarLayout; // used for the menubar
56  TGLayoutHints *fMenuBarItemLayout; // used for for menubar items
57  TGMenuBar *fMenuBar; // editor's menu bar
58  TGPopupMenu *fMenuFile; // "File" menu entry
59  TGPopupMenu *fMenuEdit; // "Edit" menu entry
60  TGPopupMenu *fMenuSearch; // "Search" menu entry
61  TGPopupMenu *fMenuTools; // "Tools" menu entry
62  TGPopupMenu *fMenuHelp; // "Help" menu entry
63  Bool_t fExiting; // true if editor is closing
64  Bool_t fTextChanged; // true if text has changed
65  TString fFilename; // name of the opened file
66  TMacro *fMacro; // pointer on the opened macro
67  virtual void Build();
68 
69 public:
70  TGTextEditor(const char *filename = 0, const TGWindow *p = 0,
71  UInt_t w = 900, UInt_t h = 600);
72  TGTextEditor(TMacro *macro, const TGWindow *p = 0, UInt_t w = 0,
73  UInt_t h = 0);
74  virtual ~TGTextEditor();
75 
76  void ClearText();
77  Bool_t LoadBuffer(const char *buf) { return fTextEdit->LoadBuffer(buf); }
78  void LoadFile(const char *fname = 0);
79  void SaveFile(const char *fname);
81  void PrintText();
82  void Search(Bool_t ret);
83  void Goto();
84  void About();
85  void DataChanged();
86  void DataDropped(char *fname);
87  Int_t IsSaved();
88  void CompileMacro();
89  void ExecuteMacro();
90  void InterruptMacro();
91  void SetText(TGText *text) { fTextEdit->SetText(text); }
92  void AddText(TGText *text) { fTextEdit->AddText(text); }
93  void AddLine(const char *string) { fTextEdit->AddLine(string); }
94  void AddLineFast(const char *string) { fTextEdit->AddLineFast(string); }
95  TGText *GetText() const { return fTextEdit->GetText(); }
96 
97  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
98  virtual Bool_t HandleKey(Event_t *event);
99  virtual Bool_t HandleTimer(TTimer *t);
100  virtual void CloseWindow();
101  virtual void DeleteWindow();
102 
103  ClassDef(TGTextEditor,0) // Simple text editor using TGTextEdit widget
104 };
105 
106 #endif
TGToolBar * fToolBar
Definition: TGTextEditor.h:49
void Search(Bool_t ret)
Invokes search dialog, or just search previous string if again is true.
TGPopupMenu * fMenuFile
Definition: TGTextEditor.h:58
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:71
virtual void CloseWindow()
Close TGTextEditor window.
TTimer * fTimer
Definition: TGTextEditor.h:47
virtual Bool_t HandleTimer(TTimer *t)
Handle timer event.
TH1 * h
Definition: legend2.C:5
TGLabel * fLabel
Definition: TGTextEditor.h:51
virtual Bool_t HandleKey(Event_t *event)
Keyboard event handler.
void AddLine(const char *string)
Definition: TGTextEditor.h:93
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:92
static const char * filename()
TGTextBuffer * fCommandBuf
Definition: TGTextEditor.h:54
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:33
Basic string class.
Definition: TString.h:137
TGMenuBar * fMenuBar
Definition: TGTextEditor.h:57
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t fTextChanged
Definition: TGTextEditor.h:64
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:130
void DataChanged()
Slot setting the fTextChanged flag to true when the text has been modified in fTextEdit.
TGLayoutHints * fMenuBarLayout
Definition: TGTextEditor.h:55
Bool_t LoadBuffer(const char *buf)
Definition: TGTextEditor.h:77
TGPopupMenu * fMenuSearch
Definition: TGTextEditor.h:60
void SetText(TGText *text)
Definition: TGTextEditor.h:91
#define ClassDef(name, id)
Definition: Rtypes.h:254
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:63
void AddLineFast(const char *string)
Definition: TGTextEditor.h:94
TThread * t[5]
Definition: threadsh1.C:13
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:48
tuple w
Definition: qtexample.py:51
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
TMacro * fMacro
Definition: TGTextEditor.h:66
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
long Long_t
Definition: RtypesCore.h:50
TGPopupMenu * fMenuTools
Definition: TGTextEditor.h:61
TGTextEntry * fCommand
Definition: TGTextEditor.h:53
TGLayoutHints * fMenuBarItemLayout
Definition: TGTextEditor.h:56
TText * text
TGComboBox * fComboCmd
Definition: TGTextEditor.h:52
TString fFilename
Definition: TGTextEditor.h:65
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:50
TGTextEditor(const char *filename=0, const TGWindow *p=0, UInt_t w=900, UInt_t h=600)
Int_t IsSaved()
Check if file has to be saved in case of modifications.
TGPopupMenu * fMenuEdit
Definition: TGTextEditor.h:59
void InterruptMacro()
Interrupt execution of a macro.
virtual void DeleteWindow()
Delete TGTextEditor Window.
TGText * GetText() const
Definition: TGTextEditor.h:95
virtual ~TGTextEditor()
TGTextEditor destructor.
void DataDropped(char *fname)
Update file information when receiving the signal DataDropped from TGTextEdit widget.
TGPopupMenu * fMenuHelp
Definition: TGTextEditor.h:62