source: tags/Mars-V0.9.1/mbase/MStatusDisplay.h

Last change on this file was 6938, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.0 KB
Line 
1#ifndef MARS_MStatusDisplay
2#define MARS_MStatusDisplay
3
4#ifndef MARS_MAGIC
5#include "MAGIC.h"
6#endif
7
8#ifndef ROOT_TGFrame
9#include <TGFrame.h>
10#endif
11
12#ifndef ROOT_TTimer
13#include <TTimer.h>
14#endif
15
16#ifndef ROOT_TImage
17#include <TImage.h>
18#endif
19
20class MLog;
21class MGList;
22class MParContainer;
23
24class TPad;
25class TTimer;
26class TMutex;
27class TCanvas;
28
29class TGTab;
30class TGTextView;
31class TGStatusBar;
32class TGProgressBar;
33class TGHProgressBar;
34class TGCompositeFrame;
35class TRootEmbeddedCanvas;
36
37class MStatusDisplay : public TGMainFrame
38{
39 friend class MStatusArray;
40public:
41 typedef enum {
42 // kFile
43 kFileBrowser, kFileCanvas, kFileOpen, kFileSave, kFileSaveAs, kFileSaveAsPS,
44 kFileSaveAsRoot, kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG,
45 kFileSaveAsXPM, kFileSaveAsC, kFilePrint, kFilePrinterName,
46 kFileClose, kFileExit, kFileReset,
47 // kLoop
48 kLoopNone, kLoopStop,
49 // kTab
50 kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsPNG,
51 kTabSaveAsGIF, kTabSaveAsJPG, kTabSaveAsXPM, kTabSaveAsC,
52 kTabPrint, kTabNext, kTabPrevious, kTabRemove,
53 // kSize
54 kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
55 kSize1280, kSize1400, kSize1600,
56 // kLog
57 kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
58 // kPic
59 kPicMagic, kPicMars,
60 // kGui
61 kSearch, kTabs
62 } Status_t;
63
64 enum
65 {
66 // TGMainFrame::kDontCallClose = BIT(14)
67 kExitLoopOnExit = BIT(15),
68 kExitLoopOnClose = BIT(16)
69 };
70
71protected:
72 TString fName; // status display identifier (name) (gROOT->FindObject())
73 TString fTitle; // status display title
74
75 MLog *fLog;
76 MGList *fList;
77 TGCompositeFrame *fUserFrame;
78
79 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
80
81private:
82 TGHProgressBar *fBar;
83 TGTab *fTab;
84 TGLayoutHints *fLayCanvas;
85
86 TTimer fTimer;
87 TMutex *fMutex;
88
89 TGStatusBar *fStatusBar;
90
91 Status_t fStatus;
92
93 TString fPrinter;
94
95 Int_t fLogIdx;
96 TTimer fLogTimer;
97 TGTextView *fLogBox;
98
99 FontStruct_t fFont;
100
101 UInt_t fIsLocked;
102
103 TList *fBatch; //!
104
105 void AddMenuBar();
106 void AddUserFrame();
107 void AddTabs();
108 void AddProgressBar();
109 void AddStatusBar();
110 void AddMarsTab();
111 void AddLogTab();
112
113 TCanvas *GetCanvas(TGCompositeFrame *f) const;
114
115 Bool_t ProcessMessageCommandMenu(Long_t mp1);
116 Bool_t ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2);
117 Bool_t ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2);
118 Bool_t ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2);
119 Bool_t Close();
120 void CloseWindow();
121 Bool_t HandleConfigureNotify(Event_t *);
122 Bool_t HandleEvent(Event_t *event);
123
124 Bool_t HandleTimer(TTimer *timer=NULL);
125 void UpdateTab(TGCompositeFrame *f);
126 void UpdateMemory() const;
127
128 void DrawClonePad(TCanvas &newc, TCanvas &oldc) const;
129 void CanvasSetFillColor(TPad &c, Int_t col) const;
130 Bool_t Display(const TObjArray &list, const char *tab=0);
131
132 const TString &AddExtension(TString &name, const TString &ext, Int_t num) const;
133
134 void UpdatePSHeader(const TString &name) const;
135
136 void RemoveTab(int i);
137 void SetStatusLine(const char *txt, Int_t idx);
138
139 TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
140
141 Bool_t SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type);
142
143public:
144 MStatusDisplay(Long_t t=1000);
145 virtual ~MStatusDisplay();
146
147 void SetLogStream(MLog *log, Bool_t enable=kFALSE);
148
149 void StartUpdate(Int_t millisec=-1);
150 void StopUpdate();
151 void SetUpdateTime(Long_t t);
152
153 void SetProgressBarPosition(Float_t p);
154 TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
155
156 void SetStatusLine1(const char *txt) { SetStatusLine(txt, 0); }
157 void SetStatusLine2(const char *txt) { SetStatusLine(txt, 1); }
158 void SetStatusLine2(const MParContainer &cont);
159
160 void SetPrinter(const TString &lpr) { fPrinter = lpr; }
161
162 virtual void SetName(const char *name) { fName = name; }
163 virtual void SetTitle(const char *title="") { fTitle = title; }
164 virtual const char *GetName() const { return fName.Data(); }
165 virtual const char *GetTitle() const { return fTitle.Data(); }
166
167 TCanvas &AddTab(const char *name);
168 TGCompositeFrame *AddRawTab(const char *name);
169
170 Bool_t HasCanvas(const TCanvas *c) const;
171 TCanvas *GetCanvas(int i) const;
172 TCanvas *GetCanvas(const TString &name) const;
173 TVirtualPad *GetFullPad(const Int_t canvas, const Int_t pad);
174
175 Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const;
176
177 Int_t Read(const char *name, const char *tab);
178 Int_t Read(const char *name="MStatusDisplay")
179 {
180 return Read(name, 0);
181 }
182 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
183 {
184 return Write(-1, name, option, bufsize);
185 }
186 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const
187 {
188 return Write(-1, name, option, bufsize);
189 }
190
191 Bool_t CdCanvas(const TString &name);
192 void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
193
194 void SetNoContextMenu(Bool_t flag=kTRUE);
195
196 Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsPS(-1, name, addon); }
197 Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); }
198 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
199 Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); }
200 Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); }
201 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
202 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
203 Int_t PrintToLpr() { return PrintToLpr(-1); }
204
205 Int_t SaveAsPS(Int_t num, TString name="", const TString addon="");
206 Bool_t SaveAsPNG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kPng); }
207 Bool_t SaveAsGIF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kGif); }
208 Bool_t SaveAsXPM(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXpm); }
209 Bool_t SaveAsJPG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kJpeg); }
210 Bool_t SaveAsC(Int_t num, TString name="");
211 Int_t SaveAsRoot(Int_t num, TString name="");
212 Int_t PrintToLpr(Int_t num);
213
214 Int_t SaveAs(Int_t num=-1);
215 Int_t Open(TString fname, const char *name="MStatusDisplay");
216 Int_t Open();
217
218 Status_t CheckStatus() const { return fStatus; }
219 void ClearStatus() { fStatus = kLoopNone; }
220
221 void Lock() { fIsLocked++; }
222 void UnLock() { if (fIsLocked>0) fIsLocked--; }
223
224 void Reset();
225
226 Bool_t CheckTabForCanvas(int num) const;
227
228 void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
229
230 ClassDef(MStatusDisplay, 0) // Window for a status display
231};
232
233#endif
Note: See TracBrowser for help on using the repository browser.