Class MonthCalendarableItemControl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int align
      the alignment.
      private java.lang.String appToolTipText  
      private org.eclipse.swt.graphics.Color background  
      private org.eclipse.swt.graphics.Image backgroundImage  
      private CalendarableItem calendarableItem  
      private int clipping  
      private int continued  
      private static int DRAW_FLAGS  
      private static java.lang.String ELLIPSIS
      a string inserted in the middle of text that has been shortened
      private static int GAP
      Gap between icon and text
      private org.eclipse.swt.graphics.Color[] gradientColors  
      private int[] gradientPercents  
      private boolean gradientVertical  
      private int hIndent  
      private org.eclipse.swt.graphics.Image image
      the current icon
      private static int INDENT
      Left and right margins
      private java.lang.String text
      the current text
      private int vIndent  
      • Fields inherited from class org.eclipse.swt.widgets.Composite

        embeddedHandle
      • Fields inherited from class org.eclipse.swt.widgets.Widget

        handle
    • Constructor Summary

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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) char _findMnemonic​(java.lang.String string)  
      private static int checkStyle​(int style)
      Check the style bits to ensure that no invalid styles are applied.
      org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)  
      private void drawBevelRect​(org.eclipse.swt.graphics.GC gc, int x, int y, int w, int h, org.eclipse.swt.graphics.Color topleft, org.eclipse.swt.graphics.Color bottomright)
      Draw a rectangle in the given colors.
      int getAlignment()
      Returns the alignment.
      CalendarableItem getCalendarableItem()  
      int getClipping()  
      int getContinued()  
      org.eclipse.swt.graphics.Image getImage()
      Return the CLabel's image or null.
      int getStyle()  
      java.lang.String getText()
      Return the Label's text.
      java.lang.String getToolTipText()  
      private org.eclipse.swt.graphics.Point getTotalSize​(org.eclipse.swt.graphics.Image image, java.lang.String text)
      Compute the minimum size.
      private void initAccessible()  
      (package private) void onDispose​(org.eclipse.swt.events.DisposeEvent event)  
      (package private) void onPaint​(org.eclipse.swt.events.PaintEvent event)  
      private void paintBorder​(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle r)
      Paint the Label's border.
      void setAlignment​(int align)
      Set the alignment of the CLabel.
      void setBackground​(org.eclipse.swt.graphics.Color color)  
      void setBackground​(org.eclipse.swt.graphics.Color[] colors, int[] percents)
      Specify a gradient of colours to be drawn in the background of the CLabel.
      void setBackground​(org.eclipse.swt.graphics.Color[] colors, int[] percents, boolean vertical)
      Specify a gradient of colours to be drawn in the background of the CLabel.
      void setBackground​(org.eclipse.swt.graphics.Image image)
      Set the image to be drawn in the background of the label.
      void setCalendarableItem​(CalendarableItem calendarable)
      Method setCalendarable.
      void setClipping​(int clipping)
      Sets the clipping style bits
      void setContinued​(int continued)
      Sets the continued style bits
      void setFont​(org.eclipse.swt.graphics.Font font)  
      void setImage​(org.eclipse.swt.graphics.Image image)
      Set the label's Image.
      void setSelected​(boolean selected)
      Set or clear the selection indicator in the UI.
      void setText​(java.lang.String text)
      Set the label's text.
      void setToolTipText​(java.lang.String string)  
      protected java.lang.String shortenText​(org.eclipse.swt.graphics.GC gc, java.lang.String t, int width)
      Shorten the given text t so that its length doesn't exceed the given width.
      private java.lang.String[] splitString​(java.lang.String text)  
      • Methods inherited from class org.eclipse.swt.widgets.Canvas

        drawBackground, getCaret, getIME, scroll, setCaret, 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, addMouseListener, 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, 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, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, 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, 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

      • ELLIPSIS

        private static final java.lang.String ELLIPSIS
        a string inserted in the middle of text that has been shortened
        See Also:
        Constant Field Values
      • align

        private int align
        the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT
      • hIndent

        private int hIndent
      • vIndent

        private int vIndent
      • text

        private java.lang.String text
        the current text
      • image

        private org.eclipse.swt.graphics.Image image
        the current icon
      • appToolTipText

        private java.lang.String appToolTipText
      • backgroundImage

        private org.eclipse.swt.graphics.Image backgroundImage
      • gradientColors

        private org.eclipse.swt.graphics.Color[] gradientColors
      • gradientPercents

        private int[] gradientPercents
      • gradientVertical

        private boolean gradientVertical
      • background

        private org.eclipse.swt.graphics.Color background
      • DRAW_FLAGS

        private static int DRAW_FLAGS
      • clipping

        private int clipping
      • continued

        private int continued
    • Constructor Detail

      • MonthCalendarableItemControl

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

      • setSelected

        public void setSelected​(boolean selected)
        Description copied from interface: ICalendarableItemControl
        Set or clear the selection indicator in the UI.
        Specified by:
        setSelected in interface ICalendarableItemControl
        Parameters:
        selected - true if this control should appear selected; false otherwise.
      • checkStyle

        private static int checkStyle​(int style)
        Check the style bits to ensure that no invalid styles are applied.
      • computeSize

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

        private void drawBevelRect​(org.eclipse.swt.graphics.GC gc,
                                   int x,
                                   int y,
                                   int w,
                                   int h,
                                   org.eclipse.swt.graphics.Color topleft,
                                   org.eclipse.swt.graphics.Color bottomright)
        Draw a rectangle in the given colors.
      • _findMnemonic

        char _findMnemonic​(java.lang.String string)
      • getAlignment

        public int getAlignment()
        Returns the alignment. The alignment style (LEFT, CENTER or RIGHT) is returned.
        Returns:
        SWT.LEFT, SWT.RIGHT or SWT.CENTER
      • getImage

        public org.eclipse.swt.graphics.Image getImage()
        Return the CLabel's image or null.
        Returns:
        the image of the label or null
      • getTotalSize

        private org.eclipse.swt.graphics.Point getTotalSize​(org.eclipse.swt.graphics.Image image,
                                                            java.lang.String text)
        Compute the minimum size.
      • getStyle

        public int getStyle()
        Overrides:
        getStyle in class org.eclipse.swt.widgets.Widget
      • getText

        public java.lang.String getText()
        Return the Label's text.
        Returns:
        the text of the label or null
      • getToolTipText

        public java.lang.String getToolTipText()
        Overrides:
        getToolTipText in class org.eclipse.swt.widgets.Control
      • initAccessible

        private void initAccessible()
      • onDispose

        void onDispose​(org.eclipse.swt.events.DisposeEvent event)
      • onPaint

        void onPaint​(org.eclipse.swt.events.PaintEvent event)
      • paintBorder

        private void paintBorder​(org.eclipse.swt.graphics.GC gc,
                                 org.eclipse.swt.graphics.Rectangle r)
        Paint the Label's border.
      • setAlignment

        public void setAlignment​(int align)
        Set the alignment of the CLabel. Use the values LEFT, CENTER and RIGHT to align image and text within the available space.
        Parameters:
        align - the alignment style of LEFT, RIGHT or CENTER
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        • ERROR_INVALID_ARGUMENT - if the value of align is not one of SWT.LEFT, SWT.RIGHT or SWT.CENTER
      • setBackground

        public void setBackground​(org.eclipse.swt.graphics.Color color)
        Overrides:
        setBackground in class org.eclipse.swt.widgets.Control
      • setBackground

        public void setBackground​(org.eclipse.swt.graphics.Color[] colors,
                                  int[] percents)
        Specify a gradient of colours to be drawn in the background of the CLabel.

        For example, to draw a gradient that varies from dark blue to blue and then to white and stays white for the right half of the label, use the following call to setBackground:

                clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
                                                   display.getSystemColor(SWT.COLOR_BLUE),
                                                   display.getSystemColor(SWT.COLOR_WHITE), 
                                                   display.getSystemColor(SWT.COLOR_WHITE)},
                                       new int[] {25, 50, 100});
         
        Parameters:
        colors - an array of Color that specifies the colors to appear in the gradient in order of appearance from left to right; The value null clears the background gradient; the value null can be used inside the array of Color to specify the background color.
        percents - an array of integers between 0 and 100 specifying the percent of the width of the widget at which the color should change; the size of the percents array must be one less than the size of the colors array.
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        • ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent
      • setBackground

        public void setBackground​(org.eclipse.swt.graphics.Color[] colors,
                                  int[] percents,
                                  boolean vertical)
        Specify a gradient of colours to be drawn in the background of the CLabel.

        For example, to draw a gradient that varies from dark blue to white in the vertical, direction use the following call to setBackground:

                clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
                                                   display.getSystemColor(SWT.COLOR_WHITE)},
                                         new int[] {100}, true);
         
        Parameters:
        colors - an array of Color that specifies the colors to appear in the gradient in order of appearance from left/top to right/bottom; The value null clears the background gradient; the value null can be used inside the array of Color to specify the background color.
        percents - an array of integers between 0 and 100 specifying the percent of the width/height of the widget at which the color should change; the size of the percents array must be one less than the size of the colors array.
        vertical - indicate the direction of the gradient. True is vertical and false is horizontal.
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        • ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent
        Since:
        3.0
      • setBackground

        public void setBackground​(org.eclipse.swt.graphics.Image image)
        Set the image to be drawn in the background of the label.
        Parameters:
        image - the image to be drawn in the background
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      • setFont

        public void setFont​(org.eclipse.swt.graphics.Font font)
        Overrides:
        setFont in class org.eclipse.swt.widgets.Canvas
      • setImage

        public void setImage​(org.eclipse.swt.graphics.Image image)
        Set the label's Image. The value null clears it.
        Specified by:
        setImage in interface ICalendarableItemControl
        Parameters:
        image - the image to be displayed in the label or null
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      • setText

        public void setText​(java.lang.String text)
        Set the label's text. The value null clears it.
        Specified by:
        setText in interface ICalendarableItemControl
        Parameters:
        text - the text to be displayed in the label or null
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      • setToolTipText

        public void setToolTipText​(java.lang.String string)
        Specified by:
        setToolTipText in interface ICalendarableItemControl
        Overrides:
        setToolTipText in class org.eclipse.swt.widgets.Control
      • shortenText

        protected java.lang.String shortenText​(org.eclipse.swt.graphics.GC gc,
                                               java.lang.String t,
                                               int width)
        Shorten the given text t so that its length doesn't exceed the given width. The default implementation replaces characters in the center of the original string with an ellipsis ("..."). Override if you need a different strategy.
        Parameters:
        gc - the gc to use for text measurement
        t - the text to shorten
        width - the width to shorten the text to, in pixels
        Returns:
        the shortened text
      • splitString

        private java.lang.String[] splitString​(java.lang.String text)