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.
UtilCode/DialogUtil.c
/* |
DialogUtil.c |
------------ |
This is real old code I have been using since the start for dealing with the DialogManager |
*/ |
PutNumericItem(DialogPtr theDialog, int itemNumber, int 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(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(DialogPtr theDialog, int itemNumber, Str255 *text) |
{ |
Handle iHandle; |
Rect box; |
int iType; |
GetDItem(theDialog,itemNumber,&iType,&iHandle,&box); |
GetIText(iHandle,text); |
} |
PutTextItem(DialogPtr theDialog, int itemNumber, Str255 *text) |
{ |
Handle iHandle; |
Rect box; |
int iType; |
GetDItem(theDialog,itemNumber,&iType,&iHandle,&box); |
SetIText(iHandle,text); |
} |
ShowDialog(int dialog_id) |
{ |
DialogPtr dialog_ptr; |
int itemHit; |
dialog_ptr = GetNewDialog(dialog_id,nil,(WindowPtr)-1); |
ModalDialog(nil,&itemHit); |
DisposDialog(dialog_ptr); |
} |
int GetDialogCtlValue(DialogPtr dialog, int item) |
{ |
ControlHandle iHandle; |
Rect box; |
int iType; |
GetDItem(dialog,item,&iType,&iHandle,&box); |
return(GetCtlValue(iHandle)); |
} |
SetDialogCtlValue(DialogPtr dialog, int item, int newValue) |
{ |
ControlHandle iHandle; |
Rect box; |
int iType; |
GetDItem(dialog,item,&iType,&iHandle,&box); |
SetCtlValue(iHandle,newValue); |
} |
void BoxItem(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(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(DialogPtr dialog, int item, Point start) |
{ |
Handle cHandle; |
Rect box; |
int iType; |
GetDItem(dialog,item,&iType,&cHandle,&box); |
return(TrackControl(cHandle,start,nil)); |
} |
GetDbox(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