Class Calendar
- All Implemented Interfaces:
Accessible,Buildable,ConstraintTarget,Proxy
A GtkCalendar can be created with Calendar().
The selected date can be retrieved from a GtkCalendar using
getDate().
It can be altered with setDate(org.gnome.glib.DateTime).
To place a visual marker on a particular day, use
markDay(int) and to remove the marker,
unmarkDay(int). Alternative, all
marks can be cleared with clearMarks().
Users should be aware that, although the Gregorian calendar is the legal calendar in most countries, it was adopted progressively between 1582 and 1929. Display before these dates is likely to be historically incorrect.
Shortcuts and Gestures
GtkCalendar supports the following gestures:
- Scrolling up or down will switch to the previous or next month.
- Date strings can be dropped for setting the current day.
CSS nodes
calendar.view
├── header
│ ├── button
│ ├── stack.month
│ ├── button
│ ├── button
│ ├── label.year
│ ╰── button
╰── grid
╰── label[.day-name][.week-number][.day-number][.other-month][.today]
GtkCalendar has a main node with name calendar. It contains a subnode
called header containing the widgets for switching between years and months.
The grid subnode contains all day labels, including week numbers on the left (marked with the .week-number css class) and day names on top (marked with the .day-name css class).
Day labels that belong to the previous or next month get the .other-month style class. The label of the current day get the .today style class.
Marked day labels get the :selected state assigned.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCalendar.Builder<B extends Calendar.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theDaySelectedCallbackcallback.static interfaceFunctional interface declaration of theNextMonthCallbackcallback.static interfaceFunctional interface declaration of theNextYearCallbackcallback.static interfaceFunctional interface declaration of thePrevMonthCallbackcallback.static interfaceFunctional interface declaration of thePrevYearCallbackcallback.Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.Widget$Impl, Widget.WidgetClassNested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.Accessible$Impl, Accessible.AccessibleInterfaceNested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.Buildable$Impl, Buildable.BuildableIfaceNested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTarget$Impl, ConstraintTarget.ConstraintTargetInterface -
Constructor Summary
ConstructorsConstructorDescriptionCalendar()Creates a new Calendar.Calendar(MemorySegment address) Create a Calendar proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected CalendarasParent()Returns this instance as if it were its parent type.static Calendar.Builder<? extends Calendar.Builder> builder()ACalendar.Builderobject constructs aCalendarwith the specified properties.voidRemove all visual markers.voidEmits the "day-selected" signal.voidEmits the "next-month" signal.voidEmits the "next-year" signal.voidEmits the "prev-month" signal.voidEmits the "prev-year" signal.getDate()Returns aGDateTimerepresenting the shown year, month and the selected day.intgetDay()Gets the day of the selected date.booleangetDayIsMarked(int day) Returns if thedayof the this Calendar is already marked.intgetMonth()Gets the month of the selected date.booleanReturns whether this Calendar is currently showing the names of the week days.booleanReturns whether this Calendar is currently showing the heading.booleanReturns whether this Calendar is showing week numbers right now.static @Nullable TypegetType()Get the GType of the Calendar classintgetYear()Gets the year of the selected date.voidmarkDay(int day) Places a visual marker on a particular day of the current month.Emitted when the user selects a day.onNextMonth(Calendar.NextMonthCallback handler) Emitted when the user switches to the next month.onNextYear(Calendar.NextYearCallback handler) Emitted when user switches to the next year.onPrevMonth(Calendar.PrevMonthCallback handler) Emitted when the user switches to the previous month.onPrevYear(Calendar.PrevYearCallback handler) Emitted when user switches to the previous year.voidDeprecated.voidSwitches todate'syear and month and selects its day.voidsetDay(int day) Sets the day for the selected date.voidsetMonth(int month) Sets the month for the selected date.voidsetShowDayNames(boolean value) Sets whether the calendar shows day names.voidsetShowHeading(boolean value) Sets whether the calendar should show a heading.voidsetShowWeekNumbers(boolean value) Sets whether week numbers are shown in the calendar.voidsetYear(int year) Sets the year for the selected date.voidunmarkDay(int day) Removes the visual marker from a particular day.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateDefault, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMemoryLayout, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlagsMethods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateStateMethods inherited from interface org.gnome.gtk.Buildable
getBuildableId
-
Constructor Details
-
Calendar
Create a Calendar proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Calendar
public Calendar()Creates a new Calendar.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
clearMarks
public void clearMarks()Remove all visual markers. -
getDate
Returns aGDateTimerepresenting the shown year, month and the selected day.The returned date is in the local time zone.
- Returns:
- the
GDateTimerepresenting the selected date
-
getDay
public int getDay()Gets the day of the selected date.- Returns:
- the day of the selected date.
- Since:
- 4.14
-
getDayIsMarked
public boolean getDayIsMarked(int day) Returns if thedayof the this Calendar is already marked.- Parameters:
day- the day number between 1 and 31.- Returns:
- whether the day is marked.
-
getMonth
public int getMonth()Gets the month of the selected date.- Returns:
- The month of the selected date (as a number between 0 and 11).
- Since:
- 4.14
-
getShowDayNames
public boolean getShowDayNames()Returns whether this Calendar is currently showing the names of the week days.This is the value of the
Gtk.Calendar:show-day-namesproperty.- Returns:
- Whether the calendar shows day names.
-
getShowHeading
public boolean getShowHeading()Returns whether this Calendar is currently showing the heading.This is the value of the
Gtk.Calendar:show-headingproperty.- Returns:
- Whether the calendar is showing a heading.
-
getShowWeekNumbers
public boolean getShowWeekNumbers()Returns whether this Calendar is showing week numbers right now.This is the value of the
Gtk.Calendar:show-week-numbersproperty.- Returns:
- Whether the calendar is showing week numbers.
-
getYear
public int getYear()Gets the year of the selected date.- Returns:
- the year of the selected date.
- Since:
- 4.14
-
markDay
public void markDay(int day) Places a visual marker on a particular day of the current month.- Parameters:
day- the day number to mark between 1 and 31.
-
selectDay
Deprecated.UsesetDate(org.gnome.glib.DateTime)instead.Switches todate'syear and month and select its day.- Parameters:
date- aGDateTimerepresenting the day to select
-
setDate
Switches todate'syear and month and selects its day.- Parameters:
date- aGDateTimerepresenting the day to select- Since:
- 4.20
-
setDay
public void setDay(int day) Sets the day for the selected date.The new date must be valid. For example, setting the day to 31 when the month is February will fail.
- Parameters:
day- The desired day for the selected date (as a number between 1 and 31).- Since:
- 4.14
-
setMonth
public void setMonth(int month) Sets the month for the selected date.The new date must be valid. For example, setting the month to 1 (February) when the day is 31 will fail.
- Parameters:
month- The desired month for the selected date (as a number between 0 and 11).- Since:
- 4.14
-
setShowDayNames
public void setShowDayNames(boolean value) Sets whether the calendar shows day names.- Parameters:
value- Whether to show day names above the day numbers
-
setShowHeading
public void setShowHeading(boolean value) Sets whether the calendar should show a heading.The heading contains the current year and month as well as buttons for changing both.
- Parameters:
value- Whether to show the heading in the calendar
-
setShowWeekNumbers
public void setShowWeekNumbers(boolean value) Sets whether week numbers are shown in the calendar.- Parameters:
value- whether to show week numbers alongside the days
-
setYear
public void setYear(int year) Sets the year for the selected date.The new date must be valid. For example, setting the year to 2023 when the date is February 29 will fail.
- Parameters:
year- The desired year for the selected date (withinGLib.DateTimelimits, i.e. from 0001 to 9999).- Since:
- 4.14
-
unmarkDay
public void unmarkDay(int day) Removes the visual marker from a particular day.- Parameters:
day- the day number to unmark between 1 and 31.
-
onDaySelected
public SignalConnection<Calendar.DaySelectedCallback> onDaySelected(Calendar.DaySelectedCallback handler) Emitted when the user selects a day.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDaySelected
public void emitDaySelected()Emits the "day-selected" signal. SeeonDaySelected(org.gnome.gtk.Calendar.DaySelectedCallback). -
onNextMonth
Emitted when the user switches to the next month.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitNextMonth
public void emitNextMonth()Emits the "next-month" signal. SeeonNextMonth(org.gnome.gtk.Calendar.NextMonthCallback). -
onNextYear
Emitted when user switches to the next year.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitNextYear
public void emitNextYear()Emits the "next-year" signal. SeeonNextYear(org.gnome.gtk.Calendar.NextYearCallback). -
onPrevMonth
Emitted when the user switches to the previous month.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPrevMonth
public void emitPrevMonth()Emits the "prev-month" signal. SeeonPrevMonth(org.gnome.gtk.Calendar.PrevMonthCallback). -
onPrevYear
Emitted when user switches to the previous year.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPrevYear
public void emitPrevYear()Emits the "prev-year" signal. SeeonPrevYear(org.gnome.gtk.Calendar.PrevYearCallback). -
builder
ACalendar.Builderobject constructs aCalendarwith the specified properties. Use the variousset...()methods to set properties, and finish construction withCalendar.Builder.build().- Returns:
- the builder object
-
setDate(org.gnome.glib.DateTime)instead.