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

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