|
|
This Technote presents the Application Programmer's Interface for the DataBrowser control. This new control is available through the Carbon API and was introduced in CarbonLib 1.1. Carbon applications running in Mac OS 8.6 or later with CarbonLib 1.1 can use the DataBrowser control.
The browser control is object oriented in design, and conceptually it serves as a base class that you can use to build your own specialized lists. In its current implementation, the DataBrowser is a small object-oriented hierarchy with two different specializations that are available for use in applications: the column view and the list view. The column view provides the multi-column hierarchical navigation scheme appearing in the file selection lists in Mac OS X. The list view specialization provides a display scheme similar to the one provided by the list manager together with hierarchical display capabilities as found in the Finder's list view. This document discusses the list view specialization of the browser control.
Using DataBrowser will ensure that your lists adhere to the Macintosh Human
Interface Guidelines. It also ensures that users will find your lists
familiar and easy to understand since they appear and behave in a way that
is consistent with the way lists appear and behave in other applications. As
well, the DataBrowser does all of its drawing in accordance with the
appearance manager. As a result, if your application uses the DataBrowser to
display lists, your lists will always be drawn in a way that is consistent
with the current appearance settings, whether on Mac OS 9 or Mac OS X. Most
importantly, this means that your application running in Mac OS X and using
the DataBrowser will have the full benefits of Aqua appearance in the lists
it displays. DataBrowser does the difficult user interface work for you,
letting you focus on the functionality of your application.
This note is directed at application developers who are interested in using the DataBrowser control in their applications.
Updated: [Dec 05 2000]
|
Overview
This section provides a description of what the browser control is and definitions for key concepts used in the rest of this document. The main points described in this section include how the DataBrowser interacts with your application, and how both your application and the DataBrowser use ID numbers to reference items displayed in the browser control.
The DataBrowser is a list management utility that allows your application to provide complex lists that have built-in user interaction functionality. Figure 1 provides an illustration of the DataBrowser control in action.
| |
Figure 1. An illustration of the DataBrowser being used to display a list of files.
|
About the DataBrowser....
The DataBrowser is a user interface gadget used to display lists of items inside of windows in your application. The DataBrowser replaces the older List Manager API and surpasses the List Manager API in many ways. Major features found in the DataBrowser that were not supported in the List Manager include:
- No limitation on the number of cells displayed in a list,
- Built-in drag-and-drop handling,
- Built-in display types for text, icons, checkboxes, pop-up menus, progress bars, relevance ranks, and sliders,
- Support for contextual menus and context-sensitive help,
- Built-in text editing for cells displaying text, and
- Built-in hierarchical list support.
The DataBrowser's implementation is object oriented in nature. The List View discussed in this document is only one of the many possible specializations of the DataBrowser's Table View. Figure 2 illustrates the object-oriented hierarchy internal to the DataBrowser. For the purposes of this document, it is useful to be aware of this structure since some of the routines defined for the Table View class can also be used in List View class.
| |
Figure 2. An illustration of the object-oriented hierarchy used inside of the browser control.
|
In the interfaces you will find routines that appear to reference different parts of this hierarchy. The routines discussed in this document include both routines for the Table View class and routines for the List View class. Table View is really an abstract class, and when you create a browser control of type List View, the List View object will have its own specialized methods for all of the methods defined for the Table View class.
Back to top
You call the DataBrowser, the DataBrowser calls you....
The DataBrowser provides your application with
sophisticated list display and interaction functionality
that is both easy to use and extensible in many ways. To
allow this level of fidelity and control, the DataBrowser
control uses callbacks to your application at several
points during processing where key choices in the
interaction process are made. At the very least, your
application must provide a routine that allows the data
browser to gain access to the information it displays.
Further discussion of how to provide your own callback
routines for the DataBrowser control are discussed
later in this document starting in the DataBrowser Call-back Routines section.
Back to top
Data & the DataBrowser
The DataBrowser control can be used to display a
single linear list of data items. When you provide a list of
items for display in a DataBrowser control, you do not
provide the actual data that will be displayed. Instead, you
provide a unique 32-bit ID number that your application can
use to refer to the actual data. Whether you store the
actual data in memory, on disk, or across a network is
entirely up to your application. The DataBrowser control
uses these ID numbers when it is drawing the list of items
to ask your application for information about particular
properties of the data items that are being drawn in the
display as that information is required.
| |
Figure 3. How Data ID numbers are used together with Property ID numbers to address particular rows in a table.
|
The values your application uses as data item ID numbers
are entirely up to you. The only requirement is that the values are
non-zero. (The value zero is used internally by the Data
Browser in a way similar to the NULL pointer to indicate
that a row has no data item associated with it.) For example,
some possibilities for data item ID numbers you may use are
pointer values, data file offsets, or 32-bit TCP/IP host
addresses. Whenever the DataBrowser needs to display the
data for a particular data item, it will ask your
application for the data associated with the data item ID
number you provided.
Back to top
Rows
Each row in a table displayed by the DataBrowser control
has a unique data item ID number associated with it, together
with some flags describing state information related to the
row. Figure 4 provides a view of the values associated with
each row in a list displayed by the DataBrowser
control.
| |
Figure 4. Information maintained by the DataBrowser
for each row displayed in a DataBrowser control.
|
The selection state reflects the selection state of the
item. The collapsed/uncollapsed state is used in
hierarchical lists that feature turn-down arrows that open
sub-lists. These flags are read-only states associated with
rows displayed in the list: an application can query these
values using DataBrowser routines.
|
Definition 1. Data Element ID or Data ID. Any non-zero, 32-bit value uniquely identifying a data element being displayed in a list. Data ID values map to rows in the tables displayed by the DataBrowser. Data ID values need not be in any particular order, and the values used are entirely up to the application.
The constant kDataBrowserNoItem is a special Data ID value used by the DataBrowser to mean "none of the Data ID numbers currently stored in the browser control." Its usage is analogous to the NULL pointer in C.
|
Concepts relating to specifying the Data ID numbers that
will be used to display a list are discussed in the
Adding Rows section.
Back to top
Columns
For every column that is to be displayed in a table, the
application must provide a number of parameters governing
how the column will be displayed. One of these parameters is a
non-zero, 32-bit value called the column's Property ID
number. Together with the data item ID number, property
numbers are used to refer to individual cells in the table
during callbacks to the application. Figure 3 illustrates
how the DataBrowser uses Property ID numbers together with
Data ID numbers to reference particular cells in the
tables it displays. As with Data ID numbers, the values
an application chooses to use as Property ID numbers are
completely arbitrary.
Definition 2. Property ID.
Any non-zero, 32-bit unsigned integer value that uniquely identifies a column in
a table being displayed by the DataBrowser. Property ID numbers do not need to be ordered or sequential, and the values used are entirely up to the application. Property ID values
0 through 1023 are reserved by Apple for use in the DataBrowser control.
The constant kDataBrowserItemNoProperty is a special Property ID value used by the DataBrowser to mean "none of the Property ID numbers (columns) currently stored in the browser control." Its usage is analogous to the NULL pointer in C.
|
Other information an application provides when a column
is being added to a table includes the column's title,
formatting information for the title, and some other
parameters governing the format of the information displayed.
Figure 5 provides and expanded view of some of the
information associated with a column.
| |
Figure 5. Information associated with each column.
|
Later sections will discuss this information in greater
detail; however, at this point, it is worthwhile to take
note of the property display type that is associated with a
column. For convenience, the DataBrowser pre-defines
several display types including strings, pop-up menus,
icons, pictures, and buttons. It is also possible for
applications to implement their own custom display types
through callback routines. We revisit this subject later in
the Defining Columns and Defining Custom Columns sections.
Back to top
Cells
As shown in Figure 3, particular
cells displayed in the tables drawn by the DataBrowser
control are addressed using a combination of the Data ID
assigned to the row and the Property ID assigned to the
column.
Definition 3. Cell.
A Data ID together with a Property ID uniquely identifies a cell in a table
displayed by the DataBrowser. A cell corresponds to a location inside of a Data
Browser list that is at the intersection of a row and a column.
|
Individual cells are used to display facets of the data
items being displayed in a list. The method used to display
the cell's contents is governed by its Property ID.
The concepts presented in this section describe how the
DataBrowser control represents data. It does not
necessarily entail that your application must use this same
data model for the information it is displaying in a Data
Browser control; however, if an application has its own
data model, then the application must provide the mapping
between the structures expected by the DataBrowser and its
own internal representation. As will be shown in later
sections, the DataBrowser control has been designed to
accommodate developers providing a mapping between their own
data model and the data model used by the DataBrowser.
Back to top
Creating DataBrowser Controls
This section discusses about how you can create and initialize a new DataBrowser control inside of your application. Basic structures and operations for adding columns and rows to a browser control are discussed. The structures used to define columns allow your application to provide columns that utilize any of the pre-defined display types such as checkboxes, menus, icons, or text, while at the same time allowing you to design your own presentation mechanisms used when drawing columns. Listing 1 illustrates how an application would add a column to a browser control.
DataBrowser controls can be created using the CreateDataBrowserControl routine. Once a control has been created, applications can proceed to install their own custom callback routines, columns, and rows.
|
The CreateDataBrowserControl routine.
|
OSStatus CreateDataBrowserControl(
WindowRef window,
const Rect *boundsRect,
DataBrowserViewStyle style,
ControlRef *outControl);
|
- window - the window where the control should be placed.
- boundsRect - location where the control should appear in the window.
- style - the view style that should be used when the control is drawn. Currently, the only view styles defined are
kDataBrowserListView and kDataBrowserColumnView. This document's primary focus is the kDataBrowserListView type.
- outControl - if the control has been successfully created, then it will be returned in the location referenced by this parameter.
|
When an application is finished with a DataBrowser control, it can call DisposeControl to release the memory occupied by the control. If an application has allocated any special UPPs for use in the DataBrowser control, then it should de-allocate these after disposing of all of the DataBrowser controls where they were installed.
Back to top
Defining Columns
Columns have both a unique Property ID number associated with them along with information governing the appearance of the information displayed in the column. This information is specified by an application in a DataBrowserListViewColumnDesc structure. It is the application's responsibility to fill in all of the fields in this structure before providing it to a DataBrowser control.
The DataBrowserPropertyDesc sub-record
The DataBrowserPropertyDesc contains
information about the Property ID associated with the column
described in the DataBrowserListViewColumnDesc.
Specific values that can be stored in this structure are
described in the following.
|
The DataBrowserPropertyDesc Structure
|
typedef struct DataBrowserPropertyDesc
DataBrowserTableViewColumnDesc;
struct DataBrowserPropertyDesc {
DataBrowserPropertyID propertyID;
DataBrowserPropertyType propertyType;
DataBrowserPropertyFlags propertyFlags;
};
|
- propertyID. This field contains a 32-bit integer
value that uniquely identifies this column. It is the
Property ID that your application
uses to identify the column. This Property ID number will
also be used by the DataBrowser to identify the column in
callbacks to your application. The DataBrowser interfaces
use the type
DataBrowserPropertyID for Property
ID values.
- propertyType. This field contains a 32-bit
OSType
value that indicates the type of data that is to be
displayed in the column. At the time of this writing,
permissible values for use in this field are as follows:
- propertyFlags. This field contains a 32-bit
integer value of type
DataBrowserPropertyFlags containing
flags controlling the display or interaction provided by
this column. The following constants define mask values that
can be used to set particular flags in this field. All
unused bits in this field are currently reserved for future
use.
kDataBrowserDefaultPropertyFlags - this
constant contains the default property flags that should
be used to initialize the propertyFlags field if no other
flags are required.
kDataBrowserRelativeDateTime - this flag
is only used if the propertyType field is set to the
constant kDataBrowserDateTimeType. When this flag is
specified, date values close to the current date will be
displayed as relative dates.
kDataBrowserPropertyIsEditable - this flag may be set if the values being displayed in the
column can be changed. If an application specifies this
flag, then the application must also provide a callbacks
that allow the DataBrowser to both retrieve and store
data values displayed in this column.
|
|
Note:
The DataBrowser requires the kDataBrowserPropertyIsEditable flag to be set in order to enable editing of any changeable display type (namely checkboxes, pop-up menus, etc). Be sure your application is setting the kDataBrowserPropertyIsEditable flag when defining columns containing checkboxes, menus, and so forth.
|
The DataBrowserListViewHeaderDesc sub-record
DataBrowserListViewHeaderDesc contains a
number of fields describing the appearance of the column's
title. Specific contents of the fields in the structure are
as follows:
|
The DataBrowserListViewHeaderDesc Structure
|
struct DataBrowserListViewHeaderDesc {
UInt32 version; /* Use kDataBrowserListViewLatestHeaderDesc */
UInt16 minimumWidth;
UInt16 maximumWidth;
SInt16 titleOffset;
CFStringRef titleString;
DataBrowserSortOrder initialOrder;
ControlFontStyleRec btnFontStyle;
ControlButtonContentInfo btnContentInfo;
};
|
- version. The version field identifies the format
of the structure. You should always set this field to
the value
kDataBrowserListViewLatestHeaderDesc.
- minimumWidth. For resizable columns, this field
contains the smallest width that the column can be resized
to. If the column is not resizable, then
minimumWidth should
be set to the same value as maximumWidth.
- maximumWidth. For resizable columns, this field
contains the largest width that the column can be resized
to. If the column is not resizable, then
maximumWidth should
be set to the same value as minimumWidth.
- titleOffset. This field contains an offset in
pixels from the left side of the title column where the
title text will be drawn. Both the
titleAlignment and the titleOffset
fields dictate the alignment and offset (inset by default)
of the content of the column when displaying one of the
pre-defined content types.
- titleString. This field contains the text that is
to be drawn as the column's titled.
titleString
may be NULL to indicate that no string is to be
displayed.
- initialOrder. This field contains a value of type
DataBrowserSortOrder. initialOrder is the initial
sort ordering presentation for the column when that column is
the current sort column. Once the DataBrowser is visible, the
user may change this via direct manipulation. Setting this value
to anything other than kDataBrowserOrderDecreasing
will map to kDataBrowserOrderIncreasing. initialOrder
may be assigned one of the following values:
kDataBrowserOrderUndefined - this value
is currently not supported.
kDataBrowserOrderIncreasing - means this
column is to be sorted in ascending order.
kDataBrowserOrderDecreasing - means this
column is to be sorted in descending order.
- btnContentInfo. Contains a structure of type
ControlButtonContentInfo. This structure
describes the contents of the column heading and how it should
be drawn. Only text-only and IconRef (& text) are
supported.
- btnFontStyle. This field contains a structure of
type
ControlFontStyleRec that defines the text
style used for the column heading.
|
Installing Columns
Once an application has initialized the
DataBrowserListViewHeaderDesc structure with
all of the values it requires, then the application can
install the column in a DataBrowser control by calling the
AddDataBrowserListViewColumn routine.
|
The AddDataBrowserListViewColumn routine
|
OSStatus AddDataBrowserListViewColumn(
ControlRef browser,
DataBrowserListViewColumnDesc *columnDesc,
UInt32 position);
|
- browser - a DataBrowser control created by the
CreateDataBrowserControl
routine.
- columnDesc - a record
of type
DataBrowserListViewColumnDesc
with all of its fields initialized to
their appropriate values.
- position - refers to
the position among the columns that are
already installed in the DataBrowser
where this column should be inserted.
To insert this column to the right of
all other columns, provide a very large
value such as
ULONG_MAX.
Returns an operating system result code
describing the success of the operation.
The code noErr will be
returned if the operation was successful.
paramErr will be returned if
the columnDesc record is not
formatted correctly.
|
The routine AddDataBrowserListViewColumn
assumes that the DataBrowserListViewColumnDesc
has been set up by your application to describe the column
being added to the list. The application must set all of the
fields in this record, including the reserved fields (that
must be set to -1) before calling
AddDataBrowserListViewColumn. Listing 1
provides an example showing how you would go about adding a
new column to a DataBrowser control.
|
Listing 1. Adding a new column to a DataBrowser control.
|
DataBrowserListViewColumnDesc columnDesc;
columnDesc.propertyDesc.propertyID = kCheckboxColumn;
columnDesc.propertyDesc.propertyType = kDataBrowserCheckboxType;
columnDesc.propertyDesc.propertyFlags = kDataBrowserDefaultPropertyFlags;
columnDesc.headerBtnDesc.minimumWidth = 30;
columnDesc.headerBtnDesc.maximumWidth = 30;
columnDesc.headerBtnDesc.titleAlignment = teCenter;
columnDesc.headerBtnDesc.titleFontTypeID = kControlFontViewSystemFont;
columnDesc.headerBtnDesc.titleFontStyle = normal;
columnDesc.headerBtnDesc.titleOffset = 0;
columnDesc.titleString = CFStringCreateWithPascalString(
CFAllocatorGetDefault(), "\p", kCFStringEncodingMacRoman);
AddDataBrowserListViewColumn(a_browser, &columnDesc, ULONG_MAX),
|
In this example, the column being added to the browser
control will be a fixed-width column containing checkboxes.
All of the user interactions related to those checkboxes
will be handled automatically be the browser control.
Back to top
Installing Rows
Adding rows to a DataBrowser control is simply a matter
of providing a list of Data ID numbers that you would like
to display in the control. Routines for adding rows are
described in the Providing Data section below.
Back to top
Providing and Ordering Your Data
As discussed earlier, the DataBrowser control itself does not store any
of the data displayed in the list. The data itself is provided by your application's clientDataCallback routine that you provide in the DataBrowserCallbacks structure. Internally, though, the DataBrowser stores 32-bit key values that it passes to your clientDataCallback routine that your application can use to retrieve the data being requested. Listing 6 illustrates how your clientDataCallback should translate these ID numbers to look up and data values as requested by the DataBrowser. This section describes routines your application can use to provide and modify the Data ID values being used by the DataBrowser control for displaying data.
Providing Data
The AddDataBrowserItems and RemoveDataBrowserItems routines can be used to modify the list of Data ID values that are being displayed in the list. In addition, by using AddDataBrowserItems' container parameter, an application can construct a hierarchical list of items that can be displayed with turn-down arrows. For more information about routines available for managing hierarchical lists, see the section Managing Hierarchical Lists section.
|
The AddDataBrowserItems routine.
|
OSStatus AddDataBrowserItems(
ControlRef browser,
DataBrowserItemID container,
UInt32 numItems,
const DataBrowserItemID *items,
DataBrowserPropertyID preSortProperty);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- container - if the items being installed are sub-items of another data element already installed in the browser control, then this parameter should contain the Data ID of that data element. Otherwise, if the items have no parent data element, then you can provide the constant
kDataBrowserNoItem as this argument. The container parameter can be used to construct hierarchical lists for display.
NOTE: adding an item to a container item will have the side
effect of opening that container item.
- numItems - the number of items in the array pointed to by the items parameter.
- items - points to an array of unsigned long integers containing the Data ID numbers of items that are to be added. Note: If
items is set to NULL, then the data browser will automatically generate and add the Data ID numbers 1, 2, ..., numItems to the browser control.
- preSortProperty - If the array of items have been sorted according to the sorting order currently in use in one of the columns in the list being displayed, then you can use this parameter to reference this column. This will allow the DataBrowser to skip the sorting step if the values are already in the correct order.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
If the new items being added to the browser control will appear in the
visible part of the list, then they will be drawn to the screen. Applications constructing hierarchical lists must proceed in a top-down fashion when installing the Data IDs in the browser control. Once a Data ID has been installed in a browser control, it is possible to associate a list of Data ID numbers with it as sub-items.
|
IMPORTANT:
Adding items to an existing item (as the parent) means that the specified parent item must be classified as a container. This means that when the DataBrowser asks for the kDataBrowserItemIsContainerProperty of the specified parent item, the answer must be true. If your application does not provide this condition, then the AddDataBrowserItems call will fail.
|
Listing 2 illustrates some possible ways you can go about adding a sequence of Data ID numbers to a browser control. Of course, the numbers you decide to use in your application will depend on what is most appropriate for the particular data set you are trying to display.
|
Listing 2.
Adding a sequence of Data IDs (rows) to a browser control.
|
#define kMyItemCount 22
DataBrowserItemID newitems[kMyItemCount];
long i;
/* add a bunch of generated ID
numbers to the control */
for (i = 0; i < kMyItemCount; i++) {
/* Make some arbitrary ID value. The only
requirement is that it be unique. */
newitems[i] = ( i<<12 ) + (4095 ^ i);
}
AddDataBrowserItems(mybrowser, kDataBrowserNoItem,
kMyItemCount, items, kDataBrowserItemNoProperty);
/* instead of indexes or codes, let's use
picture references. Of course, we're assuming we
have a resource file set up with picture resources
128, 129, ... */
for (i = 0; i < kMyItemCount; i++) {
newitems[i] = (DataBrowserItemID) GetResource('PICT', i+128);
if (newitems[i] == NULL) { err = resNotFound; goto bail; }
}
AddDataBrowserItems(some_other_browser, kDataBrowserNoItem,
kMyItemCount, items, kDataBrowserItemNoProperty);
/* let's just use the numbers 1, 2, ..., kMyItemCount. We
only have kMyItemCount items to display, so why not just
number them from 1 to kMyItemCount. In this case, we don't
need to provide an array of ID numbers - the browser will
generate them the ID numbers for us. */
AddDataBrowserItems(yet_another_browser, kDataBrowserNoItem,
kMyItemCount, NULL, kDataBrowserItemNoProperty);
|
The RemoveDataBrowserItems can be used to remove Data IDs from the list of Data ID numbers internally maintained by the DataBrowser. If one of the Data IDs you provide refers to a container item that has a number of sub items, then those sub-items will be removed from the list as well.
|
The RemoveDataBrowserItems routine.
|
OSStatus RemoveDataBrowserItems(
ControlRef browser,
DataBrowserItemID container,
UInt32 numItems,
const DataBrowserItemID *items,
DataBrowserPropertyID preSortProperty);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- container - if the items being removed are sub-items of another data element already installed in the browser control, then this parameter should contain the Data ID of that data element. Otherwise, if the items have no parent data element, then you can provide the constant
kDataBrowserNoItem as this argument.
- numItems - the number of items in the array pointed to by the items parameter.
- items - points to an array of unsigned long integers containing the Data ID numbers of items that are to be removed. If this parameter is set to
NULL, then all of the items will be removed. If this parameter is NULL, then all of the items in the container item referenced by the container parameter will be removed. If items is NULL, then the numItems parameter is ignored.
- preSortProperty - if the array of items has already been sorted, then set this parameter to the Property ID of the column that has the same sorting order.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
The GetDataBrowserItems, the GetDataBrowserItemCount, and the ForEachDataBrowserItem routines can be used to walk through the Data IDs your application has installed for the DataBrowser control.
|
The GetDataBrowserItems routine.
|
OSStatus GetDataBrowserItems(
ControlRef browser,
DataBrowserItemID container,
Boolean recurse,
DataBrowserItemState state,
Handle items);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- container - to obtain a list of items displayed at the top level of the control's display, provide the constant
kDataBrowserNoItem. Otherwise, to obtain a list of items that are organized as sub-items of a container item, provide the container item's Data ID.
- recurse - When this parameter is true,
GetDataBrowserItems will return a flattened list of all of the data IDs stored in the DataBrowser as sub-items of container parameter. The list will be created using a in-order traversal of the Data ID hierarchy maintained internally by the DataBrowser.
- state - When this field is non-zero, only items with this state will be incorporated into the result.
- items - should contain a new zero-length handle. Upon return, the contents of this handle will be set to contain an array of Data ID numbers for the items that match the criteria provided by other parameters.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
GetDataBrowserItems is a powerful routine for gathering information about the items being displayed in a DataBrowser during user interaction sequences. For example, to obtain a list of all of the selected items in a list, your application would call the GetDataBrowserItems as shown in Listing 3. The example to GetDataBrowserItems in Listing 3 calculates both the number of items in the selection and it creates a list of the Data ID numbers in the selection. If your application is only interested in determining the number of items in the selection (and not the Data IDs of those items), then you should use the GetDataBrowserItemCount routine as shown in Listing 4.
|
Listing 3. Obtaining a list of all of the selected items in a browser control.
|
Handle selectedItems;
OSStatus err;
UInt32 selectionCount;
selectedItems = NewHandle(0);
if (selectedItems == NULL) { err = memFullErr; goto bail; }
err = GetDataBrowserItems(browser,
kDataBrowserNoItem, /* start searching at the root item */
true, /* recursively search all subitems */
kDataBrowserItemIsSelected, /* only return selected items */
selectedItems);
if (err != noErr) goto bail;
selectionCount = (GetHandleSize(selectedItems) /
sizeof(DataBrowserItemID));
|
This is a one-step call that provides a complete list of all of the items the user has highlighted in the browser control.
|
Note:
When the recurse parameter to the GetDataBrowserItems is set to true, the routine will flatten an entire hierarchy into a single vector of Data ID numbers, but, when it does so, it does not encode any information about that hierarchy into the list of returned Data ID numbers. If your application requires the sort of functionality where it would like to save and restore a hierarchy of Data IDs as they are displayed in a DataBrowser control, then you should build that functionality yourself using combinations of the routines described in this section.
|
|
The GetDataBrowserItemCount routine.
|
OSStatus GetDataBrowserItemCount(
ControlRef browser,
DataBrowserItemID container,
Boolean recurse,
DataBrowserItemState state,
UInt32 *numItems);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- container - to obtain a list of items displayed at the top level of the control's display, provide the constant
kDataBrowserNoItem. Otherwise, to obtain a list of items that are organized as sub-items of a container item, provide the container item's Data ID.
- recurse - When this parameter is true,
GetDataBrowserItemCount will return the number of all of the data IDs stored in the DataBrowser as sub-items of container parameter.
- state - When this field is non-zero, only items with this state will be counted.
- numItems - The total number of items found is returned in the unsigned 32-bit integer referenced by this parameter.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
The routine GetDataBrowserItemCount is useful for performing quick inquiries about the state of the items being displayed in a browser control. For example, Listing 4 illustrates how you could go about finding out how many items are selected in the browser control. This routine provides a fast efficient mechanism for an application to perform such inquiries.
|
Listing 4. Counting the number of selected rows in a browser control.
|
UInt32 selectionCount;
OSStatus err;
err = GetDataBrowserItemCount(myBrowserControl,
kDataBrowserNoItem, /* start searching at the root item */
true, /* recursively search all subitems */
kDataBrowserItemIsSelected, /* only return selected items */
&selectionCount);
if (err != noErr) goto bail;
if (selectionCount > 0) { ...
|
For enumerating the Data ID numbers stored in a DataBrowser control or performing some operation for each of those items, your application can use the ForEachDataBrowserItem routine. One of the parameters to this routine is a callback procedure that will be called for each of the Data ID numbers referenced by the other parameters to this routine.
|
The ForEachDataBrowserItem routine.
|
typedef void (*DataBrowserItemProcPtr)(
DataBrowserItemID item,
DataBrowserItemState state,
SInt32 clientData);
typedef DataBrowserItemProcPtr DataBrowserItemUPP;
OSStatus ForEachDataBrowserItem(
ControlRef browser,
DataBrowserItemID container,
Boolean recurse,
DataBrowserItemState state,
DataBrowserItemUPP callback,
SInt32 clientData);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- container - to have your callback called for all of the items displayed at the top level of the control's display, provide the constant
kDataBrowserNoItem. Otherwise, to have your callback called for all of the items that are organized as sub-items of a container item, provide the container item's Data ID.
- recurse - When this parameter is true,
ForEachDataBrowserItem will call the callback routine for all of the data IDs stored in the DataBrowser as sub-items of container parameter.
- state - When this field is non-zero, only items with this state will be counted.
- callback - a UPP referencing your callback routine. The
DataBrowserItemProcPtr declaration above shows how this routine should be defined in your application. This routine will be called for every Data ID currently stored in the browser control matching the criteria you provide in the other ForEachDataBrowserItem parameters.
- clientData - this is a reference value passed through to your callback routine. Its contents are defined by the application.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
The ForEachDataBrowserItem routine is especially useful for situations where you would like to enumerate and perform some operation on some set of Data ID numbers. Listing 5 illustrates how your application could use the ForEachDataBrowserItem to perform some additional filtering when selecting Data ID numbers. ForEachDataBrowserItem is a powerful routine that allows your application to perform complex inquiries about the Data IDs stored in a data browser control; however, before calling this routine for all of the inquiry operations required by your application you should consider whether it would be more appropriate to call either GetDataBrowserItems or GetDataBrowserItemCount.
|
Listing 5. Enumerating and acting on certain items in the selection.
|
static Handle gCollector = NULL;
OSStatus gCoStatus = noErr;
/* in our item callback routine, we add any of the items
that satisfy some interesting criteria to the list of
data ID numbers we are accumulating in the handle
referenced by the global variable gCollector. */
static void MyDataBrowserItemProc( DataBrowserItemID item,
DataBrowserItemState state, SInt32 clientData) {
if (gCoStatus == noErr && clientData == 'Yeah') {
if ( SatisfiesSomeInterestingCriteria(item) ) {
gCoStatus = PtrAndHand(&item, gCollector, sizeof(item));
}
}
}
....
OSStatus err;
DataBrowserItemUPP myItemProc;
UInt32 selectionCount;
gCoStatus = noErr;
gCollector = NewHandle(0);
if (gCollector == NULL) { err = memFullErr; goto bail; }
/* set up our callback's routine descriptor */
myItemProc = NewDataBrowserItemUPP(MyDataBrowserItemProc);
if (myItemProc == NULL) { err = memFullErr; goto bail; }
/* call our callback routine for every item that
is currently a member of the selection. */
err = ForEachDataBrowserItem(any_old_browser,
kDataBrowserNoItem, /* start searching at the root item */
true, /* recursively search all subitems */
kDataBrowserItemIsSelected, /* call it for selected items */
myItemProc, /* a reference to our callback */
'Yeah'); /* our arbitrary and private parameter */
if (err != noErr) goto bail;
if ((err = gCoStatus) != noErr) goto bail;
selectionCount = (GetHandleSize(selectedItems) /
sizeof(DataBrowserItemID));
|
To discover the state of a particular item, your application can
call the GetDataBrowserItemState routine. Using this routine your
application can find out if a cell is selected or if a container cell
has been opened (i.e., the turn-down arrow is in the down position).
|
The GetDataBrowserItemState routine.
|
OSStatus GetDataBrowserItemState(
ControlRef browser,
DataBrowserItemID item,
DataBrowserItemState *state);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- item - the Data ID of the row you are interested in. NOTE: As discussed later in the Selection Handling section, the DataBrowser provides facilities for selecting and highlighting entire rows of data, but it does not provide any facilities for selecting individual cells within rows.
- state - various combinations of the following flags:
kDataBrowserItemNoState - has no state associated with it at this time.
kDataBrowserItemIsSelected - is a member of the current selection.
kDataBrowserContainerIsOpen - disclosure open.
kDataBrowserItemIsDragTarget - Only true during a drag operation.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
Back to top
Ordering Data
There are two sides to ordering the data displayed by the DataBrowser control. First, your application must provide a way for the DataBrowser
to compare items referenced by Data ID numbers based with a common Property ID
number. That is to say, your application must provide a method for comparing rows based on values displayed in particular columns. Your application can do this by providing a comparison callback routine in the compareCallback field of the DataBrowserCallbacks structure. For more information providing a comparison routine, please refer to that section.
The other side of ordering the data displayed by the DataBrowser is telling the browser control which column should be used for sorting and in what order items should be presented (ascending or descending). For the most part, your application should leave these settings up to the user. However, in situations where you would like to sort the values displayed in the DataBrowser control explicitly, the following routines have been provided.
|
Note:
The sorting routine used by the DataBrowser is non destructive
and it preserves the
ordering of elements that are equal across sorts. This means
that if the list displayed is sorted based on column 1, and then
you sort
using column 2 and all of the Data IDs in column 2 map to the same
value, then the order of the list will not change.
|
SetDataBrowserSortOrder can be used to explicitly set the sorting order for the list. If the list has not been sorted or the sorting order requested is not in effect, then the list with be sorted and re-drawn using the new sorting order. To find out what sorting order is currently in effect, your application can call the GetDataBrowserSortOrder routine.
|
The SetDataBrowserSortOrder routine.
|
OSStatus SetDataBrowserSortOrder(
ControlRef browser,
DataBrowserSortOrder order);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- order - this parameter should be set to one of the three following constant values:
kDataBrowserOrderUndefined - not supported.
kDataBrowserOrderIncreasing - ascending order.
kDataBrowserOrderDecreasing - descending order.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
|
The GetDataBrowserSortOrder routine.
|
OSStatus GetDataBrowserSortOrder(
ControlRef browser,
DataBrowserSortOrder *order);
| |
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
To designate a column that is used for the sorting operation, your application call SetDataBrowserSortProperty with the column's associated Property ID number. If the list is not currently sorted or if the list is currently sorted with a different column, then the list will be resorted and re-drawn. The GetDataBrowserSortProperty can be used to discover the Property ID number of the column currently being used for sorting the list.
|
The SetDataBrowserSortProperty routine.
|
OSStatus SetDataBrowserSortProperty(
ControlRef browser,
DataBrowserPropertyID property);
| |
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
|
The GetDataBrowserSortProperty routine.
|
OSStatus GetDataBrowserSortProperty(
ControlRef browser,
DataBrowserPropertyID *property);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- property - the Property ID of the column being used to sort the list will be stored in the variable pointed to by this parameter.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
The routine SortDataBrowserContainer can be used to sort hierarchical lists of items. For information about setting up a hierarchical list, refer to the
Managing Hierarchical Lists section.
|
The SortDataBrowserContainer routine.
|
OSStatus SortDataBrowserContainer(
ControlRef browser,
DataBrowserItemID container,
Boolean sortChildren);
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- container - to sort all of the items displayed at the top level of the control's display, provide the constant
kDataBrowserNoItem. Otherwise, sort all of the items that are organized as sub-items of a container item, provide the container item's Data ID.
- sortChildren - if this parameter is true, then all of the sub-items and sub-containers organized within the container will be sorted.
Returns an operating system result code describing the success of the operation. The code noErr will be returned if the operation was successful.
|
Back to top
DataBrowser Callback Routines
As discussed in the preliminary section discussing callbacks, "You call the DataBrowser, the DataBrowser calls you....", the DataBrowser control calls back to your application at key points during its execution either to request information from your application or to notify your application of changing conditions. As the DataBrowser control was designed to support many varied and complex scenarios of deployment, there are a large number of callback routines that your application can provide. Keep in mind, though, it is not necessary for an application to provide its own definition for each callback - only the ones actually required by an application need to be defined.
The DataBrowserCallbacks Structure
The DataBrowserCallbacks structure is the structure your application must use to provide references to the routines it would like the DataBrowser control to use when asking your application for information or notifying your application about changing conditions. At the very least, your application must define its own clientDataCallback routine, but keep in mind, the functionality of the list will improve as you add more routines.
clientDataCallback. The client data callback is used for communicating data between the DataBrowser and your application. When the DataBrowser needs to display a value for a particular cell, it will call your clientDataCallback to request the data. If the user changes the value for a particular cell, the DataBrowser will call your clientDataCallback with a new copy of the data that you should use to replace your application's internal copy.
|
DataBrowserGetSetItemDataUPP - the Client Data Callback.
|
typedef OSStatus (*DataBrowserGetSetItemDataProcPtr)(
ControlRef browser,
DataBrowserItemID item,
DataBrowserPropertyID property,
DataBrowserItemDataRef itemData,
Boolean setValue);
typedef DataBrowserGetSetItemDataProcPtr
DataBrowserGetSetItemDataUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- item - the Data ID of the data row whose data is being requested in this call.
- property - the Property ID to be used in conjunction with the Data ID to locate the cell whose data is being requested in this call. This value uniquely identifies the column.
- itemData - a pointer to the data or to a data buffer prepared to receive the data.
- setValue - if
setValue is true, then your callback should replace its current copy of the value associated with (item, property) with the value pointed to by itemData. If setValue to false, then your application should store a copy of the value associated with (item, property) to the buffer pointed to by itemData.
Returns an operating system result code describing the success of the operation. Your callback should return the result code noErr if the operation was successful.
|
The data callback routine is the place where your application provides a mapping between Data ID numbers used to identify rows in the list, Property ID numbers used to identify columns, and the actual data that should be displayed in any particular cell. The DataBrowser will call your data callback routine with a Data ID and a Property ID. Your data callback routine should respond by either saving or returning the appropriate value depending on the state of the setValue parameter. Listing 6 a simple example of how your application could implement a data callback routine.
|
Listing 6.
Example data callback routine.
|
/* MySimpleDataCallback is a simple data callback routine
that would be used in a browser control displaying a list
of generic document icons together with a list of checkboxes.
The checkbox column is a mutable column. */
OSStatus MySimpleDataCallback(
ControlRef browser,
DataBrowserItemID itemID,
DataBrowserPropertyID property,
DataBrowserItemDataRef itemData,
Boolean changeValue) {
IconRef myIcon;
OSStatus err;
/* start with a known state */
myIcon = NULL;
/* look at the property ID and decide what to do
depending on what column we're dealing with... */
if (property == kMyCheckboxColumn) {
ThemeButtonValue buttonValue;
/* are we being asked to change the value
we have in our own store or are we being
asked to retried the value? You'll only
have ask this question for mutable columns. */
if (changeValue) {
err = GetDataBrowserItemDataButtonValue(itemData,
&buttonValue);
if (err != noErr) goto bail;
/* NOTE: our internal storage lookup mechanism must
map itemID numbers to the values stored for each
button in the list. */
err = StoreTheValueSomewhere(itemID, buttonValue);
if (err != noErr) goto bail;
} else {
err = GetTheButtonValueFromSomewhere(itemID, &buttonValue);
if (err != noErr) goto bail;
err = SetDataBrowserItemDataButtonValue(itemData,
buttonValue);
if (err != noErr) goto bail;
}
} else if (property == kMyIconOnlyColumn) {
/* if the column is not mutable, then we
can safely assume we are only being asked
to retrieve the value. */
err = GetIconRef(kOnSystemDisk, kSystemIconsCreator,
kGenericDocumentIcon, &myIcon);
if (err != noErr) goto bail;
err = SetDataBrowserItemDataIcon(itemData, myIcon);
if (err != noErr) goto bail;
ReleaseIconRef(myIcon);
myIcon = NULL;
} else {
err = errDataBrowserPropertyNotSupported
goto bail;
}
return noErr;
bail:
if (myIcon != NULL) ReleaseIconRef(myIcon);
return err;
}
|
compareCallback. This routine will be called by the DataBrowser when it is ordering the values displayed in a column. Your application should provide a comparison for all of the every property type your application presents that is capable of being sorted.
typedef Boolean (*DataBrowserCompareProcPtr)(
ControlRef browser,
DataBrowserItemID itemOne,
DataBrowserItemID itemTwo,
DataBrowserPropertyID sortProperty);
typedef DataBrowserCompareProcPtr DataBrowserCompareUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- itemOne - the Data ID of the first row to be used in the comparison.
- itemTwo - the Data ID of the second row to be used in the comparison.
- sortProperty - the Property ID number for the column being sorted.
Your application's callback should return true if the value of the data referenced by itemOne is less than the value of the data referenced by itemTwo, and it should return should return false if the value of the data referenced by itemOne is greater than or equal to the value of the data referenced by itemTwo. The comparison should only consider the values being displayed in the column referenced by the Property ID in sortProperty. Sorting is stable, so you can use secondary and tertiary sorting. Each time a user clicks a column, the column will be sorted, but the sort order of matching items will be preserved.
|
itemNotificationCallback. The item notification callback routine will be called by the DataBrowser to notify your application of interesting conditions that it may wish to respond to. The kinds of conditions that your application will be notified of are enumerated and defined in Table 1.
typedef void (*DataBrowserItemNotificationProcPtr)(
ControlRef browser,
DataBrowserItemID item,
DataBrowserItemNotification message);
typedef DataBrowserItemNotificationProcPtr
DataBrowserItemNotificationUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- item - the Data ID of the row being identified by this call.
- message Possible values for this parameter are described in Table 1.
|
|
Table 1. Notifications provided by the browser control.
|
|
Constant Name | Description |
|
kDataBrowserItemAdded
| The specified item has been added to the browser. |
kDataBrowserItemRemoved
| The specified item has been removed from the browser. |
kDataBrowserEditStarted
| Starting an EditText session for specified item. |
kDataBrowserEditStopped
| Stopping an EditText session for specified item. |
kDataBrowserItemSelected
| Item has just been added to the selection set. |
kDataBrowserItemDeselected
| Item has just been removed from the selection set. |
kDataBrowserItemDoubleClicked
| The user double clicked on an item. |
kDataBrowserContainerOpened
| Container has been opened. |
kDataBrowserContainerClosing
| Container is about to close. |
kDataBrowserContainerClosed
| Container has been closed. |
kDataBrowserContainerSorting
| Container is about to be sorted (lock any volatile
properties). |
kDataBrowserContainerSorted
| Container has been sorted (you may release any
property locks). |
kDataBrowserTargetChanged
| The target has changed to the specified item. |
kDataBrowserUserStateChanged
| The user has reformatted the view for the target. |
kDataBrowserSelectionSetChanged
| The selection set has been modified (net result
may be the same). |
addDragItemCallback. Once the DataBrowser has determined it is beginning an outgoing drag, it iterates through all of the selected items calling the DataBrowserAddDragItemProcPtr. At this point, your application can add the items drag inside of the addDragItemCallback routine. Your application's addDragItemCallback routine will be called after the DragReference has been created, but before TrackDrag is called. DataBrowser takes care of the imaging and adds transparency for you, so there is no need to create or add your own transparency information to the drag reference.
In this routine your application should add the item to the drag. Return true from this routine to tell the DataBrowser to add a transparent representation of the row to the drag image.
typedef Boolean (*DataBrowserAddDragItemProcPtr)(
ControlRef browser,
DragReference theDrag,
DataBrowserItemID item,
ItemReference *itemRef);
typedef DataBrowserAddDragItemProcPtr DataBrowserAddDragItemUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- theDrag - the drag reference being constructed by the DataBrowser.
- item - this is the item ID of the item your application should add to the drag.
- itemRef - this parameter is currently unused. You should set this parameter to point to an
ItemReference variable before calling this routine.
If your callback returns true, then the item will be added to the transparent drag image. If it returns false, it will not.
|
acceptDragCallback. As an incoming drag is moved over an item, this routine is called. If your routine returns true, then the DataBrowser will draw the right highlighting and be prepared to receive a DataBrowserReceiveDragProcPtr call.
typedef Boolean (*DataBrowserAcceptDragProcPtr)(
ControlRef browser,
DragReference theDrag,
DataBrowserItemID item);
typedef DataBrowserAcceptDragProcPtr DataBrowserAcceptDragUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- theDrag - a Drag Manager reference.
- item - This is the item ID of the item the drag is being held over. If the drag is being held over the list but not over any item, then item will contain the default target item ID for the list. The default target item ID for the list is discussed in the section Setting the Root Container.
Your callback should return true if it is capable of accepting the drag in the location designated by the item parameter.
|
receiveDragCallback. Your receiveDragCallback routine will be called to receive drags. In this routine, your application should extract the items it needs from the drag and add them to the list in the location defined by the item parameter.
Boolean (*DataBrowserReceiveDragProcPtr) (
ControlRef browser,
DragReference theDrag,
DataBrowserItemID item);
typedef DataBrowserReceiveDragProcPtr
DataBrowserReceiveDragUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- theDrag - a Drag Manager reference.
- item - This is the item ID of the item the drag is being held over. If the drag is being held over the list but not over any item, then item will contain the default target item ID for the list. The default target item ID for the list is discussed in the section Setting the Root Container.
Your callback should return true if is successfully completes processing all of the information in the drag. Otherwise, it should return false. If your callback returns false, the zoom-back animation will occur for the drag.
|
postProcessDragCallback. Your application's postProcessDragCallback routine will be called after a drag command has been completed if any one of the drag processing callback routines you installed (receiveDragCallback, acceptDragCallback, or addDragItemCallback) were called during the drag. Specifically, this routine will be called if any one call to addDragItemCallback returns true, and after all calls acceptDragCallback and receiveDragCallback. Inside of your postProcessDragCallback routine, your application should deallocate any resources that were allocated when the other drag handlers were called. The postProcessDragCallback will be called immediately before the drag reference is deallocated by the DataBrowser so your application should not assume that this structure will remain intact after this callback is made.
typedef void (*DataBrowserPostProcessDragProcPtr)(
ControlRef browser,
DragReference theDrag,
OSStatus trackDragResult);
typedef DataBrowserPostProcessDragProcPtr
DataBrowserPostProcessDragUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- theDrag - a Drag Manager drag reference.
- trackDragResult - the result returned by
TrackDrag
Returns an operating system result code describing the success of the operation. Your callback should return the result code noErr if the operation was successful.
|
getHelpContentCallback - for Displaying Help Content.
typedef void (*DataBrowserGetHelpContentProcPtr)(
ControlRef browser,
DataBrowserItemID item,
DataBrowserPropertyID property,
HMContentRequest inRequest,
HMContentProvidedType *outContentProvided,
HMHelpContentPtr ioHelpContent);
typedef DataBrowserGetHelpContentProcPtr
DataBrowserGetHelpContentUPP;
|
- browser - a Data
Browser control created by a call to
CreateDataBrowserControl.
- item - the Data ID indentifying the row.
- property - the Property ID identifying the column.
- inRequest - either
kHMSupplyContent or kHMDisposeContent.
- outContentProvided - should be set to the content type provided in the record pointed to by
ioHelpContent.
- ioHelpContent - a help content record containing the help information to be displayed.
Returns an operating system result code describing the success of the operation.
Your callback should return the result code noErr if the operation
was successful.
|
contextualMenuCallback.
typedef void (*DataBrowserGetContextualMenuProcPtr)(
ControlRef browser,
MenuRef *menu,
UInt32 *helpType,
CFStringRef *helpItemString,
AEDesc *selection);
typedef DataBrowserGetContextualMenuProcPtr
DataBrowserGetContextualMenuUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- menu - Your callback should provide a MenuRef in this parameter.
- helpType - set this variable to one of the values
kCMHelpItemNoHelp, kCMHelpItemAppleGuide, or kCMHelpItemOtherHelp. This value will be passed to ContextualMenuSelect.
- helpItemString - The very first item that appears in the contextual menu. If you set this value to
Null, then the default "Help" string will be displayed.
- selection - this will point to an empty
AEDesc and your callback should set this to your own internal representation of the selection. This will be passed to ContextualMenuSelect.
Returns an operating system result code describing the success of the operation. Your callback should return the result code noErr if the operation was successful.
|
selectContextMenuCallback.
typedef void (*DataBrowserSelectContextualMenuProcPtr)(
ControlRef browser,
MenuRef menu,
UInt32 selectionType,
SInt16 menuID,
MenuItemIndex menuItem);
typedef DataBrowserSelectContextualMenuProcPtr
DataBrowserSelectContextualMenuUPP;
|
- browser - a DataBrowser control created by a call to
CreateDataBrowserControl.
- menu - the menu reference your application provided in its
contextualMenuCallback.
- selectionType - returned from
ContextualMenuSelect.
- menuID - the menu ID of the menu selected. This field will be
zero if no selection was made.
- menuItem - the menu item number of the item selected.
|
This section discusses operations on the
DataBrowserCallbacks structure as a whole;
discussion of the meaning of its constituent elements is
provided later in this document. For your convenience, the
field names listed above are linked to those descriptions.
In the simplest of cases, the
clientDataCallback is the only callback your
application will need to re-define.
Pointers to the callback routines used by a particular
DataBrowser control can be accessed through the
DataBrowserCallbacks structure. The mechanism
used for installing the callback routines for a Data
Browser control is analogous to the mechanism used for
QuickDraw's SetStdProcs
routine: an application calls
InitDataBrowserCallbacks to set up a
DataBrowserCallbacks structure so it contains
all of the standard DataBrowser callback routines, then
your application replaces the callbacks it wishes to
customize with pointers to its own routines.
|
The InitDataBrowserCallbacks routine.
|
OSStatus InitDataBrowserCallbacks(
DataBrowserCallbacks* callbacks);
| |
Returns an operating system result code describing the success of the operation.
The code noErr will be returned if the operation was
successful.
|
The routine InitDataBrowserCallbacks
initializes a DataBrowserCallbacks structure so
it contains references to all of the default callback
routines used by the DataBrowser control. After calling
InitDataBrowserCallbacks, your application
should replace the callback routines it wishes to customize
with references to its own routines.
Once your application has installed references to its own
callback routines in the DataBrowserCallbacks
structure, it can install the new callbacks in a Data
Browser control by calling the
SetDataBrowserCallbacks routine. This routine
replaces the DataBrowserCallbacks structure
currently being used by the control with the structure the
application provides as a parameter.
|
The SetDataBrowserCallbacks routine.
|
OSStatus SetDataBrowserCallbacks(
ControlRef control,
const DataBrowserCallbacks *callbacks);
| |
Returns an operating system result code describing the success of the operation.
The code noErr will be returned if the operation was
successful.
|
It is also possible to retrieve a copy of the
DataBrowserCallbacks structure that is
currently being used by a DataBrowser control. This can be
done using the GetDataBrowserCallbacks
routine.
|
The GetDataBrowserCallbacks routine.
|
OSStatus GetDataBrowserCallbacks(
ControlRef control,
DataBrowserCallbacks *callbacks);
|
- control - a DataBrowser contro
| |