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

Last change on this file since 2534 was 2493, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.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{
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
56protected:
57 MGList *fList;
58 TGCompositeFrame *fUserFrame;
59
60 Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
61
62private:
63 TGHProgressBar *fBar;
64 TGTab *fTab;
65 TGLayoutHints *fLayCanvas;
66
67 TTimer fTimer;
68 TMutex *fMutex;
69
70 TGStatusBar *fStatusBar;
71
72 Status_t fStatus;
73
74 TString fPrinter;
75
76 MLog *fLog;
77 Int_t fLogIdx;
78 TTimer fLogTimer;
79 TGTextView *fLogBox;
80
81 FontStruct_t fFont;
82
83 UInt_t fIsLocked;
84
85 TList *fBatch; //!
86
87 void AddMenuBar();
88 void AddUserFrame();
89 void AddTabs();
90 void AddProgressBar();
91 void AddStatusBar();
92 void AddMarsTab();
93 void AddLogTab();
94
95 TCanvas *GetCanvas(TGCompositeFrame *f) const;
96
97 Bool_t ProcessMessageCommandMenu(Long_t mp1);
98 Bool_t ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2);
99 Bool_t ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2);
100 Bool_t ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2);
101 void CloseWindow();
102 Bool_t HandleConfigureNotify(Event_t *);
103 Bool_t HandleEvent(Event_t *event);
104
105 Bool_t HandleTimer(TTimer *timer=NULL);
106 void UpdateTab(TGCompositeFrame *f);
107
108 void DrawClonePad(TCanvas &newc, const TCanvas &oldc) const;
109 void CanvasSetFillColor(TPad &c, Int_t col) const;
110
111 void AddExtension(TString &name, const TString &ext, Int_t num) const;
112
113 void UpdatePSHeader(const TString &name) const;
114
115 void RemoveTab(int i);
116
117 TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
118
119public:
120 MStatusDisplay(Long_t t=1000);
121 virtual ~MStatusDisplay();
122
123 void SetLogStream(MLog *log, Bool_t enable=kFALSE);
124
125 void StartUpdate(Int_t millisec=-1);
126 void StopUpdate();
127 void SetUpdateTime(Long_t t);
128
129 void SetProgressBarPosition(Float_t p);
130 TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
131
132 void SetStatusLine1(const char *txt);
133 void SetStatusLine2(const char *txt);
134 void SetStatusLine2(const MParContainer &cont);
135
136 void SetPrinter(const TString &lpr) { fPrinter = lpr; }
137
138 TCanvas &AddTab(const char *name);
139 TGCompositeFrame *AddRawTab(const char *name);
140
141 Bool_t HasCanvas(const TCanvas *c) const;
142 TCanvas *GetCanvas(int i) const;
143 TCanvas *GetCanvas(const TString &name) const;
144
145 Int_t Read(const char *name="MStatusDisplay");
146 Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
147 {
148 return Write(-1, name, option, bufsize);
149 }
150 Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0);
151
152 Bool_t CdCanvas(const TString &name);
153 void Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
154
155 void SetNoContextMenu(Bool_t flag=kTRUE);
156
157 Int_t SaveAsPS(TString name="") { return SaveAsPS(-1, name); }
158 Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
159 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
160 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
161 Int_t PrintToLpr() { return PrintToLpr(-1); }
162
163 Int_t SaveAsPS(Int_t num, TString name="");
164 Bool_t SaveAsGIF(Int_t num, TString name="");
165 Bool_t SaveAsC(Int_t num, TString name="");
166 Int_t SaveAsRoot(Int_t num, TString name="");
167 Int_t PrintToLpr(Int_t num);
168
169 Status_t CheckStatus() const { return fStatus; }
170 void ClearStatus() { fStatus = kLoopNone; }
171
172 void Lock() { fIsLocked++; }
173 void UnLock() { if (fIsLocked>0) fIsLocked--; }
174
175 Bool_t CheckTabForCanvas(int num) const;
176
177 ClassDef(MStatusDisplay, 0) // Window for a status display
178};
179
180#endif
Note: See TracBrowser for help on using the repository browser.