Class: Wx::TextDataObject

Inherits:
DataObjectSimple show all
Defined in:
lib/wx/doc/gen/data_object.rb

Overview

TextDataObject is a specialization of DataObjectSimple for text data.

It can be used without change to paste data into the Clipboard or a DropSource. A user may wish to derive a new class from this class for providing text on-demand in order to minimize memory consumption when offering data in several formats, such as plain text and RTF because by default the text is stored in a string in this class, but it might as well be generated when requested. For this, #get_text_length and #get_text will have to be overridden. Note that if you already have the text inside a string, you will not achieve any efficiency gain by overriding these functions because copying Strings is already a very efficient operation (data is not actually copied because Strings are reference counted).

Category: Clipboard and Drag & Drop

See Also:

Requires:

  • USE_CLIPBOARD

Instance Method Summary collapse

Methods inherited from DataObjectSimple

#get_data_here, #get_data_size, #get_format, #set_data

Methods inherited from DataObject

#get_all_formats, #get_data_here, #get_data_size, #get_format_count, #get_preferred_format, #is_supported, #set_data

Constructor Details

#initialize(text = ('')) ⇒ Wx::TextDataObject

Constructor, may be used to initialise the text (otherwise #set_text should be used later).

Parameters:

  • text (String) (defaults to: (''))


320
# File 'lib/wx/doc/gen/data_object.rb', line 320

def initialize(text=('')) end

Instance Method Details

#get_textString Also known as: text

Returns the text associated with the data object.

You may wish to override this method when offering data on-demand, but this is not required by wxWidgets’ internals. Use this method to get data in text form from the Clipboard.

Returns:

  • (String)


326
# File 'lib/wx/doc/gen/data_object.rb', line 326

def get_text; end

#get_text_lengthInteger Also known as: text_length

Returns the data size.

By default, returns the size of the text data set in the constructor or using #set_text. This can be overridden to provide text size data on-demand. It is recommended to return the text length plus 1 for a trailing zero, but this is not strictly required.

Returns:

  • (Integer)


333
# File 'lib/wx/doc/gen/data_object.rb', line 333

def get_text_length; end

#set_text(strText) ⇒ void Also known as: text=

This method returns an undefined value.

Sets the text associated with the data object.

This method is called when the data object receives the data and, by default, copies the text into the member variable. If you want to process the text on the fly you may wish to override this function.

Parameters:

  • strText (String)


341
# File 'lib/wx/doc/gen/data_object.rb', line 341

def set_text(strText) end