diff --git a/calendar.go b/calendar.go index 59735b6..82118af 100644 --- a/calendar.go +++ b/calendar.go @@ -6,10 +6,12 @@ import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo/event" import "git.tebibyte.media/tomo/objects/layouts" +var _ tomo.Object = new(Calendar) + // Calendar is an object that can display a date and allow the user to change // it. It can display one month at a time. type Calendar struct { - tomo.ContainerBox + box tomo.ContainerBox grid tomo.ContainerBox time time.Time @@ -23,11 +25,11 @@ type Calendar struct { // NewCalendar creates a new calendar with the specified date. func NewCalendar (tm time.Time) *Calendar { calendar := &Calendar { - ContainerBox: tomo.NewContainerBox(), - time: tm, + box: tomo.NewContainerBox(), + time: tm, } - calendar.SetRole(tomo.R("objects", "Calendar")) - calendar.SetAttr(tomo.ALayout(layouts.ContractVertical)) + calendar.box.SetRole(tomo.R("objects", "Calendar")) + calendar.box.SetAttr(tomo.ALayout(layouts.ContractVertical)) prevButton := NewButton("") prevButton.SetIcon(tomo.IconGoPrevious) @@ -48,17 +50,22 @@ func NewCalendar (tm time.Time) *Calendar { calendar.grid.SetRole(tomo.R("objects", "CalendarGrid")) calendar.grid.SetAttr(tomo.ALayout(layouts.NewGrid ( true, true, true, true, true, true, true)())) - calendar.Add(NewInnerContainer ( + calendar.box.Add(NewInnerContainer ( layouts.Row { false, true, false }, prevButton, calendar.monthLabel, nextButton)) - calendar.Add(calendar.grid) + calendar.box.Add(calendar.grid) - calendar.OnScroll(calendar.handleScroll) + calendar.box.OnScroll(calendar.handleScroll) calendar.refresh() return calendar } +// GetBox returns the underlying box. +func (this *Calendar) GetBox () tomo.Box { + return this.box +} + // Value returns the time this calendar is displaying. func (this *Calendar) Value () time.Time { return this.time