# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # # FORMAT_INVALID = nil # A {Wx::DataObject} represents data that can be copied to or from the clipboard, or dragged and dropped. # The important thing about {Wx::DataObject} is that this is a 'smart' piece of data unlike 'dumb' data containers such as memory buffers or files. Being 'smart' here means that the data object itself should know what data formats it supports and how to render itself in each of its supported formats. # A supported format, incidentally, is exactly the format in which the data can be requested from a data object or from which the data object may be set. In the general case, an object may support different formats on 'input' and 'output', i.e. it may be able to render itself in a given format but not be created from data on this format or vice versa. {Wx::DataObject} defines the {Wx::DataObject::Direction} enumeration type which distinguishes between them. # See {Wx::DataFormat} documentation for more about formats. # Not surprisingly, being 'smart' comes at a price of added complexity. This is reasonable for the situations when you really need to support multiple formats, but may be annoying if you only want to do something simple like cut and paste text. # To provide a solution for both cases, wxWidgets has two predefined classes which derive from {Wx::DataObject}: {Wx::DataObjectSimple} and {Wx::DataObjectComposite}. {Wx::DataObjectSimple} is the simplest {Wx::DataObject} possible and only holds data in a single format (such as HTML or text) and {Wx::DataObjectComposite} is the simplest way to implement a {Wx::DataObject} that does support multiple formats because it achieves this by simply holding several {Wx::DataObjectSimple} objects. # So, you have several solutions when you need a {Wx::DataObject} class (and you need one as soon as you want to transfer data via the clipboard or drag and drop): # # - Use one of the built-in classes. # # - You may use {Wx::TextDataObject}, {Wx::BitmapDataObject} {Wx::FileDataObject}, {Wx::URLDataObject} in the simplest cases when you only need to support one format and your data is either text, bitmap or list of files. # - Use {Wx::DataObjectSimple} # # - Deriving from {Wx::DataObjectSimple} is the simplest solution for custom data - you will only support one format and so probably won't be able to communicate with other programs, but data transfer will work in your program (or between different instances of it). # - Use {Wx::DataObjectComposite} # # - This is a simple but powerful solution which allows you to support any number of formats (either standard or custom if you combine it with the previous solution). # - Use {Wx::DataObject} directly # # - This is the solution for maximum flexibility and efficiency, but it is also the most difficult to implement. # # Please note that the easiest way to use drag and drop and the clipboard with multiple formats is by using {Wx::DataObjectComposite}, but it is not the most efficient one as each {Wx::DataObjectSimple} would contain the whole data in its respective formats. Now imagine that you want to paste 200 pages of text in your proprietary format, as well as Word, RTF, HTML, Unicode and plain text to the clipboard and even today's computers are in trouble. For this case, you will have to derive from {Wx::DataObject} directly and make it enumerate its formats and provide the data in the requested format on demand. # Note that neither the GTK+ data transfer mechanisms for clipboard and drag and drop, nor OLE data transfer, copies any data until another application actually requests the data. This is in contrast to the 'feel' offered to the user of a program who would normally think that the data resides in the clipboard after having pressed 'Copy' - in reality it is only declared to be available. # You may also derive your own data object classes from {Wx::CustomDataObject} for user-defined types. The format of user-defined data is given as a mime-type string literal, such as "application/word" or "image/png". These strings are used as they are under Unix (so far only GTK+) to identify a format and are translated into their Windows equivalent under Win32 (using the OLE IDataObject for data exchange to and from the clipboard and for drag and drop). Note that the format string translation under Windows is not yet finished. # Each class derived directly from {Wx::DataObject} must override and implement all of its functions which are pure virtual in the base class. The data objects which only render their data or only set it (i.e. work in only one direction), should return 0 from {Wx::DataObject#get_format_count}. # # === # # Category: Clipboard and Drag & Drop # @see Drag and Drop Overview # @see Drag & Drop Sample # @see Wx::FileDataObject # @see Wx::TextDataObject # @see Wx::BitmapDataObject # @see Wx::CustomDataObject # @see Wx::DropTarget # @see Wx::DropSource # @see Wx::TextDropTarget # @see Wx::FileDropTarget # # class DataObject < ::Object # # # # class Direction < Wx::Enum # Format is supported by {Wx::DataObject#get_data_here} # Get = Wx::DataObject::Direction.new(1) # Format is supported by {Wx::DataObject#set_data} # Set = Wx::DataObject::Direction.new(2) # Format is supported by both {Wx::DataObject#get_data_here} and {Wx::DataObject#set_data} (unused currently) # Both = Wx::DataObject::Direction.new(3) end # Direction # Constructor. # @return [Wx::DataObject] def initialize; end # Copies all formats supported in the given direction dir to the array pointed to by formats. # There must be enough space for GetFormatCount(dir) formats in it. # @param dir [Wx::wxDataObject::Direction] # @return [Array] def get_all_formats(dir=Wx::RTC::RichTextBufferDataObject::Direction::Get) end alias_method :all_formats, :get_all_formats # The method will write the data of the format format to the buffer buf. # In other words, copy the data from this object in the given format to the supplied buffer. Returns true on success, false on failure. # @param format [Wx::DataFormat] # @return [String] def get_data_here(format) end alias_method :data_here, :get_data_here # Returns the number of available formats for rendering or setting the data. # @param dir [Wx::wxDataObject::Direction] # @return [Integer] def get_format_count(dir=Wx::RTC::RichTextBufferDataObject::Direction::Get) end alias_method :format_count, :get_format_count # Returns the preferred format for either rendering the data (if dir is Get, its default value) or for setting it. # Usually this will be the native format of the {Wx::DataObject}. # @param dir [Wx::wxDataObject::Direction] # @return [Wx::DataFormat] def get_preferred_format(dir=Wx::RTC::RichTextBufferDataObject::Direction::Get) end alias_method :preferred_format, :get_preferred_format # Set the data in the format format of the length len provided in the buffer buf. # In other words, copy length bytes of data from the buffer to this data object. # # true on success, false on failure. # @param format [Wx::DataFormat] The format for which to set the data. # @param buf [String] Non-NULL pointer to the data. # @return [Boolean] def set_data(format, buf) end # Returns true if this format is supported. # @param format [Wx::DataFormat] # @param dir [Wx::wxDataObject::Direction] # @return [Boolean] def is_supported(format, dir=Wx::RTC::RichTextBufferDataObject::Direction::Get) end alias_method :supported?, :is_supported end # DataObject class DataObjectSimple < DataObject # Constructor accepts the supported format (none by default) which may also be set later with {Wx::DataObjectSimple#set_format}. # @param format [Wx::DataFormat] # @return [Wx::DataObjectSimple] def initialize(format=Wx::FORMAT_INVALID) end # Returns the (one and only one) format supported by this object. # It is assumed that the format is supported in both directions. # @return [Wx::DataFormat] def get_format; end alias_method :format, :get_format end # DataObjectSimple # {Wx::DataObjectComposite} is the simplest {Wx::DataObject} derivation which may be used to support multiple formats. # It contains several {Wx::DataObjectSimple} objects and supports any format supported by at least one of them. Only one of these data objects is preferred (the first one if not explicitly changed by using the second parameter of {Wx::DataObjectComposite#add}) and its format determines the preferred format of the composite data object as well. # See {Wx::DataObject} documentation for the reasons why you might prefer to use {Wx::DataObject} directly instead of {Wx::DataObjectComposite} for efficiency reasons. # This example shows how a composite data object capable of storing either bitmaps or file names (presumably of bitmap files) can be initialized and used: # # ```ruby # class MyDropTarget < Wx::DropTarget # # def initialize # dataobj = Wx::DataObjectComposite.new # dataobj.add(Wx::BitmapDataObject.new, true) # dataobj.add(Wx::FileDataObject.new) # set_data_object(dataobj) # end # # def on_data(x, y, defaultDragResult) # return Wx::DragNone unless get_data # # dataobj_comp = get_data_object # # format = dataobj_comp.get_received_format # dataobj = dataobj_comp.get_object(format) # case format.get_type # when Wx::DataFormatId::DF_BITMAP # # dataobj is Wx::BitmapDataObject # # ... use dataobj.get_bitmap ... # # when Wx::DataFormatId::DF_FILENAME # # dataobj is Wx::FileDataObject # # ... use dataobj->GetFilenames() ... # # else # Wx.log_error("unexpected data object format") # end # # defaultDragResult # end # # end # ``` # # === # # Category: Clipboard and Drag & Drop # @see Drag and Drop Overview # @see Wx::DataObject # @see Wx::DataObjectSimple # @see Wx::FileDataObject # @see Wx::TextDataObject # @see Wx::BitmapDataObject # # class DataObjectComposite < DataObject # The default constructor. # @return [Wx::DataObjectComposite] def initialize; end # Adds the dataObject to the list of supported objects and it becomes the preferred object if preferred is true. # @param dataObject [Wx::DataObjectSimple] # @param preferred [Boolean] # @return [void] def add(dataObject, preferred=false) end # Report the format passed to the {Wx::DataObjectComposite#set_data} method. # This should be the format of the data object within the composite that received data from the clipboard or the DnD operation. You can use this method to find out what kind of data object was received. # @return [Wx::DataFormat] def get_received_format; end alias_method :received_format, :get_received_format # Returns the pointer to the object which supports the passed format for the specified direction. # NULL is returned if the specified format is not supported for this direction dir. The returned pointer is owned by {Wx::DataObjectComposite} itself and shouldn't be deleted by caller. # @param format [Wx::DataFormat] # @param dir [Wx::wxDataObject::Direction] # @return [Wx::DataObjectSimple] def get_object(format, dir=Wx::DataObject::Get) end alias_method :object, :get_object end # DataObjectComposite # {Wx::BitmapDataObject} is a specialization of {Wx::DataObject} for bitmap data. # It can be used without change to paste data into the {Wx::Clipboard} or a {Wx::DropSource}. A user may wish to derive a new class from this class for providing a bitmap on-demand in order to minimize memory consumption when offering data in several formats, such as a bitmap and GIF. # This class may be used as is, but {Wx::BitmapDataObject#get_bitmap} may be overridden to increase efficiency. # === # # Category: Clipboard and Drag & Drop # @see Drag and Drop Overview # @see Wx::DataObject # @see Wx::DataObjectSimple # @see Wx::FileDataObject # @see Wx::TextDataObject # @see Wx::DataObject # # class BitmapDataObject < DataObjectSimple # Constructor, optionally passing a bitmap (otherwise use {Wx::BitmapDataObject#set_bitmap} later). # @param bitmap [Wx::Bitmap] # @return [Wx::BitmapDataObject] def initialize(bitmap=Wx::NULL_BITMAP) end # Returns the bitmap 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 bitmap form from the {Wx::Clipboard}. # @return [Wx::Bitmap] def get_bitmap; end alias_method :bitmap, :get_bitmap # Sets the bitmap associated with the data object. # This method is called when the data object receives data. Usually there will be no reason to override this function. # @param bitmap [Wx::Bitmap] # @return [void] def set_bitmap(bitmap) end alias_method :bitmap=, :set_bitmap end # BitmapDataObject # {Wx::FileDataObject} is a specialization of {Wx::DataObject} for file names. # The program works with it just as if it were a list of absolute file names, but internally it uses the same format as Explorer and other compatible programs under Windows or GNOME/KDE file manager under Unix which makes it possible to receive files from them using this class. # === # # Category: Clipboard and Drag & Drop # @see Wx::DataObject # @see Wx::DataObjectSimple # @see Wx::TextDataObject # @see Wx::BitmapDataObject # @see Wx::DataObject # # class FileDataObject < DataObjectSimple # Constructor. # @return [Wx::FileDataObject] def initialize; end # Adds a file to the file list represented by this data object (Windows only). # @param file [String] # @return [void] def add_file(file) end # Returns the array of file names. # @return [Wx::ArrayString] def get_filenames; end alias_method :filenames, :get_filenames end # FileDataObject # {Wx::TextDataObject} is a specialization of {Wx::DataObjectSimple} for text data. # It can be used without change to paste data into the {Wx::Clipboard} or a {Wx::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, {Wx::TextDataObject#get_text_length} and {Wx::TextDataObject#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 {Wx::Strings} is already a very efficient operation (data is not actually copied because {Wx::Strings} are reference counted). # === # # Category: Clipboard and Drag & Drop # @see Drag and Drop Overview # @see Wx::DataObject # @see Wx::DataObjectSimple # @see Wx::FileDataObject # @see Wx::BitmapDataObject # # class TextDataObject < DataObjectSimple # Constructor, may be used to initialise the text (otherwise {Wx::TextDataObject#set_text} should be used later). # @param text [String] # @return [Wx::TextDataObject] def initialize(text=('')) end # 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 {Wx::Clipboard}. # @return [String] def get_text; end alias_method :text, :get_text # Returns the data size. # By default, returns the size of the text data set in the constructor or using {Wx::TextDataObject#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. # @return [Integer] def get_text_length; end alias_method :text_length, :get_text_length # 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. # @param strText [String] # @return [void] def set_text(strText) end alias_method :text=, :set_text end # TextDataObject # {Wx::CustomDataObject} is a specialization of {Wx::DataObjectSimple} for some application-specific data in arbitrary (either custom or one of the standard ones). # The only restriction is that it is supposed that this data can be copied bitwise (i.e. with memcpy()), so it would be a bad idea to make it contain a C++ object (though C struct is fine). # By default, {Wx::CustomDataObject} stores the data inside in a buffer. To put the data into the buffer you may use either {Wx::CustomDataObject#set_data} or {Wx::CustomDataObject#take_data} depending on whether you want the object to make a copy of data or not. # This class may be used as is, but if you don't want store the data inside the object but provide it on demand instead, you should override {Wx::CustomDataObject#get_size}, {Wx::CustomDataObject#get_data} and {Wx::CustomDataObject#set_data} (or may be only the first two or only the last one if you only allow reading/writing the data). # === # # Category: Clipboard and Drag & Drop # @see Wx::DataObject # # class CustomDataObject < DataObjectSimple # The constructor accepts a format argument which specifies the (single) format supported by this object. # If it isn't set here, {Wx::DataObjectSimple#set_format} should be used. # @param format [Wx::DataFormat] # @return [Wx::CustomDataObject] def initialize(format=Wx::FORMAT_INVALID) end end # CustomDataObject # {Wx::ImageDataObject} is a specialization of {Wx::DataObject} for image data. # It can be used e.g. when you need to put on and retrieve from the clipboard a {Wx::Image} with its metadata (like image resolution). # # === # # Category: Clipboard and Drag & Drop # @see Drag and Drop Overview # @see Wx::DataObject # @see Wx::CustomDataObject # @see Wx::BitmapDataObject # # class ImageDataObject < CustomDataObject # Constructor, optionally passing an image (otherwise use {Wx::ImageDataObject#set_image} later). # @param image [Wx::Image] # @return [Wx::ImageDataObject] def initialize(image=Wx::NULL_IMAGE) end # Returns the image associated with the data object. # @return [Wx::Image] def get_image; end alias_method :image, :get_image # Sets the image stored by the data object. # @param image [Wx::Image] # @return [void] def set_image(image) end alias_method :image=, :set_image end # ImageDataObject # {Wx::URLDataObject} is a {Wx::DataObject} containing an URL and can be used e.g. # when you need to put an URL on or retrieve it from the clipboard: # # ```ruby # Wx::Clipboard.open { |clip| clip.place(Wx::URLDataObject.new(url)) # ``` # # The actual base class of this class is not always {Wx::DataObject} itself, but rather either {Wx::DataObjectComposite} in wxMSW and wxGTK or {Wx::TextDataObject} in the other ports. Please don't rely on the exact base class, it is not guaranteed that it won't change in the future. # # === # # Category: Clipboard and Drag & Drop # @see Drag and Drop Overview # @see Wx::DataObject # # class URLDataObject < DataObject # Constructor, may be used to initialize the URL. # If url is empty, {Wx::URLDataObject#set_url} can be used later. # @param url [String] # @return [Wx::URLDataObject] def initialize(url=('')) end # Returns the URL stored by this object, as a string. # @return [String] def get_url; end alias_method :url, :get_url # Sets the URL stored by this object. # @param url [String] # @return [void] def set_url(url) end alias_method :url=, :set_url end # URLDataObject end