.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2017 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.richtext.RichTextSelection:

==========================================================================================================================================
|phoenix_title|  **wx.richtext.RichTextSelection**
==========================================================================================================================================

Stores selection information.          

The selection does not have to be contiguous, though currently non-contiguous selections are only supported for a range of table cells (a geometric block of cells can consist of a set of non-contiguous positions). 

The selection consists of an array of ranges, and the container that is the context for the selection. It follows that a single selection object can only represent ranges with the same parent container. 







         



.. seealso:: :ref:`wx.richtext.RichTextBuffer`, :ref:`wx.richtext.RichTextCtrl`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>RichTextSelection</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.richtext.RichTextSelection_inheritance.png" alt="Inheritance diagram of RichTextSelection" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.richtext.RichTextSelection.html" title="wx.richtext.RichTextSelection" alt="" coords="5,5,208,35"/> </map> 
   </p>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.richtext.RichTextSelection.__init__`                                  Copy constructor.
:meth:`~wx.richtext.RichTextSelection.Add`                                       Adds a range to the selection.
:meth:`~wx.richtext.RichTextSelection.Copy`                                      Copies from `sel`.
:meth:`~wx.richtext.RichTextSelection.GetContainer`                              Returns the container for which the selection is valid.
:meth:`~wx.richtext.RichTextSelection.GetCount`                                  Returns the number of ranges in the selection.
:meth:`~wx.richtext.RichTextSelection.GetRange`                                  Returns the range at the given index.
:meth:`~wx.richtext.RichTextSelection.GetRanges`                                 Returns the selection ranges.
:meth:`~wx.richtext.RichTextSelection.GetSelectionForObject`                     Returns the selection appropriate to the specified object, if any; returns an empty array if none at the level of the object's container.
:meth:`~wx.richtext.RichTextSelection.IsValid`                                   Returns ``True`` if the selection is valid.
:meth:`~wx.richtext.RichTextSelection.Reset`                                     Resets the selection.
:meth:`~wx.richtext.RichTextSelection.Set`                                       Sets the selection.
:meth:`~wx.richtext.RichTextSelection.SetContainer`                              Sets the container for which the selection is valid.
:meth:`~wx.richtext.RichTextSelection.SetRange`                                  Sets a single range.
:meth:`~wx.richtext.RichTextSelection.SetRanges`                                 Sets the selection ranges.
:meth:`~wx.richtext.RichTextSelection.WithinSelection`                           Returns ``True`` if the given position is within the selection.
:meth:`~wx.richtext.RichTextSelection.__nonzero__`                               
:meth:`~wx.richtext.RichTextSelection.__eq__`                                    Equality operator.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.richtext.RichTextSelection.Container`                                 See :meth:`~wx.richtext.RichTextSelection.GetContainer` and :meth:`~wx.richtext.RichTextSelection.SetContainer`
:attr:`~wx.richtext.RichTextSelection.Count`                                     See :meth:`~wx.richtext.RichTextSelection.GetCount`
:attr:`~wx.richtext.RichTextSelection.Range`                                     See :meth:`~wx.richtext.RichTextSelection.GetRange` and :meth:`~wx.richtext.RichTextSelection.SetRange`
:attr:`~wx.richtext.RichTextSelection.Ranges`                                    See :meth:`~wx.richtext.RichTextSelection.GetRanges` and :meth:`~wx.richtext.RichTextSelection.SetRanges`
:attr:`~wx.richtext.RichTextSelection.m_container`                               A public C++ attribute of type :ref:`~wx.richtext.RichTextParagraphLayoutBox`.
:attr:`~wx.richtext.RichTextSelection.m_ranges`                                  A public C++ attribute of type ``RichTextRangeArray``.
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.richtext.RichTextSelection(object)

   **Possible constructors**::

       RichTextSelection(sel)
       
       RichTextSelection(range, container)
       
       RichTextSelection()
       
   
   Stores selection information.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self, sel)`
      
      Copy constructor.                  
      
      
      :param `sel`: 
      :type `sel`: wx.richtext.RichTextSelection
      
      
      
      
      
      
      **~~~**

      
      **__init__** `(self, range, container)`
      
      Creates a selection from a range and a container.                  
      
      
      :param `range`: 
      :type `range`: wx.richtext.RichTextRange
      :param `container`: 
      :type `container`: wx.richtext.RichTextParagraphLayoutBox
      
      
      
      
      
      
      **~~~**

      
      **__init__** `(self)`
      
      Default constructor.                   
      
      
      
      
      **~~~**






   .. method:: Add(self, range)

      Adds a range to the selection.                  


      :param `range`: 
      :type `range`: wx.richtext.RichTextRange







   .. method:: Copy(self, sel)

      Copies from `sel`.                  


      :param `sel`: 
      :type `sel`: wx.richtext.RichTextSelection







   .. method:: GetContainer(self)

      Returns the container for which the selection is valid.                  

      :rtype: :ref:`wx.richtext.RichTextParagraphLayoutBox`








   .. method:: GetCount(self)

      Returns the number of ranges in the selection.                  

      :rtype: `int`








   .. method:: GetRange(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **GetRange** `(self, i)`
      
      Returns the range at the given index.                  
      
      
      :param `i`: 
      :type `i`: int
      
      
      
      
      :rtype: :ref:`wx.richtext.RichTextRange`
      
      
      
      
      
      
      
      **~~~**

      
      **GetRange** `(self)`
      
      Returns the first range if there is one, otherwise ``wx.richtext.RICHTEXT_NO_SELECTION``.                  
      
      :rtype: :ref:`wx.richtext.RichTextRange`
      
      
      
      
      
      
      
      **~~~**






   .. method:: GetRanges(self)

      Returns the selection ranges.                  

      :rtype: :ref:`RichTextRangeArray`








   .. method:: GetSelectionForObject(self, obj)

      Returns the selection appropriate to the specified object, if any; returns an empty array if none at the level of the object's container.                  


      :param `obj`: 
      :type `obj`: wx.richtext.RichTextObject




      :rtype: :ref:`RichTextRangeArray`








   .. method:: IsValid(self)

      Returns ``True`` if the selection is valid.                  

      :rtype: `bool`








   .. method:: Reset(self)

      Resets the selection.                   





   .. method:: Set(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **Set** `(self, range, container)`
      
      Sets the selection.                  
      
      
      :param `range`: 
      :type `range`: wx.richtext.RichTextRange
      :param `container`: 
      :type `container`: wx.richtext.RichTextParagraphLayoutBox
      
      
      
      
      
      
      **~~~**

      
      **Set** `(self, ranges, container)`
      
      Sets the selections from an array of ranges and a container object.                  
      
      
      :param `ranges`: 
      :type `ranges`: RichTextRangeArray
      :param `container`: 
      :type `container`: wx.richtext.RichTextParagraphLayoutBox
      
      
      
      
      
      
      **~~~**






   .. method:: SetContainer(self, container)

      Sets the container for which the selection is valid.                  


      :param `container`: 
      :type `container`: wx.richtext.RichTextParagraphLayoutBox







   .. method:: SetRange(self, range)

      Sets a single range.                  


      :param `range`: 
      :type `range`: wx.richtext.RichTextRange







   .. method:: SetRanges(self, ranges)

      Sets the selection ranges.                  


      :param `ranges`: 
      :type `ranges`: RichTextRangeArray







   .. method:: WithinSelection(self, *args, **kw)



      |overload| Overloaded Implementations:

      **~~~**

      
      **WithinSelection** `(self, pos, obj)`
      
      Returns ``True`` if the given position is within the selection.                  
      
      
      :param `pos`: 
      :type `pos`: long
      :param `obj`: 
      :type `obj`: wx.richtext.RichTextObject
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      **~~~**

      
      **WithinSelection** `(self, pos)`
      
      Returns ``True`` if the given position is within the selection.                  
      
      
      :param `pos`: 
      :type `pos`: long
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      **~~~**

      
      **WithinSelection** `(pos, ranges)`
      
      Returns ``True`` if the given position is within the selection range.                  
      
      
      :param `pos`: 
      :type `pos`: long
      :param `ranges`: 
      :type `ranges`: RichTextRangeArray
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      **~~~**

      
      **WithinSelection** `(range, ranges)`
      
      Returns ``True`` if the given range is within the selection range.                  
      
      
      :param `range`: 
      :type `range`: wx.richtext.RichTextRange
      :param `ranges`: 
      :type `ranges`: RichTextRangeArray
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      **~~~**






   .. method:: __nonzero__(self)



      :rtype: `int`








   .. method:: __eq__(self)

      Equality operator.                  


      :param `sel`: 
      :type `sel`: wx.richtext.RichTextSelection







   .. attribute:: Container

      See :meth:`~wx.richtext.RichTextSelection.GetContainer` and :meth:`~wx.richtext.RichTextSelection.SetContainer`


   .. attribute:: Count

      See :meth:`~wx.richtext.RichTextSelection.GetCount`


   .. attribute:: Range

      See :meth:`~wx.richtext.RichTextSelection.GetRange` and :meth:`~wx.richtext.RichTextSelection.SetRange`


   .. attribute:: Ranges

      See :meth:`~wx.richtext.RichTextSelection.GetRanges` and :meth:`~wx.richtext.RichTextSelection.SetRanges`


   .. attribute:: m_container

      A public C++ attribute of type :ref:`~wx.richtext.RichTextParagraphLayoutBox`.


   .. attribute:: m_ranges

      A public C++ attribute of type ``RichTextRangeArray``.

