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

Last change on this file since 5832 was 5713, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.8 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 Read(const char *name="MStatusDisplay");
165 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
166 {
167 return Write(-1, name, option, bufsize);
168 }
169 Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0);
170
171 Bool_t CdCanvas(const TString &name);
172 void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
173
174 void SetNoContextMenu(Bool_t flag=kTRUE);
175
176 Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsPS(-1, name, addon); }
177 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
178 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
179 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
180 Int_t PrintToLpr() { return PrintToLpr(-1); }
181
182 Int_t SaveAsPS(Int_t num, TString name="", const TString addon="");
183 Bool_t SaveAsGIF(Int_t num, TString name="");
184 Bool_t SaveAsC(Int_t num, TString name="");
185 Int_t SaveAsRoot(Int_t num, TString name="");
186 Int_t PrintToLpr(Int_t num);
187
188 Int_t SaveAs(Int_t num=-1);
189 Int_t Open(TString fname, const char *name="MStatusDisplay");
190 Int_t Open();
191
192 Status_t CheckStatus() const { return fStatus; }
193 void ClearStatus() { fStatus = kLoopNone; }
194
195 void Lock() { fIsLocked++; }
196 void UnLock() { if (fIsLocked>0) fIsLocked--; }
197
198 void Reset();
199
200 Bool_t CheckTabForCanvas(int num) const;
201
202 void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
203
204 ClassDef(MStatusDisplay, 0) // Window for a status display
205};
206
207#endif
Note: See TracBrowser for help on using the repository browser.