home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / New System Software Extensions / QuickDraw 3D ß / Programming / SampleCode / VCDemo / Source / TestFunctions.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-17  |  4.9 KB  |  209 lines  |  [TEXT/MPCC]

  1. /*
  2.     TestFunctions.c
  3.  
  4.     Functions for the Test menu commands.
  5.  
  6.     © 1995 Apple Computer, Inc.
  7. */
  8. #include <Types.h>
  9. #include <QuickDraw.h>
  10. #include <Dialogs.h>
  11. #include <Windows.h>
  12.  
  13. #include "MenuDispatch.h"
  14. #include "vcInterface.h"
  15. #include <Files.h>
  16. #include <TextUtils.h>
  17. #include <ColorPicker.h>
  18.  
  19. PicHandle    gPicture;
  20.  
  21. void    ChooseTest(short item);
  22. pascal void DrawPictureItem(WindowPtr theWindow, short itemNo);
  23. void    DoInfoDialog(Str255 str1, Str255 str2, Str255 str3, Str255 str4, Str255 strPrompt);
  24. void    DoBoundsInfoDialog(Rect *bounds, Str255 strPrompt);
  25.  
  26. extern    ViewerObject    gViewer;
  27.  
  28. enum
  29. {
  30.     tcItemOK        = 1,
  31.     tcItemText1,
  32.     tcItemText2,
  33.     tcItemPict
  34. };
  35.  
  36. void ChooseTest(short item)
  37. {
  38.     short        iType, itemHit;
  39.     Handle        iHandle;
  40.     Rect        iRect;
  41.     DialogPtr    testDialog;
  42.     OSErr        anErr = noErr;
  43.     long        width, height;
  44.     Str255        widthStr, heightStr;
  45.     Rect        bounds;
  46.  
  47.     switch(item)
  48.     {
  49.         case cmdGetPicture:
  50.         {
  51.             PicHandle    aPicture;
  52.  
  53.             aPicture = Q3ViewerGetPict(gViewer);    // get a picture of the view
  54.  
  55.             if (aPicture)
  56.             {
  57.                 gPicture = aPicture;
  58.     
  59.                     // Display the picture
  60.                 testDialog = GetNewDialog(GETINFO_ID, nil, (WindowPtr)-1);
  61.                 ParamText("\p", "\p", "\p", "\p");
  62.                 GetDItem(testDialog, tcItemText1, &iType, &iHandle, &iRect);
  63.                 SetIText(iHandle, "\pGet Picture");
  64.                 GetDItem(testDialog, tcItemPict, &iType, &iHandle, &iRect);
  65.                 SetDItem(testDialog, tcItemPict, iType, (Handle)DrawPictureItem, &iRect);
  66.                 do
  67.                     ModalDialog(nil, &itemHit);
  68.                 while (itemHit != tcItemOK);
  69.                 DisposDialog(testDialog);
  70.  
  71.                 KillPicture(aPicture);
  72.             }
  73.             break;
  74.         }
  75.  
  76.         case cmdGetDimensions:
  77.         {
  78.             anErr = Q3ViewerGetDimension(gViewer, (unsigned long *)&width, (unsigned long *)&height);
  79.  
  80.             NumToString(width, widthStr);
  81.             NumToString(height, heightStr);
  82.  
  83.             DoInfoDialog(widthStr, heightStr, "\p", "\p", "\pGet Dimensions (width, height)");
  84.             break;
  85.         }
  86.         
  87.         case cmdGetCameraRect:
  88.         {
  89.             anErr = Q3ViewerGetButtonRect(gViewer, vcButtonCamera, &bounds);
  90.             DoBoundsInfoDialog(&bounds, "\pGet Camera Button Rect (top, left, bottom, right)");
  91.             break;
  92.         }
  93.         case cmdGetTruckRect:
  94.         {
  95.             anErr = Q3ViewerGetButtonRect(gViewer, vcButtonTruck, &bounds);
  96.             DoBoundsInfoDialog(&bounds, "\pGet Truck Button Rect (top, left, bottom, right)");
  97.             break;
  98.         }
  99.         case cmdGetOrbitRect:
  100.         {
  101.             anErr = Q3ViewerGetButtonRect(gViewer, vcButtonOrbit, &bounds);
  102.             DoBoundsInfoDialog(&bounds, "\pGet Orbit Button Rect (top, left, bottom, right)");
  103.             break;
  104.         }
  105.         case cmdGetZoomRect:
  106.         {
  107.             anErr = Q3ViewerGetButtonRect(gViewer, vcButtonZoom, &bounds);
  108.             DoBoundsInfoDialog(&bounds, "\pGet Zoom Button Rect (top, left, bottom, right)");
  109.             break;
  110.         }
  111.         case cmdGetDollyRect:
  112.         {
  113.             anErr = Q3ViewerGetButtonRect(gViewer, vcButtonDolly, &bounds);
  114.             DoBoundsInfoDialog(&bounds, "\pGet Dolly Button Rect (top, left, bottom, right)");
  115.             break;
  116.         }
  117.         
  118.         case cmdGetBounds:
  119.         {
  120.             anErr = Q3ViewerGetBounds(gViewer, &bounds);
  121.             DoBoundsInfoDialog(&bounds, "\pGet Bounds (top, left, bottom, right)");
  122.             break;
  123.         }
  124.  
  125.         case cmdSetBounds:
  126.             break;
  127.  
  128.         case cmdGetBackgroundColor:
  129.             break;
  130.  
  131.         case cmdSetBackgroundColor:
  132.         {
  133.             Point        where = {-1, -1};
  134.             RGBColor    oldBColor, newBColor;
  135.             TQ3ColorARGB    qOldBColor, qNewBColor;
  136.  
  137.             Q3ViewerGetBackgroundColor(gViewer, &qOldBColor);
  138.             oldBColor.red = qOldBColor.r * 65535.0;
  139.             oldBColor.green = qOldBColor.g * 65535.0;
  140.             oldBColor.blue = qOldBColor.b * 65535.0;
  141.             if (GetColor(where, "\pPick a background color:", &oldBColor, &newBColor))
  142.             {
  143.                 qNewBColor.r = newBColor.red / 65535.0;
  144.                 qNewBColor.g = newBColor.green / 65535.0;
  145.                 qNewBColor.b = newBColor.blue / 65535.0;
  146.                 Q3ViewerSetBackgroundColor(gViewer, &qNewBColor);
  147.             }
  148.             break;
  149.         }
  150.  
  151.         case cmdUseBoxData:
  152.         case cmdUseGroupData:
  153.         case cmdVerifyGroupData:
  154.         case cmdResetPort:
  155.         
  156.         case cmdNormalMemory:
  157.         case cmdPig500:
  158.         case cmdPig100:
  159.             break;
  160.         default:            break;
  161.     }
  162. }
  163.  
  164.  
  165. pascal void DrawPictureItem(WindowPtr theWindow, short itemNo)
  166. {
  167.     short    iType;
  168.     Handle    iHandle;
  169.     Rect    iRect, picRect;
  170.  
  171.     GetDItem(theWindow, itemNo, &iType, &iHandle, &iRect);
  172.     picRect = (*gPicture)->picFrame;
  173.     OffsetRect(&picRect, -picRect.left, -picRect.top);
  174.     OffsetRect(&picRect, iRect.left, iRect.top);
  175.     DrawPicture(gPicture, &picRect);
  176. }
  177.  
  178. void    DoInfoDialog(Str255 str1, Str255 str2, Str255 str3, Str255 str4, Str255 strPrompt)
  179. {
  180.     short        iType, itemHit;
  181.     Handle        iHandle;
  182.     Rect        iRect;
  183.     DialogPtr    testDialog;
  184.     OSErr        anErr = noErr;
  185.  
  186.     testDialog = GetNewDialog(GETINFO_ID, nil, (WindowPtr)-1);
  187.     ParamText(str1, str2, str3, str4);
  188.     GetDItem(testDialog, tcItemText1, &iType, &iHandle, &iRect);
  189.     SetIText(iHandle, strPrompt);
  190.     do
  191.         ModalDialog(nil, &itemHit);
  192.     while (itemHit != tcItemOK);
  193.     DisposDialog(testDialog);
  194. }
  195.  
  196. void    DoBoundsInfoDialog(Rect *bounds, Str255 strPrompt)
  197. {
  198.     Str255        topStr, leftStr, rightStr, bottomStr;
  199.  
  200.     NumToString(bounds->top, topStr);
  201.     NumToString(bounds->left, leftStr);
  202.     NumToString(bounds->bottom, bottomStr);
  203.     NumToString(bounds->right, rightStr);
  204.  
  205.     DoInfoDialog(topStr, leftStr, bottomStr, rightStr, strPrompt);
  206. }
  207.  
  208. /* EOF */
  209.