Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files 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 #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);
76  Bool_t SaveFileAs();
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