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

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