home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 8 / IOPROG_8.ISO / soft / sdkplnet / mac / plgsk401.sit / PluginSDK 4.01a / Examples / CharFlipper / Source / CWinFlipView.cpp < prev    next >
Encoding:
Text File  |  1996-07-09  |  3.7 KB  |  158 lines

  1. // The class is basically created to take advantage of the message handling functionality
  2. // of MFC
  3.  
  4. // The child window created by Netscape Navigator for the plug-in will be sub-classed to
  5. // the CWinFlipView by my npshell.cpp code.  
  6.  
  7. // This particular example handles left and right mouse clicks, paint messages, and has a
  8. // set of Avi specific calls.
  9.  
  10. #include "stdafx.h"
  11. #include "CWinFlipView.h"
  12. #include "CCharFlipper.h"
  13.  
  14. // CWinFlipView constructor:
  15. //
  16. CWinFlipView::CWinFlipView( CCharFlipper* inController )
  17. :    CPluginView( inController )
  18. {
  19. }
  20.  
  21. // The following functions all simply call the relevant AVI function of the CAvi member.
  22. // They don't do any error checking because they are only called if the data is valid (we
  23. // hope...*grin*)
  24. void CWinFlipView::OnPlay() 
  25. {
  26.     CCharFlipper* flipper = (CCharFlipper*)mController
  27.     flipper->SetRunning( TRUE );
  28. }
  29.  
  30. void CWinFlipView::OnStop() 
  31. {
  32.     CCharFlipper* flipper = (CCharFlipper*)mController
  33.     flipper->SetRunning( FALSE );
  34. }
  35.  
  36. void CWinFlipView::OnRewind() 
  37. {
  38.     
  39. }
  40.  
  41. void CWinFlipView::OnForward() 
  42. {
  43.     
  44. }
  45.  
  46. void CWinFlipView::OnFrameBack() 
  47. {
  48.     
  49. }
  50.  
  51. void CWinFlipView::OnFrameForward() 
  52. {
  53.     
  54. }
  55.  
  56. void CWinFlipView::OnLButtonDown(UINT flags, CPoint point) 
  57. {
  58.     CCharFlipper* flipper = (CCharFlipper*)mController
  59.     NPBool isRunning = flipper->GetRunning();
  60.     flipper->SetRunning( ! isRunning );
  61. }
  62.  
  63. void CWinFlipView::OnRButtonDown(UINT uFlags, CPoint cpPoint) 
  64. {
  65.     UINT uState;
  66.     //    Call the base class to handle the click.
  67.     CWnd::OnRButtonDown(uFlags, cpPoint);
  68.     CCharFlipper* flipper = (CCharFlipper*)mController
  69.  
  70.     CMenu cmPopup;
  71.     if(cmPopup.CreatePopupMenu() == 0)    {
  72.         return;
  73.     }
  74.  
  75.     if(flipper->GetRunning()) {
  76.         uState = MF_GRAYED;
  77.     }
  78.     else {
  79.         uState = MF_ENABLED;
  80.     }
  81.     cmPopup.AppendMenu(uState, ID_VIDEO_PLAY, "Play...");    
  82.  
  83.     if(!(flipper->GetRunning())) {
  84.         uState = MF_GRAYED;
  85.     }
  86.     else {
  87.         uState = MF_ENABLED;
  88.     }
  89.     cmPopup.AppendMenu(uState, ID_VIDEO_STOP, "Pause...");
  90.  
  91.     //    Separator
  92.     cmPopup.AppendMenu(MF_SEPARATOR);
  93.  
  94.     uState = MF_ENABLED;    
  95.     cmPopup.AppendMenu(uState, ID_VIDEO_REWIND,  "Rewind (Start of movie)...");
  96.     cmPopup.AppendMenu(uState, ID_VIDEO_FORWARD, "Forward (End of movie)...");
  97.  
  98.     //    Separator
  99.     cmPopup.AppendMenu(MF_SEPARATOR);
  100.     
  101.     cmPopup.AppendMenu(uState, ID_VIDEO_FRAME_BACK,  "Frame Back...");
  102.     cmPopup.AppendMenu(uState, ID_VIDEO_FRAME_FORWARD, "Frame Forward...");
  103.  
  104.     ClientToScreen(&cpPoint);
  105.     cmPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, cpPoint.x, cpPoint.y, this, NULL);
  106.  
  107. }
  108.  
  109. void CWinFlipView::OnPaint() {
  110.     CPaintDC dc(this); // device context for painting
  111.  
  112.     //CWnd::OnPaint();
  113. }
  114.  
  115. void CWinFlipView::OnPaletteChanged(CWnd* pFocusWnd) {
  116.     //    Don't do this if we caused it to happen.
  117.     if(pFocusWnd == (CWnd *)this)    {
  118.         return;
  119.     }
  120. //    if (m_data && m_data->cAvi) {        
  121. //        m_data->cAvi->Realize();
  122. //    }    
  123. }
  124.  
  125. //////////////////
  126. // Return place to hold original window proc
  127. WNDPROC* CWinFlipView::GetSuperWndProcAddr()
  128. {   
  129. #ifdef WIN32
  130.     return CWnd::GetSuperWndProcAddr();
  131. #else
  132.     static WNDPROC pfnSuper;   // place to store window proc
  133.     return &pfnSuper;          // always return the same address
  134. #endif
  135. }
  136.  
  137. // CMainWindow message map:
  138. // Associate messages with member functions.
  139. //
  140. // It is implied that the ON_WM_PAINT macro expects a member function
  141. // "void OnPaint()".
  142. //
  143. BEGIN_MESSAGE_MAP( CWinFlipView, CWnd )
  144.     //{{AFX_MSG_MAP( CMainWindow )
  145.     ON_WM_PAINT()
  146.      ON_WM_PALETTECHANGED()
  147.     ON_WM_LBUTTONDOWN()
  148.     ON_WM_RBUTTONDOWN()
  149.     ON_COMMAND(ID_VIDEO_PLAY,OnPlay)
  150.     ON_COMMAND(ID_VIDEO_STOP,OnStop)
  151.     ON_COMMAND(ID_VIDEO_REWIND,OnRewind)
  152.     ON_COMMAND(ID_VIDEO_FORWARD,OnForward)
  153.     ON_COMMAND(ID_VIDEO_FRAME_BACK,OnFrameBack)
  154.     ON_COMMAND(ID_VIDEO_FRAME_FORWARD,OnFrameForward)
  155.     //}}AFX_MSG_MAP
  156. END_MESSAGE_MAP()
  157.  
  158.