Class TextSelection


  • public class TextSelection
    extends TextRange
    Class TextSelection represents a range of selected text. As such, it extends class TextRange withy selection colour information. One can pass a text selection object to the text drawing method to render text with selection highlighting. Note that a multi-view application would maintain a separate selection for each view.
    • Constructor Detail

      • TextSelection

        public TextSelection()
        Default constructor.

        Construct a text selection object with no initial stream association. The default foreground colour is white and the default background colour is black.

      • TextSelection

        public TextSelection​(TextSelection oSource)
        Copy constructor.

        Copy the source selection object including range and colours.

        Parameters:
        oSource - - Source selection to copy.
      • TextSelection

        public TextSelection​(GFXColour oColour,
                             GFXColour oColourBg,
                             TextStream poStream)
        Constructor with colours and stream.

        Construct a text selection object associated with the given stream and using the given colours. The selection range initially covers the entire text stream.

        Parameters:
        oColour - - Foreground colour.
        oColourBg - - Background colour.
        poStream - - (optional) Text stream for association. NULL (default) creates the text selection with no initial association.
    • Method Detail

      • colour

        public GFXColour colour()
        Obtain the current foreground colour of the selection.
        Returns:
        Foreground colour.
      • colour

        public void colour​(GFXColour oNewColour)
        Change the foreground colour of the selection.

        Note: changing the colour does not automatically cause an invalidation of the selected text in any view.

        Parameters:
        oNewColour - - New foreground colour.
      • colourBg

        public GFXColour colourBg()
        Obtain the current background colour of the selection.
        Returns:
        Background colour.
      • colourBg

        public void colourBg​(GFXColour oNewColourBg)
        Change the background colour of the selection.

        Note: changing the colour does not automatically cause an invalidation of the selected text in any view.

        Parameters:
        oNewColourBg - - New background colour.
      • copyFrom

        public void copyFrom​(TextSelection oSource)
        Assignment operator.

        Copies all attrbutes of the source selection, including underlying text range and colours.

        Parameters:
        oSource - - Source selection to copy.
      • equals

        public boolean equals​(Object object)
        Equality comparison.

        Two selections are considered equal of the represent the same range in the same text stream, and have the same foreground and background colours.

        Overrides:
        equals in class TextRange
        Parameters:
        object - the object to compare against.
        Returns:
        TRUE if the text selections are equal; FALSE if not.