5 posts / 0 new
Last post
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:
Widget - Calendar

This is a widget to create a monthly calendar view.  It defaults to showing the current date, but you can set any date.  It provides methods to navigate by day, week and month, and it is touch ready.

There is an interface to respond to calendar date selections.  You can implement the interface CalendarListener, which has a virtual method calendarDateSelected(time_t selectedDate).  When a date is selected, the interface method is called with the selected date.

You can configure the colours and fonts.

Usage:

Calendar* calendar = new Calendar(0, 0, 240, 240, NULL);
void CalendarScreen::keyPressEvent(int keyCode, int nativeCode) 
{
	switch(keyCode) {
			case MAK_SOFTLEFT:
				calendarDateSelected(calendar->getSelectedDate());
				break;
			case MAK_SOFTRIGHT:
				APPCONTROLLER->back();
				break;
			case MAK_UP:
				calendar->selectPreviousWeek();
				break;
			case MAK_DOWN:
				calendar->selectNextWeek();
				break;
			case MAK_LEFT:
				calendar->selectPreviousDay();
				break;
			case MAK_RIGHT:
				calendar->selectNextDay();
				break;
	}
}
AttachmentSize
Calender.zip4.76 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gretty
gretty's picture
Offline
Mobile Wizard
Joined: 27 Jan 2011
Posts:

Hi, is this calendar allowed to be used in commercial apps? :)

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Yeah, you're free to use it wherever, particularly if you've got a MoSync commercial licence 8-)

hyui
hyui's picture
Offline
Joined: 19 Oct 2011
Posts:

Hi,

Thanks for making this available, I have good use for it :)

I think I fixed the black border to the right of the calendar days:

for(int i = 0; i < 7; i++)
{
	//lprintfln("Adding day %s", days[i]);
	if(i==0)
		tempLabel = new Label(0, 0, this->getPaddedBounds().width-(cellWidth*6), cellHeight, NULL);
	else
		tempLabel = new Label(0, 0, cellWidth, cellHeight, NULL);
	. . .
}

And:

for(int i = 0; i < 42; i++)
{
	if(i%7==0)
		dayLabel = new Label(0, 0, this->getPaddedBounds().width-(cellWidth*6), cellHeight, NULL);
	else
		dayLabel = new Label(0, 0, cellWidth, cellHeight, NULL);
	. . .
}
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Cool, thanks!