home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / compfrm2.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.6 KB  |  137 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. /* COMPFRM.CPP - Compose Window Frame.  This module contains code for the
  20.  * compose window frame class.  Handles all menu and tool commands.
  21.  *
  22.  */
  23.  
  24. #include "stdafx.h"
  25. #include "edt.h"
  26. #include "compbar.h"
  27. #include "compfrm.h"
  28. #include "prefapi.h"
  29. #include "addrdlg.h"
  30. #include "intl_csi.h"
  31.  
  32. extern "C" {
  33. #include "xpgetstr.h"
  34. extern int MK_MSG_SAVE_AS;
  35. extern int MK_MSG_CANT_OPEN;
  36. extern int MK_MSG_MISSING_SUBJECT;
  37. };
  38.  
  39. #ifdef XP_WIN32
  40. #include "postal.h"
  41. #endif
  42. #include "netsvw.h"
  43.  
  44. void CComposeFrame::SetEditorParent(CWnd * pWnd)
  45. {
  46.    CWinCX * pWinCX = (CWinCX*)GetMainContext();
  47.  
  48.    // after the window is created, tell the browser view to resize the 
  49.    // parent which resizes the editor.
  50.    if (pWinCX) 
  51.    {
  52.       CNetscapeView * pView = (CNetscapeView*)pWinCX->GetView();
  53.       if (pView)
  54.          pView->SetChild (pWnd);
  55.    }
  56. }
  57.  
  58. void CComposeFrame::SetHtmlMode(BOOL bMode)
  59. {
  60.     m_bUseHtml = bMode;
  61. }
  62.  
  63. void CComposeFrame::SetQuoteSelection(void)
  64. {
  65.     int32 eReplyOnTop = 0;
  66.  
  67.     if (PREF_NOERROR == PREF_GetIntPref("mailnews.reply_on_top", &eReplyOnTop) &&
  68.             eReplyOnTop != 0) {
  69.     // call backend with insertion call-back
  70.         if (UseHtml()) 
  71.         {
  72.             int32 offset = EDT_GetInsertPointOffset( GetMainContext()->GetContext() );
  73.             SetQuoteSel(offset);
  74.         }
  75.         else 
  76.         {
  77.             int tmpStartSel, tmpEndSel;
  78.             GetEditor()->GetSel(tmpStartSel, tmpEndSel);
  79.             // we only care about start position
  80.             SetQuoteSel((int32) tmpStartSel);
  81.         }
  82.     }
  83. }
  84.  
  85. CWnd * CComposeFrame::GetEditorWnd(void)
  86. {
  87.     if (m_bUseHtml) 
  88.     {
  89.         CWinCX * pWinCX = (CWinCX*)GetMainContext();
  90.         HWND hwnd = pWinCX->GetPane();
  91.         return CWnd::FromHandle(hwnd);
  92.     }
  93.     return (CWnd *)&m_Editor;
  94. }
  95.  
  96. void CComposeFrame::UpdateAttachmentInfo(void)
  97. {
  98.     ASSERT(m_pComposeBar);
  99.     m_pComposeBar->UpdateAttachmentInfo(MSG_GetAttachmentList(GetMsgPane()) ? 1 : 0);
  100. }
  101.  
  102. BOOL CComposeFrame::PreTranslateMessage( MSG* pMsg )
  103. {
  104.     if (pMsg->message == WM_KEYDOWN)
  105.     {
  106.         if (pMsg->wParam == VK_TAB)
  107.         {
  108.             BOOL bControl = GetKeyState(VK_CONTROL) & 0x8000;
  109.             BOOL bShift = GetKeyState(VK_SHIFT) & 0x8000;
  110.             CWnd * pWnd = CWnd::FromHandle(pMsg->hwnd);
  111.             if (GetComposeBar()->TabControl(bShift, bControl, pWnd))
  112.                 return TRUE;                    
  113.         }
  114.     }
  115.     else if (pMsg->message == WM_COMMAND)
  116.     {
  117.         int ID = (int)LOWORD(pMsg->wParam);
  118.         if (ID == ID_CHECK_SPELLING)
  119.         {
  120.             OnCheckSpelling();
  121.             return TRUE;
  122.         }
  123.     }
  124.     return CGenericFrame::PreTranslateMessage(pMsg);
  125. }
  126.  
  127. void CComposeFrame::OnSelectAddresses()
  128. {
  129.     CAddrDialog AddressDialog(this);
  130.     GetComposeBar()->OnAddressTab();
  131.     GetComposeBar()->UpdateWindow();
  132.     CWnd * pWnd = GetFocus();
  133.     AddressDialog.DoModal();
  134.     pWnd->SetFocus();
  135. }
  136.  
  137.