28TString monthNames[12] = {
"January",
"February",
"March",
"April",
"May",
"June",
29 "July",
"August",
"September",
"October",
"November",
"December"};
42 HtmlDayName(
const char *day);
43 virtual ~HtmlDayName() {}
45 TString Html()
const {
return fHtml; }
51HtmlDayName::HtmlDayName(
const char *day)
52 : fDay(day), fAlign(
"middle"), fBgColor(
"#000000"), fFontSize(
"4"), fFontColor(
"#FFFFFF")
56 fHtml +=
"<TH width=14%";
57 fHtml +=
" align=" + fAlign;
58 fHtml +=
" bgcolor=" + fBgColor +
">";
59 fHtml +=
"<font size=" + fFontSize;
60 fHtml +=
" color=" + fFontColor +
">";
62 fHtml +=
"</font></TH>\n";
87 virtual ~HtmlMonthTable() {}
90 TString Html()
const {
return fHtml; }
96HtmlMonthTable::HtmlMonthTable(
Int_t year,
Int_t month)
103 fCellBgcolor(
"#eeeeee"),
104 fTodayColor(
"#ffff00")
112void HtmlMonthTable::SetDate(
Int_t year,
Int_t month)
122void HtmlMonthTable::Build()
126 fHtml =
"<TABLE width=100%";
127 fHtml +=
" border=" + fBorder;
128 fHtml +=
" bgcolor=" + fBgColor;
129 fHtml +=
" cellpadding=" + fCellpadding;
135 fHtml +=
"</TBODY></TABLE>\n";
139void HtmlMonthTable::BuildDayNames()
144 fHtml += HtmlDayName(
"Sunday").Html();
145 fHtml += HtmlDayName(
"Monday").Html();
146 fHtml += HtmlDayName(
"Tuesday").Html();
147 fHtml += HtmlDayName(
"Wednesday").Html();
148 fHtml += HtmlDayName(
"Thursday").Html();
149 fHtml += HtmlDayName(
"Friday").Html();
150 fHtml += HtmlDayName(
"Saturday").Html();
155void HtmlMonthTable::BuildDays()
159 static Int_t maxdays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
161 Int_t maxday = maxdays[fMonth - 1];
168 for (
int week = 0; week < 6; week++) {
171 for (
int weekday = 0; weekday < 7; weekday++) {
172 Int_t day = week * 7 + weekday - first + 1;
174 if ((day > maxday) && !weekday)
177 fHtml +=
"<TD align=left width=14% ";
180 if ((fToday.GetYear() == fYear) && (fToday.GetMonth() == fMonth) && (fToday.GetDay() == day)) {
181 fHtml +=
" bgcolor=" + fTodayColor;
183 fHtml +=
" bgcolor=" + fCellBgcolor;
188 if ((day <= 0) || (day > maxday)) {
189 fHtml +=
" </TD>";
193 fHtml +=
"<font size=" + fCellFontSize +
">";
194 fHtml +=
Form(
"%d", day);
195 fHtml +=
"</font></TD>\n";
206 HtmlMonthTable fMonthTable;
217 virtual ~HtmlCalendar() {}
220 TString Html()
const {
return fHtml; }
226HtmlCalendar::HtmlCalendar(
Int_t year,
Int_t month) : fMonthTable(year, month)
237 fHtml += fMonthTable.Html();
242void HtmlCalendar::SetDate(
Int_t year,
Int_t month)
249 fMonthTable.SetDate(year, month);
253 fHtml += fMonthTable.Html();
258void HtmlCalendar::MakeHeader()
262 fTitle = monthNames[fMonth - 1] +
Form(
" %d", fYear);
263 fHeader =
"<html><head><title>";
265 fHeader +=
"</title></head><body>\n";
266 fHeader +=
"<center><H2>" + fTitle +
"</H2></center>";
270void HtmlCalendar::MakeFooter()
274 fFooter =
"<br><p><br><center><strong><font size=2 color=#2222ee>";
275 fFooter +=
"Example of using Html widget to display tabular data.";
276 fFooter +=
"</font></strong></center></body></html>";
281class CalendarWindow {
284 HtmlCalendar *fHtmlText;
294 virtual ~CalendarWindow();
302CalendarWindow::~CalendarWindow()
311CalendarWindow::CalendarWindow()
327 fHtml =
new TGHtml(fMain, 1, 1);
331 fHtml->ParseText((
char *)fHtmlText->Html().Data());
338 for (
int i = 0; i < 12; i++) {
339 fMonthBox->AddEntry(monthNames[i].Data(), i + 1);
341 fMonthBox->Select(today.
GetMonth());
348 fMonthBox->Resize(100, fYearEntry->GetHeight());
353 Int_t fontsize = atoi(fHtmlText->fMonthTable.fCellFontSize.Data());
363 gClient->GetColorByName(fHtmlText->fMonthTable.fBgColor.Data(), color);
370 gClient->GetColorByName(fHtmlText->fMonthTable.fCellBgcolor.Data(), color);
375 fMonthBox->Connect(
"Selected(Int_t)",
"CalendarWindow",
this,
"UpdateHTML()");
376 fYearEntry->GetNumberEntry()->Connect(
"TextChanged(char*)",
"CalendarWindow",
this,
"UpdateHTML()");
377 fFontEntry->GetNumberEntry()->Connect(
"TextChanged(char*)",
"CalendarWindow",
this,
"UpdateHTML()");
378 fTableColor->Connect(
"ColorSelected(Pixel_t)",
"CalendarWindow",
this,
"UpdateHTML()");
379 fCellColor->Connect(
"ColorSelected(Pixel_t)",
"CalendarWindow",
this,
"UpdateHTML()");
382 fMain->Connect(
"CloseWindow()",
"TApplication",
gApplication,
"Terminate()");
383 fMain->DontCallClose();
385 fMain->MapSubwindows();
386 fMain->Resize(600, 333);
389 fMain->SetWMSizeHints(controls->
GetDefaultWidth(), fMain->GetDefaultHeight(), 1000, 1000, 0, 0);
391 TString title =
"Calendar for ";
392 title += fHtmlText->fTitle;
393 fMain->SetWindowName(title.
Data());
398void CalendarWindow::UpdateHTML()
402 Int_t month = fMonthBox->GetSelected();
403 Int_t year = atoi(fYearEntry->GetNumberEntry()->GetText());
404 fHtmlText->fMonthTable.fCellFontSize = fFontEntry->GetNumberEntry()->GetText();
410 pixel = fTableColor->GetColor();
414 fHtmlText->fMonthTable.fBgColor = color->
AsHexString();
418 pixel = fCellColor->GetColor();
422 fHtmlText->fMonthTable.fCellBgcolor = color->
AsHexString();
426 fHtmlText->SetDate(year, month);
430 fHtml->ParseText((
char *)fHtmlText->Html().Data());
434 TString title =
"Calendar for ";
435 title += fHtmlText->fTitle;
436 fMain->SetWindowName(title.
Data());
444 new CalendarWindow();
ULong_t Pixel_t
Pixel value.
int Int_t
Signed integer 4 bytes (int)
#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.
static Int_t Pixel2Number(ULong_t pixel)
Static method returning color number for color specified by system dependent pixel value.