Class Day

  • All Implemented Interfaces:
    java.util.EventListener, org.eclipse.swt.events.DisposeListener, org.eclipse.swt.events.PaintListener, org.eclipse.swt.graphics.Drawable, org.eclipse.swt.internal.SWTEventListener

    public class Day
    extends org.eclipse.swt.widgets.Canvas
    implements org.eclipse.swt.events.PaintListener, org.eclipse.swt.events.DisposeListener
    An SWT custom control representing a single day in a month-mode calendar.
    • Constructor Summary

      Constructors 
      Constructor Description
      Day​(org.eclipse.swt.widgets.Composite parent, int style)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMouseListener​(org.eclipse.swt.events.MouseListener listener)  
      org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)  
      private org.eclipse.swt.graphics.Color getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth​(boolean focused)  
      java.util.Date getDate()
      Returns the Date represented by this Day.
      int getDayNumber()  
      int getFocusState()  
      org.eclipse.swt.graphics.Point getMonthPosition()  
      private void initialize()  
      private org.eclipse.swt.graphics.RGB lighten​(org.eclipse.swt.graphics.RGB color, float amount)  
      void paintControl​(org.eclipse.swt.events.PaintEvent e)  
      void removeMouseListener​(org.eclipse.swt.events.MouseListener listener)  
      private void resetAllBackgrounds​(org.eclipse.swt.widgets.Composite composite, org.eclipse.swt.graphics.Color color)  
      private org.eclipse.swt.graphics.RGB saturate​(org.eclipse.swt.graphics.RGB color, float saturation)
      Sets the color's saturation to the specified value.
      void setDate​(java.util.Date date)
      Sets the Date represented by this Day.
      void setDayNumber​(int dayNum)  
      void setFocusState​(int focusState)  
      void setInCurrentMonth​(boolean inCurrentMonth)  
      void setItems​(CalendarableItem[] controls)  
      void setMonthPosition​(org.eclipse.swt.graphics.Point monthPosition)  
      void widgetDisposed​(org.eclipse.swt.events.DisposeEvent e)  
      • Methods inherited from class org.eclipse.swt.widgets.Canvas

        drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIME
      • Methods inherited from class org.eclipse.swt.widgets.Composite

        changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
      • Methods inherited from class org.eclipse.swt.widgets.Scrollable

        computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
      • Methods inherited from class org.eclipse.swt.widgets.Control

        addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
      • Methods inherited from class org.eclipse.swt.widgets.Widget

        addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • FOCUS_RUBBERBAND

        private final org.eclipse.swt.graphics.Color FOCUS_RUBBERBAND
      • NONACTIVE_FOCUS_RUBBERBAND

        private final org.eclipse.swt.graphics.Color NONACTIVE_FOCUS_RUBBERBAND
      • CURRENT_MONTH

        private org.eclipse.swt.graphics.Color CURRENT_MONTH
      • OTHER_MONTH

        private org.eclipse.swt.graphics.Color OTHER_MONTH
      • CELL_BACKGROUND_LIGHT

        private org.eclipse.swt.graphics.Color CELL_BACKGROUND_LIGHT
      • focusState

        private int focusState
      • dayNumber

        private org.eclipse.swt.widgets.Label dayNumber
      • spacer

        private org.eclipse.swt.widgets.Label spacer
      • textBounds

        private org.eclipse.swt.graphics.Point textBounds
      • monthPosition

        private org.eclipse.swt.graphics.Point monthPosition
      • mouseListeners

        private java.util.LinkedList<org.eclipse.swt.events.MouseListener> mouseListeners
      • mouseListener

        private org.eclipse.swt.events.MouseListener mouseListener
      • keyListener

        private org.eclipse.swt.events.KeyListener keyListener
      • traverseListener

        private org.eclipse.swt.events.TraverseListener traverseListener
        Permit focus events via keyboard.
      • focusListener

        private org.eclipse.swt.events.FocusListener focusListener
        When we gain/lose focus, redraw ourselves appropriately
      • inCurrentMonth

        private boolean inCurrentMonth
      • date

        private java.util.Date date
    • Constructor Detail

      • Day

        public Day​(org.eclipse.swt.widgets.Composite parent,
                   int style)
        Parameters:
        parent -
        style -
    • Method Detail

      • saturate

        private org.eclipse.swt.graphics.RGB saturate​(org.eclipse.swt.graphics.RGB color,
                                                      float saturation)
        Sets the color's saturation to the specified value.
        Parameters:
        color - The RGB of the color
        saturation - the new saturation (between 0 and 1)
        Returns:
        a Color that is saturated by the specified amount
      • lighten

        private org.eclipse.swt.graphics.RGB lighten​(org.eclipse.swt.graphics.RGB color,
                                                     float amount)
        Parameters:
        color - The RGB of the color
        amount - The amount to lighten as a percentage expresssed as a float between -1 and 1.
        Returns:
        The new RGB that is lightened by the specified amount
      • widgetDisposed

        public void widgetDisposed​(org.eclipse.swt.events.DisposeEvent e)
        Specified by:
        widgetDisposed in interface org.eclipse.swt.events.DisposeListener
      • initialize

        private void initialize()
      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(int wHint,
                                                          int hHint,
                                                          boolean changed)
        Overrides:
        computeSize in class org.eclipse.swt.widgets.Control
      • getMonthPosition

        public org.eclipse.swt.graphics.Point getMonthPosition()
        Returns:
        The (day, week) of this day in the month.
      • setMonthPosition

        public void setMonthPosition​(org.eclipse.swt.graphics.Point monthPosition)
        Parameters:
        monthPosition - The (day, week) of this day in the month.
      • getDayNumber

        public int getDayNumber()
        Returns:
        The day's number
      • setDayNumber

        public void setDayNumber​(int dayNum)
        Parameters:
        dayNum - the day number to set
      • paintControl

        public void paintControl​(org.eclipse.swt.events.PaintEvent e)
        Specified by:
        paintControl in interface org.eclipse.swt.events.PaintListener
      • addMouseListener

        public void addMouseListener​(org.eclipse.swt.events.MouseListener listener)
        Overrides:
        addMouseListener in class org.eclipse.swt.widgets.Control
      • removeMouseListener

        public void removeMouseListener​(org.eclipse.swt.events.MouseListener listener)
        Overrides:
        removeMouseListener in class org.eclipse.swt.widgets.Control
      • resetAllBackgrounds

        private void resetAllBackgrounds​(org.eclipse.swt.widgets.Composite composite,
                                         org.eclipse.swt.graphics.Color color)
      • getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth

        private org.eclipse.swt.graphics.Color getBackgroundTakingIntoAccountIfWeAreInTheCurrentMonth​(boolean focused)
      • setInCurrentMonth

        public void setInCurrentMonth​(boolean inCurrentMonth)
        Parameters:
        inCurrentMonth -
      • setItems

        public void setItems​(CalendarableItem[] controls)
        Parameters:
        controls -
      • setDate

        public void setDate​(java.util.Date date)
        Sets the Date represented by this Day.
        Parameters:
        date - The date to set
      • getDate

        public java.util.Date getDate()
        Returns the Date represented by this Day.
        Returns:
        This Day's date
      • getFocusState

        public int getFocusState()
      • setFocusState

        public void setFocusState​(int focusState)