source: trunk/MagicSoft/Mars/mbase/MStatusDisplay.h@ 8675

Last change on this file since 8675 was 8642, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 9.6 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;
28class TVirtualPS;
29
30class TGTab;
31class TGTextView;
32class TGStatusBar;
33class TGTabElement;
34class TGProgressBar;
35class TGHProgressBar;
36class TGCompositeFrame;
37class TRootEmbeddedCanvas;
38
39class MStatusDisplay : public TGMainFrame
40{
41 friend class MStatusArray;
42public:
43 typedef enum {
44 // kFile
45 kFileBrowser, kFileCanvas, kFileTab, kFileOpen, kFileSave, kFileSaveAs,
46 kFileSaveAsPS, kFileSaveAsPDF, kFileSaveAsSVG, kFileSaveAsRoot,
47 kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG, kFileSaveAsXPM,
48 kFileSaveAsBMP, /*kFileSaveAsXCF, kFileSaveAsTIFF,*/
49 kFileSaveAsXML, kFileSaveAsC, kFilePrint, kFilePrinterName,
50 kFileClose, kFileExit, kFileReset,
51 // kLoop
52 kLoopNone, kLoopStop,
53 // kTab
54 kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsPDF, kTabSaveAsSVG,
55 kTabSaveAsRoot, kTabSaveAsPNG, kTabSaveAsGIF, kTabSaveAsJPG,
56 kTabSaveAsXPM, kTabSaveAsBMP, /*kTabSaveAsXCF, kTabSaveAsTIFF,*/
57 kTabSaveAsXML, kTabSaveAsC,
58 kTabPrint, kTabNext, kTabPrevious, kTabRemove,
59 // kSize
60 kSize640, kSize768, kSize800, kSize960, kSize1024, kSize1152,
61 kSize1280, kSize1400, kSize1600, kSizeOptimum,
62 // kLog
63 kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
64 kLogPrint,
65 // kPic
66 kPicMagic, kPicMars,
67 // kGui
68 kSearch, kTabs,
69 // kLastElement
70 kLastElement
71 } Status_t;
72
73 enum
74 {
75 // TGMainFrame::kDontCallClose = BIT(14)
76 kExitLoopOnExit = BIT(15),
77 kExitLoopOnClose = BIT(16)
78 };
79
80protected:
81 TString fName; // status display identifier (name) (gROOT->FindObject())
82 TString fTitle; // status display title
83
84 MLog *fLog;
85 MGList *fList;
86 TGCompositeFrame *fUserFrame;
87
88 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
89
90private:
91 TGHProgressBar *fBar;
92 TGTab *fTab;
93 TGLayoutHints *fLayCanvas;
94
95 TTimer fTimer;
96 TMutex *fMutex;
97
98 TGStatusBar *fStatusBar;
99
100 Status_t fStatus;
101
102 Int_t fLogIdx;
103 TTimer fLogTimer;
104 TGTextView *fLogBox;
105
106 FontStruct_t fFont;
107
108 UInt_t fIsLocked;
109
110 TList *fBatch; //!
111
112 void AddMenuBar();
113 void AddUserFrame();
114 void AddTabs();
115 void AddProgressBar();
116 void AddStatusBar();
117 void AddMarsTab();
118 void AddLogTab();
119
120 TCanvas *GetCanvas(TGCompositeFrame *f) const;
121
122 Bool_t ProcessMessageCommandMenu(Long_t mp1);
123 Bool_t ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2);
124 Bool_t ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2);
125 Bool_t ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2);
126 Bool_t Close();
127 void CloseWindow();
128 Bool_t HandleConfigureNotify(Event_t *);
129 Bool_t HandleEvent(Event_t *event);
130
131 TGCompositeFrame *GetTabContainer(const char *name) const;
132 TGTabElement *GetTabTab(const char *name) const;
133
134 Bool_t HandleTimer(TTimer *timer=NULL);
135 void UpdateTab(TGCompositeFrame *f);
136 void UpdateMemory() const;
137
138 void DrawClonePad(TCanvas &newc, TCanvas &oldc) const;
139 void CanvasSetFillColor(TPad &c, Int_t col) const;
140 Bool_t Display(const TObjArray &list, const char *tab=0);
141
142 const TString &AddExtension(TString &name, const TString &ext, Int_t num=-1) const;
143
144 void UpdatePSHeader(const TString &name) const;
145
146 void RemoveTab(int i);
147 void SetStatusLine(const char *txt, Int_t idx);
148
149 TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
150
151 Bool_t SaveAsImage(Int_t num, TString name, TImage::EImageFileTypes type);
152 Int_t SaveAsVGF(Int_t num, TString name, const TString addon, const TString ext);
153
154 void PSToolsRange(TVirtualPS &vps, Float_t w, Float_t h) const;
155 void PSToolsTextNDC(TVirtualPS &vps, Double_t u, Double_t v, const char *string) const;
156 TString PrintDialog(TString &p, TString &c, TString &t, const char *ext=0);
157
158 void GetCanvasRange(Int_t &from, Int_t &to, Int_t num=-1) const;
159
160public:
161 MStatusDisplay(Int_t w=-1, Int_t h=-1, Long_t t=1000);
162 virtual ~MStatusDisplay();
163
164 void SetLogStream(MLog *log, Bool_t enable=kFALSE);
165
166 void StartUpdate(Int_t millisec=-1);
167 void StopUpdate();
168 void SetUpdateTime(Long_t t);
169
170 void SetProgressBarPosition(Float_t p);
171 TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
172
173 void SetStatusLine1(const char *txt) { SetStatusLine(txt, 0); }
174 void SetStatusLine2(const char *txt) { SetStatusLine(txt, 1); }
175 void SetStatusLine2(const MParContainer &cont);
176
177 virtual void SetName(const char *name) { fName = name; }
178 virtual void SetTitle(const char *title="") { fTitle = title; }
179 virtual const char *GetName() const { return fName.Data(); }
180 virtual const char *GetTitle() const { return fTitle.Data(); }
181
182 TCanvas &AddTab(const char *name);
183 TGCompositeFrame *AddRawTab(const char *name);
184
185 Bool_t HasCanvas(const TCanvas *c) const;
186 TCanvas *GetCanvas(int i) const;
187 TCanvas *GetCanvas(const TString &name) const;
188 TVirtualPad *GetFullPad(const Int_t canvas, const Int_t pad);
189
190 Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const;
191
192 Int_t Read(const char *name, const char *tab);
193 Int_t Read(const char *name="MStatusDisplay")
194 {
195 return Read(name, 0);
196 }
197 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
198 {
199 return Write(-1, name, option, bufsize);
200 }
201 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0) const
202 {
203 return Write(-1, name, option, bufsize);
204 }
205
206 Bool_t CdCanvas(const TString &name);
207 void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
208
209 void DrawClonePad(const char *tab, TCanvas &oldc)
210 {
211 DrawClonePad(AddTab(tab), oldc);
212 }
213
214 void SetNoContextMenu(Bool_t flag=kTRUE);
215
216 Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "ps"); }
217 Int_t SaveAsPDF(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "pdf"); }
218 Int_t SaveAsSVG(TString name="", const TString addon="") { return SaveAsVGF(-1, name, addon, "svg"); }
219 Bool_t SaveAsPNG(TString name="") { return SaveAsPNG(-1, name); }
220 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
221 Bool_t SaveAsXPM(TString name="") { return SaveAsXPM(-1, name); }
222 Bool_t SaveAsJPG(TString name="") { return SaveAsJPG(-1, name); }
223 //Bool_t SaveAsTIFF(TString name="") { return SaveAsTIFF(-1, name); }
224 //Bool_t SaveAsXCF(TString name="") { return SaveAsXCF(-1, name); }
225 Bool_t SaveAsBMP(TString name="") { return SaveAsBMP(-1, name); }
226 Bool_t SaveAsXML(TString name="") { return SaveAsXML(-1, name); }
227 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
228 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
229 Int_t SaveAs(TString name) { return SaveAs(-1, name); }
230 Int_t PrintPS() { return PrintPS(-1); }
231
232 Int_t SaveAsPS(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "ps"); }
233 Int_t SaveAsPDF(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "pdf"); }
234 Int_t SaveAsSVG(Int_t num, TString name="", const TString addon="") { return SaveAsVGF(num, name, addon, "svg"); }
235 Bool_t SaveAsPNG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kPng); }
236 Bool_t SaveAsGIF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kGif); }
237 Bool_t SaveAsXPM(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXpm); }
238 Bool_t SaveAsJPG(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kJpeg); }
239 //Bool_t SaveAsTIFF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kTiff); }
240 //Bool_t SaveAsXCF(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXcf); }
241 Bool_t SaveAsBMP(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kBmp); }
242 Bool_t SaveAsXML(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXml); }
243 Bool_t SaveAsC(Int_t num, TString name="");
244 Int_t SaveAsRoot(Int_t num, TString name="");
245 Int_t SaveAs(Int_t num, TString name);
246 Int_t PrintPS(Int_t num, const char *p=0, const char *cmd=0, const char *tmp=0);
247 Bool_t PrintLog(const char *p=0, const char *c=0);
248 Bool_t SaveLogAsPS(const char *name) const;
249
250 // Size options
251 void SetCanvasWidth(UInt_t w);
252 void SetCanvasHeight(UInt_t h);
253
254 void SetDisplayWidth(UInt_t w);
255 void SetDisplayHeight(UInt_t h);
256
257 void SetOptimumSize();
258 void SetDisplaySize(UInt_t w, UInt_t h);
259
260 Int_t SaveAs(Int_t num=-1);
261 Int_t Open(TString fname, const char *name="MStatusDisplay");
262 Int_t Open();
263
264 Status_t CheckStatus() const { return fStatus; }
265 void ClearStatus() { fStatus = kLoopNone; }
266
267 void Lock() { fIsLocked++; }
268 void UnLock() { if (fIsLocked>0) fIsLocked--; }
269
270 void Reset();
271
272 Bool_t CheckTabForCanvas(int num) const;
273
274 void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
275
276 ClassDef(MStatusDisplay, 0) // Window for a status display
277};
278
279#endif
Note: See TracBrowser for help on using the repository browser.