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

Last change on this file since 5138 was 3825, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 5.7 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 void CloseWindow();
113 Bool_t HandleConfigureNotify(Event_t *);
114 Bool_t HandleEvent(Event_t *event);
115
116 Bool_t HandleTimer(TTimer *timer=NULL);
117 void UpdateTab(TGCompositeFrame *f);
118
119 void DrawClonePad(TCanvas &newc, const TCanvas &oldc) const;
120 void CanvasSetFillColor(TPad &c, Int_t col) const;
121 Bool_t Display(const TObjArray &list);
122
123 void AddExtension(TString &name, const TString &ext, Int_t num) const;
124
125 void UpdatePSHeader(const TString &name) const;
126
127 void RemoveTab(int i);
128
129 TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
130
131public:
132 MStatusDisplay(Long_t t=1000);
133 virtual ~MStatusDisplay();
134
135 void SetLogStream(MLog *log, Bool_t enable=kFALSE);
136
137 void StartUpdate(Int_t millisec=-1);
138 void StopUpdate();
139 void SetUpdateTime(Long_t t);
140
141 void SetProgressBarPosition(Float_t p);
142 TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
143
144 void SetStatusLine1(const char *txt);
145 void SetStatusLine2(const char *txt);
146 void SetStatusLine2(const MParContainer &cont);
147
148 void SetPrinter(const TString &lpr) { fPrinter = lpr; }
149
150 virtual void SetName(const char *name) { fName = name; }
151 virtual void SetTitle(const char *title="") { fTitle = title; }
152 virtual const char *GetName() const { return fName.Data(); }
153 virtual const char *GetTitle() const { return fTitle.Data(); }
154
155 TCanvas &AddTab(const char *name);
156 TGCompositeFrame *AddRawTab(const char *name);
157
158 Bool_t HasCanvas(const TCanvas *c) const;
159 TCanvas *GetCanvas(int i) const;
160 TCanvas *GetCanvas(const TString &name) const;
161
162 Int_t Read(const char *name="MStatusDisplay");
163 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
164 {
165 return Write(-1, name, option, bufsize);
166 }
167 Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0);
168
169 Bool_t CdCanvas(const TString &name);
170 void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
171
172 void SetNoContextMenu(Bool_t flag=kTRUE);
173
174 Int_t SaveAsPS(TString name="", const TString addon="") { return SaveAsPS(-1, name, addon); }
175 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
176 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
177 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
178 Int_t PrintToLpr() { return PrintToLpr(-1); }
179
180 Int_t SaveAsPS(Int_t num, TString name="", const TString addon="");
181 Bool_t SaveAsGIF(Int_t num, TString name="");
182 Bool_t SaveAsC(Int_t num, TString name="");
183 Int_t SaveAsRoot(Int_t num, TString name="");
184 Int_t PrintToLpr(Int_t num);
185
186 Int_t SaveAs(Int_t num=-1);
187 Int_t Open(TString fname, const char *name="MStatusDisplay");
188 Int_t Open();
189
190 Status_t CheckStatus() const { return fStatus; }
191 void ClearStatus() { fStatus = kLoopNone; }
192
193 void Lock() { fIsLocked++; }
194 void UnLock() { if (fIsLocked>0) fIsLocked--; }
195
196 void Reset();
197
198 Bool_t CheckTabForCanvas(int num) const;
199
200 void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
201
202 ClassDef(MStatusDisplay, 0) // Window for a status display
203};
204
205#endif
Note: See TracBrowser for help on using the repository browser.