27TString monthNames[12] = {
"January",
"February",
"March",
"April",
"May",
"June",
28 "July",
"August",
"September",
"October",
"November",
"December"};
41 HtmlDayName(
const char *day);
42 virtual ~HtmlDayName() {}
44 TString Html()
const {
return fHtml; }
50HtmlDayName::HtmlDayName(
const char *day)
51 : fDay(day), fAlign(
"middle"), fBgColor(
"#000000"), fFontSize(
"4"), fFontColor(
"#FFFFFF")
55 fHtml +=
"<TH width=14%";
56 fHtml +=
" align=" + fAlign;
57 fHtml +=
" bgcolor=" + fBgColor +
">";
58 fHtml +=
"<font size=" + fFontSize;
59 fHtml +=
" color=" + fFontColor +
">";
61 fHtml +=
"</font></TH>\n";
86 virtual ~HtmlMonthTable() {}
89 TString Html()
const {
return fHtml; }
95HtmlMonthTable::HtmlMonthTable(
Int_t year,
Int_t month)
102 fCellBgcolor(
"#eeeeee"),
103 fTodayColor(
"#ffff00")
111void HtmlMonthTable::SetDate(
Int_t year,
Int_t month)
121void HtmlMonthTable::Build()
125 fHtml =
"<TABLE width=100%";
126 fHtml +=
" border=" + fBorder;
127 fHtml +=
" bgcolor=" + fBgColor;
128 fHtml +=
" cellpadding=" + fCellpadding;
134 fHtml +=
"</TBODY></TABLE>\n";
138void HtmlMonthTable::BuildDayNames()
143 fHtml += HtmlDayName(
"Sunday").Html();
144 fHtml += HtmlDayName(
"Monday").Html();
145 fHtml += HtmlDayName(
"Tuesday").Html();
146 fHtml += HtmlDayName(
"Wednesday").Html();
147 fHtml += HtmlDayName(
"Thursday").Html();
148 fHtml += HtmlDayName(
"Friday").Html();
149 fHtml += HtmlDayName(
"Saturday").Html();
154void HtmlMonthTable::BuildDays()
158 static Int_t maxdays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
160 Int_t maxday = maxdays[fMonth - 1];
167 for (
int week = 0; week < 6; week++) {
170 for (
int weekday = 0; weekday < 7; weekday++) {
171 Int_t day = week * 7 + weekday - first + 1;
173 if ((day > maxday) && !weekday)
176 fHtml +=
"<TD align=left width=14% ";
179 if ((fToday.GetYear() == fYear) && (fToday.GetMonth() == fMonth) && (fToday.GetDay() == day)) {
180 fHtml +=
" bgcolor=" + fTodayColor;
182 fHtml +=
" bgcolor=" + fCellBgcolor;
187 if ((day <= 0) || (day > maxday)) {
188 fHtml +=
" </TD>";
192 fHtml +=
"<font size=" + fCellFontSize +
">";
193 fHtml +=
Form(
"%d", day);
194 fHtml +=
"</font></TD>\n";
205 HtmlMonthTable fMonthTable;
216 virtual ~HtmlCalendar() {}
219 TString Html()
const {
return fHtml; }
225HtmlCalendar::HtmlCalendar(
Int_t year,
Int_t month) : fMonthTable(year, month)
236 fHtml += fMonthTable.Html();
241void HtmlCalendar::SetDate(
Int_t year,
Int_t month)
248 fMonthTable.SetDate(year, month);
252 fHtml += fMonthTable.Html();
257void HtmlCalendar::MakeHeader()
261 fTitle = monthNames[fMonth - 1] +
Form(
" %d", fYear);
262 fHeader =
"<html><head><title>";
264 fHeader +=
"</title></head><body>\n";
265 fHeader +=
"<center><H2>" + fTitle +
"</H2></center>";
269void HtmlCalendar::MakeFooter()
273 fFooter =
"<br><p><br><center><strong><font size=2 color=#2222ee>";
274 fFooter +=
"Example of using Html widget to display tabular data.";
275 fFooter +=
"</font></strong></center></body></html>";
280class CalendarWindow {
283 HtmlCalendar *fHtmlText;
293 virtual ~CalendarWindow();
301CalendarWindow::~CalendarWindow()
310CalendarWindow::CalendarWindow()
326 fHtml =
new TGHtml(fMain, 1, 1);
330 fHtml->ParseText((
char *)fHtmlText->Html().Data());
337 for (
int i = 0; i < 12; i++) {
338 fMonthBox->AddEntry(monthNames[i].Data(), i + 1);
340 fMonthBox->Select(today.
GetMonth());
347 fMonthBox->Resize(100, fYearEntry->GetHeight());
352 Int_t fontsize = atoi(fHtmlText->fMonthTable.fCellFontSize.Data());
362 gClient->GetColorByName(fHtmlText->fMonthTable.fBgColor.Data(), color);
369 gClient->GetColorByName(fHtmlText->fMonthTable.fCellBgcolor.Data(), color);
374 fMonthBox->Connect(
"Selected(Int_t)",
"CalendarWindow",
this,
"UpdateHTML()");
375 fYearEntry->GetNumberEntry()->Connect(
"TextChanged(char*)",
"CalendarWindow",
this,
"UpdateHTML()");
376 fFontEntry->GetNumberEntry()->Connect(
"TextChanged(char*)",
"CalendarWindow",
this,
"UpdateHTML()");
377 fTableColor->Connect(
"ColorSelected(Pixel_t)",
"CalendarWindow",
this,
"UpdateHTML()");
378 fCellColor->Connect(
"ColorSelected(Pixel_t)",
"CalendarWindow",
this,
"UpdateHTML()");
381 fMain->Connect(
"CloseWindow()",
"TApplication",
gApplication,
"Terminate()");
382 fMain->DontCallClose();
384 fMain->MapSubwindows();
385 fMain->Resize(600, 333);
388 fMain->SetWMSizeHints(controls->
GetDefaultWidth(), fMain->GetDefaultHeight(), 1000, 1000, 0, 0);
390 TString title =
"Calendar for ";
391 title += fHtmlText->fTitle;
392 fMain->SetWindowName(title.
Data());
397void CalendarWindow::UpdateHTML()
401 Int_t month = fMonthBox->GetSelected();
402 Int_t year = atoi(fYearEntry->GetNumberEntry()->GetText());
403 fHtmlText->fMonthTable.fCellFontSize = fFontEntry->GetNumberEntry()->GetText();
409 pixel = fTableColor->GetColor();
413 fHtmlText->fMonthTable.fBgColor = color->
AsHexString();
417 pixel = fCellColor->GetColor();
421 fHtmlText->fMonthTable.fCellBgcolor = color->
AsHexString();
425 fHtmlText->SetDate(year, month);
429 fHtml->ParseText((
char *)fHtmlText->Html().Data());
433 TString title =
"Calendar for ";
434 title += fHtmlText->fTitle;
435 fMain->SetWindowName(title.
Data());
443 new CalendarWindow();
ULong_t Pixel_t
Pixel value.
#define ClassDef(name, id)
R__EXTERN TApplication * gApplication
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void pixel
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
The color creation and management class.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
const char * AsHexString() const
Return color as hexadecimal string.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
UInt_t GetDefaultWidth() const override
A composite frame that layout their children in horizontal way.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
TGNumberEntry is a number entry input widget with up/down buttons.
const char * Data() const
Bool_t IsLeapYear(Bool_t inUTC=kTRUE, Int_t secOffset=0) const
Is the year a leap year.
Int_t GetDayOfWeek(Bool_t inUTC=kTRUE, Int_t secOffset=0) const
Method is using Zeller's formula for calculating the day number.