home *** CD-ROM | disk | FTP | other *** search
- /*
- TestFunctions.c
-
- Functions for the Test menu commands.
-
- © 1995 Apple Computer, Inc.
- */
- #include <Types.h>
- #include <QuickDraw.h>
- #include <Dialogs.h>
- #include <Windows.h>
-
- #include "MenuDispatch.h"
- #include "vcInterface.h"
- #include <Files.h>
- #include <TextUtils.h>
- #include <ColorPicker.h>
-
- PicHandle gPicture;
-
- void ChooseTest(short item);
- pascal void DrawPictureItem(WindowPtr theWindow, short itemNo);
- void DoInfoDialog(Str255 str1, Str255 str2, Str255 str3, Str255 str4, Str255 strPrompt);
- void DoBoundsInfoDialog(Rect *bounds, Str255 strPrompt);
-
- extern ViewerObject gViewer;
-
- enum
- {
- tcItemOK = 1,
- tcItemText1,
- tcItemText2,
- tcItemPict
- };
-
- void ChooseTest(short item)
- {
- short iType, itemHit;
- Handle iHandle;
- Rect iRect;
- DialogPtr testDialog;
- OSErr anErr = noErr;
- long width, height;
- Str255 widthStr, heightStr;
- Rect bounds;
-
- switch(item)
- {
- case cmdGetPicture:
- {
- PicHandle aPicture;
-
- aPicture = Q3ViewerGetPict(gViewer); // get a picture of the view
-
- if (aPicture)
- {
- gPicture = aPicture;
-
- // Display the picture
- testDialog = GetNewDialog(GETINFO_ID, nil, (WindowPtr)-1);
- ParamText("\p", "\p", "\p", "\p");
- GetDItem(testDialog, tcItemText1, &iType, &iHandle, &iRect);
- SetIText(iHandle, "\pGet Picture");
- GetDItem(testDialog, tcItemPict, &iType, &iHandle, &iRect);
- SetDItem(testDialog, tcItemPict, iType, (Handle)DrawPictureItem, &iRect);
- do
- ModalDialog(nil, &itemHit);
- while (itemHit != tcItemOK);
- DisposDialog(testDialog);
-
- KillPicture(aPicture);
- }
- break;
- }
-
- case cmdGetDimensions:
- {
- anErr = Q3ViewerGetDimension(gViewer, (unsigned long *)&width, (unsigned long *)&height);
-
- NumToString(width, widthStr);
- NumToString(height, heightStr);
-
- DoInfoDialog(widthStr, heightStr, "\p", "\p", "\pGet Dimensions (width, height)");
- break;
- }
-
- case cmdGetCameraRect:
- {
- anErr = Q3ViewerGetButtonRect(gViewer, vcButtonCamera, &bounds);
- DoBoundsInfoDialog(&bounds, "\pGet Camera Button Rect (top, left, bottom, right)");
- break;
- }
- case cmdGetTruckRect:
- {
- anErr = Q3ViewerGetButtonRect(gViewer, vcButtonTruck, &bounds);
- DoBoundsInfoDialog(&bounds, "\pGet Truck Button Rect (top, left, bottom, right)");
- break;
- }
- case cmdGetOrbitRect:
- {
- anErr = Q3ViewerGetButtonRect(gViewer, vcButtonOrbit, &bounds);
- DoBoundsInfoDialog(&bounds, "\pGet Orbit Button Rect (top, left, bottom, right)");
- break;
- }
- case cmdGetZoomRect:
- {
- anErr = Q3ViewerGetButtonRect(gViewer, vcButtonZoom, &bounds);
- DoBoundsInfoDialog(&bounds, "\pGet Zoom Button Rect (top, left, bottom, right)");
- break;
- }
- case cmdGetDollyRect:
- {
- anErr = Q3ViewerGetButtonRect(gViewer, vcButtonDolly, &bounds);
- DoBoundsInfoDialog(&bounds, "\pGet Dolly Button Rect (top, left, bottom, right)");
- break;
- }
-
- case cmdGetBounds:
- {
- anErr = Q3ViewerGetBounds(gViewer, &bounds);
- DoBoundsInfoDialog(&bounds, "\pGet Bounds (top, left, bottom, right)");
- break;
- }
-
- case cmdSetBounds:
- break;
-
- case cmdGetBackgroundColor:
- break;
-
- case cmdSetBackgroundColor:
- {
- Point where = {-1, -1};
- RGBColor oldBColor, newBColor;
- TQ3ColorARGB qOldBColor, qNewBColor;
-
- Q3ViewerGetBackgroundColor(gViewer, &qOldBColor);
- oldBColor.red = qOldBColor.r * 65535.0;
- oldBColor.green = qOldBColor.g * 65535.0;
- oldBColor.blue = qOldBColor.b * 65535.0;
- if (GetColor(where, "\pPick a background color:", &oldBColor, &newBColor))
- {
- qNewBColor.r = newBColor.red / 65535.0;
- qNewBColor.g = newBColor.green / 65535.0;
- qNewBColor.b = newBColor.blue / 65535.0;
- Q3ViewerSetBackgroundColor(gViewer, &qNewBColor);
- }
- break;
- }
-
- case cmdUseBoxData:
- case cmdUseGroupData:
- case cmdVerifyGroupData:
- case cmdResetPort:
-
- case cmdNormalMemory:
- case cmdPig500:
- case cmdPig100:
- break;
- default: break;
- }
- }
-
-
- pascal void DrawPictureItem(WindowPtr theWindow, short itemNo)
- {
- short iType;
- Handle iHandle;
- Rect iRect, picRect;
-
- GetDItem(theWindow, itemNo, &iType, &iHandle, &iRect);
- picRect = (*gPicture)->picFrame;
- OffsetRect(&picRect, -picRect.left, -picRect.top);
- OffsetRect(&picRect, iRect.left, iRect.top);
- DrawPicture(gPicture, &picRect);
- }
-
- void DoInfoDialog(Str255 str1, Str255 str2, Str255 str3, Str255 str4, Str255 strPrompt)
- {
- short iType, itemHit;
- Handle iHandle;
- Rect iRect;
- DialogPtr testDialog;
- OSErr anErr = noErr;
-
- testDialog = GetNewDialog(GETINFO_ID, nil, (WindowPtr)-1);
- ParamText(str1, str2, str3, str4);
- GetDItem(testDialog, tcItemText1, &iType, &iHandle, &iRect);
- SetIText(iHandle, strPrompt);
- do
- ModalDialog(nil, &itemHit);
- while (itemHit != tcItemOK);
- DisposDialog(testDialog);
- }
-
- void DoBoundsInfoDialog(Rect *bounds, Str255 strPrompt)
- {
- Str255 topStr, leftStr, rightStr, bottomStr;
-
- NumToString(bounds->top, topStr);
- NumToString(bounds->left, leftStr);
- NumToString(bounds->bottom, bottomStr);
- NumToString(bounds->right, rightStr);
-
- DoInfoDialog(topStr, leftStr, bottomStr, rightStr, strPrompt);
- }
-
- /* EOF */
-