source: trunk/MagicSoft/Mars/mtools/MCalendar.h@ 7764

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