home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Text / SimpleText Sample / AboutBox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-17  |  4.2 KB  |  138 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        AboutBox.c
  3.  
  4.     Contains:    About Box support for SimpleText
  5.  
  6.     Version:    GX 1.2 or later
  7.  
  8. ** Copyright 1993-1996 Apple Computer. All rights reserved.
  9. **
  10. **    You may incorporate this sample code into your applications without
  11. **    restriction, though the sample code has been provided "AS IS" and the
  12. **    responsibility for its operation is 100% yours.  However, what you are
  13. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  14. **    after having made changes. If you're going to re-distribute the source,
  15. **    we require that you make it clear in the source that the code was
  16. **    descended from Apple Sample Code, but that you've made changes.
  17.  
  18. */
  19.  
  20. #include "MacIncludes.h"
  21.  
  22. #include "AboutBox.h"
  23.  
  24.  
  25. // --------------------------------------------------------------------------------------------------------------
  26. // INTERNAL ROUTINES
  27. // --------------------------------------------------------------------------------------------------------------
  28. static void DrawCenteredStringAt(Str255 theString, short yLocation)
  29. {
  30.     Rect    portRect = qd.thePort->portRect;
  31.     
  32.     MoveTo(portRect.left + ((portRect.right-portRect.left) >> 1) -
  33.                             (StringWidth(theString) >> 1), yLocation);
  34.     DrawString(theString);
  35.     
  36. } // DrawCenteredStringAt
  37.  
  38. // --------------------------------------------------------------------------------------------------------------
  39. // OOP INTERFACE ROUTINES
  40. // --------------------------------------------------------------------------------------------------------------
  41.  
  42. static OSErr    AboutUpdateWindow(WindowRef pWindow, WindowDataPtr pData)
  43. {
  44. #pragma unused (pData)
  45.  
  46.     Str255        theString;
  47.     
  48.     // type style for application name
  49.     TextFont(systemFont);
  50.     TextSize(12);
  51.     
  52.     // name of application
  53.     GetIndString(theString, kAboutStrings, 1);
  54.     DrawCenteredStringAt(theString, 32);
  55.     
  56.     // type style for all others
  57.     TextFont(applFont);
  58.     TextSize(9);
  59.     
  60.     // author names
  61.     GetIndString(theString, kAboutStrings, 2);
  62.     DrawCenteredStringAt(theString, 50);
  63.     GetIndString(theString, kAboutStrings, 3);
  64.     DrawCenteredStringAt(theString, 65);
  65.     GetIndString(theString, kAboutStrings, 4);
  66.     DrawCenteredStringAt(theString, 80);
  67.     
  68.     // copyright, on the left
  69.     GetIndString(theString, kAboutStrings, 5);
  70.     MoveTo(10, 105);
  71.     DrawString(theString);
  72.     
  73.     // version, on the right
  74.     GetIndString(theString, kAboutStrings, 6);
  75.     MoveTo((GetWindowPort(pWindow)->portRect.right - 10) - StringWidth(theString), 105);
  76.     DrawString(theString);
  77.     
  78.     return noErr;
  79.     
  80. } // AboutUpdateWindow
  81.  
  82. // --------------------------------------------------------------------------------------------------------------
  83.  
  84. static OSErr    AboutGetBalloon(WindowRef pWindow, WindowDataPtr pData, 
  85.         Point *localMouse, short * returnedBalloonIndex, Rect *returnedRectangle)
  86. {
  87. #pragma unused (pWindow, pData, localMouse, returnedRectangle)
  88.  
  89.     *returnedBalloonIndex = iNoBalloon;
  90.     
  91.     return noErr;
  92.     
  93. } // AboutGetBalloon
  94.  
  95. // --------------------------------------------------------------------------------------------------------------
  96.  
  97. static OSErr    AboutKeyEvent(WindowRef pWindow, WindowDataPtr pData, EventRecord *pEvent, Boolean isMotionKey)
  98. {
  99.     #pragma unused(pWindow, pData, pEvent, isMotionKey)
  100.  
  101.     return noErr;
  102.  
  103. } // AboutKeyEvent
  104.  
  105. // --------------------------------------------------------------------------------------------------------------
  106.  
  107. static OSErr    AboutMakeWindow(WindowRef pWindow, WindowDataPtr pData)
  108. {
  109. #pragma unused (pWindow)
  110.  
  111.     pData->pUpdateWindow = (UpdateWindowProc) AboutUpdateWindow;
  112.     pData->pGetBalloon     = (GetBalloonProc) AboutGetBalloon;
  113.     pData->pKeyEvent     = (KeyEventProc) AboutKeyEvent;
  114.  
  115.     return noErr;
  116.     
  117. } // AboutMakeWindow
  118.  
  119. // --------------------------------------------------------------------------------------------------------------
  120.  
  121. OSErr    AboutPreflightWindow(PreflightPtr pPreflightData)
  122. {
  123.     pPreflightData->resourceID             = kAboutWindowID;
  124.     pPreflightData->continueWithOpen     = true;
  125.     pPreflightData->makeProcPtr         = (MakeWindowProc) AboutMakeWindow;
  126.     
  127.     return noErr;
  128.     
  129. } // AboutPreflightWindow
  130.  
  131. // --------------------------------------------------------------------------------------------------------------
  132.  
  133. void AboutGetFileTypes(OSType * pFileTypes, OSType * pDocumentTypes, short * numTypes)
  134. {
  135. #pragma unused (pFileTypes, pDocumentTypes, numTypes)
  136.  
  137. } // AboutGetFileTypes
  138.