Clipboard
 

 < Home   < Developers   < Development Support   < Documentation

6 Clipboard


 Table of Contents  |  < Previous  |  Next >  |  Index
   
   

Title -
Palm OS® Programmer's API Reference

Part I: User Interface

6 Clipboard

Clipboard Data Structures

ClipboardFormatType

Clipboard Functions

ClipboardAddItem

ClipboardAppendItem

ClipboardGetItem

       

This chapter provides reference material for the clipboard API defined in Clipboard.h. It covers:

Clipboard Data Structures

Clipboard Functions

Clipboard Data Structures

ClipboardFormatType

The ClipboardFormatType enum specifies the type of data to add to the clipboard or retrieve from the clipboard.

enum clipboardFormats {  
  clipboardText,  
  clipboardInk,  
  clipboardBitmap }; 
typedef enum clipboardFormats  
  ClipboardFormatType; 

Value Descriptions

clipboardText
Textual data. This is the most commonly used clipboard.
clipboardInk
Reserved.
clipboardBitmap
Bitmap data.

Clipboards for each type of data are separately maintained. That is, if you add a string of text to the clipboard, then add a bitmap, then ask to retrieve a clipboardText item from the clipboard, you will receive the string you added before the bitmap; the bitmap does not overwrite textual data and vice versa.

Clipboard Functions

ClipboardAddItem

Purpose

Add the item passed to the specified clipboard. Replaces the current item (if any) of that type.

Prototype

void ClipboardAddItem (const ClipboardFormatType format, const void *ptr, UInt16 length)

Parameters

-> formatText, ink, bitmap, etc. See ClipboardFormatType.
-> ptrPointer to the item to place on the clipboard.
-> lengthSize in bytes of the item to place on the clipboard.

Result

Returns nothing.

Comments

The clipboard makes a copy of the data that you pass to this function. Thus, you may free any data that you've passed to the clipboard without destroying the contents of the clipboard. You may also add constant data or stack-based data to the clipboard.

See Also

FldCut, FldCopy

ClipboardAppendItem

Purpose

Append data to the item on the clipboard.

Prototype

Err ClipboardAppendItem (const ClipboardFormatType format, const void *ptr, UInt16 length)

Parameters

-> formatText, ink, bitmap, etc. See ClipboardFormatType. This function is intended to be used only for the clipboardText format.
-> ptrPointer to the data to append to the item on the clipboard.
-> lengthSize in bytes of the data to append to the clipboard.

Result

0 upon success or memErrNotEnoughSpace if there is not enough space to append the data to the clipboard.

Comments

This function differs from ClipboardAddItem in that it does not overwrite data already on the clipboard. It allows you to create a large text item on the clipboard from several small disjointed pieces. When other applications retrieve the text from the clipboard, it's retrieved as a single unit.

This function simply appends the specified item to the item already on the clipboard without attempting to parse the format. It's assumed that you'll call it several times over a relatively short interval and that no other application will attempt to retrieve text from the clipboard before your application is finished appending.

Compatibility

Implemented only if 3.2 New Feature Set is present.

ClipboardGetItem

Purpose

Return the handle of the contents of the clipboard of a specified type and the length of a clipboard item.

Prototype

MemHandle ClipboardGetItem (const ClipboardFormatType format, UInt16 *length)

Parameters

-> formatText, ink, bitmap, etc. See ClipboardFormatType.
<- lengthThe length in bytes of the clipboard item is returned here.

Result

Handle of the clipboard item.

Comments

The handle returned is a handle to the actual clipboard chunk. It is not suitable for passing to any API that modifies memory (such as FldSetTextHandle). Consider this to be read-only access to the chunk. Copy the contents of the clipboard to your application's own storage as soon as possible and use that reference instead of the handle returned by this function.

Don't free the handle returned by this function; it is freed when a new item is added to the clipboard.

Text retrieved from the clipboard does not have a null terminator. You must use the length parameter to determine the length in bytes of the string you've retrieved.