home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Developer University / DUProjects / Events / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-04-05  |  3.5 KB  |  136 lines  |  [TEXT/CWIE]

  1. //    Copyright © 1995 Apple Computer, Inc. All rights reserved.
  2. //    Release Version:    $ 1.0 d11 $
  3.  
  4. //=======================================================================
  5. #ifndef FRAME_H
  6. #include "Frame.h"
  7. #endif
  8.  
  9. #ifndef PART_H
  10. #include "Part.h"
  11. #endif
  12.  
  13. // ----- Framework Layer -----
  14. #ifndef FWUTIL_H
  15. #include "FWUtil.h"                // FW_CFacetContext
  16. #endif
  17.  
  18. #ifndef FWCONTXT_H
  19. #include "FWContxt.h"            // FW_CViewContext
  20. #endif
  21.  
  22. #ifndef FWEVEDEF_H
  23. #include "FWEveDef.h"            // FW_RIGHT
  24. #endif
  25.  
  26. // ----- Graphic Includes -----
  27. #ifndef FWRECT_H
  28. #include <FWRect.h>                // FW_CRect
  29. #endif
  30.  
  31. #ifndef FWRECSHP_H
  32. #include "FWRecShp.h"            // FW_CRectShape
  33. #endif
  34.  
  35. // ------- 
  36. #ifndef SLMIXCOS_H
  37. #include "SLMixOS.h"            // FW_Beep
  38. #endif
  39.  
  40. //========================================================================================
  41. #ifdef FW_BUILD_MAC
  42. #pragma segment Events
  43. #endif
  44.  
  45. //========================================================================================
  46. FW_DEFINE_AUTO(CEventsFrame)
  47.  
  48. //========================================================================================
  49. CEventsFrame::CEventsFrame(Environment* ev, ODFrame* odFrame, 
  50.                                     FW_CPresentation* presentation, CEventsPart* eventsPart)
  51.   : FW_CFrame(ev, odFrame, presentation, eventsPart)
  52. {
  53.     FW_END_CONSTRUCTOR
  54. }
  55.  
  56. //----------------------------------------------------------------------------------------
  57. CEventsFrame::~CEventsFrame()
  58. {
  59.     FW_START_DESTRUCTOR
  60. }
  61.  
  62. //----------------------------------------------------------------------------------------
  63. void 
  64. CEventsFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape)    // Override
  65. {
  66.     FW_CViewContext context(ev, this, odFacet, invalidShape);
  67.     FW_CRect frameRect = this->GetBounds(ev);
  68.  
  69.     // fill frame with green  
  70.     FW_CRectShape rectShape(frameRect, FW_kFill);
  71.     rectShape.GetInk().SetForeColor(FW_kRGBGreen);
  72.     rectShape.Render(context);
  73. }
  74.  
  75. //----------------------------------------------------------------------------------------
  76. FW_Boolean 
  77. CEventsFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
  78. {    
  79.     FW_UNUSED(ev);
  80.     FW_Boolean handledEvent = FALSE;
  81.  
  82.     // get position of mouse click in case you need it
  83.     FW_CPoint position = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  84.     this->GetContentView(ev)->FrameToViewContent(ev, position);
  85.     // use mouse position here if you need it
  86.     
  87.     // check for triple-clicks
  88.     if (theMouseEvent.GetNumberOfClicks(ev) == 3) {
  89.         FW_Beep();
  90.         handledEvent = TRUE;
  91.         }
  92.     return handledEvent;
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. FW_Boolean 
  97. CEventsFrame::DoCharKey(Environment* ev, const FW_CCharKeyEvent& event)
  98. {
  99.     FW_Boolean handledEvent = FALSE;
  100.     char c = event.GetChar(ev);
  101.     if (c == 'b') {
  102.         FW_Beep();                // do something with the character
  103.         handledEvent = TRUE;
  104.         }
  105.     return handledEvent;
  106. }
  107.   
  108. //--------------------------------------------------------------------------------------
  109. FW_Boolean 
  110. CEventsFrame::DoVirtualKey(Environment* ev, 
  111.                                     const FW_CVirtualKeyEvent& theVirtualKeyEvent)
  112. {
  113.     FW_Boolean handledKey = TRUE;
  114.     if (theVirtualKeyEvent.GetKeyboardState(ev) == FW_CVirtualKeyEvent::kKeyDown)
  115.         ;    // do something if any key down
  116.         
  117.     short keyCode = theVirtualKeyEvent.GetKeyCode(ev);
  118.     switch (keyCode) {
  119.         case FW_kVKBackspace:                // Mac delete
  120.             FW_Beep();
  121.             break;
  122.             
  123.         case FW_kVKRight:                    // right-arrow
  124.             FW_Beep();
  125.             break;
  126.             
  127.         case FW_kVKEnter:                    // enter key
  128.             FW_Beep(); FW_Beep();
  129.             break;
  130.             
  131.         default:
  132.             handledKey = FALSE;
  133.     }    // switch
  134.     return handledKey;
  135. }
  136.