Control.h
. It discusses the following topics:
ButtonFrameType
enum specifies the border style for the button. It defines values for the frame
field of
ControlAttrType
.
enum buttonFrames {noButtonFrame,
    standardButtonFrame, boldButtonFrame,
    rectangleButtonFrame};
typedef enum buttonFrames ButtonFrameType;
ControlAttrType
bit field specifies the control's visible characteristics. It is defined as follows:
typedef struct {
    UInt8 usable :1;
    UInt8 enabled :1;
    UInt8 visible :1;
    UInt8 on :1;
    UInt8 leftAnchor :1;
    UInt8 frame :3;
    UInt8 drawnAsSelected : 1;
    UInt8 graphical :1;
    UInt8 vertical :1;
} ControlAttrType;
ControlAttrType
structure as opaque. Use the functions specified in the descriptions below to retrieve and set each value. Do not attempt to change structure member values directly.
drawnAsSelected
, graphical
, and vertical
attributes are only present if 3.5 New Feature Set is present.
ControlPtr
is a pointer to a
ControlType
structure.
typedef ControlType* ControlPtr;
ControlStyleType
enum specifies values for the
ControlType
style
field, which specifies the type of the control (button, push button, and so on).
enum controlStyles {buttonCtl, pushButtonCtl,
    checkboxCtl, popupTriggerCtl,
    selectorTriggerCtl, repeatingButtonCtl,
    sliderCtl, feedbackSliderCtl};
typedef enum controlStyles ControlStyleType;
sliderCtl
and feedbackSliderCtl
values are only defined if 3.5 New Feature Set is present.
ControlType
structure defines the type and characteristics of a control. It is defined as follows:
typedef struct {
    UInt16 id;
    RectangleType bounds;
    Char * text;
    ControlAttrType attr;
    ControlStyleType style;
    FontID font;
    UInt8 group;
    UInt8 reserved;
} ControlType;
ControlType
structure as opaque. The fields in the struct are set by values you specify when you create the control resource, and they typically do not change. Use the functions specified in the descriptions below to retrieve and set the values. Do not attempt to change structure member values directly.
GraphicControlType
struct defines a graphical control. A graphical control is like any other control except that it displays a bitmap in place of the text label.
typedef struct GraphicControlType {
    UInt16 id;
    RectangleType bounds;
    DmResID bitmapID;
    DmResID selectedBitmapID;
    ControlAttrType attr;
    ControlStyleType style;
    FontID unused;
    UInt8 group;
    UInt8 reserved;
} GraphicControlType;
GraphicControlType
structure as opaque. The fields in the struct are set by values you specify when you create the control resource, and they typically do not change. Use the functions specified in the descriptions below to retrieve and set the values. Do not attempt to change structure member values directly.
SliderControlType
struct defines a slider control or a feedback slider control.
typedef struct SliderControlType {
    UInt16 id;
    RectangleType bounds;
    DmResID thumbID;
    DmResID backgroundID;
    ControlAttrType attr;
    ControlStyleType style;
    UInt8 reserved;
    Int16 minValue;
    Int16 maxValue;
    Int16 pageSize;
    Int16 value;
    MemPtr activeSliderP;
} SliderControlType;
SliderControlType
structure as opaque. The fields in the struct are set by values you specify when you create the control resource, and they typically do not change. You can use
CtlSetSliderValues
to set new minimum, maximum, page size, and current values, and
CtlGetSliderValues
to retrieve these values. Do not attempt to change structure member values directly.
void CtlDrawControl (ControlType *controlP)
usable
attribute is true
. This function sets the visible
attribute to true
.
GraphicControlType
.) CtlDrawControl
attempts to provide backward compatibility for the old-style graphical buttons.
true
if the control responds to the pen.
Boolean CtlEnabled (const ControlType *controlP)
true
if the controls object responds to the pen; false
if not.
CtlSetEnabled
void CtlEraseControl (ControlType *controlP)
visible
attribute to false
. If 3.5 New Feature Set is present, it also sets the drawnAsSelected
attribute to false
.
FrmHideObject
, which calls this function.
const Char *CtlGetLabel (const ControlType *controlP)
controlP
is not a graphical control or a slider control. The graphical control and slider control structures do not contain a text label field.
CtlSetLabel
void CtlGetSliderValues (const ControlType *ctlP, UInt16 *minValueP, UInt16 *maxValueP, UInt16 *pageSizeP, UInt16 *valueP)
  |
-> |
Pointer to a control object. (See ControlType .) |
  |
<- |
The slider's minimum value. Pass NULL if you don't want to retrieve this value. |
  |
<- |
The slider's maximum value. Pass NULL if you don't want to retrieve this value. |
  |
<- |
The slider's page size value. Pass NULL if you don't want to retrieve this value. |
  |
<- |
The slider's current value. Pass NULL if you don't want to retrieve this value. |
ctlP
is not a slider or a feedback slider, this function immediately returns.
CtlSetSliderValues
,
SliderControlType
Int16 CtlGetValue (const ControlType *controlP)
value
field.
CtlSetValue
,
FrmGetControlGroupSelection
,
FrmSetControlGroupSelection
,
FrmGetControlValue
,
FrmSetControlValue
Boolean CtlHandleEvent (ControlType *controlP, EventType pEvent)
  |
|
Pointer to control object. (See ControlType .) |
  |
|
Pointer to an EventType structure. |
true
if an event is handled by this function. Events that are handled are:
penDownEvent
, it checks if the pen position is within the bounds of the control object. If it is, a ctlEnterEvent
is added to the event queue and the routine exits.
ctlEnterEvent
, the control object is redrawn as necessary as either selected or deselected, depending on its previous state.
ctlEnterEvent
or ctlRepeatEvent
, it checks that the control ID in the passed event record matches the ID of the specified control. If they match, this routine tracks the pen until it comes up or until it leaves the object's bounds. When that happens, ctlSelectEvent
is sent to the event queue if the pen came up in the bounds of the control. If the pen exits the bounds, a ctlExitEvent
is sent to the event queue.
usable
attribute to false
and erase the control from the screen.
void CtlHideControl (ControlType *controlP)
usable
to false
(in addition to setting visible
to false
).
FrmHideObject
, which performs the same function and works for all user interface objects.
CtlShowControl
void CtlHitControl (const ControlType *controlP)
ControlType *CtlNewControl (void **formPP, UInt16 ID, ControlStyleType style, const Char *textP, Coord x, Coord y, Coord width, Coord height, FontID font, UInt8 group, Boolean leftAnchor)
  |
|
Symbolic ID of the control. |
  |
|
Horizontal coordinate of the upper-left corner of the control's boundaries, relative to the window in which it appears. |
  |
|
Vertical coordinate of the upper-left corner of the control's boundaries, relative to the window in which it appears. |
  |
|
Font used to draw the control's label. |
  |
|
true specifies that the left bound of this control is fixed. This attribute is used by controls that resize dynamically in response to label text changes. |
CtlValidatePointer
,
FrmRemoveObject
GraphicControlType *CtlNewGraphicControl (void **formPP, UInt16 ID, ControlStyleType style, DmResID bitmapID, DmResID selectedBitmapID, Coord x, Coord y, Coord width, Coord height, UInt8 group, Boolean leftAnchor)
  |
|
Symbolic ID of the control. |
  |
|
A ControlStyleType value specifying the kind of control to create: button, push button, popup trigger, repeating button, or popup selector. Graphic controls cannot be check boxes. |
  |
|
Resource ID of the bitmap to display on the control. |
  |
-> |
Resource ID of the bitmap to display when the control is selected, if different from bitmapID . |
  |
|
Horizontal coordinate of the upper-left corner of the control's boundaries, relative to the window in which it appears. |
  |
|
Vertical coordinate of the upper-left corner of the control's boundaries, relative to the window in which it appears. |
  |
|
Width of the control, expressed in pixels. Valid values are 1-160. |
  |
|
Height of the control, expressed in pixels. Valid values are 1-160. |
  |
|
true specifies that the left bound of this control is fixed. |
GraphicControlType
.
CtlNewSliderControl
,
CtlNewControl
,
CtlValidatePointer
,
FrmRemoveObject
SliderControlType *CtlNewSliderControl (void **formPP, UInt16 ID, ControlStyleType style, DmResID thumbID, DmResID backgroundID, Coord x, Coord y, Coord width, Coord height, UInt16 minValue, UInt16 maxValue, UInt16 pageSize, UInt16 value)
  |
-> |
Symbolic ID of the slider. |
  |
-> |
Either sliderCtl or feedbackSliderCtl . See ControlStyleType . |
  |
-> |
Resource ID of the bitmap to display as the slider background. To use the default background bitmap, pass NULL for this parameter. |
  |
-> |
Horizontal coordinate of the upper-left corner of the slider's boundaries, relative to the window in which it appears. |
  |
-> |
Vertical coordinate of the upper-left corner of the slider's boundaries, relative to the window in which it appears. |
  |
-> |
Width of the slider, expressed in pixels. Valid values are 1-160. |
  |
-> |
Height of the slider, expressed in pixels. Valid values are 1-160. |
  |
-> |
Value of the slider when its thumb is all the way to the left. |
  |
-> |
Value of the slider when its thumb is all the way to the right. |
  |
-> |
Amount by which to increase or decrease the slider's value when the user clicks to the right or left of the thumb. |
  |
-> |
The initial value to display in the slider. |
SliderControlType
.
CtlNewGraphicControl
,
CtlNewControl
,
CtlValidatePointer
,
FrmRemoveObject
void CtlSetEnabled (ControlType *controlP, Boolean enable)
  |
|
Pointer to a control object. (See ControlType .) |
  |
|
true to enable the control; false to disable the control. |
CtlEnabled
void CtlSetGraphics (ControlType *ctlP, DmResID newBitmapID, DmResID newSelectedBitmapID)
  |
-> |
Pointer to a graphical control object. (See GraphicControlType .) |
  |
-> |
Resource ID of a new bitmap to display on the control, or NULL to use the current bitmap. |
  |
-> |
Resource ID of a new bitmap to display when the control is selected, or NULL to use the current selected bitmap. |
ctlP
is not a graphical control, this function immediately returns.
GraphicControlType
void CtlSetLabel (ControlType *controlP, const Char *newLabel)
  |
|
Pointer to a control object. (See ControlType .) |
  |
|
Pointer to the new text label. Must be a NULL -terminated string. |
newLabel
pointer in the control's data structure. It doesn't make a copy of the string that is passed in. Therefore, if you use CtlSetLabel
, you must manage the string yourself. You must ensure that it persists for as long as it is being displayed (that is, for as long as the control is displayed or until you call CtlSetLabel
with a new string), and you must free the string after it is no longer in use (typically after the form containing the control is freed).
CtlSetLabel
, you do not need to worry about freeing a control's label.
controlP
is not a graphical control or a slider control. The graphical controls and slider control structures do not contain a text label field, so attempting to set one will crash your application.
CtlGetLabel
void CtlSetSliderValues (ControlType *ctlP, const UInt16 *minValueP, const UInt16 *maxValueP, const UInt16 *pageSizeP, const UInt16 *valueP)
  |
-> |
Pointer to an inactive slider or feedback slider control. (See SliderControlType .) |
  |
-> |
Pointer to a new value to use for the slider's minimum or NULL if you don't want to change this value. |
  |
-> |
Pointer to a new value to use for the slider's maximum, or NULL if you don't want to change this value. |
  |
-> |
Pointer to a new value to use for the slider's page size, or NULL if you don't want to change this value. |
  |
-> |
Pointer to a new value to use for the current value, or NULL if you don't want to change this value. |
sliderCtl
or feedbackSliderCtl
, and it not be currently tracking the pen. If the slider is currently tracking the pen, use
CtlSetValue
to set the value
field.
CtlGetSliderValues
,
SliderControlType
void CtlSetUsable (ControlType *controlP, Boolean usable)
  |
|
Pointer to a control object. (See ControlType .) |
  |
|
true to have the control be usable; false to have the control be not usable. |
CtlHideControl
,
CtlShowControl
void CtlSetValue (ControlType *controlP, Int16 newValue)
  |
|
Pointer to a control object. (See ControlType .) |
CtlGetValue
,
FrmGetControlGroupSelection
,
FrmSetControlGroupSelection
,
FrmGetControlValue
,
FrmSetControlValue
usable
attribute to true
and draw the control on the screen. This function calls CtlDrawControl.
void CtlShowControl (ControlType *controlP)
CtlDrawControl
.
visible
and the usable
attributes to true
. (See
ControlAttrType
.)
FrmShowObject
, which does the same thing.
CtlHideControl
true
if the specified pointer references a valid control object.
Boolean CtlValidatePointer (const ControlType *controlP)
true
when passed a valid pointer to a control; otherwise, returns false
.
FrmValidatePtr
,
WinValidateHandle
  |   |