source: branches/Mars_McMismatchStudy/mtools/MCalendar.h@ 18459

Last change on this file since 18459 was 8988, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 8.7 KB
Line 
1#ifndef MARS_MCalendar
2#define MARS_MCalendar
3
4#ifndef ROOT_TObject
5#include <TObject.h>
6#endif
7#ifndef ROOT_TString
8#include <TString.h>
9#endif
10#ifndef ROOT_TImage
11#include <TImage.h>
12#endif
13#ifndef ROOT_Gtypes
14#include <Gtypes.h>
15#endif
16
17/*
18#include <TAttLine.h>
19#include <TAttFill.h>
20#include <TAttText.h>
21*/
22
23class TEnv;
24class TPave;
25class TLatex;
26class TAttText;
27class TAttFill;
28class TArrayD;
29class TASImage;
30
31class MEnv;
32class MTime;
33
34class MCalendar : public TObject//, public TAttLine, public TAttText, public TAttFill
35{
36private:
37 /*
38 enum {
39 kMoonPhase,
40 kMoonPeriod,
41 kMagicPeriod
42 };*/
43
44 /*
45 Int_t fAlign;
46 Bool_t fActive;
47 Bool_t fUpdate;
48 Int_t fDay;
49 */
50 MEnv *fEnv;
51 MEnv *fEnvHolidays;
52
53 Bool_t fOrientation;
54 Bool_t fRotation;
55
56 Int_t fYear;
57 Int_t fMonth;
58 Int_t fFirstDay;
59 Int_t fNumBlocks;
60
61 TString fLanguage;
62
63 Double_t fMarginX;
64 Double_t fMarginY;
65 Double_t fCellSpace;
66 Double_t fBlockSpace;
67
68 Int_t fMoonAlignGraf;
69 Int_t fMoonAlignText;
70 Int_t fMoonTextType;
71 Int_t fMoonTextCont;
72 Float_t fMoonRadius;
73
74 // Resource file evaluation
75 void GetPave(TPave &pave, Bool_t active, Int_t n);
76 void GetMoon(TAttText &text, TAttFill &fill, Bool_t active, Int_t n);
77 void GetLatex(TLatex &latex, Bool_t active, Int_t n);
78 TString GetHoliday(const TObject &o, const MTime &tm);
79
80 // Helper function for Paint
81 TArrayD ConvertAlign(Int_t align, Double_t x[2], Double_t y[2], Double_t m[2]) const;
82 Bool_t GetBox(Int_t n, Double_t x[2], Double_t y[2], Double_t *ratio=0);
83
84 // Helper function for GetImage
85 TASImage *ReturnFile(const char *file) const;
86 const char *GetTTFontPath(const char *file) const;
87
88 // Orientation
89 Int_t Rotate(Int_t align, Bool_t fwd=kTRUE) const;
90 Int_t Derotate(Int_t align) const { return Rotate(align, kFALSE); }
91
92 // Menu interaction
93 Int_t GetN(Double_t x[2], Double_t y[2]);
94 Int_t GetN() { Double_t x[2], y[2]; return GetN(x,y); }
95 MTime GetDate();
96 Int_t GetAlign();
97
98 // Paint text
99 void PaintLatex(TAttText &att, Int_t align, Double_t x[2], Double_t y[2], Double_t ratio[2], /*Double_t height,*/ TString str);
100 void PaintClock(Double_t x[2], Double_t y[2], Double_t r[2], Int_t fill, char dir);
101
102 // GUI interactions
103 Int_t DistancetoPrimitive(Int_t px, Int_t py);
104
105public:
106 MCalendar(UShort_t y=0, Byte_t m=0, const char *fname=0);
107 ~MCalendar();
108
109 TObject *Clone(const char *newname="") const;
110
111 // Getter
112 const char *GetName() const { return Form("%04d-%02d", fYear, fMonth); }
113 const char *GetLanguage() const { return fLanguage; }
114 Int_t GetYear() const { return fYear; }
115 Int_t GetMonth() const { return fMonth; }
116 Int_t GetFirstDay() const { return fFirstDay; }
117 Int_t GetNumBlocks() const { return fNumBlocks; }
118 Double_t GetMarginX() const { return fMarginX; }
119 Double_t GetMarginY() const { return fMarginY; }
120 Double_t GetCellSpace() const { return fCellSpace; }
121 Double_t GetBlockSpace() const { return fBlockSpace; }
122 Int_t GetMoonAlignGraf() const { return fMoonAlignGraf; }
123 Int_t GetMoonAlignText() const { return fMoonAlignText; }
124 Int_t GetMoonTextType() const { return fMoonTextType; }
125 Int_t GetMoonTextCont() const { return fMoonTextCont; }
126 Float_t GetMoonRadius() const { return fMoonRadius; }
127 TString GetStringFmt(const char *fmt="%B", Int_t day=1, Int_t h=12, Int_t m=0, Int_t s=0) const;
128 Bool_t IsRotated() const { return fRotation; }
129 Bool_t IsVertical() const { return fOrientation; }
130
131
132 // Setter - Menu
133 void SetDate(UInt_t Month, Int_t Year=-1) { fMonth=Month; if (Year>0) fYear=Year; } // *MENU* *ARGS={Month=>fMonth,Year=>fYear}
134 void SetLocal(const char *Locale="") { fLanguage=Locale; } // *MENU* *ARGS={Locale=>fLanguage}
135 void SetFirstDay(Int_t FirstDay) { fFirstDay=FirstDay%7; } // *MENU* *ARGS={FirstDay=>fFirstDay}
136 void SetLayout(Byte_t NumberOfBlocks, Double_t MarginX, Double_t MarginY, Double_t CellSpace, Double_t BlockSpace) { fNumBlocks=NumberOfBlocks, fMarginX=MarginX; fMarginY=MarginY; fCellSpace=CellSpace; fBlockSpace=BlockSpace; } //*MENU* *ARGS={NumberOfBlocks=>fNumBlocks,MarginX=>fMarginX,MarginY=>fMarginY,CellSpace=>fCellSpace,BlockSpace=>fBlockSpace}
137
138 void ResetLayout(Int_t num);
139 void ResetLayout() { ResetLayout(-1); } //*MENU
140 void ResetHolidays(); //*MENU
141
142 void SetDefaultLayout(Int_t num);
143 void SetDefaultLayout() { SetDefaultLayout(-1); } //*MENU
144 void SetDefaultHolidays(); //*MENU
145
146 void ReadResourceFile(const char *FileName=0); //*MENU
147 void ReadHolidayFile(const char *FileName=0); //*MENU
148 void SaveResourceFile(const char *FileName=0); //*MENU
149 void SaveHolidayFile(const char *FileName=0); //*MENU
150
151 void Add(const char *Name, Int_t Align, const char *Format, Float_t FontSize=0.3, Int_t FontColor=1); //*MENU
152 void Add(const char *name, const char *fmt, const TAttText &att);
153
154 void SetDay(const char *Format="%a", Float_t FontSize=0.3, Int_t Color=kBlack) { Remove(GetAlign()); Add("Day", GetAlign(), Format, FontSize, Color); } //*MENU*
155 void SetDate(const char *Format="%e", Float_t FontSize=0.3, Int_t Color=kBlack) { Remove(GetAlign()); Add("Date", GetAlign(), Format, FontSize, Color); } //*MENU*
156 void SetHoliday(Float_t FontSize=0.13, Int_t Color=kBlue) { Remove(GetAlign()); Add("Holiday", GetAlign(), "", FontSize, Color); } //*MENU*
157 void SetBirthday(Float_t FontSize=0.13, Int_t Color=kBlue) { Remove(GetAlign()); Add("Birthday", GetAlign(), "", FontSize, Color); } //*MENU*
158 void SetEaster(Float_t FontSize=0.13, Int_t Color=kBlue) { Remove(GetAlign()); Add("Easter", GetAlign(), "", FontSize, Color); } //*MENU*
159
160 void AddHoliday(const char *text); //*MENU
161 void AddBirthday(const char *text); //*MENU
162 void AddEaster(const char *text); //*MENU
163
164 void Remove() { Remove(GetAlign()); } //*MENU*
165 void Remove(Int_t align);
166
167 // void ToggleOrientation() { fOrientation = !fOrientation; } //*MENU
168 void SetRotated(Bool_t b=kTRUE) { fRotation = b; } // *TOGGLE* *GETTER=IsRotated
169 void SetVertical(Bool_t b=kTRUE) { fOrientation = b; } // *TOGGLE* *GETTER=IsVertical
170
171 void PrintEnv() const; //*MENU
172 void SetEnv(const char *VariableName, const char *Value) const;//*MENU
173 void RemoveEnv(const char *VariableName) const;//*MENU
174
175 void SetMoonGraf(Int_t Align, Float_t Radius) { fMoonAlignGraf=Align; fMoonRadius=Radius; } //*MENU* *ARGS={Align=>fMoonAlignGraf,Radius=>fMoonRadius}
176 void SetMoonText(Int_t Align, Int_t Type, Int_t Continous) { fMoonAlignText=Align; fMoonTextType=Type; fMoonTextCont=Continous; } //*MENU* *ARGS={Align=>fMoonAlignText,Type=>fMoonTextType,Continous=>fMoonTextCont}
177
178 // Calendar sheet interface
179 static TASImage *DrawImage(const TASImage &img, Float_t x1, Float_t y1, Float_t x2, Float_t y2, Bool_t rot=kFALSE);
180 TASImage *GetImage(TEnv *env=NULL, const char *path="");
181 void DrawLatex(Float_t x, Float_t y, const char *text, const TAttText &att);
182 void DrawDate(Float_t x, Float_t y, const char *text, const TAttText &att)
183 {
184 DrawLatex(x, y, GetStringFmt(text), att);
185 }
186 void DrawText(TASImage &img, Int_t x, Int_t y, const char *txt,
187 Int_t size=50, const char *color = 0,
188 const char *font = "fixed", TImage::EText3DType type = TImage::kPlain, const char *path=0);
189 void DrawDate(TASImage &img, Int_t x, Int_t y, const char *txt,
190 Int_t size=50, const char *color = 0,
191 const char *font = "fixed", TImage::EText3DType type = TImage::kPlain, const char *path=0)
192 {
193 DrawText(img, x, y, GetStringFmt(txt), size, color, font, type, path);
194 }
195 TASImage *DrawTTF(Float_t x1, Float_t x2, Float_t y1, Float_t y2,
196 const char *text, Float_t size, const char *font);
197 TASImage *DrawTTFDate(Float_t x1, Float_t x2, Float_t y1, Float_t y2,
198 const char *text, Float_t size, const char *font)
199 {
200 return DrawTTF(x1, y1, x2, y2, GetStringFmt(text), size, font);
201 }
202 //Bool_t DrawImage(TEnv &env, Float_t x1, Float_t y1, Float_t x2, Float_t y2) const;
203
204 // Convertions
205 static void Convert2Latex(TString &str);
206 static void ConvertUTF8(TString &str, Bool_t fwd=kTRUE);
207
208 // TObject
209 void Paint(Option_t *o="");
210
211 /*
212 void Update();
213 void SetLineAttributes() {}
214 void SetFillAttributes() {}
215 void SetTextAttributes() {}
216 void SetTextAngle(Float_t) {}
217 void Selected(TVirtualPad*,TObject*,Int_t);
218 */
219 //void SetAttributes(); //*MENU
220
221 ClassDef(MCalendar, 1)
222};
223
224#endif
Note: See TracBrowser for help on using the repository browser.