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

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