semorg.gui.util
Class CalendarControl.SWTDayChooser

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by semorg.gui.util.CalendarControl.SWTDayChooser
All Implemented Interfaces:
EventListener, org.eclipse.swt.events.FocusListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.TraverseListener, org.eclipse.swt.graphics.Drawable, org.eclipse.swt.internal.SWTEventListener
Enclosing class:
CalendarControl

public class CalendarControl.SWTDayChooser
extends org.eclipse.swt.widgets.Composite
implements org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.FocusListener, org.eclipse.swt.events.TraverseListener, org.eclipse.swt.events.KeyListener

The Class SWTDayChooser.


Nested Class Summary
 class CalendarControl.SWTDayChooser.DayControl
          The Class DayControl.
 class CalendarControl.SWTDayChooser.DayLabel
          The Class DayLabel.
 
Field Summary
private  org.eclipse.swt.graphics.Color activeSelectionBackground
          The active selection background.
private  org.eclipse.swt.graphics.Color activeSelectionForeground
          The active selection foreground.
private  Calendar calendar
          The calendar.
private  int dayOffset
          The day offset.
private  CalendarControl.SWTDayChooser.DayControl[] days
          The days.
private  org.eclipse.swt.widgets.Label[] dayTitles
          The day titles.
private  org.eclipse.swt.graphics.Color inactiveSelectionBackground
          The inactive selection background.
private  org.eclipse.swt.graphics.Color inactiveSelectionForeground
          The inactive selection foreground.
private  List<CalendarControl.SWTCalendarListener> listeners
          The listeners.
private  Locale locale
          The locale.
private  org.eclipse.swt.graphics.Color otherMonthColor
          The other month color.
static int RED_SATURDAY
          Style constant for making Saturdays red.
static int RED_SUNDAY
          Style constant for making Sundays red.
static int RED_WEEKEND
          Style constant for making weekends red.
private  int style
          The style.
private  Calendar today
          The today.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
CalendarControl.SWTDayChooser(org.eclipse.swt.widgets.Composite parent, int style)
          Instantiates a new SWT day chooser.
 
Method Summary
 void addRealMouseListener(org.eclipse.swt.events.MouseListener listener)
          Adds the real mouse listener.
 void addSWTCalendarListener(CalendarControl.SWTCalendarListener listener)
          Adds the SWT calendar listener.
private  void dateChanged()
          Date changed.
protected  void drawDays()
          Draw days.
private  int findDay(org.eclipse.swt.widgets.Widget dayControl)
          Finds position of a control in days array.
 void focusGained(org.eclipse.swt.events.FocusEvent event)
           
 void focusLost(org.eclipse.swt.events.FocusEvent event)
           
 Calendar getCalendar()
          Gets the calendar.
private  CalendarControl.SWTDayChooser.DayControl getSelectedDayControl()
          Gets the selected day control.
private  org.eclipse.swt.graphics.Color getSelectionBackgroundColor()
          Gets the selection background color.
private  org.eclipse.swt.graphics.Color getSelectionForegroundColor()
          Gets the selection foreground color.
protected  void init()
          Init.
 boolean isFocusControl()
           
private  boolean isSameDay(Calendar cal1, Calendar cal2)
          Checks if is same day.
private  boolean isSameMonth(Calendar cal1, Calendar cal2)
          Checks if is same month.
 void keyPressed(org.eclipse.swt.events.KeyEvent event)
           
 void keyReleased(org.eclipse.swt.events.KeyEvent event)
           
 void keyTraversed(org.eclipse.swt.events.TraverseEvent event)
           
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent event)
           
 void mouseDown(org.eclipse.swt.events.MouseEvent event)
           
 void mouseUp(org.eclipse.swt.events.MouseEvent event)
           
 void removeRealMouseListener(org.eclipse.swt.events.MouseListener listener)
          Removes the real mouse listener.
 void removeSWTCalendarListener(CalendarControl.SWTCalendarListener listener)
          Removes the SWT calendar listener.
private  void selectDay(int day)
          Select day.
 void setCalendar(Calendar cal)
          Sets the calendar.
 void setFont(org.eclipse.swt.graphics.Font font)
           
 void setLocale(Locale locale)
          Sets the locale.
 void setMonth(int month)
          Sets the month.
 void setYear(int year)
          Sets the year.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RED_SUNDAY

public static final int RED_SUNDAY
Style constant for making Sundays red.

See Also:
Constant Field Values

RED_SATURDAY

public static final int RED_SATURDAY
Style constant for making Saturdays red.

See Also:
Constant Field Values

RED_WEEKEND

public static final int RED_WEEKEND
Style constant for making weekends red.

See Also:
Constant Field Values

dayTitles

private org.eclipse.swt.widgets.Label[] dayTitles
The day titles.


days

private CalendarControl.SWTDayChooser.DayControl[] days
The days.


dayOffset

private int dayOffset
The day offset.


activeSelectionBackground

private org.eclipse.swt.graphics.Color activeSelectionBackground
The active selection background.


inactiveSelectionBackground

private org.eclipse.swt.graphics.Color inactiveSelectionBackground
The inactive selection background.


activeSelectionForeground

private org.eclipse.swt.graphics.Color activeSelectionForeground
The active selection foreground.


inactiveSelectionForeground

private org.eclipse.swt.graphics.Color inactiveSelectionForeground
The inactive selection foreground.


otherMonthColor

private org.eclipse.swt.graphics.Color otherMonthColor
The other month color.


calendar

private Calendar calendar
The calendar.


today

private Calendar today
The today.


locale

private Locale locale
The locale.


listeners

private List<CalendarControl.SWTCalendarListener> listeners
The listeners.


style

private int style
The style.

Constructor Detail

CalendarControl.SWTDayChooser

public CalendarControl.SWTDayChooser(org.eclipse.swt.widgets.Composite parent,
                                     int style)
Instantiates a new SWT day chooser.

Parameters:
parent - the parent
style - the style
Method Detail

init

protected void init()
Init.


drawDays

protected void drawDays()
Draw days.


isSameDay

private boolean isSameDay(Calendar cal1,
                          Calendar cal2)
Checks if is same day.

Parameters:
cal1 - the cal1
cal2 - the cal2
Returns:
true, if is same day

isSameMonth

private boolean isSameMonth(Calendar cal1,
                            Calendar cal2)
Checks if is same month.

Parameters:
cal1 - the cal1
cal2 - the cal2
Returns:
true, if is same month

setMonth

public void setMonth(int month)
Sets the month.

Parameters:
month - the new month

setYear

public void setYear(int year)
Sets the year.

Parameters:
year - the new year

setCalendar

public void setCalendar(Calendar cal)
Sets the calendar.

Parameters:
cal - the new calendar

mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent event)
Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent event)
Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent event)
Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener

focusGained

public void focusGained(org.eclipse.swt.events.FocusEvent event)
Specified by:
focusGained in interface org.eclipse.swt.events.FocusListener

focusLost

public void focusLost(org.eclipse.swt.events.FocusEvent event)
Specified by:
focusLost in interface org.eclipse.swt.events.FocusListener

keyTraversed

public void keyTraversed(org.eclipse.swt.events.TraverseEvent event)
Specified by:
keyTraversed in interface org.eclipse.swt.events.TraverseListener

keyPressed

public void keyPressed(org.eclipse.swt.events.KeyEvent event)
Specified by:
keyPressed in interface org.eclipse.swt.events.KeyListener

keyReleased

public void keyReleased(org.eclipse.swt.events.KeyEvent event)
Specified by:
keyReleased in interface org.eclipse.swt.events.KeyListener

findDay

private int findDay(org.eclipse.swt.widgets.Widget dayControl)
Finds position of a control in days array.

Parameters:
dayControl - a control to find.
Returns:
an index of dayControl in days array, or -1 if not found.

selectDay

private void selectDay(int day)
Select day.

Parameters:
day - the day

getSelectedDayControl

private CalendarControl.SWTDayChooser.DayControl getSelectedDayControl()
Gets the selected day control.

Returns:
the selected day control

getSelectionBackgroundColor

private org.eclipse.swt.graphics.Color getSelectionBackgroundColor()
Gets the selection background color.

Returns:
the selection background color

getSelectionForegroundColor

private org.eclipse.swt.graphics.Color getSelectionForegroundColor()
Gets the selection foreground color.

Returns:
the selection foreground color

isFocusControl

public boolean isFocusControl()
Overrides:
isFocusControl in class org.eclipse.swt.widgets.Control

addSWTCalendarListener

public void addSWTCalendarListener(CalendarControl.SWTCalendarListener listener)
Adds the SWT calendar listener.

Parameters:
listener - the listener

removeSWTCalendarListener

public void removeSWTCalendarListener(CalendarControl.SWTCalendarListener listener)
Removes the SWT calendar listener.

Parameters:
listener - the listener

dateChanged

private void dateChanged()
Date changed.


getCalendar

public Calendar getCalendar()
Gets the calendar.

Returns:
the calendar

setLocale

public void setLocale(Locale locale)
Sets the locale.

Parameters:
locale - the new locale

setFont

public void setFont(org.eclipse.swt.graphics.Font font)
Overrides:
setFont in class org.eclipse.swt.widgets.Control

addRealMouseListener

public void addRealMouseListener(org.eclipse.swt.events.MouseListener listener)
Adds the real mouse listener.

Parameters:
listener - the listener

removeRealMouseListener

public void removeRealMouseListener(org.eclipse.swt.events.MouseListener listener)
Removes the real mouse listener.

Parameters:
listener - the listener