Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

PATHDocumentation > Mac OS 8 and 9 > Human Interface Toolbox > Control Manager >

Mac OS 8 Control Manager Reference


Defining Your Own User Pane Functions

This section describes the application-defined user pane functions that provide you with the ability to create a custom Appearance-compliant control without writing your own control definition function. A user pane is a general purpose stub control; it can be used as the root control for a window, as well as providing a way to hook in application-defined functions such as those described below. When Appearance is available, user panes should be used in dialog boxes instead of user items.

Once you have provided a user pane application-defined function, pass the tag constant representing the user pane function you wish to get or set in the tagName parameter of SetControlData . For a description of the tag constants, see Control Data Tag Constants . For example, to set a user pane draw function, pass the constant kControlUserPaneDrawProcTag of type ControlUserPaneDrawingUPP in the tagName parameter of SetControlData .The Control Manager then draws the control using a universal procedure pointer to your user pane draw function.

The following Control Manager functions for defining your own user pane functions are new with Appearance Manager 1.0:


MyUserPaneDrawProc

Draws the content of your user pane control in the rectangle of user pane control.

The Control Manager declares the type for an application-defined user pane draw function as follows:

typedef pascal void (*ControlUserPaneDrawProc)(
                     ControlHandle control,
                     SInt16 part);

The Control Manager defines the data type ControlUserPaneDrawUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneDrawUPP;

You typically use the NewControlUserPaneDrawProc macro like this:

ControlUserPaneDrawUPP myControlUserPaneDraw UPP; myControlUserPaneDraw UPP = NewControlUserPaneDrawProc (MyUserPaneDraw);

You typically use the CallControlUserPaneDrawProc macro like this:

CallControlUserPaneDrawProc (myControlUserPaneDraw UPP, control, part);

Here's how to declare the function MyUserPaneDrawProc:

pascal void MyUserPaneDrawProc (
                     ControlHandle control,
                     SInt16 part);
control
A handle to the user pane control in which you wish drawing to occur.
part
The part code of the control you should draw. If 0, draw the entire control.

DISCUSSION

Once you have created the function MyUserPaneDrawProc , pass kControlUserPaneDrawProcTag in the tagName parameter of SetControlData .The Control Manager will draw the user pane control with a universal procedure pointer to MyUserPaneDrawProc .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


MyUserPaneHitTestProc

Returns the part code of the control that the point was in when the mouse-down event occurred.

The Control Manager declares the type for an application-defined user pane hit test function as follows:

typedef pascal ControlPartCode (*ControlUserPaneHitTestProc) (
                     ControlHandle control,
                     Point where);

The Control Manager defines the data type ControlUserPaneHitTestUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneHitTestUPP;

You typically use the NewControlUserPaneHitTestProc macro like this:

ControlUserPaneHitTestUPP myControlUserPaneHitTest UPP; myControlUserPaneHitTest UPP = NewControlUserPaneHitTest Proc (MyUserPaneHitTest);

You typically use the CallControlUserPaneHitTestProc macro like this:

CallControlUserPaneHitTest Proc(myControlUserPaneHitTest UPP, control, where);

Here's how to declare the function MyUserPaneHitTestProc:

pascal ControlPartCode MyUserPaneHitTestProc (
                     ControlHandle control,
                     Point where);
control
A handle to the control in which the mouse-down event occurred.
where
The point, in a window's local coordinates, where the mouse-down event occurred.
function result
Returns the part code of the control where the mouse-down event occurred. If the point was not over a control, your function should return kControlNoPart .

DISCUSSION

Once you have created the function MyUserPaneHitTestProc , pass kControlUserPaneHitTestProcTag in the tagName parameter of SetControlData .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


MyUserPaneTrackingProc

Tracks a control while the user holds down the mouse button.

The Control Manager declares the type for an application-defined user pane tracking function as follows:

typedef pascal ControlPartCode (*ControlUserPaneTrackingProc)(
                     ControlHandle control,
                     Point startPt,
                     ControlActionUPP actionProc);

The Control Manager defines the data type ControlUserPaneTrackingUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneTrackingUPP;

You typically use the NewControlUserPaneTrackingingProc macro like this:

ControlUserPaneTrackingUPP myControlUserPaneTracking UPP; myControlUserPaneTracking UPP = NewControlUserPaneTracking Proc (MyUserPaneTracking );

You typically use the CallControlUserPaneTrackingingProc macro like this:

CallControlUserPaneTracking Proc(myControlUserPaneTracking UPP, control, startPt, actionProc);

Here's how to declare the function MyUserPaneTrackingProc:

pascal ControlPartCode MyUserPaneTrackingProc (
                     ControlHandle control,
                     Point startPt,
                     ControlActionUPP actionProc);
control
A handle to the control in which the mouse-down event occurred.
startPt
The location of the cursor at the time the mouse button was first pressed, in local coordinates. Your application retrieves this point from the where field of the event structure.
actionProc
A pointer to an action function defining what action your application takes while the user holds down the mouse button. The value of the actionProc parameter can be a valid procPtr , nil , or -1. A value of -1 indicates that the control should either perform auto tracking, or if it is incapable of doing so, do nothing (like nil ).
function result
Returns the part code of the control part that was tracked. If tracking was unsuccessful, kControlNoPartCode is returned.

DISCUSSION

Your MyUserPaneTrackingProc function should track the control by repeatedly calling the action function specified in the actionProc parameter until the mouse button is released. When the mouse button is released, your function should return the part code of the control part that was tracked.

This function will only get called if you've set the kControlHandlesTracking feature bit on creation of the user pane control. Once you have created the function MyUserPaneTrackingProc , pass kControlUserPaneTrackingProcTag in the tagName parameter of SetControlData .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


MyUserPaneIdleProc

Performs idle processing.

The Control Manager declares the type for an application-defined user pane idle function as follows:

typedef pascal void (*ControlUserPaneIdleProc)(ControlHandle control);

The Control Manager defines the data type ControlUserPaneIdleUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneIdleUPP;

You typically use the NewControlUserPaneIdleProc macro like this:

ControlUserPaneIdleUPP myControlUserPaneIdle UPP; myControlUserPaneIdle UPP = NewControlUserPaneIdleProc (MyUserPaneIdle );

You typically use the CallControlUserPaneIdleProc macro like this:

Call ControlUserPaneIdleProc (myControlUserPaneIdle UPP, control);

Here's how to declare the function MyUserPaneIdleProc:

pascal void MyUserPaneIdleProc (ControlHandle control);
control
A handle to the control for which you wish to perform idle processing.

DISCUSSION

This function will only get called if you've set the kControlWantsIdle feature bit on creation of the user pane control. Once you have created the function MyUserPaneIdleProc , pass kControlUserPaneIdleProcTag in the tagName parameter of SetControlData .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


MyUserPaneKeyDownProc

Handles keyboard event processing.

The Control Manager declares the type for an application-defined user pane key down function as follows:

typedef pascalControlPartCode(*ControlUserPaneKeyDownProc)(
                     ControlHandle control
                     SInt16 keyCode,
                     SInt16 charCode,
                     SInt16 modifiers);

The Control Manager defines the data type UserPaneKeyDownUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneKeyDownUPP;

You typically use the NewControlUserPaneKeyDownProc macro like this:

ControlUserPaneKeyDownUPP myControlUserPaneKeyDown UPP; myControlUserPaneKeyDown UPP = NewControlUserPaneKeyDown Proc (MyUserPaneKeyDown );

You typically use the CallControlUserPaneKeyDownProc macro like this:

Call ControlUserPaneKeyDown Proc(myControlUserPaneKeyDown UPP, control, keyCode, charCode, modifiers);

Here's how to declare the function MyUserPaneKeyDownProc:

pascal ControlPartCode MyUserPaneKeyDownProc (
                     ControlHandle control,
                     SInt16 keyCode,
                     SInt16 charCode,
                     SInt16 modifiers);
control
A handle to the control in which the keyboard event occurred.
keyCode
The virtual key code derived from event structure. This value represents the key pressed or released by the user. It is always the same for a specific physical key on a particular keyboard regardless of which modifier keys were also pressed.
charCode
A particular character derived from the event structure. This value depends on the virtual key code, the state of the modifier keys, and the current 'KCHR' resource.
modifiers
The constant in the modifiers field of the event structure specifying the state of the modifier keys and the mouse button at the time the event was posted.
function result
Returns the part code of the control where the keyboard event occurred. If the keyboard event did not occur in a control, your function should return kControlNoPart .

DISCUSSION

Your MyUserPaneKeyDownProc function should handle the key pressed or released by the user and return the part code of the control where the keyboard event occurred. This function will only get called if you've set the kControlSupportsFocus feature bit on creation of the user pane control. Once you have created the function MyUserPaneKeyDownProc , pass kControlUserPaneKeyDownProcTag in the tagName parameter of SetControlData .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


MyUserPaneActivateProc

Handles activate and deactivate event processing.

The Control Manager declares the type for an application-defined user pane activate function as follows:

typedef pascal void (*ControlUserPaneActivateProc)(
                     ControlHandle control,
                     Boolean activating);

The Control Manager defines the data type UserPaneActivateUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneActivateUPP;

You typically use the NewControlUserPaneActivateProc macro like this:

ControlUserPaneActivateUPP myControlUserPaneActivateUPP;
myControlUserPaneActivateUPP = NewControlUserPaneActivateProc
(MyUserPaneActivate);

You typically use the CallControlUserPaneActivateProc macro like this:

CallControlUserPaneActivateProc(myControlUserPaneActivateUPP, control,
activating);

Here's how to declare the function MyUserPaneActivateProc:

pascal void MyUserPaneActivateProc (
                     ControlHandle control
                     Boolean activating);
control
A handle to the control in which the activate event occurred.
activating
A Boolean value indicating whether or not the control is being activated. If true , the control is being activated. If false , the control is being deactivated.

DISCUSSION

Your MyUserPaneActivateProc function should perform any special processing before the user pane becomes activated or deactivated. For example, it should deactivate its TEHandle or ListHandle if the user pane is about to be deactivated.

This function will only get called if you've set the kControlWantsActivate feature bit on creation of the user pane control. Once you have created the function MyUserPaneActivateProc , pass kControlUserPaneActivateProcTag in the tagName parameter of SetControlData .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


MyUserPaneFocusProc

Handles keyboard focus.

The Control Manager declares the type for an application-defined user pane focus function as follows:

typedef pascal ControlPartCode (*ControlUserPaneFocusProc)(
                     ControlHandle control,
                     ControlFocusPart action);

The Control Manager defines the data type ControlUserPaneFocusUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneFocusUPP;

You typically use the NewControlUserPaneFocusProc macro like this:

ControlUserPaneFocusUPP myControlUserPaneFocusUPP;
myControlUserPaneFocusUPP = NewControlUserPaneFocusProc
(MyUsePaneFocus);

You typically use the CallControlUserPaneFocusProc macro like this:

CallControlUserPaneFocusProc(myControlUserPaneFocusUPP, control, action);

Here's how to declare the function MyUserPaneFocusProc:

pascal ControlPartCode MyUserPaneFocusProc (
                     ControlHandle control
                     ControlFocusPart action);
control
A handle to the control that is to adjust its focus.
action
The part code of the user pane to receive keyboard focus; see Handling Keyboard Focus .
function result
Returns the part of the user pane actually focused. kControlFocusNoPart is returned if the user pane has lost the focus or cannot be focused.

DISCUSSION

Your MyUserPaneFocusProc function is called in response to a change in keyboard focus. It should respond by changing keyboard focus based on the part code passed in the action parameter.

This function will only get called if you've set the kControlSupportsFocus feature bit on creation of the user pane control. Once you have created the function MyUserPaneFocusProc , pass kControlUserPaneFocusProcTag in the tagName parameter of SetControlData .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


MyUserPaneBackgroundProc

Sets the background color or pattern for user panes that support embedding.

The Control Manager declares the type for an application-defined user pane background color function as follows:

typedef pascal (*ControlUserPaneBackgroundProcPtr)(
                     ControlHandle control,
                     ControlBackgroundPtr info);

The Control Manager defines the data type ControlUserPaneBackgroundUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneBackgroundUPP;

You typically use the NewControlUserPaneBackgroundProc macro like this:

ControlUserPaneBackgroundUPP myControlUserPaneBackgroundUPP;
myControlUserPaneBackgroundUPP = NewControlUserPaneBackgroundProc
(MyUsePaneBackground);

You typically use the CallControlUserPaneBackgroundProc macro like this:

CallControlUserPaneBackgroundProc(myControlUserPaneBackgroundUPP, control,
info);

Here's how to declare the function MyUserPaneBackgroundProc:

pascal void MyUserPaneBackgroundProc (
                     ControlHandle control
                     ControlBackgroundPtr info);
control
A handle to the control for which the background color or pattern is to be set.
info
A pointer to information such as the depth and type of the drawing device.

DISCUSSION

Your MyUserPaneBackgroundProc function should set the user pane background color or pattern to whatever is appropriate given the bit depth and device type passed in. Your MyUserPaneBackgroundProc function is called to set up the background color. This ensures that when an embedded control calls EraseRgn or EraseRect , the background is erased to the correct color or pattern.

This function will only get called if there is a control embedded in the user pane and if you've set the kControlHasSpecialBackground and kControlSupportsEmbedding feature bits on creation of the user pane control. Once you have created the function MyUserPaneBackgroundProc , pass kControlUserPaneBackgroundProcTag in the tagName parameter of SetControlData .


VERSION NOTES

Available with Appearance Manager 1.0 and later.


\xA9 1998 Apple Computer, Inc. – (Last Updated 19 Nov 98)