Next Page > Hide TOC

Legacy Documentclose button

Important: The List Manager is deprecated in Mac OS X version 10.5 and later. The replacement API is the Data Browser. For more information, see Data Browser Programming Guide.

List Manager Reference (Not Recommended)

Framework
Carbon/Carbon.h
Declared in
Lists.h

Overview

Important: The List Manager is deprecated in Mac OS X version 10.5 and later. The replacement API is the Data Browser. For more information, see Data Browser Programming Guide.

In Mac OS 9 and earlier, the List Manager allowed applications to create, manipulate, and display scrolling lists of data items in a window. The List Manager was included in Carbon to facilitate the porting of legacy applications to Mac OS X. For Carbon applications, the Data Browser provides a more convenient way to present data for browsing and to create easily customized lists whose columns can be sorted, moved, and resized.

You should not use the List Manager in new application development.

Functions by Task

Accessing and Manipulating Cell Data

Adding and Deleting Columns and Rows To and From a List

Changing the Size of Cells and Lists

Creating and Disposing of Lists

Creating and Managing Universal Procedure Pointers

Determining or Changing the Selection

Getting Information About Cells

Modifying a List’s Appearance

Responding to Events Affecting Lists

Searching a List for a Particular Item

Miscellaneous

Callbacks

ListClickLoopProcPtr

Defines a pointer to a list click loop callback function. Your list click loop callback function overrides the standard click-loop function that is used to select cells and automatically scroll a list.

typedef Boolean (*ListClickLoopProcPtr)
(
);

If you name your function MyListClickLoopProc, you would declare it like this:

Boolean MyListClickLoopProc ();

Parameters
Return Value

A value indicating whether the LClick function should continue tracking the mouse. Your function should return TRUE if you wish LClick to continue to track the mouse, and FALSE if LClick should stop and return immediately.

Discussion

If your application defines a custom click-loop function, then the LClick function repeatedly calls the function until the user releases the mouse button. A click-loop function may perform any processing desired when it is executed.

Because no parameters are passed to the click-loop function, your click-loop function probably needs to access a global variable that contains a handle to the list record, which contains information about the location of the cursor and other information potentially of interest to a click-loop function. You might also create a global variable that stores the state of the modifier keys immediately before a call to the LClick function. You would need to set these global variables immediately before calling LClick.

The pointer to your function, which you provide in the list record structure, should be a universal procedure pointer (UPP). The definition of the UPP data type for your list click loop function is as follows:

typedef (ListClickLoopProcPtr) ListClickLoopUPP;

Before using your list click loop function, you must first create a new universal procedure pointer to it, using the NewListClickLoopUPP function, as shown here:

ListClickLoopUPP MyListClickLoopUPP;
MyListClickLoopUPP = NewListClickLoopUPP(&MyListClickLoopProc)

You then use MyListClickLoopUPP in the lClickLoop field of the ListRec structure for your list. The LClick function calls your list click loop function while the user holds down the mouse button. If you wish to call your own list click loop function, you can use the InvokeListClickLoopUPP function:

continueTracking = InvokeListClickLoopUPP(MyListClickLoopUPP);

When you are finished using your list click loop callback function, you should dispose of the universal procedure pointer associated with it, using the DisposeListClickLoopUPP function.

DisposeListClickLoopUPP(MyListClickLoopUPP);

A click-loop function does not execute at interrupt time. Instead, it is called directly by the LClick function. Thus, a click-loop function can allocate memory, and it does not need to adjust the value contained in the A5 register.

Special Considerations

A click-loop function does not execute at interrupt time. Instead, it is called directly by the LClick function. Thus, a click-loop function can allocate memory, and it does not need to adjust the value contained in the A5 register.

Availability
Declared In
Lists.h

ListDefProcPtr

Defines a pointer to a list definition callback function. Your list definition callback function defines a custom list display.

typedef void (*ListDefProcPtr) (
   SInt16 lMessage,
   Boolean lSelect,
   Rect *lRect,
   Cell lCell,
   SInt16 lDataOffset,
   SInt16 lDataLen,
   ListHandle lHandle
);

If you name your function MyListDefProc, you would declare it like this:

void MyListDefProc (
   SInt16 lMessage,
   Boolean lSelect,
   Rect * lRect,
   Cell lCell,
   SInt16 lDataOffset,
   SInt16 lDataLen,
   ListHandle lHandle
);

Parameters
lMessage

A value that identifies the operation to be performed. See “List Definition Constants.”

lSelect

Indicates whether the cell specified by the lCell parameter should be highlighted. This parameter is defined only for the lDrawMessage and lHiliteMsg messages.

lRect

A pointer to the rectangle (in local coordinates of the list’s graphics port) that encloses the specified cell. Although this parameter is defined as a pointer, your list definition function must not change the coordinates of the rectangle. This parameter is defined only for the lDrawMessage and lHiliteMsg messages.

lCell

The coordinates of the cell to be drawn or highlighted. This parameter is defined only for the lDrawMessage and lHiliteMsg messages.

lDataOffset

The location of the cell data associated with the specified cell. The location is specified as an offset from the beginning of the relocatable block referenced by the cells field of the list record. This parameter is defined only for the lDrawMessage and lHiliteMsg messages.

lDataLen

The length in bytes of the cell data associated with the specified. This parameter is defined only for the lDrawMessage and lHiliteMsg messages.

lHandle

A handle to the list for which a message is being sent. Your application can access the list’s list record, or it can call List Manager functions to manipulate the list.

Discussion

Your application can write a list definition function to customize list display. For example, you can write a list definition function to support the display of color icons. A custom list definition function must be compiled as a code resource of type 'LDEF' and added to the resource file of the application that needs to use it.

The List Manager calls your list definition function whenever an application using the function creates a new list with the LNew function, needs a cell to be drawn, needs a cell’s highlighting state to be reversed, or has called the LDispose function to dispose of a list.

The pointer to your list definition function should be a universal procedure pointer (UPP). The definition of the UPP data type for your definition function is as follows:

typedef (ListDefProcPtr) ListDefUPP;

Before using your list definition function, you must first create a new universal procedure pointer to it, using the NewListDefUPP function, as shown here:

ListDefUPP MyListDefUPP;
MyListDefUPP = NewListDefUPP(&MyListDefProc)

The List Manager automatically invokes your list definition function when a new list is created. If you wish to call your own list definition callback function, you can use the InvokeListDefUPP function:

InvokeListDefUPP(lMessage, lSelect, &lRect, lCell, lDataOffset,                      lDataLen, lHandle, MyListDefUPP)

When you are finished with your list definition function, you should dispose of the universal procedure pointer associated with it, using the DisposeListDefUPP function.

DisposeListDefUPP(MyListDefUPP);

Because a list definition function is stored in a code resource, it cannot have its own global variables that it accesses through the A5 register. (Some development systems, however, may allow code resources to access global variables through some other register, such as A4. See your development system’s documentation for more information.) If your list definition function needs access to global data, it might store a handle to such data in the refCon or userHandle fields of the list record; however, applications would not then be able to use these fields for their own purposes.

Special Considerations

Because a list definition function is stored in a code resource, it cannot have its own global variables that it accesses through the A5 register. (Some development systems, however, may allow code resources to access global variables through some other register, such as A4. See your development system’s documentation for more information.) If your list definition function needs access to global data, it might store a handle to such data in the refCon or userHandle fields of the list record; however, applications would not then be able to use these fields for their own purposes.

Availability
Declared In
Lists.h

ListNotificationProcPtr

typedef void (*ListNotificationProcPtr)
(
   ListHandle theList,
   ListNotification notification,
   SInt32 param
);

If you name your function MyListNotificationProc, you would declare it like this:

void MyListNotificationProc (
   ListHandle theList,
   ListNotification notification,
   SInt32 param
);

Parameters
theList
notification
param

ListSearchProcPtr

Defines a pointer to a list search callback function. Your list search callback function compares data in a search field to the contents of a list cell.

typedef SInt16 (*ListSearchProcPtr) (
   Ptr aPtr,
   Ptr bPtr,
   SInt16 aLen,
   SInt16 bLen
);

If you name your function MyListSearchProc, you would declare it like this:

short MyListSearchProc (
   Ptr aPtr,
   Ptr bPtr,
   short aLen,
   short bLen
);

Parameters
aPtr

A pointer to the data contained in a cell.

bPtr

A pointer to the data for which you are searching.

aLen

The number of bytes of data contained in the cell.

bLen

The number of bytes of data for which you are searching.

Return Value

If the cell data matches the search data, your function should return 0. Otherwise, your search function should return 1.

Discussion

You can pass a pointer to your search function as the third parameter to the LSearch function. A search function must compare the data defined by the aPtr and aLen parameters with the data defined by the bPtr and bLen parameters. Your function can use any technique you choose to compare the data.

If you do not wish to create your own search function, your application can specify NULL as a parameter to LSearch, in place of a pointer to your function. LSearch then uses the Text Utilities function IUMagIDString, the default search function. The IUMagIDString function returns 0 if the search data exactly matches the cell data, but IUMagIDString considers the strings 'Rose' and 'rosé' to be equivalent. If your application simply needs a search function that works like IUMagIDString but considers 'Rose' to be different from 'rosé', the Text Utilities provides the case-sensitive comparison function IUMagString. Instead of writing a custom function, your application can simply pass @IUMagString as the third parameter to the LSearch function.

The pointer which you pass to the LSearch function should be a universal procedure pointer (UPP). The definition of the UPP data type for your search function is as follows:

typedef (ListSearchProcPtr) ListSearchUPP;

Before using your search function, you must first create a universal procedure pointer to it, using the NewListSearchUPP NewListSearchUPP function, as shown here:

ListSearchUPP MyListSearchUPP;
MyListSearchUPP = NewListSearchUPP(&MyListSearchProc)

You then pass MyListSearchUPP to the LSearch function, which will call your custom search function on each cell it searches. If you wish to call your own list search function, use the InvokeListSearchUPP function:

isMatch = InvokeListSearchUPP(aPtr, bPtr, aLen, bLen,                                              MyListSearchUPP);

When you are finished with your list search callback function, you should dispose of the universal procedure pointer associated with it, using the DisposeListSearchUPP function:

DisposeListSearchUPP(MyListSearchUPP);

A search function does not execute at interrupt time. Instead, it is called directly by the LSearch function. Thus, a search function can allocate memory, and it does not need to adjust the value contained in the A5 register.

Special Considerations

A search function does not execute at interrupt time. Instead, it is called directly by the LSearch function. Thus, a search function can allocate memory, and it does not need to adjust the value contained in the A5 register.

Availability
Declared In
Lists.h

Data Types

Cell

typedef Point Cell;

Discussion

The Cell data type defines a cell record. The functions LGetSelect , LSetSelect , LSetCell , LAddToCell , LClrCell , LGetCellDataLocation , LGetCell , LDraw , LSearch , LNextCell , LRect , and LLastClick use the Cell data type to specify the coordinates of a cell in a list.

Note that column and row numbers are 0-based. Also note that this reference designates cells using the notation (column–1, row–1), so that a cell with coordinates (2,5) is in the third column and sixth row of a list. You specify a cell with coordinates (2,5) by setting the cell’s h field to 2 and its v field to 5.

Availability
Declared In
Lists.h

DataArray

typedef  DataArray[32001];

Availability
Declared In
Lists.h

DataHandle

typedef  DataPtr * DataHandle;

Availability
Declared In
Lists.h

DataPtr

typedef  char * DataPtr;

Availability
Declared In
Lists.h

ListBounds

typedef Rect ListBounds;

Availability
Declared In
Lists.h

ListClickLoopUPP

typedef ListClickLoopProcPtr ListClickLoopUPP;

Discussion

For more information, see the description of the ListClickLoopUPP () callback function.

Availability
Declared In
Lists.h

ListDefSpec

struct ListDefSpec {
   ListDefType defType
   union {
      ListDefUPP userProc;
   } u;
};
typedef struct ListDefSpec ListDefSpec;
typedef ListDefSpec * ListDefSpecPtr;

Fields
defType
ListDefUPP
Availability
Declared In
Lists.h

ListDefType

typedef UInt32 ListDefType;

Availability
Declared In
Lists.h

ListDefUPP

typedef ListDefProcPtr ListDefUPP;

Discussion

For more information, see the description of the ListDefUPP () callback function.

Availability
Declared In
Lists.h

ListNotification

typedef SInt32 ListNotification;

ListNotificationUPP

typedef ListNotificationProcPtr ListNotificationUPP;

ListRec

struct ListRec {
   Rect rView;
   GrafPtr port;
   Point indent;
   Point cellSize;
   ListBounds visible;
   ControlRef vScroll;
   ControlRef hScroll;
   SInt8 selFlags;
   Boolean lActive;
   SInt8 lReserved;
   SInt8 listFlags;
   long clikTime;
   Point clikLoc;
   Point mouseLoc;
   ListClickLoopUPP lClickLoop;
   Cell lastClick;
   long refCon;
   Handle listDefProc;
   Handle userHandle;
   ListBounds dataBounds;
   DataHandle cells;
   short maxIndex;
   short cellArray[1];
};
typedef struct ListRec ListRec;
typedef ListRec * ListPtr;
typedef ListPtr * ListHandle

Fields
rView

The rectangle in which the list’s visible rectangle is located, in local coordinates of the graphics port specified by the port field. Note that the list’s visible rectangle does not include the area needed for the list’s scroll bars. The width of a vertical scroll bar (which equals the height of a horizontal scroll bar) is 15 pixels.

port

The graphics port of the window containing the list.

indent

The location, relative to the upper-left corner of a cell, at which drawing should begin. List definition functions should set this field to a value appropriate to the type of data that a cell in a list is to contain.

cellSize

The size in pixels of each cell in the list. When your application creates a list, it can either specify the cell size or let the List Manager calculate the cell size. You should not change the cellSize field directly; if you need to change the cell size after creating a list, use the LCellSize function.

visible

The cells in a list that are visible within the area specified by the rView field. The List Manager sets the left and top fields of visible to the coordinates of the first visible cell; however, the List Manager sets the right and bottom fields so that each is 1 greater than the horizontal and vertical coordinates of the last visible cell. For example, if a list contains 4 columns and 10 rows but only the first 2 columns and the first 5 rows are visible (that is, the last visible cell has coordinates (1,4)), the List Manager sets the visible field to (0,0,2,5).

vScroll

A control handle for a list’s vertical scroll bar, or NULL if a list does not have a vertical scroll bar.

hScroll

A control handle for a list’s horizontal scroll bar, or NULL if a list does not have a horizontal scroll bar.

selFlags

Indicates the selection flags for a list. When your application creates a list, the List Manager clears the selFlags field to 0. This defines the List Manager’s default selection algorithm. To change the default behavior for a particular list, set the desired bits in the list’s selFlags field. See “Selection Flags.”

lActive

Indicates whether the list is active (TRUE if active, FALSE if inactive).

lReserved

Reserved.

listFlags

Indicates whether the List Manager should automatically scroll the list if the user clicks the list and then drags the cursor outside the list display rectangle. See “List Flags” for the values used in this field.

By default, the List Manager enables horizontal autoscrolling for a list if the list includes a horizontal scroll bar, and enables vertical autoscrolling for a list if the list includes a vertical scroll bar.

clikTime

The time in ticks of the last click in the list. If your application depends on the value contained in this field, then your application should update the field if the application selects a list item in response to keyboard input.

clikLoc

The location in local coordinates of the last click in the list.

mouseLoc

Indicates the current location of the cursor in local coordinates. This value is continuously updated by the LClick function after the user clicks a list.

lClickLoop

A universal procedure pointer to your click loop callback function, which is repeatedly called by the LClick function, or NULL if the default click-loop function is to be used.

lastClick

The coordinates of the last cell in the list that was clicked. This may not be the same as the last cell selected if the user selects a range of cells by Shift-dragging or Command-dragging. If your application depends on the value contained in this field, then your application should update the field whenever your application selects a list item in response to keyboard input.

refCon

4 bytes for use by your application.

listDefProc

A handle to the code for the list definition function that defines how the list is drawn.

userHandle

4 bytes that your application can use as needed. For example, your application might use this field to store a handle to additional storage associated with the list. However, the LDispose function does not automatically release this storage when disposing of the list.

dataBounds

The range of cells in a list. When your application creates a list, it specifies the initial bounds of the list. As your application adds rows and columns, the List Manager updates this field. The List Manager sets the left and top fields of dataBounds to the coordinates of the first cell in the list; the List Manager sets the right and bottom fields so that each is 1 greater than the horizontal and vertical coordinates of the last cell. For example, if a list contains 4 columns and 10 rows (that is, the last cell in the list has coordinates (3,9)), the List Manager sets the dataBounds field to (0,0,4,10).

cells

A handle to a relocatable block used to store cell data. Your application should not change the contents of this relocatable block directly.

maxIndex

Used internally.

cellArray

Offsets to data that indicate the location of different cells’ data within the data handle specified by the cells parameter. Your application should not access this field directly.

Discussion

Functions in the List Manager interface use the ListHandle datatype to identify a list. The ListHandle type uses a ListRec structure to maintain information about a list. The ListRec data type defines a list record.

Availability
Declared In
Lists.h

ListRef

typedef ListHandle ListRef;

Availability
Declared In
Lists.h

ListSearchUPP

typedef ListSearchProcPtr ListSearchUPP;

Discussion

For more information, see the description of the ListSearchUPP () callback function.

Availability
Declared In
Lists.h

StandardIconListCellDataRec

struct StandardIconListCellDataRec {
   Handle iconHandle;
   short font;
   short face;
   short size;
   Str255 name;
};
typedef struct StandardIconListCellDataRec StandardIconListCellDataRec;
typedef StandardIconListCellDataRec * StandardIconListCellDataPtr;

Fields
iconHandle
font
face
size
name
Discussion
Version Notes
Carbon Porting Notes
Availability
Declared In
Lists.h

Constants

kListDefProcPtr

enum {
   kListDefProcPtr = 0,
   kListDefUserProcType = kListDefProcPtr,
   kListDefStandardTextType = 1,
   kListDefStandardIconType = 2
};

Constants
kListDefProcPtr

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

kListDefUserProcType

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

kListDefStandardTextType

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

kListDefStandardIconType

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lDrawingModeOff

enum {
   lDrawingModeOff = 8,
   lDoVAutoscroll = 2,
   lDoHAutoscroll = 1
};

Constants
lDrawingModeOff

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lDoVAutoscroll

Set this bit to 1 if you wish to allow automatic vertical scrolling.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lDoHAutoscroll

Set this bit to 1 if you wish to allow automatic horizontal scrolling.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lDrawingModeOffBit

enum {
   lDrawingModeOffBit = 3,
   lDoVAutoscrollBit = 1,
   lDoHAutoscrollBit = 0
};

Constants
lDrawingModeOffBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lDoVAutoscrollBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lDoHAutoscrollBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

List Definition Constants

enum {
   lInitMsg = 0,
   lDrawMsg = 1,
   lHiliteMsg = 2,
   lCloseMsg = 3
};

Constants
lInitMsg

In response to the lInitMsg message, your list definition function should perform any special initialization needed for a list. For example, the function might set fields of the list record, such as the cellSize and indent fields, to appropriate values. Your list definition function does not necessarily need to do anything in response to the initialization message. If it does nothing, then memory is still allocated for the list, and fields of the list record are set to the same values as they would be set to if the default list definition function were being used.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lDrawMsg

Your list definition function should draw the cell specified by the theCell parameter after receiving an lDrawMsg message. The function must ensure that it does not draw anywhere but within the rectangle specified by the cellRect parameter. If the selected parameter is TRUE, then your list definition function should draw the cell in its highlighted state; otherwise, it should draw the cell without highlighting. When drawing, your list definition function should take care not to permanently change any characteristics of the drawing environment.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lHiliteMsg

Your list definition function should respond to the lHiliteMsg message by reversing the selection status of the cell contained within the rectangle specified by the cellRect parameter. If a cell is highlighted, your list definition function should remove the highlighting; if a cell is not highlighted, your list definition function should highlight it.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lCloseMsg

The List Manager sends your list definition function an lCloseMsg message before it disposes of a list and its data. Your list definition function need only respond to this message if additional memory has been allocated for the list. For example, your list definition function might allocate a relocatable block in response to the lInitMsg message. In this case, your list definition function would need to dispose of this relocatable block in response to the lCloseMsg message. Or, if your list definition function defines cells simply to contain pointers or handles to data stored elsewhere in memory, it would need to dispose of that memory in response to the lCloseMsg message.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

Discussion

The List Manager passes these values to your ListDefProcPtr function to identify the operation to be performed.

List Flags

Constants
Discussion

The following constants define bits in the listFlags field of the ListRec structure that determine whether horizontal autoscrolling and vertical autoscrolling are enabled:.

listNotifyNothing

enum {
   listNotifyNothing = 'nada',
   listNotifyClick = 'clik',
   listNotifyDoubleClick = 'dblc',
   listNotifyPreClick = 'pclk'
};

Constants
listNotifyNothing
listNotifyClick
listNotifyDoubleClick
listNotifyPreClick

lOnlyOneBit

enum {
   lOnlyOneBit = 7,
   lExtendDragBit = 6,
   lNoDisjointBit = 5,
   lNoExtendBit = 4,
   lNoRectBit = 3,
   lUseSenseBit = 2,
   lNoNilHiliteBit = 1
};

Constants
lOnlyOneBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lExtendDragBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoDisjointBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoExtendBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoRectBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lUseSenseBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoNilHiliteBit

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

Selection Flags

enum {
   lOnlyOne = -128,
   lExtendDrag = 64,
   lNoDisjoint = 32,
   lNoExtend = 16,
   lNoRect = 8,
   lUseSense = 4,
   lNoNilHilite = 2
};

Constants
lOnlyOne

Specify this value if you wish to allow only one item to be selected at once.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lExtendDrag

Specify this value if you wish to enable selection of multiple items by dragging without the Shift key.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoDisjoint

Specify this value if you wish to prevent discontinuous selections using the Command key.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoExtend

Specify this value if you wish to prevent extending Shift key selections. All items are deselected before responding to Shift-click.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoRect

Specify this value if you wish to select all items in the cursor’s path during Shift-drag.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lUseSense

Specify this value if you wish to allow the user to deselect one or more items using the Shift key

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

lNoNilHilite

Specify this value if you wish to disable the highlighting of empty cells.

Available in Mac OS X v10.0 and later.

Declared in Lists.h.

Discussion

The ListRec structure uses these values in the selFlags field to indicate the List Manager’s default selection algorithm. Use these values additively to select more than one selection option.



Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-12-11)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.