Loading document parsing libraries...
# GraffitiCalendar
Class Inherits GraffitiWebUIControl
## About
GraffitiCalendar is an advanced calendar-view class. It allows for the addition of events to a calendar by using Xojo date objects, with support for a wide variety of views and allows for event dragging and resizing. Includes support for a large number of languages built-in, jQuery UI theme support, and Google Calendar imports.
## Compatibility
### Framework API Version
| 1.0 | 2.0 |
| :---: | :---: |
| True | True |
### Web
| 32-Bit | 64-Bit |
| :---: | :---: |
| True | True |
## Enumerations
| Name | Value | Description |
| --- | :---: | --- |
| NavigationButtons | Today <br> PreviousPeriod <br> NextPeriod <br> PreviousYear <br> NextYear | Support toolbar navigation buttons. |
| Views | Month <br> Agenda <br> AgendaWeek <br> AgendaDay <br> Basic <br> BasicWeek <br> BasicDay <br> List <br> ListYear <br> ListMonth <br> ListWeek <br> ListDay | Supported event views. |
## Event Definitions
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| DateDoubleClick | theDate as DateTime | (None) | Raised when the user double clicks a date/time. |
| DateSelected | DateStart as DateTime <br> DateEnd as DateTime <br> StartTime as Boolean <br> EndTime as Boolean <br> mouseX as Integer <br> mouseY as Integer | (None) | Raised when the user clicks on a day/time on the calendar. |
| EventChanged | theEvent as GraffitiCalendarEvent | (None) | Fires when the user changes an event (such as by dragging). |
| EventDoubleClick | theEvent as GraffitiCalendarEvent <br> atDate as DateTime | (None) | Raised when the user double-clicks an event. |
| EventFromRowSet | newEvent as GraffitiCalendarEvent | (None) | Raised when a new event is created from a RowSet. |
| EventMouseEnter | theEvent as GraffitiCalendarEvent <br> X as Integer <br> Y as Integer | (None) | Raised when the user moves their mouse in to an event. |
| EventMouseLeave | theEvent as GraffitiCalendarEvent | (None) | Raised when the user moves their mouse out of an event. |
| EventSelected | theEvent as GraffitiCalendarEvent <br> atDate as DateTime | (None) | Raised when the user clicks an event. |
| EventToRowSet | theEvent as GraffitiCalendarEvent | (None) | Raised when an event is modified. |
| GoogleCalendarError | Domain as String <br> Reason as String <br> Message as String | (None) | Raised when an error was encountered while retrieving events from a Google calendar. |
| LanguagesLoaded | (None) | (None) | This event is raised once the calendar has completely loaded the list of available languages, and facilitates dynamic locale selection. |
| NavigationButtonPressed | button as GraffitiCalendar.NavigationButtons | (None) | Raised when the user clicks one of the navigation buttons in the toolbar. Does not cancel the default action. |
| Open | (None) | (None) | |
| Shown | (None) | (None) | |
| ViewChanged | NewView as GraffitiCalendar.Views <br> StartDate as DateTime <br> EndDate as DateTime | (None) | Fired when the user changes the view ( IE : from Month to Week to Day). |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| AddEvent | newEvent as GraffitiCalendarEvent | (None) | Add a new event to the calendar. |
| AddExternalSource | GoogleCalendarID as String <br> GoogleCalendarKey as String <br> BGColor as Color = &c3a87ad <br> BorderColor as Color = &c3a87ad <br> TextColor as Color = &cFFFFFF | (None) | Add an external source to the calendar, such as a Google Calendar feed. |
| AddRestriction | theRestriction as GraffitiCalendarRestriction | (None) | Adds a view restriction. |
| AddRowSet | rs as RowSet | (None) | Adds a RowSet's entries to the calendar. See notes for schema. |
| AddViewButton | View as Views | (None) | Adds a new view button to the right-hand side of the header. |
| DayStyle | day as DateTime | GraffitiStyle | Returns the GraffitiStyle assigned to the specified day slot. |
| DayStyle | day as DateTime <br> assigns style as GraffitiStyle | (None) | Returns the GraffitiStyle assigned to the specified day slot. |
| DayTitle | Day as DateTime | String | Returns the title set for the specified date. |
| DayTitle | Day as DateTime <br> Title as String <br> Style as GraffitiStyle = Nil | (None) | Returns the title set for the specified date. |
| DeselectAll | (None) | (None) | Deselect all selected dates and events. |
| EventAt | index as Integer | GraffitiCalendarEvent | Returns the event at the specified index. |
| FindEvent | theID as String | GraffitiCalendarEvent | Used to find an event by ID, and return the event object. |
| FindEventIndex | theID as String | Integer | Used to find an event by ID, and return an integer index. |
| ICSExport | Domain as String | String | Exports all current events to ICS format. |
| ICSImport | theICS as String | (None) | Imports ICS-formatted event data to GraffitiCalendar events. |
| LastIndex | (None) | Integer | Returns the final index in the internal events array. |
| LoadTheme | themeURL as String | (None) | Loads an applies the specified jQuery theme. |
| MoveNext | (None) | (None) | Move to the next Month/Week/Day |
| MoveNextYear | (None) | (None) | Move to the next year. |
| MovePrev | (None) | (None) | Move to the previous Month/Week/Day |
| MovePrevYear | (None) | (None) | Move to the previous year. |
| MoveToDate | theDate as DateTime | (None) | Bring theDate in to view. |
| MoveToToday | (None) | (None) | Move the view to show the current date. |
| Print | (None) | (None) | Opens a print dialog with print-save version of the current view. |
| RefetchEvents | (None) | (None) | Causes the calendar to refetch all events. Useful if changes are made to an external source. |
| RemoveAllEvents | (None) | (None) | Removes all events from the calendar. |
| RemoveAllRestrictions | (None) | (None) | Removes all restrictions from the calendar view. |
| RemoveAllViewButtons | (None) | (None) | Removes all view buttons. |
| RemoveEvent | theEvent as GraffitiCalendarEvent | (None) | Remove the supplied event object from the calendar. |
| RemoveExternalSource | sourceID as String | (None) | Remove the external source signified by URL . |
| RemoveRestriction | theID as String | (None) | Removes a restriction from the calendar view. |
| RemoveViewButton | index as Integer | (None) | Removes the specified view button. |
| RerenderEvents | (None) | (None) | Forces the calendar to rerender all events. Useful if you notice any weirdness. |
| ScrollTime | d as DateTime | (None) | Scrolls the current view to display the provided DateTime. |
| SelectDates | StartDate as DateTime <br> EndDate as DateTime = Nil | (None) | Selects a range of dates in the view. |
| UpdateEvent | theEvent as GraffitiCalendarEvent | (None) | Updates theEvent. The GraffitiCalendarEvent object passed should be the same one that has been modified. |
| UpdateHeight | (None) | (None) | |
| UpdateProperty | item as Variant <br> identifier as String | (None) | |
| UpdatePropertyMultiple | identifier as String <br> item as Variant <br> modifier as Variant | (None) | |
| ViewButton | index as Integer | Views | Returns the view button at the specified index. |
| ViewButtonCount | (None) | Integer | Returns the number of View buttons. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| CalendarView | Views | Nil | The current view state. |
| DatabaseAutoUpdate | Boolean | True | When True and an Event has been loaded using AddRowSet, GraffitiCalendar will attempt to update the database row for that Event. |
| DisplayEventTime | Boolean | Nil | Controls the visibility of time in the event display. |
| Editable | Boolean | Nil | Determines if events are editable in the display by, for example, dragging. |
| Events() | GraffitiCalendarEvent | Nil | The array of events that the calendar currently contains. |
| HidePastEvents | Boolean | Nil | |
| IconNext | String | Nil | |
| IconNextYear | String | Nil | |
| IconPrevious | String | Nil | |
| IconPreviousYear | String | Nil | |
| Language | String | Nil | The short language string which determines the locale of the calendar. Currently contains: “en”, “ar-ma”, “ar-sa”, “ar”, “bg”, “ca”, “cs”, “da”, “de-at”, “de”, “el”, “en-au”, “en-gb”, “es”, “fa”, “fi”, “fr-ca”, “fr”, “hi”, “hr”, “hu”, “id”, “is”, “it”, “ja”, “ko”, “lt”, “lv”, “nl”, “pl”, “pt-br”, “pt”, “ro”, “ru”, “sk”, “sl”, “sr-cyrl”, “sr”, “sv”, “th”, “tr”, “uk”, “vi”, “zh-cn”, “zh-tw” |
| Languages() | String | Nil | Locale to use for display purposes. |
| LockUpdate | Boolean | Nil | |
| RestrictEventDisplay | Boolean | Nil | |
| RestrictSelection | Boolean | Nil | |
| RestrictView | Boolean | Nil | Restricts the view to the restrictions provided via AddRestriction. |
| ShowDayNames | Boolean | Nil | Determines whether the bar containing the names of the days of the week is visible. |
| ShowNavButtons | Boolean | Nil | Determines if the Prev/Next navigation buttons are visible. |
| ShowNavButtonsAtToday | Boolean | Nil | When True, shows the navigation buttons on either side of the Today button. |
| ShowTitle | Boolean | Nil | Whether the calendar shows the title ( IE : October 2014). |
| ShowTodayButton | Boolean | Nil | Determines if the Today button is displayed. |
| ShowYearButtons | Boolean | Nil | Determines if the Year navigation buttons are displayed. |
| StyleDayFuture | GraffitiStyle | Nil | GraffitiStyle for a day following Today. |
| StyleDayPast | GraffitiStyle | Nil | GraffitiStyle for a day the precedes today. |
| StyleDayToday | GraffitiStyle | Nil | |
| StyleFridayHeader | GraffitiStyle | Nil | GraffitiStyle for the Friday header. |
| StyleMondayHeader | GraffitiStyle | Nil | GraffitiStyle for the MondayHeader. |
| StyleSaturdayHeader | GraffitiStyle | Nil | GraffitiStyle for the SaturdayHeader. |
| StyleSundayHeader | GraffitiStyle | Nil | GraffitiStyle for the SundayHeader. |
| StyleThursdayHeader | GraffitiStyle | Nil | GraffitiStyle for the ThursdayHeader. |
| StyleTitle | GraffitiStyle | Nil | GraffitiStyle applied to the title of the view, for example July 2022 in a month view. |
| StyleToolbar | GraffitiStyle | Nil | GraffitiStyle for the toolbar area. |
| StyleToolbarButtons | GraffitiStyle | Nil | GraffitiStyle for the toolbar buttons. |
| StyleTuesdayHeader | GraffitiStyle | Nil | GraffitiStyle for the TuesdayHeader. |
| StyleWednesdayHeader | GraffitiStyle | Nil | GraffitiStyle for the WednesdayHeader. |
| TimeMaximum | DateTime | Nil | Restricts new event creation to time between TimeMinimum and TimeMaximum. Both must be set for effect. |
| TimeMinimum | DateTime | Nil | Restricts new event creation to time between TimeMinimum and TimeMaximum. Both must be set for effect. |
| TitleFormat | String | Nil | When empty, the locale-specific default string will be displayed. Accepts moment.js formats or arbitrary text inside brackets: [Hello World]. |
| ViewDate | DateTime | Nil | The starting day of the view, if set internally. Otherwise, any date may be provided to update the view. |
## Notes
### AddRowSet Support
AddRowSet is supported on all Xojo Database types.
### Custom Styling
To apply custom styles to your GraffitiCalendar instance, there are a number of Style* properties provided.
### Database Writing Support
Automatic writing of changes to the database of GraffitiCalendarEvents added via AddRowSet is currently limited to SQLiteDatabase and OracleDatabase. Using a different database type will require writing updates to the database using the events provided.
### Table Schema for AddRowSet
```
+-----------------+-------------+------+-------------------------+
| Field | Primary Key | NULL | Type |
+-----------------+-------------+------+-------------------------+
| id | Yes | No | Integer (auto-increment)|
| title | No | No | String |
| description | No | Yes | String |
| start | No | No | DateTime Equiv |
| end | No | No | DateTime Equiv |
| all_day | No | Yes | Boolean |
| background_color| No | Yes | String (#rrggbbaa) |
| text_color | No | Yes | String (#rrggbbaa) |
| border_color | No | Yes | String (#rrggbbaa) |
| can_move | No | Yes | Boolean |
| can_resize | No | Yes | Boolean |
| location | No | Yes | String |
| repeat_frequency| No | No | Integer (default '-1') |
| repeat_period | No | No | Integer (default '-1') |
| tooltip | No | Yes | String |
| url | No | Yes | String |
+-----------------+-------------+------+-------------------------+
```
## Examples
### Google Calendar Events
Using the AddExternalSource method, it is possible to import the events from a public Google Calendar as a single series:
```
myCalendar.AddExternalSource( "en.usa#holiday@group.v.calendar.google.com", "yourAPIkey" )
```
GraffitiCalendar does not currently support updating Google Calendar events when changed in GraffitiCalendar. In order to support this functionality, users may implement the Google Calendar RESTful API.