Logo ROOT  
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
25class TGComboBox;
26class TGLabel;
27class TGLayoutHints;
28class TGMenuBar;
29class TGPopupMenu;
30class TGStatusBar;
31class TGText;
32class TGTextBuffer;
33class TGTextEntry;
34class TGToolBar;
35class TMacro;
36class TString;
37class TTimer;
38
39class TGTextEditor : public TGMainFrame {
40
41protected:
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
65public:
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();
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
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:43
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
#define ClassDef(name, id)
Definition: Rtypes.h:322
virtual void DeleteWindow()
Delete TGTextEditor Window.
Bool_t LoadBuffer(const char *buf)
Definition: TGTextEditor.h:73
virtual Bool_t HandleKey(Event_t *event)
Keyboard event handler.
TGStatusBar * fStatusBar
Definition: TGTextEditor.h:44
Bool_t fTextChanged
Definition: TGTextEditor.h:60
TGPopupMenu * fMenuTools
Definition: TGTextEditor.h:57
void DataChanged()
Slot setting the fTextChanged flag to true when the text has been modified in fTextEdit.
TString fFilename
Definition: TGTextEditor.h:61
void InterruptMacro()
Interrupt execution of a macro.
Int_t IsSaved()
Check if file has to be saved in case of modifications.
void Search(Bool_t ret)
Invokes search dialog, or just search previous string if again is true.
TTimer * fTimer
Definition: TGTextEditor.h:43
void SetText(TGText *text)
Definition: TGTextEditor.h:87
TGPopupMenu * fMenuFile
Definition: TGTextEditor.h:54
TGLayoutHints * fMenuBarLayout
Definition: TGTextEditor.h:51
TGTextEntry * fCommand
Definition: TGTextEditor.h:49
TGText * GetText() const
Definition: TGTextEditor.h:91
TGLabel * fLabel
Definition: TGTextEditor.h:47
void DataDropped(char *fname)
Update file information when receiving the signal DataDropped from TGTextEdit widget.
void CompileMacro()
Save the edited text in a temporary macro, then compile it.
void ClearText()
Clear text edit widget.
virtual void Build()
Build TGTextEditor widget.
virtual void CloseWindow()
Close TGTextEditor window.
void AddLineFast(const char *string)
Definition: TGTextEditor.h:90
void Goto()
Invokes goto dialog, and go to the specified line.
void About()
Display ROOT splash screen.
void ExecuteMacro()
Save the edited text in a temporary macro, execute it, and then delete the temporary file.
Bool_t SaveFileAs()
Save the edited text in a file selected with TGFileDialog.
TMacro * fMacro
Definition: TGTextEditor.h:62
virtual Bool_t HandleTimer(TTimer *t)
Handle timer event.
TGMenuBar * fMenuBar
Definition: TGTextEditor.h:53
TGTextEdit * fTextEdit
Definition: TGTextEditor.h:46
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other command generated by the user.
void PrintText()
Open the print dialog and send current buffer to printer.
void AddLine(const char *string)
Definition: TGTextEditor.h:89
TGLayoutHints * fMenuBarItemLayout
Definition: TGTextEditor.h:52
void SaveFile(const char *fname)
Save the edited text in the file "fname".
TGComboBox * fComboCmd
Definition: TGTextEditor.h:48
TGPopupMenu * fMenuEdit
Definition: TGTextEditor.h:55
TGPopupMenu * fMenuSearch
Definition: TGTextEditor.h:56
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.
virtual ~TGTextEditor()
TGTextEditor destructor.
TGTextBuffer * fCommandBuf
Definition: TGTextEditor.h:50
TGPopupMenu * fMenuHelp
Definition: TGTextEditor.h:58
void AddText(TGText *text)
Definition: TGTextEditor.h:88
void LoadFile(const char *fname=0)
Load a file into the editor. If fname is 0, a TGFileDialog will popup.
TGToolBar * fToolBar
Definition: TGTextEditor.h:45
Bool_t fExiting
Definition: TGTextEditor.h:59
virtual Bool_t LoadBuffer(const char *txtbuf)
Load text from a text buffer. Return false in case of failure.
Definition: TGTextView.cxx:470
virtual void AddLine(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:228
TGText * GetText() const
Definition: TGTextView.h:126
virtual void AddLineFast(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:250
virtual void SetText(TGText *text)
Adopt a new text buffer. The text will be deleted by this object.
Definition: TGTextView.cxx:196
virtual void AddText(TGText *text)
Add text to the view widget.
Definition: TGTextView.cxx:207
Definition: TGText.h:67
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:31
Basic string class.
Definition: TString.h:131
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TText * text