Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
NotificationMon.ƒ/Source/DialogUtil.c
/* |
DialogUtil.c |
------------ |
*/ |
#ifndef NIL |
#define NIL 0L |
#endif |
#ifndef THE_FRONT_WINDOW |
#define THE_FRONT_WINDOW (Ptr)(void *) -1L |
#endif |
pascal void HiliteItemProc(WindowPtr wp, short item) |
{ |
HilightItem(wp,item); |
} |
SetUserItemProc(DialogPtr dp, short item, ProcPtr proc) |
{ |
Handle iHandle; |
Rect box; |
int iType; |
Str255 tempString; |
long itemValue; |
GetDItem(dp,item,&iType,&iHandle,&box); |
SetDItem(dp,item,iType,(Handle)proc,&box); |
} |
PutNumericItem(theDialog,itemNumber,number) |
DialogPtr theDialog; |
short itemNumber; |
short number; |
{ |
Handle iHandle; |
Rect box; |
int iType; |
Str255 tempString; |
long itemValue; |
NumToString(number,&tempString); |
GetDItem(theDialog,itemNumber,&iType,&iHandle,&box); |
SetIText(iHandle,&tempString); |
} |
short GetNumericItem(theDialog,itemNumber) |
DialogPtr theDialog; |
int itemNumber; |
{ |
Handle iHandle; |
Rect box; |
int iType; |
Str255 tempString; |
long itemValue; |
GetDItem(theDialog,itemNumber,&iType,&iHandle,&box); |
GetIText(iHandle,&tempString); |
StringToNum(&tempString,&itemValue); |
return(itemValue); |
} |
GetTextItem(theDialog,itemNumber,text) |
DialogPtr theDialog; |
int itemNumber; |
Str255 *text; |
{ |
Handle iHandle; |
Rect box; |
int iType; |
GetDItem(theDialog,itemNumber,&iType,&iHandle,&box); |
GetIText(iHandle,text); |
} |
PutTextItem(theDialog,itemNumber,text) |
DialogPtr theDialog; |
int itemNumber; |
Str255 *text; |
{ |
Handle iHandle; |
Rect box; |
int iType; |
GetDItem(theDialog,itemNumber,&iType,&iHandle,&box); |
SetIText(iHandle,text); |
} |
ShowDialog(dialog_id) |
int dialog_id; |
{ |
DialogPtr dialog_ptr; |
int itemHit; |
dialog_ptr = GetNewDialog(dialog_id,NIL,THE_FRONT_WINDOW); |
ModalDialog(NIL,&itemHit); |
DisposDialog(dialog_ptr); |
} |
int GetDialogCtlValue(dialog,item) |
DialogPtr dialog; |
int item; |
{ |
ControlHandle iHandle; |
Rect box; |
int iType; |
GetDItem(dialog,item,&iType,&iHandle,&box); |
return(GetCtlValue(iHandle)); |
} |
SetDialogCtlValue(dialog,item,newValue) |
DialogPtr dialog; |
int item; |
{ |
ControlHandle iHandle; |
Rect box; |
int iType; |
GetDItem(dialog,item,&iType,&iHandle,&box); |
SetCtlValue(iHandle,newValue); |
} |
SetDialogCtlHilite(dialog,item,hilite) |
DialogPtr dialog; |
short item; |
short hilite; |
{ |
ControlHandle iHandle; |
Rect box; |
int iType; |
GetDItem(dialog,item,&iType,&iHandle,&box); |
HiliteControl(iHandle,hilite); |
} |
void BoxItem(dialog,item) |
DialogPtr dialog; |
int item; |
{ |
Handle iHandle; |
Rect box; |
int iType; |
GrafPtr savePort; |
GetPort(&savePort); |
SetPort(dialog); |
GetDItem(dialog,item,&iType,&iHandle,&box); |
InsetRect(&box,-2,-2); |
FrameRect(&box); |
SetPort(savePort); |
} |
HilightItem(dialog,item) |
DialogPtr dialog; |
int item; |
{ |
Handle iHandle; |
Rect box; |
int iType; |
PenState savePen; |
GrafPtr savePort; |
GetPort(&savePort); |
SetPort(dialog); |
GetPenState(&savePen); |
GetDItem(dialog,item,&iType,&iHandle,&box); |
PenSize(3,3); |
InsetRect(&box,-4,-4); |
FrameRoundRect(&box,16,16); |
SetPenState(&savePen); |
SetPort(savePort); |
} |
int TrackDialogControl(dialog,item,start) |
DialogPtr dialog; |
int item; |
Point start; |
{ |
Handle cHandle; |
Rect box; |
int iType; |
GetDItem(dialog,item,&iType,&cHandle,&box); |
return(TrackControl(cHandle,start,NIL)); |
} |
GetDbox(dialog,item,box) |
DialogPtr dialog; |
int item; |
Rect *box; |
{ |
Handle iHandle; |
int iType; |
GetDItem(dialog,item,&iType,&iHandle,box); |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14