Definitions for the Clipboard to hold Cut or Copied data for Pasting.

clipbrd.pp contains classes, types, and routines used to implement TClipboard. TClipboard encapsulates the system clipboard for supported platforms. This file is part of the Lazarus Component Library (LCL).

Gets the pre-defined clipboard format used for plain text.
Gets the pre-defined clipboard format used for bitmap images.
Gets the pre-defined clipboard format used for the LCL Picture type.
Gets the pre-defined clipboard format used for the LCL Meta-File Picture type.
Gets the pre-defined clipboard format used for the LCL Object type.
Gets the pre-defined clipboard format used for the LCL Component type.
Gets the pre-defined clipboard format used for HTML content.
Record type with the format identifier and data for cached clipboard content.
Clipboard format identifier.
Stream with the content stored for the associated clipboard format.
TClipboard
- area for holding information that has been cut or copied, ready for pasting.

TClipboard - area for holding information that has been cut or copied, ready for pasting.

The clipboard object encapsulates the Windows clipboard and the three standard Gtk selections. For each of the three clipboards/selections there is an object: PrimarySelection, SecondarySelection and Clipboard. There is no difference between the three objects except their type.

A lot of information about Clipboard Formats, including predefined formats for Delphi/Kylix compatibility, is found in the LCLType unit, at TClipboardFormat, TClipboardType, ClipboardTypeName, TPredefinedClipboardFormat, PredefinedClipboardMimeTypes

TClipboardFormat, TClipboardType, ClipboardTypeName, TPredefinedClipboardFormat, PredefinedClipboardMimeTypes
Acquires ownership of the Clipboard and adds a format.

If not already done, this function acquires ownership of the clipboard. Acquiring ownership clears the clipboard. If the format already exists, it replaces the old content. Otherwise, it is added. The format CF_TEXT is handled by AsText and SetTextBuf. Use those functions instead.

True if format added correctly.
Copies properties from the specified persistent object to the clipboard.

Assign is an overridden method in TClipboard used to copy properties from the persistent object in Source to the clipboard instance. It provides support for using TPicture and TGraphic types in Source, and calls private methods used to copy the properties specific to the class types. If Source is not one of these class types, the inherited method is called.

TPersistent.Assign
Persistent object with the property values copied in the method.
Copies property values into the specified persistent object.
TPersistent
Persistent object where the properties in the class instance are stored.
Clear
the clipboard.
Close
down the clipboard.
Create
- Constructor: make a new instance of a clipboard.
AClipboardType
- optional argument specifying type of clipboard to be created.
Destructor for the class instance.

Destroy is the overridden destructor for the class instance. It frees resources allocated in the class instance, and calls the inherited destructor prior to exiting from the method.

FindPictureFormatID
- search for the first format ID that is a graphic.
Returns a Clipboard format.
FindFormatID
- find a Format ID that has the specified name.
Returns a Clipboard format.
GetComponent
- reads a component from the clipboard.
GetFormat
- read information on format from the clipboard.
True if Format found.
SupportedFormats
- fills a stringlist with the names of the supported MIME types.
GetTextBuf
- reads text from the clipboard and returns the number of characters.
Number of characters in text buffer.
HasFormat
- look up the list to see if the format is supported. If a TPicture format is specified, all graphic formats are searched.
True if format is supported.
HasFormatName
- checks if data have format with specified name.
True if named format found.
HasPictureFormat
- checks whether data are formatted as a picture.
True if formatted as picture.
Open
the clipboard to receive and transmit data.
Write specified component to the Clipboard.
Component stored in the clipboard.
Stores the specified Component in the clipboard.

SetComponentAsText is a Boolean function used to store the specified Component to the TClipboard instance.

SetComponentAsText calls the WriteComponentAsTextToStream routine in the lresources.pp unit to store Component to a TMemoryStream. The String value in the stream is assigned to the AsText property to store the value in the clipboard.

SetComponentAsText calls BeginUpdate prior to storing the component to the clipboard, and EndUpdate when the operation has been completed. The return value for the method is the value returned from EndUpdate.

.WriteComponentAsTextToStream TMemoryStream
Component instance stored to the clipboard in the method.
True when no other updates are pending for the clipboard, and its ownership has not changed.
Sets the clipboard format to the specified identifier and copies the value in Stream.

SetFormat is a Boolean function used to select the clipboard format for the format identifier in FormatID, and load the content in Stream. It calls AddFormat to select the supported format in FormatID, and to cache values in Stream to its TClipboardData record instance.

SetFormat calls BeginUpdate prior to activating the format and loading its value. It calls EndUpdate when the operation has been completed. The value from EndUpdate is used as the return value for the method.

SetFormat is called when TGraphic or TPicture class instances are loaded to the clipboard in the Assign method.

Format identifier needed for the specified stream.
Stream with the content loaded in the method.
SetSupportedFormats
- set all supported formats at once.

SetSupportedFormats sets all supported formats at once All data will be empty. This procedure is useful if setting the OnRequest event to put the data on the fly.

Example: Using the PrimarySelection from synedit.pp.

procedure TCustomSynEdit.AcquirePrimarySelection; var FormatList: TClipboardFormat; begin if (not SelAvail) or (PrimarySelection.OnRequest=@PrimarySelectionRequest) then exit; FormatList:=CF_TEXT; PrimarySelection.SetSupportedFormats(1,@FormatList); PrimarySelection.OnRequest:=@PrimarySelectionRequest; end;
Loads the clipboard buffer using the text in the specified PChar value.

SetTextBuf is a method used to load the text specified in Buffer into the clipboard. Buffer is a PChar type, and when not assigned (Nil), is set to #0 in the method. Its value is loaded in the TClipboardData instances used for the text clipboard format.

SetTextBuf
PChar value loaded into the clipboard.
AsText
- holds the textual data in the clipboard as a string.
Puts a HTML string on the clipboard.

Puts a HTML string on the clipboard. On Windows it will automatically insert a ClipBoard Header. The procedure can also (optionally) set a provided plaintext representation of HTML on the ClipBoard.

The HTML string that shall be put on the ClipBoard.
Optional plain text (string) representation of the HTML.
The optional string parameter PlainText is meant to be a plain text representation of the HTML string. The user is responsible for the contents of this variable. The value of PlainText can later be retrieved via the AsText property. If PlainText is an empty string, no plain text is added to the ClipBoard, nor is the current plain text content of the ClipBoard cleared.
Retrieves the HTML content of the clipboard (if available).
Retrieves the HTML content of the clipboard (if available). On Windows it will automatically remove the clipboard header that Windows inserts. The resulting HTML string will be UTF-8 encoded.
The HTML content of the clipboard as a string. Empty string if the function fails.
ClipboardType
- ctPrimarySelection, ctSecondarySelection, ctClipboard.
FormatCount
- the number of formats available.
Formats
- the formats being used in the current clipboard.

Formats - the formats being used in the current clipboard

You can read the formats with this property one by one. But this will result in many requests, which can be very slow (especially on terminals).

Better use "SupportedFormats".

OnRequest
- event handler for a request for clipboard data.

OnRequest - event handler for a request for clipboard data.

If the clipboard has the ownership, this event will be called each time data are requested from the clipboard by the application or another application.

There is one special case:

If the clipboard loses ownership the OnRequest event will be called with FormatID=0. This event will be erased on lost of ownership.

If the OnRequest event was already set before, the prior method will be called with FormatID=0 to be notified of the loss.

PrimarySelection
- the first selection if multiple clipboards exist.

The PrimarySelection is available on platforms like X. Normally when the user selects some text with the mouse the primary selection is set and when the user clicks the middle mouse button the text is copied to the mouse position. On platforms without multiple clipboards, the PrimarySelection still works in the LCL application, but does not communicate with other applications.

Returns a variable of type TClipboard.
SecondarySelection
- the second selection if multiple clipboards exist.

The SecondarySelection is available on platforms like X. See PrimarySelection for more details. There is no standard how to use the secondary selection, so it is free to use. X supports a dozen more selections, but they are not supported by the LCL.

Returns a variable of type TClipboard.
Clipboard
the function called to access the clipboard with an optional type specifier.

The Clipboard is available on most platforms and normally used by Copy/Paste.

Returns a variable of type TClipboard.
ClipboardType
- optional argument to specify type of clipboard.
SetClipboard
- sets up and returns a NewClipboard, with an optional type specifier.
Returns a variable of type TClipboard.
ClipboardType
- optional argument to specify type of clipboard.
NewClipboard
- the new clipboard to be set up.
FreeAllClipboards
- frees all existing clipboards, releasing their resources.
RegisterClipboardFormat
add the supplied format name to the register of clipboard formats.
Returns the registered clipboard format.
The name of the required format as a string.
GetComponentAsText
- read the component as text, if supported.