home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Developer University / DU Projects / Events / Sources / Frame.cpp < prev    next >
Encoding:
Text File  |  1996-08-22  |  3.4 KB  |  131 lines  |  [TEXT/CWIE]

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