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

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