home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / genview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  32.4 KB  |  1,182 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. // genview.cpp : implementation file
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "np.h"
  24.  
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char BASED_CODE THIS_FILE[] = __FILE__;
  28. #endif
  29.  
  30. #ifdef EDITOR
  31. #include "mainfrm.h"    // Need this to access CMainFrame::OnLoadHomePage()
  32. //#include "edres1.h"
  33. #endif
  34. #include "edt.h"
  35. #include "button.h"
  36. #include "libevent.h"
  37. #include "findrepl.h"
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CGenericView
  41.  
  42. #ifndef _AFXDLL
  43. #undef new
  44. #endif
  45. IMPLEMENT_DYNCREATE(CGenericView, CView)
  46. #ifndef _AFXDLL
  47. #define new DEBUG_NEW
  48. #endif
  49.  
  50. CGenericView::CGenericView()
  51. {
  52.     // no one has focus yet
  53.     m_hWndFocus = NULL;
  54.     m_pContext = NULL;
  55.     m_bInPrintPreview = FALSE;
  56.     m_bRestoreComposerToolbar = FALSE;
  57.     m_hCtlBrush = NULL;
  58. }
  59.  
  60. CGenericView::~CGenericView()
  61. {
  62.     //      when the view goes down, it would be a good idea to let the context
  63.     //              know.
  64.     if(GetContext() != NULL)        {
  65.         GetContext()->ClearView();
  66.     }
  67.  
  68.     if(m_hCtlBrush)
  69.     DeleteObject(m_hCtlBrush);
  70.  
  71. }
  72.  
  73.  
  74. BEGIN_MESSAGE_MAP(CGenericView, CView)
  75.     //{{AFX_MSG_MAP(CGenericView)
  76.     ON_WM_LBUTTONDBLCLK()
  77.     ON_WM_LBUTTONDOWN()
  78.     ON_WM_LBUTTONUP()
  79.     ON_WM_MOUSEMOVE()
  80.     ON_WM_RBUTTONDBLCLK()
  81.     ON_WM_RBUTTONDOWN()
  82.     ON_WM_RBUTTONUP()
  83.     ON_WM_MOUSEACTIVATE()
  84.     ON_WM_CTLCOLOR()
  85.     ON_WM_MOVE()
  86.     ON_WM_SETFOCUS()
  87.     ON_WM_KILLFOCUS()
  88.     ON_WM_NCPAINT()
  89.     ON_WM_NCCALCSIZE()
  90.  
  91.     ON_COMMAND(ID_FILE_MAILTO, OnFileMailto)
  92.     ON_UPDATE_COMMAND_UI(ID_FILE_MAILTO, OnUpdateFileMailto)
  93.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  94.     ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen)
  95.     ON_COMMAND(ID_NETSCAPE_SAVE_AS, OnNetscapeSaveAs)
  96.     ON_UPDATE_COMMAND_UI(ID_NETSCAPE_SAVE_AS, OnUpdateNetscapeSaveAs)
  97.     ON_COMMAND(ID_FILE_SAVEFRAME_AS, OnNetscapeSaveFrameAs)
  98.     ON_UPDATE_COMMAND_UI(ID_FILE_SAVEFRAME_AS, OnUpdateNetscapeSaveFrameAs)
  99.     ON_COMMAND(ID_NAVIGATE_BACK, OnNavigateBack)
  100.     ON_UPDATE_COMMAND_UI(ID_NAVIGATE_BACK, OnUpdateNavigateBack)
  101.     ON_UPDATE_COMMAND_UI(ID_NAVIGATE_FORWARD, OnUpdateNavigateForward)
  102.     ON_COMMAND(ID_NAVIGATE_FORWARD, OnNavigateForward)
  103.     ON_COMMAND(ID_NAVIGATE_RELOAD, OnNavigateReload)
  104.     ON_UPDATE_COMMAND_UI(ID_NAVIGATE_RELOAD, OnUpdateNavigateReload)
  105.     ON_COMMAND(ID_VIEW_LOADIMAGES, OnViewLoadimages)
  106.     ON_UPDATE_COMMAND_UI(ID_VIEW_LOADIMAGES, OnUpdateViewLoadimages)
  107.     ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
  108.     ON_UPDATE_COMMAND_UI(ID_FILE_PRINT, OnUpdateFilePrint)
  109.     ON_UPDATE_COMMAND_UI(ID_FILE_PRINT_PREVIEW, OnUpdateFilePrintPreview)
  110.     ON_COMMAND(ID_EDIT_FINDINCURRENT, OnEditFindincurrent)
  111.     ON_UPDATE_COMMAND_UI(ID_EDIT_FINDINCURRENT, OnUpdateEditFindincurrent)
  112.     ON_COMMAND(ID_EDIT_WITHFRAME_FINDINCURRENT, OnEditFindincurrent)
  113.     ON_UPDATE_COMMAND_UI(ID_EDIT_WITHFRAME_FINDINCURRENT, OnUpdateEditWithFrameFindincurrent)
  114.     ON_COMMAND(ID_EDIT_FINDAGAIN, OnEditFindAgain)
  115.     ON_UPDATE_COMMAND_UI(ID_EDIT_FINDAGAIN, OnUpdateEditFindAgain)
  116.     ON_COMMAND(ID_NAVIGATE_INTERRUPT, OnNavigateInterrupt)
  117.     ON_UPDATE_COMMAND_UI(ID_NAVIGATE_INTERRUPT, OnUpdateNavigateInterrupt)
  118.     ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
  119.     ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy)
  120.     ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut)
  121.     ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
  122.     ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
  123.     ON_COMMAND(ID_FILE_VIEWSOURCE, OnFileViewsource)
  124.     ON_UPDATE_COMMAND_UI(ID_FILE_VIEWSOURCE, OnUpdateFileViewsource)
  125.     ON_COMMAND(ID_FILE_DOCINFO, OnFileDocinfo)
  126.     ON_UPDATE_COMMAND_UI(ID_FILE_DOCINFO, OnUpdateFileDocinfo)
  127.     ON_COMMAND(ID_VIEW_PAGESERVICES, OnViewPageServices)
  128.     ON_UPDATE_COMMAND_UI(ID_VIEW_PAGESERVICES, OnUpdateViewPageServices)
  129.     ON_COMMAND(ID_GO_HOME, OnGoHome)
  130.     ON_UPDATE_COMMAND_UI(ID_GO_HOME, OnUpdateGoHome)
  131.     ON_COMMAND(ID_FILE_UPLOADFILE, OnFileUploadfile)
  132.     ON_UPDATE_COMMAND_UI(ID_FILE_UPLOADFILE, OnUpdateFileUploadfile)
  133.     ON_COMMAND(ID_NAVIGATE_RELOADCELL, OnNavigateReloadcell)
  134.     ON_UPDATE_COMMAND_UI(ID_NAVIGATE_RELOADCELL, OnUpdateNavigateReloadcell)
  135.     ON_COMMAND(ID_VIEW_FRAME_INFO, OnViewFrameInfo)
  136.     ON_UPDATE_COMMAND_UI(ID_VIEW_FRAME_INFO, OnUpdateViewFrameInfo)
  137.     ON_COMMAND(ID_VIEW_FRAME_SOURCE, OnViewFrameSource)
  138.     ON_UPDATE_COMMAND_UI(ID_VIEW_FRAME_SOURCE, OnUpdateViewFrameSource)
  139.     //}}AFX_MSG_MAP
  140. #ifdef EDITOR
  141.     // Open file or URL to edit on Browser menu - Opens into new windows
  142.     ON_UPDATE_COMMAND_UI(ID_FILE_OPEN_TO_EDIT, OnUpdateFileOpen)
  143. #endif
  144.  
  145. END_MESSAGE_MAP()
  146.  
  147. /////////////////////////////////////////////////////////////////////////////
  148. // CGenericView drawing
  149.  
  150. void CGenericView::OnDraw(CDC* pDC)
  151. {
  152. }
  153.  
  154. /////////////////////////////////////////////////////////////////////////////
  155. // CGenericView diagnostics
  156.  
  157. #ifdef _DEBUG
  158. void CGenericView::AssertValid() const
  159. {
  160.     CView::AssertValid();
  161. }
  162.  
  163. void CGenericView::Dump(CDumpContext& dc) const
  164. {
  165.     CView::Dump(dc);
  166. }
  167. #endif //_DEBUG
  168.  
  169. /////////////////////////////////////////////////////////////////////////////
  170. // CGenericView message handlers
  171.  
  172. CGenericDoc *CGenericView::GetDocument()        {
  173.     CGenericDoc *pRetval = NULL;
  174.     if(m_pContext != NULL)  {
  175.     pRetval = m_pContext->GetDocument();
  176.     }
  177.  
  178.     return(pRetval);
  179. }
  180.  
  181. void CGenericView::SetContext(CAbstractCX *pContext)    
  182. {
  183.     ASSERT(pContext->IsWindowContext());
  184.     m_pContext = (CWinCX *)pContext;
  185.  
  186. #ifdef WIN32
  187.     if (GetFrame() && GetFrame()->GetFrameWnd()) {
  188.     long lRemExStyles;
  189.     if (lRemExStyles = ((CGenericFrame*)GetFrame()->GetFrameWnd())->GetRemovedExStyles()) {
  190.         long lStyles = GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE); 
  191.         lStyles &= ~lRemExStyles;
  192.         SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, lStyles);
  193.     }
  194.     }
  195. #endif
  196.  
  197. }
  198.  
  199. void CGenericView::FrameClosing()       {
  200.     //      The view is closing.
  201.  
  202.     //      Are we responsible for print preveiw?
  203.     //      If so close it down.
  204.     if(IsInPrintPreview() == TRUE)  {
  205.         HDC pDC = GetContext()->GetContextDC();
  206.         CDC *tDC = CDC::FromHandle(pDC); 
  207.         OnEndPrintPreview(tDC, NULL, CPoint(0, 0), (CPreviewView *)GetContext()->GetFrame()->GetFrameWnd()->GetActiveView());
  208.         GetContext()->ReleaseContextDC(pDC);
  209.     }
  210.  
  211.     //      Get rid of the context if around.
  212.     if(GetContext() && GetContext()->IsDestroyed() == FALSE)        {
  213.         GetContext()->DestroyContext();
  214.     }
  215. }
  216.  
  217. CFrameGlue *CGenericView::GetFrame() const      {
  218.     CFrameGlue *pRetval = NULL;
  219.     if(m_pContext != NULL)  {
  220.         pRetval = m_pContext->GetFrame();
  221.     }
  222.     return(pRetval);
  223. }
  224.  
  225. BOOL CGenericView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
  226. {
  227.     //      Attempt to pass this off to form elements first.
  228.     //      See who's got focus.
  229.     CWnd *pFocus = GetFocus();
  230.     if(pFocus != NULL)      {
  231.         //      Make sure it's a child of us, and not a CGenericView (like us).
  232.         //      We block on the generic view, because it is already in the message map of the frame
  233.         //              and should get appropriately called there.
  234.         BOOL bViewChild = IsChild(pFocus);
  235.         BOOL bGenericView = pFocus->IsKindOf(RUNTIME_CLASS(CGenericView));
  236.         if(bViewChild == TRUE && bGenericView == FALSE) {
  237.             //      Try an OnCmdMessage directly on the window with focus.
  238.             //      Probably a form widget.
  239.             //      Walk up the list of parents until we reach ourselves.
  240.             CWnd *pTarget = pFocus;
  241.             while(pTarget != NULL && pTarget != (CWnd *)this)       {
  242.                 if(pTarget->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
  243.                     return(TRUE);
  244.                 }
  245.                 pTarget = pTarget->GetParent();
  246.  
  247.                 //  There are cases now where a child is actually a CGenericView
  248.                 //      such as the NavCenter HTML pane.  Do not allow it to
  249.                 //      receive these messages.
  250.                 if(pTarget->IsKindOf(RUNTIME_CLASS(CGenericView))) {
  251.                     pTarget = NULL;
  252.                 }
  253.             }
  254.         }
  255.     }
  256.  
  257.     //      Proceed as normal.
  258.     return CView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  259. }
  260.  
  261. void CGenericView::OnActivateView(BOOL bActivate, CView *pActivateView, CView *pDeactivateView) 
  262. {
  263.     //      Tell the frame what the new acitve context is.  
  264.     //      See if we should update the frame's idea of the currently active context.
  265.     //      Don't set the active context to be absent, someone else needs to become
  266.     //              active immediately if there is a gap.
  267.     //      If we do clear it, things like print and print preview won't work.
  268.     if(bActivate == TRUE)   {
  269.         //      Frame may be gone (WM_ENDSESSION bug fix).
  270.         if(GetFrame())  {
  271.             GetFrame()->SetActiveContext(GetContext());
  272.         }
  273.     }
  274.  
  275.     //      If we're being deactivated, do so now.
  276.     if(bActivate == FALSE)  {
  277.         if(GetContext())        {
  278.             GetContext()->ActivateCX(FALSE);
  279.         }
  280.     }
  281.  
  282.     //      Call the base.
  283.     CView::OnActivateView(bActivate, pActivateView, pDeactivateView);
  284.  
  285.     //      If we've been activated, reflect this now.
  286.     if(bActivate == TRUE)   {
  287.         if(GetContext())        {
  288.             GetContext()->ActivateCX(TRUE);
  289.         }
  290.     }
  291. }
  292.  
  293. void CGenericView::OnLButtonDblClk(UINT nFlags, CPoint point) 
  294. {
  295.     CView::OnLButtonDblClk(nFlags, point);
  296.  
  297.     //      Pass it off to the context to handle.
  298.     if(GetContext() != NULL && GetContext()->IsDestroyed() == FALSE)        {
  299.         GetContext()->OnLButtonDblClkCX(nFlags, point);
  300.     }
  301. }
  302.  
  303. void CGenericView::OnLButtonDown(UINT nFlags, CPoint point) 
  304. {
  305.     //      Clear current focus owner.
  306.     //      This will get set correctly later on in the call chain when a window
  307.     //              get's activated.
  308.     m_hWndFocus = NULL;
  309.  
  310.     //      Call the base.
  311.     CView::OnLButtonDown(nFlags, point);
  312.  
  313.     //      Pass it off to the context to handle.
  314.     if(GetContext() != NULL && GetContext()->IsDestroyed() == FALSE)        {
  315.         GetContext()->OnLButtonDownCX(nFlags, point);
  316.     }
  317. }
  318.  
  319. void CGenericView::OnLButtonUp(UINT nFlags, CPoint point) 
  320. {
  321.     CView::OnLButtonUp(nFlags, point);
  322.  
  323.     //      If focus didn't go to one of the children, this will give it back
  324.     //              to the frame so that our command keys work.
  325.     if(GetFrame() != NULL)  {
  326.         if(GetFrame()->GetFrameWnd() != NULL)   {
  327.             CPoint ptScreen = point;
  328.             ClientToScreen( &ptScreen );
  329.             HWND hWndPt = ::WindowFromPoint( ptScreen );
  330.             if( ::IsChild( GetFrame()->GetFrameWnd()->m_hWnd, hWndPt ) || (GetFrame()->GetFrameWnd()->m_hWnd == hWndPt) )   {
  331.                 GetFrame()->GetFrameWnd()->SetFocus();
  332.             }
  333.         }
  334.     }
  335.  
  336.     //      Pass it off to the context to handle.
  337.     if(GetContext() != NULL && GetContext()->IsDestroyed() == FALSE)        {
  338.         BOOL bReturnImmediately = FALSE;
  339.         GetContext()->OnLButtonUpCX(nFlags, point, bReturnImmediately);
  340.         if(bReturnImmediately)  {
  341.             return;
  342.         }
  343.     }
  344. }
  345.  
  346. void CGenericView::OnMouseMove(UINT nFlags, CPoint point) 
  347. {
  348.     CView::OnMouseMove(nFlags, point);
  349.  
  350.     //      Pass it off to the context to handle.
  351.     if(GetContext() != NULL && GetContext()->IsDestroyed() == FALSE)        {
  352.         BOOL bReturnImmediately = FALSE;
  353.         GetContext()->OnMouseMoveCX(nFlags, point, bReturnImmediately);
  354.         if(bReturnImmediately)  {
  355.             return;
  356.         }
  357.     }
  358. }
  359.  
  360. void CGenericView::OnRButtonDblClk(UINT nFlags, CPoint point) 
  361. {
  362.     CView::OnRButtonDblClk(nFlags, point);
  363.  
  364.     //      Pass it off to the context to handle.
  365.     if(GetContext() != NULL && GetContext()->IsDestroyed() == FALSE)        {
  366.         GetContext()->OnRButtonDblClkCX(nFlags, point);
  367.     }
  368. }
  369.  
  370. void CGenericView::OnRButtonDown(UINT nFlags, CPoint point) 
  371. {
  372.     //  Force ourselves as active.
  373.     //  Bug fix 61140, CGenFrame::OnCmdMsg doesn't know where to send
  374.     //      resultant message.
  375.     CFrameWnd *pFrame = NULL;
  376.     if(GetFrame())  {
  377.         pFrame = GetFrame()->GetFrameWnd();
  378.     }
  379.     if(pFrame && pFrame->IsChild(this)) {
  380.         pFrame->SetActiveView(this);
  381.     }
  382.  
  383.     CView::OnRButtonDown(nFlags, point);
  384.  
  385.     //      Pass it off to the context to handle.
  386.     if(GetContext() != NULL && GetContext()->IsDestroyed() == FALSE)        {
  387.         GetContext()->OnRButtonDownCX(nFlags, point);
  388.     }
  389. }
  390.  
  391. void CGenericView::OnRButtonUp(UINT nFlags, CPoint point) 
  392. {
  393.     CView::OnRButtonUp(nFlags, point);
  394.  
  395.     //      Pass it off to the context to handle.
  396.     if(GetContext() != NULL && GetContext()->IsDestroyed() == FALSE)        {
  397.         GetContext()->OnRButtonUpCX(nFlags, point);
  398.     }
  399. }
  400. int CGenericView::OnMouseActivate( CWnd *pWin, UINT uHitTest, UINT uMessage )
  401. {
  402.     if(GetContext() && GetContext()->IsDestroyed() == FALSE)        {
  403.         if(::GetCursor() == (theApp.LoadCursor(IDC_SELECTANCHOR)))     {
  404.             // Prevent the frame from becoming active while dragging
  405.             return MA_NOACTIVATE;
  406.         }
  407.     }
  408.  
  409.     return CView::OnMouseActivate(pWin, uHitTest, uMessage);
  410. }
  411.  
  412. //
  413. // Form element background colors
  414. // 
  415. HBRUSH CGenericView::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
  416. {
  417.  
  418.     if(!GetContext() || GetContext()->IsDestroyed())
  419.     return NULL;
  420.  
  421.     // only color buttons
  422.     if((nCtlColor != CTLCOLOR_BTN) && (nCtlColor != CTLCOLOR_STATIC))
  423.     return(CWnd::OnCtlColor(pDC, pWnd, nCtlColor ) );
  424.  
  425.     CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
  426.  
  427.     // Assume the document background color
  428.     COLORREF rgbCurrentColor = GetContext()->m_rgbBackgroundColor;
  429.  
  430.     // We need to use the background associated with the form element if there is one
  431.     // (e.g. a form element in a table cell with a specified background color)
  432.     if (pWnd->IsKindOf(RUNTIME_CLASS(CNetscapeButton))) {
  433.         LO_FormElementStruct*   pElement = ((CNetscapeButton*)pWnd)->GetElement();
  434.  
  435.         if (pElement && pElement->text_attr && pElement->text_attr->no_background == FALSE)
  436.             rgbCurrentColor = RGB(pElement->text_attr->bg.red, pElement->text_attr->bg.green, pElement->text_attr->bg.blue);
  437.     }
  438.  
  439.     if(m_hCtlBrush == NULL) {
  440.     // was no brush, just make a new one
  441.     m_hCtlBrush = ::CreateSolidBrush(0x02000000L | rgbCurrentColor);
  442.     m_rgbBrushColor = rgbCurrentColor;
  443.     } else if(m_rgbBrushColor != rgbCurrentColor) {
  444.     // old brush existed but was a different color -- destroy and remake
  445.     DeleteObject(m_hCtlBrush);
  446.     m_hCtlBrush = ::CreateSolidBrush(0x02000000L | rgbCurrentColor);
  447.     m_rgbBrushColor = rgbCurrentColor;
  448.     }
  449.  
  450.     HPALETTE hOldPal = NULL;
  451.     if(GetContext()->GetPalette())  {
  452.         hOldPal = ::SelectPalette(pDC->GetSafeHdc(), GetContext()->GetPalette(), FALSE);
  453.     }
  454.     pDC->SetBkMode(TRANSPARENT);
  455.     pDC->SetBkColor(0x02000000L | rgbCurrentColor);
  456. // XXX WHS Look into this more
  457. //  if(hOldPal) {
  458. //        ::SelectPalette(pDC->GetSafeHdc(), hOldPal, FALSE);
  459. //  }
  460.  
  461.     return(m_hCtlBrush);
  462. }
  463.  
  464.  
  465. #ifndef MOZ_MAIL_NEWS
  466. extern "C" void DoAltMailComposition(MWContext *pContext);
  467. #endif // MOZ_MAIL_NEWS
  468.  
  469. void CGenericView::OnFileMailto() 
  470. {
  471.     // Pass this off to the context for handling.
  472. #ifndef MOZ_MAIL_NEWS
  473.     DoAltMailComposition(GetContext()->GetContext());
  474. #else /* MOZ_MAIL_NEWS */
  475.     if(GetContext())        {
  476.         GetContext()->MailDocument();
  477.     }
  478. #endif /* MOZ_MAIL_NEWS */
  479. }
  480.  
  481. void CGenericView::OnUpdateFileMailto(CCmdUI* pCmdUI) 
  482. {
  483.     if(GetContext())        {
  484.         if(GetContext()->IsGridParent() || GetContext()->IsGridCell())  {
  485.             pCmdUI->SetText(szLoadString(IDS_MAIL_FRAME));
  486.         }
  487.         else    {
  488.             pCmdUI->SetText(szLoadString(IDS_MAIL_NOFRAME));
  489.         }
  490.         pCmdUI->Enable(GetContext()->CanMailDocument());
  491.     }
  492.     else    {
  493.         pCmdUI->Enable(FALSE);  
  494.     }
  495. }
  496.  
  497. // Opens a file to browse - currently called only from browser,
  498. //   but will be called from editor in future
  499. // Context figures out which and opens in new window  
  500. //   only if called from and editor
  501. void CGenericView::OnFileOpen() 
  502. {
  503.     if(GetContext())        {
  504.         GetContext()->OpenFile();
  505.     }
  506. }
  507.  
  508. void CGenericView::OnUpdateFileOpen(CCmdUI* pCmdUI) 
  509. {
  510.     if(GetContext())        {
  511.         pCmdUI->Enable(GetContext()->CanOpenFile());
  512.     }
  513.     else    {
  514.         pCmdUI->Enable(FALSE);
  515.     }
  516. }
  517.  
  518. void CGenericView::OnNetscapeSaveAs() 
  519. {
  520.     if(GetContext())        {
  521.         GetContext()->SaveAs();
  522.     }
  523. }
  524.  
  525. void CGenericView::OnUpdateNetscapeSaveAs(CCmdUI* pCmdUI) 
  526. {
  527.     if(GetContext())        {
  528.         pCmdUI->Enable(GetContext()->CanSaveAs());
  529.     }
  530.     else    {
  531.         pCmdUI->Enable(FALSE);
  532.     }
  533. }
  534.  
  535. void CGenericView::OnNetscapeSaveFrameAs() 
  536. {
  537.     if(GetContext())        {
  538.         GetContext()->SaveAs();
  539.     }
  540. }
  541.  
  542. void CGenericView::OnUpdateNetscapeSaveFrameAs(CCmdUI* pCmdUI) 
  543. {
  544.     if(GetContext())        {
  545.         if(GetContext()->IsGridParent() || GetContext()->IsGridCell())  {
  546.             pCmdUI->Enable(GetContext()->CanSaveAs());
  547.         }
  548.         else
  549.         {
  550.             pCmdUI->Enable(FALSE);
  551.         }
  552.     }
  553.     else    {
  554.         pCmdUI->Enable(FALSE);
  555.     }
  556. }
  557.  
  558. void CGenericView::OnNavigateBack() 
  559. {
  560.     //      Let the context have it.
  561.     if(GetContext())        {
  562.  
  563.         GetContext()->ResetToolTipImg();
  564.         GetContext()->AllBack();
  565.  
  566.     }
  567. }
  568.  
  569. void CGenericView::OnUpdateNavigateBack(CCmdUI* pCmdUI) 
  570. {
  571.     //      Defer to the context's wisdom.
  572.     if(GetContext())        {
  573.         pCmdUI->Enable(GetContext()->CanAllBack());
  574.     }
  575.     else    {
  576.         pCmdUI->Enable(FALSE);
  577.     }
  578. }
  579.  
  580. void CGenericView::OnNavigateForward() 
  581. {
  582.     //      Let the context have it.
  583.     if(GetContext())        {
  584.  
  585.         GetContext()->ResetToolTipImg();
  586.         GetContext()->AllForward();
  587.  
  588.     }
  589. }
  590.  
  591. void CGenericView::OnUpdateNavigateForward(CCmdUI* pCmdUI) 
  592. {
  593.     //      Defer to the context's wisdom.
  594.     if(GetContext())        {
  595.         pCmdUI->Enable(GetContext()->CanAllForward());
  596.     }
  597.     else    {
  598.         pCmdUI->Enable(FALSE);
  599.     }
  600. }
  601.  
  602. void CGenericView::OnNavigateReload() 
  603. {
  604.     //      Let the context have it.
  605.     if(GetContext())        {
  606.         GetContext()->ResetToolTipImg();
  607.         if(::GetKeyState(VK_SHIFT) & 0x8000) {
  608.             //  Shift key was down, do it up baby.
  609.             GetContext()->AllReload(NET_SUPER_RELOAD);
  610.         }
  611.         else    {
  612.             GetContext()->AllReload();
  613.         }
  614.     }
  615. }
  616.  
  617. void CGenericView::OnUpdateNavigateReload(CCmdUI* pCmdUI) 
  618. {
  619.     //      Defer to the context's wisdom.
  620.     if(GetContext())        {
  621. #ifdef EDITOR
  622.     if ( EDT_IS_EDITOR((GetContext()->GetContext())) ) {
  623.         // Don't allow reload for an unsaved new document 
  624.         pCmdUI->Enable(!EDT_IS_NEW_DOCUMENT((GetContext()->GetContext())) && 
  625.                 GetContext()->CanAllReload());
  626.     } else
  627. #endif
  628.         pCmdUI->Enable(GetContext()->CanAllReload());
  629.     }
  630.     else    {
  631.         pCmdUI->Enable(FALSE);
  632.     }
  633. }
  634.  
  635. void CGenericView::OnViewLoadimages() 
  636. {
  637.     //      Let the context have it.
  638.     if(GetContext())        {
  639.         GetContext()->ViewImages();
  640.     }
  641. }
  642.  
  643. void CGenericView::OnUpdateViewLoadimages(CCmdUI* pCmdUI) 
  644. {
  645.     //      Defer to the context's wisdom.
  646.     if(GetContext())        {
  647.         pCmdUI->Enable(GetContext()->CanViewImages());
  648.     }
  649.     else    {
  650.         pCmdUI->Enable(FALSE);
  651.     }
  652. }
  653.  
  654. void CGenericView::OnFilePrint() 
  655. {
  656.     //  Let the context have it.
  657.     //  Make sure it's the active context which gets this.
  658.     //  In print preview of a frame cell, the command goes to the
  659.     //      parent view, which isn't able to print, so route it manually....
  660.     if(GetFrame() && GetFrame()->GetActiveWinContext() && GetFrame()->GetActiveWinContext()->CanPrint())    {
  661.         // if there is a full page plugin on the page, there can't be anything else
  662.         // on the page so just tell it to print whatever it wants, using it's own
  663.         // print context dialog.  We pass NULL as a parameter today, but in the
  664.         // future, we should pass in at least the printer chosen by the user.
  665.         if(GetFrame()->GetActiveWinContext()->ContainsFullPagePlugin()) {
  666.             // there can be only one plugin if it is full page
  667.             NPL_Print(GetFrame()->GetActiveWinContext()->GetContext()->pluginList, NULL);
  668.             return;
  669.         }
  670.  
  671.         GetFrame()->GetActiveWinContext()->Print();
  672.     }
  673. }
  674.  
  675. void CGenericView::OnUpdateFilePrint(CCmdUI* pCmdUI) 
  676. {
  677.     //      Defer to the context's wisdom.
  678.     if(GetContext())        {
  679.  
  680.             // Only change the text for menu items...
  681.  
  682.             if (pCmdUI->m_pMenu) {
  683.                 MWContextType type = GetContext()->GetContext() ? 
  684.                                      GetContext()->GetContext()->type : 
  685.                                      MWContextBrowser;
  686.                 
  687.                 // Only change the menu for browser windows
  688.                 if (type == MWContextBrowser) {
  689.                     //      Need to change the menu item depending on wether or not we are a frame.
  690.                     if(GetContext()->IsGridCell() || GetContext()->IsGridParent())  {
  691.                         pCmdUI->SetText(szLoadString(IDS_PRINT_FRAME));
  692.                     }
  693.                     else    {
  694.                         pCmdUI->SetText(szLoadString(IDS_PRINT_NOFRAME));
  695.                     }
  696.                 }
  697.             }
  698.         pCmdUI->Enable(GetContext()->CanPrint());
  699.     }
  700.     else    {
  701.         pCmdUI->Enable(FALSE);
  702.     }
  703. }
  704.  
  705. void CGenericView::OnUpdateFilePrintPreview(CCmdUI* pCmdUI) 
  706. {
  707.     //      Defer to the context's wisdom.
  708.     if(GetContext())        {
  709.         // Don't enable print preview for full-page plugins, because it isn't
  710.         // currently supported (i.e. there's no routine in the plugin API to ask
  711.         // the plugin to do something sensible)
  712.         pCmdUI->Enable(!GetContext()->ContainsFullPagePlugin() && GetContext()->CanPrint(TRUE));
  713.     }
  714.     else    {
  715.         pCmdUI->Enable(FALSE);
  716.     }
  717. }
  718.  
  719. void CGenericView::OnEditFindincurrent() 
  720. {
  721.     //      Let the context have it.
  722.     if(GetContext())        {
  723.         GetContext()->AllFind();
  724.     }
  725. }
  726.  
  727. void CGenericView::OnUpdateEditFindincurrent(CCmdUI* pCmdUI) 
  728. {
  729.     //      Defer to the context's wisdom.
  730.     if(GetContext())        {
  731.         pCmdUI->Enable(GetContext()->CanAllFind());
  732.     }
  733.     else    {
  734.         pCmdUI->Enable(FALSE);
  735.     }
  736. }
  737.  
  738. void CGenericView::OnUpdateEditWithFrameFindincurrent(CCmdUI* pCmdUI) 
  739. {
  740.     //      Defer to the context's wisdom.
  741.     if(GetContext()) 
  742.     {
  743.         if(pCmdUI->m_pMenu)
  744.             pCmdUI->m_pMenu->ModifyMenu(CASTUINT(ID_EDIT_WITHFRAME_FINDINCURRENT), CASTUINT(MF_BYCOMMAND | MF_STRING),
  745.                                         CASTUINT(ID_EDIT_WITHFRAME_FINDINCURRENT), szLoadString(CASTUINT(GetContext()->IsGridCell() ? IDS_FINDINFRAME : IDS_FINDINPAGE)));
  746.  
  747.         pCmdUI->Enable(!GetContext()->IsGridParent() && GetContext()->CanAllFind());
  748.         return;
  749.     }
  750.  
  751.     pCmdUI->Enable(FALSE);
  752. }
  753.  
  754. void CGenericView::OnEditFindAgain() 
  755. {
  756.     //      Let the context have it.
  757.     if(GetContext()) {
  758.         GetContext()->FindAgain();
  759.     }
  760. }
  761.  
  762. void CGenericView::OnUpdateEditFindAgain(CCmdUI* pCmdUI) 
  763. {
  764.     //      Defer to the context's wisdom.
  765.     if(GetContext()) {
  766.         pCmdUI->Enable(GetContext()->CanFindAgain());
  767.     }
  768.     else {
  769.         pCmdUI->Enable(FALSE);
  770.     }
  771. }
  772.  
  773. //
  774. // Someone has requested a find operation
  775. //
  776. LRESULT CGenericView::OnFindReplace(WPARAM wParam, LPARAM lParam) 
  777. {  
  778.  
  779.     CFindReplaceDialog * dlg = ::CFindReplaceDialog::GetNotifier(lParam);
  780.     if (!dlg) 
  781.         return NULL;
  782.       
  783.     FINDREPLACE findstruct = dlg->m_fr;
  784.         
  785.     if (dlg->IsTerminating()) {
  786. //        dlg->DestroyWindow();
  787.         return NULL;
  788.     }     
  789.  
  790.     MWContext *pSearchContext = ((CNetscapeFindReplaceDialog*)dlg)->GetSearchContext();
  791.  
  792. #ifdef EDITOR
  793.     BOOL bReplaceAll = (BOOL)(findstruct.Flags & FR_REPLACEALL);
  794.     // If no search context set, use current window's
  795.     if( !pSearchContext )
  796.     {
  797.         if( GetContext() )
  798.             pSearchContext = GetContext()->GetContext();
  799.  
  800.         if( !pSearchContext )
  801.             return NULL;
  802.     }
  803.     BOOL bEditor = EDT_IS_EDITOR(pSearchContext);
  804.     // Ignore everything except FINDNEXT if not a Composer
  805.     if( !bEditor && ((findstruct.Flags & FR_FINDNEXT) == 0) )
  806.         return NULL;
  807. #else
  808.     // Something wrong or user cancelled dialog box
  809.     if((findstruct.Flags & FR_FINDNEXT) == 0)
  810.         return NULL;
  811. #endif
  812.  
  813.     
  814.     CWinCX *pCX;
  815.  
  816.     // can only find if we have a window
  817.     if (pSearchContext && ABSTRACTCX(pSearchContext)->IsFrameContext())    {
  818.         pCX = WINCX(pSearchContext);
  819.     }
  820.     else 
  821.         pCX = GetContext();
  822.  
  823.     if(pCX) {
  824. #ifdef EDITOR
  825.         if(bEditor && (findstruct.Flags & FR_REPLACE) || bReplaceAll)
  826.         {
  827.             // Only Composer currently replaces text
  828.             // TODO: NEED TO FINISH GETTING CORRECT PARAMS: CAN WE DO DIRECTION OR WRAP IN WINDOWS?
  829.             EDT_ReplaceText(pSearchContext, findstruct.lpstrReplaceWith, bReplaceAll,
  830.                             findstruct.lpstrFindWhat, !dlg->MatchCase() /* bCaseless */, 
  831.                             !dlg->SearchDown() /*bBackward*/, FALSE /*bDoWrap*/);
  832.             // Continue to search for next string unless we replaced all
  833.             if( bReplaceAll )
  834.                 return TRUE;
  835.         }
  836. #endif
  837.         // remember this string for next time
  838.         theApp.m_csFindString = findstruct.lpstrFindWhat;
  839.         theApp.m_csReplaceString = findstruct.lpstrReplaceWith;
  840.         theApp.m_bMatchCase   = dlg->MatchCase();
  841.         theApp.m_bSearchDown  = dlg->SearchDown(); 
  842.  
  843.         // this will pull the values we just set out of theApp and do the find
  844.         //   operation for us
  845.         pCX->DoFind(dlg, findstruct.lpstrFindWhat, dlg->MatchCase(), dlg->SearchDown(), TRUE);
  846.     }
  847.                  
  848.     return(TRUE);
  849. }  
  850.  
  851. void CGenericView::OnNavigateInterrupt() 
  852. {
  853.     //      Let the context have it.
  854.     if(GetContext())        {
  855.         GetContext()->AllInterrupt();
  856.     }
  857. }
  858.  
  859. void CGenericView::OnUpdateNavigateInterrupt(CCmdUI* pCmdUI) 
  860. {
  861.     //      Defer to the context's wisdom.
  862.     if(GetContext())        {
  863.         pCmdUI->Enable(GetContext()->CanAllInterrupt());
  864.     }
  865.     else    {
  866.         pCmdUI->Enable(FALSE);
  867.     }
  868. }
  869.  
  870. void CGenericView::OnEditCopy() 
  871. {
  872.     //      Let the context have it.
  873.     if(GetContext())        {
  874.         SetCursor(theApp.LoadStandardCursor(IDC_WAIT));
  875.         GetContext()->CopySelection();
  876.         SetCursor(theApp.LoadStandardCursor(IDC_ARROW));
  877.     }
  878. }
  879.  
  880. void CGenericView::OnUpdateEditCopy(CCmdUI* pCmdUI) 
  881. {
  882.     //      Defer to the context's wisdom.
  883.     if(GetContext())        {
  884.         pCmdUI->Enable(GetContext()->CanCopySelection());
  885.     }
  886.     else    {
  887.         pCmdUI->Enable(FALSE);
  888.     }
  889. }
  890.  
  891. void CGenericView::OnUpdateEditCut(CCmdUI* pCmdUI) 
  892. {
  893.     //      Disable until supported.
  894.     pCmdUI->Enable(FALSE);  
  895. }
  896.  
  897. void CGenericView::OnUpdateEditPaste(CCmdUI* pCmdUI) 
  898. {
  899.     //      Disable until supported.
  900.     pCmdUI->Enable(FALSE);  
  901. }
  902.  
  903. void CGenericView::OnSelectAll() 
  904. {
  905.     LO_SelectAll(GetContext()->GetDocumentContext());
  906. }
  907.  
  908. //#ifndef NO_TAB_NAVIGATION
  909. // BOOL CGenericView::procTabNavigation( MSG * pMsg )
  910. BOOL CGenericView::procTabNavigation(UINT nChar, UINT forward, UINT controlKey ) 
  911. {
  912.     //      Call the base.
  913.     // BOOL    bTranslated = CView::PreTranslateMessage(pMsg);
  914.  
  915.     //if ( bTranslated || pMsg->message != WM_KEYDOWN)
  916.     //    return( bTranslated );
  917.     
  918.  
  919.     if(    nChar != VK_TAB && nChar != VK_SPACE && nChar != VK_RETURN    )
  920.         return( FALSE );
  921.  
  922.     if( GetContext() == NULL || GetContext()->IsDestroyed() == TRUE)
  923.         return( FALSE );
  924.  
  925.     BOOL    ret;
  926.     if( nChar == VK_TAB ) {
  927.         // setTabFocusNext will search siblings
  928.         ret = GetContext()->setTabFocusNext( forward );    // 1 is forward
  929.         return( ret );        // ret == TRUE if key handled by me or by one of my sibling
  930.     } 
  931.  
  932.     if (  nChar == VK_RETURN ) {            // nChar == VK_SPACE ||
  933.         // fire action for links only. 
  934.         // Form elements will handle this in their OnChar
  935.         ret = GetContext()->fireTabFocusElement( nChar );
  936.         return( ret );        // ret == TRUE if I fired a link.
  937.     }
  938.  
  939.     // should not reach here
  940.     return( FALSE );
  941. }    // BOOL CGenericView::procTabNavigation( MSG * pMsg )
  942. //#endif    /* NO_TAB_NAVIGATION */
  943.  
  944. BOOL CGenericView::PreTranslateMessage(MSG * pMsg)
  945. {
  946.     return(FALSE);
  947. }
  948.  
  949. void CGenericView::OnFileViewsource() 
  950. {
  951.     //      Have the context handle it.
  952.     if(GetContext())        {
  953.         GetContext()->ViewSource();
  954.     }
  955. }
  956.  
  957. void CGenericView::OnUpdateFileViewsource(CCmdUI* pCmdUI) 
  958. {
  959.     //      Defer to the context's wisdom.
  960.     if(GetContext())        {
  961.         pCmdUI->Enable(GetContext()->CanViewSource());
  962.     }
  963.     else    {
  964.         pCmdUI->Enable(FALSE);
  965.     }       
  966. }
  967.  
  968. void CGenericView::OnFileDocinfo() 
  969. {
  970.     //      Have the context handle it.
  971.     if(GetContext())        {
  972.         GetContext()->DocumentInfo();
  973.     }
  974. }
  975.  
  976. void CGenericView::OnUpdateFileDocinfo(CCmdUI* pCmdUI) 
  977. {
  978.     //      Defer to the context's wisdom.
  979.     if(GetContext())        {
  980.         pCmdUI->Enable(GetContext()->CanDocumentInfo());
  981.     }
  982.     else    {
  983.         pCmdUI->Enable(FALSE);
  984.     }       
  985. }
  986.  
  987. void CGenericView::OnViewPageServices() 
  988. {
  989.     URL_Struct *pNewUrl_s;
  990.  
  991.     char *url;
  992.  
  993.     if(GetContext() && GetContext()->GetContext())
  994.     {
  995.         if(SHIST_CurrentHandlesPageServices(GetContext()->GetContext()))
  996.         {
  997.             url = SHIST_GetCurrentPageServicesURL(GetContext()->GetContext());
  998.  
  999.             if(url)
  1000.             {
  1001.                 pNewUrl_s = NET_CreateURLStruct(url, NET_DONT_RELOAD);
  1002.                 GetContext()->GetUrl(pNewUrl_s, FO_PRESENT);
  1003.             }
  1004.         }
  1005.     }    
  1006.  
  1007. }
  1008.  
  1009. void CGenericView::OnUpdateViewPageServices(CCmdUI* pCmdUI) 
  1010. {
  1011.     if(GetContext() && GetContext()->GetContext())
  1012.     {
  1013.         pCmdUI->Enable(SHIST_CurrentHandlesPageServices(GetContext()->GetContext()));
  1014.     }
  1015.     else
  1016.         pCmdUI->Enable(FALSE);
  1017.  
  1018. }
  1019.  
  1020. void CGenericView::OnGoHome() 
  1021. {
  1022.     //      Have the context handle it.
  1023.     if(GetContext())        {
  1024.         GetContext()->GoHome();
  1025.     }
  1026. }
  1027.  
  1028. void CGenericView::OnUpdateGoHome(CCmdUI* pCmdUI) 
  1029. {
  1030.     //      Defer to the context.
  1031.     if(GetContext())        {
  1032.         pCmdUI->Enable(GetContext()->CanGoHome());
  1033.     }
  1034.     else    {
  1035.         pCmdUI->Enable(FALSE);
  1036.     }
  1037. }
  1038.  
  1039. void CGenericView::OnMove(int x, int y) 
  1040. {
  1041.     CView::OnMove(x, y);
  1042.     
  1043.     if(GetContext())        {
  1044.         GetContext()->OnMoveCX();
  1045.     }
  1046. }
  1047.  
  1048. void CGenericView::OnNcPaint()
  1049. {
  1050.     //      Call the base (it will handle scrollers and other stuff).
  1051.     CView::OnNcPaint();
  1052.  
  1053.     //      Now, tell the context to do anything it needs to do.
  1054.     if(GetContext())        {
  1055.         GetContext()->OnNcPaintCX();
  1056.     }
  1057. }
  1058.  
  1059. void CGenericView::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
  1060. {
  1061.     //  Call the base (it will fill in all the normal stuff).
  1062.     CView::OnNcCalcSize(bCalcValidRects, lpncsp);
  1063.  
  1064.     //  Now, have the context shrink us if appropriate.
  1065.     if(GetContext())    {
  1066.         GetContext()->OnNcCalcSizeCX(bCalcValidRects, lpncsp);
  1067.     }
  1068. }
  1069.  
  1070.  
  1071. void CGenericView::OnFileUploadfile() 
  1072. {
  1073.     //      Have the context handle it.
  1074.     if(GetContext())        {
  1075.         GetContext()->UploadFile();
  1076.     }
  1077. }
  1078.  
  1079. void CGenericView::OnUpdateFileUploadfile(CCmdUI* pCmdUI) 
  1080. {
  1081.     //      Defer to the context.
  1082.     if(GetContext())        {
  1083.         pCmdUI->Enable(GetContext()->CanUploadFile());
  1084.     }
  1085.     else    {
  1086.         pCmdUI->Enable(FALSE);
  1087.     }
  1088. }
  1089.  
  1090. void CGenericView::OnNavigateReloadcell() 
  1091. {
  1092.     //      Have the current context reload.
  1093.     if(GetContext())        {
  1094.         if(::GetKeyState(VK_SHIFT) & 0x8000) {
  1095.             //  Shift key was down, do the super thing.
  1096.             GetContext()->Reload(NET_SUPER_RELOAD);
  1097.         }
  1098.         else    {
  1099.             GetContext()->Reload();
  1100.         }
  1101.     }
  1102. }
  1103.  
  1104. void CGenericView::OnUpdateNavigateReloadcell(CCmdUI* pCmdUI) 
  1105. {
  1106.     //      Defer to the context's wisdom.
  1107.     if(GetContext())        {
  1108.         pCmdUI->Enable(GetContext()->IsGridCell() == TRUE
  1109.             && GetContext()->IsGridParent() == FALSE);
  1110.     }
  1111.     else    {
  1112.         pCmdUI->Enable(FALSE);
  1113.     }
  1114. }
  1115.  
  1116. void CGenericView::OnViewFrameInfo() 
  1117. {
  1118.     if(GetContext())    {
  1119.     GetContext()->FrameInfo();
  1120.     }
  1121. }
  1122.  
  1123. void CGenericView::OnUpdateViewFrameInfo(CCmdUI* pCmdUI) 
  1124. {
  1125.     //  Defer to the context
  1126.     if(GetContext())    {
  1127.     pCmdUI->Enable(GetContext()->CanFrameInfo());
  1128.     }
  1129.     else    {
  1130.     pCmdUI->Enable(FALSE);
  1131.     }
  1132. }
  1133.  
  1134. void CGenericView::OnViewFrameSource() 
  1135. {
  1136.     if(GetContext())    {
  1137.     GetContext()->FrameSource();
  1138.     }
  1139. }
  1140.  
  1141. void CGenericView::OnUpdateViewFrameSource(CCmdUI* pCmdUI) 
  1142. {
  1143.     //  Defer to the context
  1144.     if(GetContext())    {
  1145.     pCmdUI->Enable(GetContext()->CanFrameSource());
  1146.     }
  1147.     else    {
  1148.     pCmdUI->Enable(FALSE);
  1149.     }
  1150. }
  1151.  
  1152. void CGenericView::OnSetFocus(CWnd* pOldWnd) 
  1153. {
  1154.     CView::OnSetFocus(pOldWnd);
  1155.     if(GetContext() && !GetContext()->IsDestroyed() && GetContext()->GetContext())    {
  1156.         // send the event to libmocha --- do any further processing
  1157.         //   in our closure routine
  1158.     JSEvent *event;
  1159.     event = XP_NEW_ZAP(JSEvent);
  1160.     event->type = EVENT_FOCUS;
  1161.         
  1162.     ET_SendEvent(GetContext()->GetContext(), NULL, event, NULL, 
  1163.                      this);
  1164.     }
  1165. }
  1166.  
  1167. void CGenericView::OnKillFocus(CWnd* pNewWnd) 
  1168. {
  1169.     CView::OnKillFocus(pNewWnd);
  1170.     if(GetContext() && !GetContext()->IsDestroyed() && GetContext()->GetContext())    {
  1171.         // send the event to libmocha --- do any further processing
  1172.         //   in our closure routine
  1173.     JSEvent *event;
  1174.     event = XP_NEW_ZAP(JSEvent);
  1175.     event->type = EVENT_BLUR;
  1176.  
  1177.         ET_SendEvent(GetContext()->GetContext(), NULL, event, NULL, 
  1178.                      this);
  1179.     }
  1180. }
  1181.  
  1182.