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#include "TGFrame.h"
17#include "TGTextEdit.h"
18
19class TGComboBox;
20class TGLabel;
21class TGLayoutHints;
22class TGMenuBar;
23class TGPopupMenu;
24class TGStatusBar;
25class TGText;
26class TGTextBuffer;
27class TGTextEntry;
28class TGToolBar;
29class TMacro;
30class TString;
31class TTimer;
32
33class TGTextEditor : public TGMainFrame {
34
35protected:
36
37 TTimer *fTimer; ///< for statusbar and toolbar update
38 TGStatusBar *fStatusBar; ///< for file name, line and col number
39 TGToolBar *fToolBar; ///< toolbar with common tool buttons
40 TGTextEdit *fTextEdit; ///< text edit widget
41 TGLabel *fLabel; ///< "command" label
42 TGComboBox *fComboCmd; ///< commands combobox
43 TGTextEntry *fCommand; ///< command text entry widget
44 TGTextBuffer *fCommandBuf; ///< command text buffer
45 TGLayoutHints *fMenuBarLayout; ///< used for the menubar
46 TGLayoutHints *fMenuBarItemLayout; ///< used for for menubar items
47 TGMenuBar *fMenuBar; ///< editor's menu bar
48 TGPopupMenu *fMenuFile; ///< "File" menu entry
49 TGPopupMenu *fMenuEdit; ///< "Edit" menu entry
50 TGPopupMenu *fMenuSearch; ///< "Search" menu entry
51 TGPopupMenu *fMenuTools; ///< "Tools" menu entry
52 TGPopupMenu *fMenuHelp; ///< "Help" menu entry
53 Bool_t fExiting; ///< true if editor is closing
54 Bool_t fTextChanged; ///< true if text has changed
55 TString fFilename; ///< name of the opened file
56 TMacro *fMacro; ///< pointer on the opened macro
57 virtual void Build();
58
59public:
60 TGTextEditor(const char *filename = nullptr, const TGWindow *p = nullptr,
61 UInt_t w = 900, UInt_t h = 600);
62 TGTextEditor(TMacro *macro, const TGWindow *p = nullptr, UInt_t w = 0,
63 UInt_t h = 0);
64 virtual ~TGTextEditor();
65
66 void ClearText();
67 Bool_t LoadBuffer(const char *buf) { return fTextEdit->LoadBuffer(buf); }
68 void LoadFile(const char *fname = nullptr);
69 void SaveFile(const char *fname);
71 void PrintText();
72 void Search(Bool_t ret);
73 void Goto();
74 void About();
75 void DataChanged();
76 void DataDropped(char *fname);
77 Int_t IsSaved();
78 void CompileMacro();
79 void ExecuteMacro();
80 void InterruptMacro();
83 void AddLine(const char *string) { fTextEdit->AddLine(string); }
84 void AddLineFast(const char *string) { fTextEdit->AddLineFast(string); }
85 TGText *GetText() const { return fTextEdit->GetText(); }
86
87 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
88 Bool_t HandleKey(Event_t *event) override;
89 Bool_t HandleTimer(TTimer *t) override;
90 void CloseWindow() override;
91 void DeleteWindow() override;
92
93 ClassDefOverride(TGTextEditor,0) // Simple text editor using TGTextEdit widget
94};
95
96#endif
#define h(i)
Definition: RSha256.hxx:106
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
long Longptr_t
Definition: RtypesCore.h:82
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char text
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition: TGComboBox.h:47
This class handles GUI labels.
Definition: TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition: TGFrame.h:397
The TGMenu.h header contains all different menu classes.
Definition: TGMenu.h:282
This class creates a popup menu object.
Definition: TGMenu.h:110
Provides a StatusBar widget.
Definition: TGStatusBar.h:21
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Definition: TGTextBuffer.h:17
A TGTextEdit is a specialization of TGTextView.
Definition: TGTextEdit.h:22
A simple text editor that uses the TGTextEdit widget.
Definition: TGTextEditor.h:33
Bool_t LoadBuffer(const char *buf)
Definition: TGTextEditor.h:67
TGStatusBar * fStatusBar
for file name, line and col number
Definition: TGTextEditor.h:38
Bool_t fTextChanged
true if text has changed
Definition: TGTextEditor.h:54
TGPopupMenu * fMenuTools
"Tools" menu entry
Definition: TGTextEditor.h:51
void DataChanged()
Slot setting the fTextChanged flag to true when the text has been modified in fTextEdit.
TString fFilename
name of the opened file
Definition: TGTextEditor.h:55
void InterruptMacro()
Interrupt execution of a macro.
void CloseWindow() override
Close TGTextEditor window.
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
for statusbar and toolbar update
Definition: TGTextEditor.h:37
void SetText(TGText *text)
Definition: TGTextEditor.h:81
TGPopupMenu * fMenuFile
"File" menu entry
Definition: TGTextEditor.h:48
TGLayoutHints * fMenuBarLayout
used for the menubar
Definition: TGTextEditor.h:45
TGTextEntry * fCommand
command text entry widget
Definition: TGTextEditor.h:43
TGText * GetText() const
Definition: TGTextEditor.h:85
TGLabel * fLabel
"command" label
Definition: TGTextEditor.h:41
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.
Bool_t HandleKey(Event_t *event) override
Keyboard event handler.
void ClearText()
Clear text edit widget.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Handle menu and other command generated by the user.
virtual void Build()
Build TGTextEditor widget.
void AddLineFast(const char *string)
Definition: TGTextEditor.h:84
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
pointer on the opened macro
Definition: TGTextEditor.h:56
TGMenuBar * fMenuBar
editor's menu bar
Definition: TGTextEditor.h:47
TGTextEditor(const char *filename=nullptr, const TGWindow *p=nullptr, UInt_t w=900, UInt_t h=600)
TGTextEditor constructor with file name as first argument.
TGTextEdit * fTextEdit
text edit widget
Definition: TGTextEditor.h:40
void PrintText()
Open the print dialog and send current buffer to printer.
void AddLine(const char *string)
Definition: TGTextEditor.h:83
TGLayoutHints * fMenuBarItemLayout
used for for menubar items
Definition: TGTextEditor.h:46
void SaveFile(const char *fname)
Save the edited text in the file "fname".
TGComboBox * fComboCmd
commands combobox
Definition: TGTextEditor.h:42
TGPopupMenu * fMenuEdit
"Edit" menu entry
Definition: TGTextEditor.h:49
TGPopupMenu * fMenuSearch
"Search" menu entry
Definition: TGTextEditor.h:50
virtual ~TGTextEditor()
TGTextEditor destructor.
TGTextBuffer * fCommandBuf
command text buffer
Definition: TGTextEditor.h:44
TGPopupMenu * fMenuHelp
"Help" menu entry
Definition: TGTextEditor.h:52
void DeleteWindow() override
Delete TGTextEditor Window.
void AddText(TGText *text)
Definition: TGTextEditor.h:82
Bool_t HandleTimer(TTimer *t) override
Handle timer event.
void LoadFile(const char *fname=nullptr)
Load a file into the editor. If fname is 0, a TGFileDialog will popup.
TGToolBar * fToolBar
toolbar with common tool buttons
Definition: TGTextEditor.h:39
Bool_t fExiting
true if editor is closing
Definition: TGTextEditor.h:53
A TGTextEntry is a one line text input widget.
Definition: TGTextEntry.h:24
virtual Bool_t LoadBuffer(const char *txtbuf)
Load text from a text buffer. Return false in case of failure.
Definition: TGTextView.cxx:471
virtual void AddLine(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:229
TGText * GetText() const
Definition: TGTextView.h:115
virtual void AddLineFast(const char *string)
Add a line of text to the view widget.
Definition: TGTextView.cxx:251
virtual void SetText(TGText *text)
Adopt a new text buffer. The text will be deleted by this object.
Definition: TGTextView.cxx:197
virtual void AddText(TGText *text)
Add text to the view widget.
Definition: TGTextView.cxx:208
A TGText is a multi line text buffer.
Definition: TGText.h:57
A toolbar is a composite frame that contains TGPictureButtons.
Definition: TGToolBar.h:33
ROOT GUI Window base class.
Definition: TGWindow.h:23
Class supporting a collection of lines with C++ code.
Definition: TMacro.h:31
Basic string class.
Definition: TString.h:136
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
Event structure.
Definition: GuiTypes.h:174