home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWAbout.cpp next >
Encoding:
Text File  |  1995-11-08  |  3.5 KB  |  154 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWAbout.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. //    The about box code is temporary. Only works on the Mac. All the resource
  11. //    have to be in the part with very specific ids. 
  12. //
  13. //            case kODCommandAbout:
  14. //                    {
  15. //                        FW_CAcquireCFMResourceAccess a;
  16. //                        About();
  17. //                    }
  18. //                    break;
  19.  
  20. #include "FWFrameW.hpp"
  21.  
  22. #ifndef FWABOUT_H
  23. #include "FWAbout.h"
  24. #endif
  25.  
  26. #ifndef FWCFMRES_H
  27. #include "FWCFMRes.h"
  28. #endif
  29.  
  30. // ----- Macintosh Includes -----
  31.  
  32. #if defined(FW_BUILD_MAC) && !defined(__OSUTILS__)
  33. #include <OSUtils.h>
  34. #endif
  35.  
  36. #if defined(FW_BUILD_MAC) && !defined(__TOOLUTILS__)
  37. #include <ToolUtils.h>
  38. #endif
  39.  
  40. #if defined(FW_BUILD_MAC) && !defined(__DIALOGS__)
  41. #include <Dialogs.h>
  42. #endif
  43.  
  44. //========================================================================================
  45. //    Runtime Informations
  46. //========================================================================================
  47.  
  48. #if FW_LIB_EXPORT_PRAGMAS
  49. #pragma lib_export on
  50. #endif
  51.  
  52. #ifdef FW_BUILD_MAC    
  53. #pragma segment FWFrameworkAbout
  54. #endif
  55.  
  56. //========================================================================================
  57. //    Globales
  58. //========================================================================================
  59.  
  60. #ifdef FW_BUILD_MAC    
  61.  
  62. #define kDialogID 300
  63.  
  64. //========================================================================================
  65. //    FW_MacAlertDialogFilter
  66. //========================================================================================
  67.  
  68. static pascal Boolean FW_MacAlertDialogFilter(DialogPtr theDialog, 
  69.                                                 EventRecord * theEvent, 
  70.                                                 short *itemHit)
  71. {
  72.     Boolean result = FALSE;
  73.  
  74.     switch (theEvent->what)
  75.     {
  76.         case keyDown:
  77.         case autoKey:
  78.             {
  79.                 switch (theEvent->message & charCodeMask)
  80.                 {                    
  81.                     case 0x0D:
  82.                     case 0x03:
  83.                     case 0x1B:
  84.                         result = TRUE;
  85.                         *itemHit = 1;
  86.                         break;
  87.                 }
  88.                 
  89.                 if (result)        // flash the button
  90.                 {
  91.                     long     theTick;
  92.                     short     itemType;
  93.                     Handle     hItem;
  94.                     Rect    box;
  95.                     
  96.                     ::GetDialogItem(theDialog, *itemHit, &itemType, &hItem, &box);
  97.                     ::HiliteControl((ControlHandle)hItem, 1);
  98.                     ::Delay(6,&theTick);
  99.                     ::HiliteControl((ControlHandle)hItem, 0);            
  100.                 }
  101.             }
  102.             break;
  103.         
  104.         case updateEvt:
  105.             if (theDialog == (DialogPtr)theEvent->message)
  106.             {
  107.                 PenState     ps;
  108.                 Rect        box;
  109.                 Handle        handle;
  110.                 short        type;
  111.                 
  112.                 ::SetPort(theDialog);
  113.                 ::GetPenState(&ps);
  114.                 ::PenSize(3, 3);
  115.                 ::GetDialogItem(theDialog, 1, &type, &handle, &box);
  116.                 ::InsetRect(&box, -4, -4);
  117.                 ::FrameRoundRect(&box, 16, 16);
  118.                 ::SetPenState(&ps);
  119.             }
  120.             break;
  121.     }
  122.  
  123.     return result;
  124. }
  125. #endif
  126.  
  127. //----------------------------------------------------------------------------------------
  128. //    FW_About
  129. //----------------------------------------------------------------------------------------
  130.  
  131. void FW_About(FW_Instance partInstance)
  132. {    
  133.     FW_CAcquireCFMResourceAccess a(partInstance);
  134.     
  135. #ifdef FW_BUILD_MAC    
  136.     DialogPtr dlg = ::GetNewDialog(kDialogID, NULL, WindowPtr(-1));
  137.     ::ShowWindow(dlg);
  138.     
  139.     short item;
  140.     ModalFilterUPP filterProc = NewModalFilterProc(&FW_MacAlertDialogFilter);
  141.     do
  142.     {
  143.         ::ModalDialog(filterProc, &item);
  144.     } while (item != 1);
  145.     DisposeRoutineDescriptor(filterProc);
  146.     
  147.     ::DisposeDialog(dlg);
  148. #endif
  149.  
  150. #ifdef FW_BUILD_WIN
  151.     // [HLX] Windows code go here
  152. #endif
  153. }
  154.