home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / template.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  21.7 KB  |  651 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. #include "stdafx.h"
  20. #include "winproto.h"
  21. #include "template.h"
  22. #include "netsvw.h"
  23. #include "mainfrm.h"
  24. #ifdef MOZ_MAIL_NEWS
  25. #include "mailfrm.h"
  26. #include "compfrm.h"
  27. #endif /* MOZ_MAIL_NEWS */
  28. #include "prefapi.h"
  29. #include "cxwin.h"
  30.  
  31. #ifdef AFX_CORE2_SEG
  32. #pragma code_seg(AFX_CORE2_SEG)
  33. #endif
  34.  
  35. #ifdef _DEBUG
  36. #undef THIS_FILE
  37. static char BASED_CODE THIS_FILE[] = __FILE__;
  38. #endif
  39.  
  40. IMPLEMENT_DYNAMIC(CGenericDocTemplate, CDocTemplate)
  41. IMPLEMENT_DYNAMIC(CNetscapeDocTemplate, CGenericDocTemplate)
  42. #ifdef EDITOR
  43. IMPLEMENT_DYNAMIC(CNetscapeEditTemplate, CGenericDocTemplate)
  44. #endif // EDITOR
  45. #ifdef MOZ_MAIL_NEWS
  46. IMPLEMENT_DYNAMIC(CNetscapeComposeTemplate, CGenericDocTemplate)
  47. IMPLEMENT_DYNAMIC(CNetscapeTextComposeTemplate, CGenericDocTemplate)
  48. IMPLEMENT_DYNAMIC(CNetscapeAddrTemplate, CGenericDocTemplate)
  49. #endif /* MOZ_MAIL_NEWS */
  50. #ifndef _AFXDLL
  51. #define new DEBUG_NEW  // MSVC Debugging new...goes to regular new in release mode
  52. #endif
  53.  
  54. //CLM:
  55. //  Set TRUE when starting an Editor
  56. //  with curent Browser document
  57. //  (CGenframe::OnNavigateToEdit)
  58. BOOL wfe_bUseLastFrameLocation = FALSE;
  59. // The last active frame before creating a new one
  60. CGenericFrame *wfe_pLastFrame = NULL;
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // construction/destruction
  64. CGenericDocTemplate::CGenericDocTemplate(UINT nIDResource,
  65.     CRuntimeClass* pDocClass,
  66.     CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
  67.     : CDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
  68. {
  69.     m_nUntitledCount = 0;
  70.     m_hMenuShared = NULL;
  71.     m_hAccelTable = NULL;
  72.     m_bHideTitlebar = FALSE;
  73.     m_bDependent = FALSE;
  74.     m_bPopupWindow = FALSE;
  75.     m_hPopupParent = NULL;
  76.     m_bBorder = TRUE;
  77. }
  78.  
  79. CGenericDocTemplate::~CGenericDocTemplate()
  80. {
  81.     //  Delete shared components
  82.     if(m_hMenuShared != NULL)   {
  83.     ::DestroyMenu(m_hMenuShared);
  84.     }
  85.     if(m_hAccelTable != NULL)   {
  86.     ::FreeResource((HGLOBAL)m_hAccelTable);
  87.     }
  88. }
  89.  
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. //  CNetscapeDocTemplate attributes
  93.  
  94. POSITION CGenericDocTemplate::GetFirstDocPosition() const  {
  95.     return m_docList.GetHeadPosition();
  96. }
  97.  
  98. CDocument *CGenericDocTemplate::GetNextDoc(POSITION& rPos) const   {
  99.     return(CDocument *)m_docList.GetNext(rPos);
  100. }
  101.  
  102.  
  103. /////////////////////////////////////////////////////////////////////////////
  104. //  CNetscapeDocTemplate document management (list of open docs)
  105.  
  106. void CGenericDocTemplate::AddDocument(CDocument *pDoc) {
  107.     CDocTemplate::AddDocument(pDoc);
  108.     m_docList.AddTail(pDoc);
  109. }
  110.  
  111. void CGenericDocTemplate::RemoveDocument(CDocument *pDoc)  {
  112.     CDocTemplate::RemoveDocument(pDoc);
  113.     m_docList.RemoveAt(m_docList.Find(pDoc));
  114. }
  115.  
  116. /////////////////////////////////////////////////////////////////////////////
  117. //  CNetscapeDocTemplate misc
  118.  
  119. BOOL CGenericDocTemplate::GetDocString(CString& rString, enum DocStringIndex index) const
  120. {
  121.     switch(index) {
  122.     case CDocTemplate::windowTitle:
  123.     rString = "Netscape Navigator";
  124.     break;
  125.     case CDocTemplate::docName:
  126.     rString = "Netscape";
  127.     break;
  128.     case CDocTemplate::fileNewName:
  129.     rString = "Hypertext";
  130.     break;
  131.     case CDocTemplate::filterName:
  132.     rString = szLoadString(IDS_SOURCE_FILETYPE);
  133.     break;
  134.     case CDocTemplate::filterExt:
  135.     rString = ".htm";
  136.     break;
  137.     case CDocTemplate::regFileTypeId:
  138.     rString = "NetscapeMarkup";
  139.     break;
  140.     case CDocTemplate::regFileTypeName:
  141.     rString = "Netscape Hypertext Document";
  142.     break;
  143.     default:
  144.     return(FALSE);
  145.     }
  146.  
  147.     return(TRUE);
  148. }
  149.  
  150. void CGenericDocTemplate::SetDefaultTitle(CDocument* pDocument)
  151. {
  152.     CString strDocName;
  153.     if (!GetDocString(strDocName, CDocTemplate::docName) ||
  154.     strDocName.IsEmpty())
  155.     {
  156.     // use generic 'untitled'
  157.     VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
  158.     }
  159.     pDocument->SetTitle(strDocName);
  160. }
  161.  
  162. //
  163. // Add the newly created frame to the end of theApp's m_pFrameList
  164. void 
  165. WFE_AddNewFrameToFrameList(CGenericFrame * pFrame)
  166. {
  167.  
  168.     //  If the application doesn't have a main frame window yet,
  169.     //      this frame is it.
  170.     if(theApp.m_pFrameList == NULL) {
  171.     theApp.m_pFrameList = pFrame;
  172.     pFrame->m_pNext = NULL;
  173.     }
  174.     //  Otherwise, we need to add this to the list of frame windows
  175.     else {
  176.     CGenericFrame *CMFp = theApp.m_pFrameList;
  177.     
  178.     while(CMFp->m_pNext != NULL) {
  179.         CMFp = CMFp->m_pNext;
  180.     }
  181.     
  182.     //  Our next is NULL.  Set it to the new frame.
  183.     CMFp->m_pNext = pFrame;
  184.     pFrame->m_pNext = NULL;
  185.     
  186.     }
  187.  
  188. }
  189.  
  190.  
  191. CDocument *CGenericDocTemplate::OpenDocumentFile(const char *pszPathName, 
  192.                                                  BOOL bMakeVisible)
  193. {
  194.     //CLM: Save last active frame for InitialUpdateFrame location mangling
  195.     //     We want either browser or editor frame only
  196.     CFrameWnd* pFrameWnd = FEU_GetLastActiveFrame(MWContextBrowser, TRUE);
  197.     if (pFrameWnd && pFrameWnd->IsKindOf(RUNTIME_CLASS(CGenericFrame)))
  198.         wfe_pLastFrame = (CGenericFrame*)pFrameWnd;
  199.     else wfe_pLastFrame = NULL;
  200.     //Don't use restricted target windows to keep them from
  201.     //being used as size and position references.
  202.     if (wfe_pLastFrame && wfe_pLastFrame->GetMainContext() && 
  203.             wfe_pLastFrame->GetMainContext()->GetContext() &&
  204.             wfe_pLastFrame->GetMainContext()->GetContext()->restricted_target)
  205.         wfe_pLastFrame = NULL;
  206.  
  207.     //  Create the document
  208.     CDocument *pDocument = CreateNewDocument();
  209.     if(pDocument == NULL)   {
  210.     return(NULL);
  211.     }
  212.     
  213.     //  Create the frame, several steps
  214.     BOOL bAutoDelete = pDocument->m_bAutoDelete;
  215.     pDocument->m_bAutoDelete = FALSE;   //  don't destroy if something goes wrong
  216.     
  217.     //  We do a nasty manual frame creation technique here.
  218.     //  Don't try this at home, kids.
  219.     CCreateContext CCC;
  220.     CCC.m_pCurrentFrame = NULL; //  nothing to base on
  221.     CCC.m_pCurrentDoc = pDocument;  //  yes, we have doc
  222.     CCC.m_pNewViewClass = m_pViewClass; //  whatever
  223.     CCC.m_pNewDocTemplate = this;   //  we are the template, duh    
  224.     
  225.     CFrameWnd *pFrame = (CFrameWnd *)m_pFrameClass->CreateObject();
  226.     CRuntimeClass* pRunTimeClass = GetRuntimeClass();
  227.  
  228. #ifdef MOZ_MAIL_NEWS
  229.     ASSERT(pRunTimeClass);
  230.     if (!stricmp("CNetscapeComposeTemplate",pRunTimeClass->m_lpszClassName))
  231.           ((CComposeFrame *) pFrame)->SetHtmlMode(TRUE);
  232. #endif /* MOZ_MAIL_NEWS */
  233.     pDocument->m_bAutoDelete = bAutoDelete;
  234.     if(pFrame == NULL)  {
  235.     delete pDocument;   //  explicit delete upon error
  236.     return(NULL);
  237.     }
  238.  
  239.     //Keep dependent windows off of the Win95/NT taskbar
  240. #ifdef WIN32    
  241.     if (m_bDependent)
  242.     ((CGenericFrame*)pFrame)->SetExStyles(WS_EX_TOOLWINDOW, 0);
  243.     if (m_bHideTitlebar || theApp.m_bSuperKioskMode)
  244.     ((CGenericFrame*)pFrame)->SetExStyles(0, WS_EX_CLIENTEDGE);
  245. #endif
  246.     
  247.     if(m_bPopupWindow)
  248.         ((CGenericFrame*)pFrame)->SetAsPopup(m_hPopupParent);
  249.  
  250.     m_bPopupWindow = FALSE;
  251.     m_hPopupParent = NULL;
  252.  
  253.     //  Create the new frame from some resources
  254.     if (m_bHideTitlebar || theApp.m_bSuperKioskMode){    
  255.         // ZZZ: Removed WS_CLIPCHILDREN because it was interfering with the frame
  256.         // gride edge tracking code. Troy
  257.         if(!pFrame->LoadFrame(m_nIDResource, WS_CLIPSIBLINGS |
  258.         WS_OVERLAPPED, NULL, &CCC))   {
  259.             delete pDocument;   //  explicit delete upon error
  260.             return(NULL);
  261.         }   
  262.     }else{
  263.         // ZZZ: Removed WS_CLIPCHILDREN because it was interfering with the frame
  264.         // gride edge tracking code. Troy
  265.  
  266.         if(!pFrame->LoadFrame(m_nIDResource, WS_CLIPSIBLINGS |
  267.         WS_OVERLAPPEDWINDOW, NULL, &CCC))   {
  268.             delete pDocument;   //  explicit delete upon error
  269.             return(NULL);
  270.         }
  271.     }
  272.  
  273.     if(m_bHideTitlebar || theApp.m_bSuperKioskMode) {
  274.     long lStyles = GetWindowLong(pFrame->GetSafeHwnd(), GWL_STYLE); 
  275.     lStyles |= WS_SYSMENU | WS_GROUP | WS_TABSTOP;
  276.     lStyles &= ~WS_CAPTION;
  277.     SetWindowLong(pFrame->GetSafeHwnd(), GWL_STYLE, lStyles);
  278.     }
  279.  
  280.     if(theApp.m_ParentAppWindow) {
  281.     SetParent(pFrame->GetSafeHwnd(), theApp.m_ParentAppWindow);
  282.     theApp.m_bChildWindow = TRUE;
  283.     theApp.m_ParentAppWindow = 0;
  284.     }
  285.  
  286.     //  Here's some hack to get some context information, and activate
  287.     //      a view
  288.     if(pFrame->GetActiveView() == NULL) {
  289.     CView *pView = (CView *)pFrame->
  290.         GetDescendantWindow(AFX_IDW_PANE_FIRST);
  291.     if(pView != NULL && pView->IsKindOf(RUNTIME_CLASS(CView)))  {
  292.         pFrame->SetActiveView(pView);
  293.     }
  294.     }
  295.  
  296.     // add to the global frame list
  297.     if (pFrame->IsKindOf(RUNTIME_CLASS(CGenericFrame))) {
  298.         WFE_AddNewFrameToFrameList((CGenericFrame *) pFrame);
  299.     }
  300.     //  Wether or not to create a new or existing document is determined
  301.     //      via the path name passed in.
  302.     if(pszPathName == NULL) {
  303.     //  Create a new document - with default document name
  304.     UINT nUntitled = m_nUntitledCount + 1;
  305.     
  306.     CString strDocName;
  307.     if(GetDocString(strDocName, CDocTemplate::docName) &&
  308.         !strDocName.IsEmpty())  {
  309.         char szNum[16];
  310.         wsprintf(szNum, "%d", nUntitled);
  311.         strDocName += szNum;
  312.     }
  313.     else    {
  314.         //  use generic 'untitiled' - ignore untitled count
  315.         VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
  316.     }
  317.     pDocument->SetTitle(strDocName);
  318.     
  319.     if(bMakeVisible && !pDocument->OnNewDocument()) {
  320.         //  user has been alerted to what failed in OnNewDocument
  321.         pFrame->DestroyWindow();
  322.         return(NULL);
  323.     }
  324.     
  325.     //  it worked, bump up the untitiled count
  326.     m_nUntitledCount++;
  327.     }
  328.     else    {
  329.     //  Open an existing document
  330.     BeginWaitCursor();
  331.     if(!pDocument->OnOpenDocument(pszPathName)) {
  332.         //  user has been alerted to what failed in OnOpenDocument
  333.         pFrame->DestroyWindow();
  334.         EndWaitCursor();
  335.         return(NULL);
  336.     }
  337.     pDocument->SetPathName(pszPathName);
  338.     EndWaitCursor();
  339.     }
  340.  
  341.     InitialUpdateFrame(pFrame, pDocument, bMakeVisible);
  342.     
  343.     return pDocument;
  344. }
  345.  
  346.  
  347.  
  348.  
  349.  
  350. /////////////////////////////////////////////////////////////////////////////
  351. //  CNetscapeDocTemplate commands
  352. CNetscapeDocTemplate::CNetscapeDocTemplate(UINT nIDResource,
  353.     CRuntimeClass* pDocClass,
  354.     CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
  355.     : CGenericDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
  356. {
  357.     HINSTANCE hInst = AfxGetResourceHandle();
  358.     m_hMenuShared = ::LoadMenu(hInst, MAKEINTRESOURCE(nIDResource));
  359.     m_hAccelTable = ::LoadAccelerators(hInst, MAKEINTRESOURCE(nIDResource));
  360. }
  361.  
  362. // Common stuff for CNetscapeDocTemplate and CNetscapeEditTemplate
  363. void wfe_InitialUpdateFrame(CFrameWnd* pFrame, 
  364.                 CDocument* pDocument, 
  365.                         BOOL bMakeVisible)      
  366. {
  367.     
  368.     WINDOWPLACEMENT wp;
  369.     FEU_InitWINDOWPLACEMENT(pFrame->GetSafeHwnd(), &wp);
  370.  
  371.     BOOL bSetLocation = FALSE;
  372.     int screenX = sysInfo.m_iScreenWidth;
  373.     int screenY = sysInfo.m_iScreenHeight;
  374.     int16 iLeft,iRight,iTop,iBottom;
  375.     PREF_GetRectPref("browser.window_rect", &iLeft, &iTop, &iRight, &iBottom);
  376.  
  377.     if ( wfe_pLastFrame ) {
  378.         bSetLocation = TRUE;
  379.  
  380.         int captionY = ::GetSystemMetrics(SM_CYCAPTION);
  381.         int titleY = ::GetSystemMetrics(SM_CYSIZE) + ::GetSystemMetrics(SM_CYFRAME);
  382.  
  383.         // Get placement and location of last frame
  384.         wfe_pLastFrame->GetWindowPlacement(&wp);
  385.         CRect rectLastFrame = wp.rcNormalPosition;
  386.  
  387.         // Impose lower and upper limits on frame size
  388.         if( rectLastFrame.Width() < 300 ){
  389.             rectLastFrame.right = rectLastFrame.left + 300;
  390.         }
  391.         if( rectLastFrame.Height() < 300 ){
  392.             rectLastFrame.bottom = rectLastFrame.top + 300;
  393.         }
  394.         if( rectLastFrame.Width() > screenX ){
  395.             rectLastFrame.right = rectLastFrame.left + screenX;
  396.         }
  397.         if( rectLastFrame.Height() > screenY ){
  398.             rectLastFrame.bottom = rectLastFrame.top + screenY;
  399.         }
  400.  
  401.         if ( wfe_bUseLastFrameLocation ) {
  402.             // Keep same location and size as last frame
  403.             // Good for just one new window!
  404.             wfe_bUseLastFrameLocation = FALSE;
  405.         } else {
  406.             // Cascade: Start down and to the right of current frame
  407.             wp.rcNormalPosition.left += titleY;
  408.             wp.rcNormalPosition.top  += titleY;
  409.         }
  410.  
  411.         // Set the right and bottom
  412.         wp.rcNormalPosition.right = 
  413.             wp.rcNormalPosition.left + rectLastFrame.Width();
  414.         wp.rcNormalPosition.bottom = 
  415.             wp.rcNormalPosition.top + rectLastFrame.Height();
  416.  
  417.         //  If we go off the screen to the right or to the bottom and
  418.         //    pulling us back to 0,0 would make us fit on the screen then
  419.         //    pull the origin back to 0,0
  420.         //  But only if these coordinates are not the same as those on 
  421.         //    the command line.
  422.         if( wp.rcNormalPosition.right > screenX &&
  423.             rectLastFrame.Width() < screenX     &&
  424.             wp.rcNormalPosition.left != theApp.m_iCmdLnX ) {
  425.  
  426.             wp.rcNormalPosition.left = 0;
  427.             wp.rcNormalPosition.right = rectLastFrame.Width();
  428.         }
  429.  
  430.         if( wp.rcNormalPosition.bottom > screenY &&
  431.             rectLastFrame.Height() < screenY  &&
  432.             wp.rcNormalPosition.top != theApp.m_iCmdLnY ) {
  433.  
  434.             wp.rcNormalPosition.top = 0;
  435.             wp.rcNormalPosition.bottom = rectLastFrame.Height();
  436.         }
  437.             
  438.         // Preserve International character set
  439.         ((CGenericFrame*)pFrame)->m_iCSID = (wfe_pLastFrame)->m_iCSID;
  440.     }
  441.     else if (iLeft != -1) {
  442.         bSetLocation = TRUE;
  443.         int32 prefInt;
  444.         PREF_GetIntPref("browser.wfe.show_value",&prefInt);
  445.         wp.showCmd = CASTINT(prefInt);
  446.  
  447.         if(theApp.m_bInInitInstance)  {
  448.             //  Any frames created while in init instance must use the style passed therein.
  449.             //  See WinExec and how we don't pay attention to it....
  450.             //  We can get away with this only if we weren't told to show up normal.
  451.             if(theApp.m_iFrameCmdShow != SW_SHOWNORMAL) {
  452.             wp.showCmd = theApp.m_iFrameCmdShow;
  453.             }
  454.         }
  455.  
  456.         // We don't have a "last frame" -- probably 1st time through
  457.         // Still do range checking in case junk was saved in preferences
  458.         wp.rcNormalPosition.left = max( 0, min(screenX-300, iLeft) );
  459.         wp.rcNormalPosition.top  = max( 0, min(screenY-300, iTop) );
  460.         wp.rcNormalPosition.right  = max( 300, min(screenX, iRight) );
  461.         wp.rcNormalPosition.bottom = max( 300, min(screenY,  iBottom) );
  462.     }
  463.     else if( iLeft == -1) {
  464.         // Bug 48772. Set window size if never set before
  465.         bSetLocation = TRUE;
  466.         wp.showCmd = SW_SHOWNORMAL;
  467.         wp.rcNormalPosition.left = 0;
  468.         wp.rcNormalPosition.top  = 0;
  469.         wp.rcNormalPosition.right  = min(632, screenX);
  470.         wp.rcNormalPosition.bottom = min(480, screenY);
  471.     }
  472.  
  473.     if ( bSetLocation ) {
  474.         // Use the modified position info for new window,
  475.         //  but set other flags first
  476.         if (wp.showCmd == SW_SHOWMINIMIZED) {
  477.             //  Can't do this conversion without first checking to see what is right and wrong
  478.             //      when paying attention to nCmdShow (winmain).
  479.             if(theApp.m_bInInitInstance == FALSE || theApp.m_iFrameCmdShow == SW_SHOWNORMAL)   {
  480.             wp.showCmd = SW_RESTORE;
  481.             }
  482.         }
  483.  
  484.         //  We're not supposed to make visible, but is it visible (someone already handled up stream).
  485.         if(bMakeVisible == FALSE && pFrame->IsWindowVisible() == FALSE) {
  486.             //      Don't show if told not to.
  487.             //      We do allow placement however, for size saving on close.
  488.             wp.showCmd = SW_HIDE;
  489.         }
  490.     if (theApp.m_bSuperKioskMode)
  491.         wp.showCmd = SW_SHOWMAXIMIZED;
  492.  
  493.         // Note: if last frame was maximized, new frame will be also
  494.         pFrame->SetWindowPlacement(&wp);
  495.     }
  496.  
  497.     if (bMakeVisible && pDocument && pFrame) {
  498.         if (theApp.m_pFrameList == pFrame) {
  499.             switch (theApp.m_nCmdShow) {
  500.             case SW_SHOWMINIMIZED:
  501.             case SW_HIDE:
  502.             case SW_SHOWMINNOACTIVE:
  503.             case SW_MINIMIZE:
  504.                 pFrame->ActivateFrame(theApp.m_nCmdShow);
  505.                 // So InitialUpdateFrame doesn't do this again
  506.                 bMakeVisible = FALSE;
  507.             default:
  508.                 break;
  509.             }
  510.         } else {
  511.             pFrame->ActivateFrame(SW_SHOW);
  512.             bMakeVisible = FALSE;
  513.         }
  514.     }
  515. }
  516.  
  517. void CNetscapeDocTemplate::InitialUpdateFrame(CFrameWnd* pFrame, 
  518.                                               CDocument* pDocument, 
  519.                                               BOOL bMakeVisible)    
  520. {
  521.     // Window positioning code shared by Editor and Browser
  522.     wfe_InitialUpdateFrame( pFrame, pDocument, bMakeVisible );
  523.     //      Call the base.
  524.     CDocTemplate::InitialUpdateFrame(pFrame, pDocument, bMakeVisible);
  525. }
  526.  
  527.  
  528. #ifdef EDITOR
  529. // CLM: Copy of CNetscapeDocTemplate -- used by CNetscapeEditView
  530. // MUST BE MAINTAINED TO MATCH ABOVE FUNCTIONS!
  531. ////////////////////////////////////////////////////////////////////////////////
  532. //  CNetscapeEditTemplate commands
  533. CNetscapeEditTemplate::CNetscapeEditTemplate(UINT nIDResource,
  534.     CRuntimeClass* pDocClass,
  535.     CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
  536.     : CGenericDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
  537. {
  538. }
  539.  
  540. void CNetscapeEditTemplate::InitialUpdateFrame(CFrameWnd *pFrame, 
  541.                                                CDocument *pDocument, 
  542.                                                BOOL bMakeVisible)
  543. {
  544.     // Window positioning code shared by Editor and Browser
  545.     wfe_InitialUpdateFrame( pFrame, pDocument, bMakeVisible );
  546.     //      Call the base.
  547.     CDocTemplate::InitialUpdateFrame(pFrame, pDocument, /*bMakeVisible */ TRUE );
  548. }
  549. #endif // EDITOR
  550.  
  551. #ifdef MOZ_MAIL_NEWS
  552. /////////////////////////////////////////////////////////////////////////////
  553. //  CNetscapeComposeTemplate commands
  554. CNetscapeComposeTemplate::CNetscapeComposeTemplate(UINT nIDResource,
  555.     CRuntimeClass* pDocClass,
  556.     CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
  557.     : CGenericDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
  558. {
  559.     // for the compose window we will use shared menus and accelerators but
  560.     //  we will not actually load them until the first compose window is created
  561. }
  562.  
  563. void CNetscapeComposeTemplate::InitialUpdateFrame(CFrameWnd *pFrame, 
  564.                                                   CDocument *pDocument, 
  565.                                                   BOOL bMakeVisible)    
  566. {
  567.     if (pDocument && pFrame) {
  568.         // tell the frame what type of widgets to create
  569.         ((CComposeFrame *) pFrame)->SetType(MWContextMessageComposition);
  570.  
  571.         // Pass win_csid to ComposeFrame, eventually ComposeEdit will use
  572.         // it to select font
  573.  
  574.         ((CComposeFrame *) pFrame)->SetCSID(win_csid);      
  575.         //  Activate the frame but do not show it until we get a call to 
  576.         //    FE_RaiseMailCompositionWindow() --- this allows us to use
  577.         //    the composition frame as a context to quote messages with and
  578.         //    such before loading exchange without flashing the netscape compose
  579.         //    window up
  580.         pFrame->ActivateFrame(SW_RESTORE);
  581.     }
  582.     CDocTemplate::InitialUpdateFrame(pFrame, pDocument, FALSE);
  583. }
  584.  
  585. /////////////////////////////////////////////////////////////////////////////
  586. //  CNetscapeTextComposeTemplate commands
  587. CNetscapeTextComposeTemplate::CNetscapeTextComposeTemplate(UINT nIDResource,
  588.     CRuntimeClass* pDocClass,
  589.     CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
  590.     : CGenericDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
  591. {
  592.     // for the compose window we will use shared menus and accelerators but
  593.     //  we will not actually load them until the first compose window is created
  594. }
  595.  
  596. void CNetscapeTextComposeTemplate::InitialUpdateFrame(
  597.     CFrameWnd *pFrame, CDocument *pDocument, BOOL bMakeVisible)    
  598. {
  599.     if (pDocument && pFrame) {
  600.         // tell the frame what type of widgets to create
  601.         ((CComposeFrame *) pFrame)->SetType(MWContextMessageComposition);
  602.  
  603.         // Pass win_csid to ComposeFrame, eventually ComposeEdit will use
  604.         // it to select font
  605.  
  606.         ((CComposeFrame *) pFrame)->SetCSID(win_csid);
  607.       
  608.         //  Activate the frame but do not show it until we get a call to 
  609.         //    FE_RaiseMailCompositionWindow() --- this allows us to use
  610.         //    the composition frame as a context to quote messages with and
  611.         //    such before loading exchange without flashing the netscape compose
  612.         //    window up
  613.         if(bMakeVisible)// SW_RESTORE i.e. show frame only if bMakeVisible. 
  614.             pFrame->ActivateFrame(SW_RESTORE);
  615.     }
  616.     CDocTemplate::InitialUpdateFrame(pFrame, pDocument, FALSE);
  617. }
  618.  
  619.  
  620.  
  621. /////////////////////////////////////////////////////////////////////////////
  622. //  CNetscapeAddrTemplate commands
  623. CNetscapeAddrTemplate::CNetscapeAddrTemplate(UINT nIDResource,
  624.     CRuntimeClass* pDocClass,
  625.     CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass)
  626.     : CGenericDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
  627. {
  628. }
  629.  
  630. void CNetscapeAddrTemplate::InitialUpdateFrame(CFrameWnd *pFrame, 
  631.                                                CDocument *pDocument, 
  632.                                                BOOL bMakeVisible)    
  633. {
  634.     if (pDocument && pFrame) {
  635.          //  Show it 
  636.         int16 iLeft,iRight,iTop,iBottom;
  637.         PREF_GetRectPref("mail.addr_book_window_rect", &iLeft, &iTop, &iRight, &iBottom);
  638.         if (iLeft != -1) {
  639.             int32 showCmd; // = *theApp.m_pAddrShow;
  640.             PREF_GetIntPref("mail.wfe.addr_book.show_value",&showCmd);
  641.  
  642.             if (showCmd == SW_SHOWMINIMIZED)
  643.                 showCmd = SW_RESTORE;
  644.             pFrame->ActivateFrame(CASTINT(showCmd));
  645.         }
  646.     }    
  647.     CDocTemplate::InitialUpdateFrame(pFrame, pDocument, bMakeVisible);
  648. }
  649.  
  650. #endif // MOZ_MAIL_NEWS
  651.