home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / CSaveProgress.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  3.5 KB  |  126 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 "CSaveProgress.h"
  20. #include "fe_proto.h"
  21. #include "CBrowserContext.h"
  22. #include "resgui.h"    // needed for EDITDLG_SAVE_PROGRESS
  23. #include "uapp.h"
  24. #include "edt.h"
  25. #include "PascalString.h"    // CStr255
  26. #include "proto.h"            // XP_InterruptContext
  27. #include "macutil.h"        // TrySetCursor
  28.  
  29.  
  30. #pragma mark CSaveProgress
  31. void CSaveProgress::FinishCreateSelf()
  32. {
  33.     fFilenameText = (LCaption*)this->FindPaneByID( 'flnm' );
  34.     LDialogBox::FinishCreateSelf();
  35. }
  36.  
  37.  
  38. void CSaveProgress::SetFilename(char *pFileName)
  39. {
  40.     if ( fFilenameText && pFileName )
  41.         fFilenameText->SetDescriptor( CStr255(pFileName) );
  42. }
  43.  
  44.  
  45. void CSaveProgress::ListenToMessage( MessageT inMessage, void* ioParam )
  46. {
  47.     switch ( inMessage )
  48.     {
  49.         case msg_Cancel:
  50.             if ( fContext )
  51.             {
  52.                 TrySetCursor( watchCursor );
  53.             
  54. #ifdef EDITOR
  55.                 if ( EDT_IS_EDITOR( fContext ) )
  56.                     EDT_SaveCancel( fContext );
  57.                 else
  58. #endif // EDITOR
  59.                     XP_InterruptContext( fContext );
  60.                 
  61.                 SetCursor( &qd.arrow );
  62.             }
  63.             break;
  64.         
  65.         default:
  66.             LDialogBox::ListenToMessage( inMessage, ioParam );
  67.         break;
  68.     }
  69. }
  70.  
  71.  
  72. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  73. //
  74. #pragma mark --- FTP Upload Dialog ---
  75. //
  76. // ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
  77. // FIX ME -- find way to use new CDownloadProgressWindow
  78. // Most likely, we'll duplicate the code from downloading
  79.  
  80.  
  81. void FE_SaveDialogCreate( MWContext *pContext, int /*iFileCount*/, ED_SaveDialogType /*saveType*/ )
  82. {
  83.     try {
  84.         CSaveProgress * newWindow = (CSaveProgress*)LWindow::CreateWindow( 
  85.                                     EDITDLG_SAVE_PROGRESS, CFrontApp::GetApplication());
  86.         if ( newWindow == NULL )
  87.             return;
  88.         
  89.         UReanimator::LinkListenerToControls( newWindow, newWindow, EDITDLG_SAVE_PROGRESS );
  90.         
  91.         newWindow->SetContext( pContext );
  92.         ExtractBrowserContext(pContext)->SetSaveDialog( newWindow );
  93.  
  94.         newWindow->Show();
  95.     }
  96.     
  97.     catch (...)
  98.     {
  99.         ExtractBrowserContext(pContext)->SetSaveDialog( NULL );
  100.     }
  101. }
  102.  
  103. #ifdef EDITOR
  104. void FE_SaveDialogSetFilename( MWContext *pContext, char *pFilename )
  105. {
  106.     char *better = FE_URLToLocalName( pFilename );
  107.     if ( better )
  108.     {
  109.         if ( pContext && ExtractBrowserContext(pContext) && ExtractBrowserContext(pContext)->GetSaveDialog() )
  110.             ExtractBrowserContext(pContext)->GetSaveDialog()->SetFilename( better );    
  111.         
  112.         XP_FREE( better );
  113.     }
  114. }
  115. #endif // EDITOR
  116.  
  117. void FE_SaveDialogDestroy( MWContext *pContext, int /*status*/, char */*pFilename*/ )
  118. {
  119.     if ( pContext && ExtractBrowserContext(pContext) && ExtractBrowserContext(pContext)->GetSaveDialog() ) 
  120.     {
  121.         ExtractBrowserContext(pContext)->GetSaveDialog()->ListenToMessage( cmd_Close, NULL );
  122.         ExtractBrowserContext(pContext)->SetSaveDialog( NULL );
  123.     }
  124. }
  125.  
  126.