home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************************/
- /* */
- /* Module Name: SetDisplay */
- /* */
- /* File Name: SetDisplay.c */
- /* */
- /* © Apple Computer, Inc. 1991-1995 */
- /* All Rights Reserved */
- /* */
- /* Revision History: */
- /* */
- /* Date Who Modification */
- /* */
- /* 1991-08-14 Chris Halim Original version */
- /* 1995-06-26 Jaakko Railo Version 2.0 */
- /* */
- /************************************************************************************************/
-
- /****************************************** DESCRIPTION ******************************************
-
- *************************************************************************************************/
-
- /******************************************** HEADERS *******************************************/
-
- #include "TextUtils.h"
-
- #include "TestModule.h"
-
- /****************************************** DEFINITIONS *****************************************/
-
- #define rGetDisplayDLOG 10000
- #define kNumber1 3
- #define kNumber2 5
- #define kText 7
-
- /****************************************** PROTOTYPES ******************************************/
-
- short GetDisplay (short * , short *, Str255);
- void DoTest (CHRSPtr paramPtr);
-
- /************************************************************************************************/
- /************************************************************************************************/
-
-
- pascal short TestModule (CHRSPtr paramPtr)
- {
- short returnValue = noErr;
-
- if (paramPtr->version <= kTestModuleVersion) {
-
- DoTest (paramPtr);
-
- }
- else
- returnValue = kWrongVersion;
-
- return (returnValue);
- }
-
-
- short GetDisplay (short * number1, short * number2, Str255 text)
- {
- short itemKind;
- Handle itemHand;
- Rect itemRect;
- short itemHit;
- DialogPtr theDialog;
- Str255 itemStr;
- long tlong;
-
- if ((theDialog = GetNewDialog (rGetDisplayDLOG, nil, (WindowPtr)(-1L))) != nil) {
- GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
- SelIText (theDialog, kNumber1, 0, 32767);
-
- ShowWindow (theDialog);
-
- ModalDialog (nil, &itemHit);
-
- if (itemHit == ok) {
- GetDItem (theDialog, kNumber1, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number1 = tlong;
-
- GetDItem (theDialog, kNumber2, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, itemStr);
- StringToNum (itemStr, &tlong);
- *number2 = tlong;
-
- GetDItem (theDialog, kText, &itemKind, &itemHand, &itemRect);
- GetIText (itemHand, text);
- }
-
- DisposeDialog (theDialog);
- }
- else
- itemHit = -1;
-
- return (itemHit);
- }
-
-
- void DoTest (CHRSPtr paramPtr)
- {
- TELHandle termHand = GetCurrentTELHandle (paramPtr);
- short itemHit;
- OSErr errCode;
- short index, dispMode;
- Str255 text;
-
- if ((itemHit = GetDisplay (&index, &dispMode, text)) == ok) {
-
- if ((errCode = TELSetDisplay (termHand, index, dispMode, text)) == noErr) {
- Print (paramPtr, "TELSetDisplay --> text = %*.*s", text[0], text[0], &text[1]);
- }
- else
- Print (paramPtr, "### TELSetDisplay failed : %d", errCode);
-
- }
- else
- if (itemHit == -1)
- Print (paramPtr, "### Unable to get a DLOG resource");
- }
-
-
-