home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / dlgdwnld.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.2 KB  |  259 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. // dlgdwnld.cpp : implementation file
  20. //
  21. #include "stdafx.h"
  22. #include "dlgdwnld.h"
  23. #include "dlgseldg.h"
  24. #include "mailpriv.h"
  25. #include "wfemsg.h"
  26. #include "prefapi.h"
  27. #include "nethelp.h"
  28. #include "xp_help.h"
  29.  
  30. #ifdef _DEBUG
  31. #define new DEBUG_NEW
  32. #undef THIS_FILE
  33. static char THIS_FILE[] = __FILE__;
  34. #endif
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CDownLoadDlg dialog
  38.  
  39.  
  40. CDownLoadDlg::CDownLoadDlg(CWnd* pParent /*=NULL*/)
  41.     : CDialog(CDownLoadDlg::IDD, pParent)
  42. {
  43.     XP_Bool bDiscussions = 0;
  44.     XP_Bool bMail = 0;
  45.     XP_Bool bMessages = 0;
  46.  
  47.     PREF_GetBoolPref("offline.download_discussions",&bDiscussions);
  48.     PREF_GetBoolPref("offline.download_mail",&bMail);
  49.     PREF_GetBoolPref("offline.download_messages",&bMessages);
  50.  
  51.     //{{AFX_DATA_INIT(CDownLoadDlg)
  52.     m_bDownLoadDiscusions = bDiscussions;
  53.     m_bDownLoadMail = bMail;
  54.     m_bSendMessages = bMessages;
  55.     //}}AFX_DATA_INIT
  56.     m_bMode = NET_IsOffline();
  57. }
  58.  
  59. void CDownLoadDlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61.     CDialog::DoDataExchange(pDX);
  62.     //{{AFX_DATA_MAP(CDownLoadDlg)
  63.     DDX_Check(pDX, IDC_CHECK_DOWNLOAD_DISC, m_bDownLoadDiscusions);
  64.     DDX_Check(pDX, IDC_CHECK_DOWNLOAD_MAIL, m_bDownLoadMail);
  65.     DDX_Check(pDX, IDC_CHECK_SEND_MESSAGES, m_bSendMessages);
  66.     //}}AFX_DATA_MAP
  67. }
  68.  
  69.  
  70. BEGIN_MESSAGE_MAP(CDownLoadDlg, CDialog)
  71.     //{{AFX_MSG_MAP(CDownLoadDlg)
  72.     ON_BN_CLICKED(IDC_BUTTON_SELECT, OnButtonSelect)
  73.     ON_BN_CLICKED(IDC_HELP_GO_OFFLINE, OnHelp)
  74.     ON_WM_PAINT()
  75.     //}}AFX_MSG_MAP
  76. END_MESSAGE_MAP()
  77.  
  78. /////////////////////////////////////////////////////////////////////////////
  79. // CDownLoadDlg message handlers
  80.  
  81. void CDownLoadDlg::OnButtonSelect() 
  82. {
  83.     CDlgSelectGroups dlgSelectGroups(this);
  84.     dlgSelectGroups.DoModal();
  85.     CWnd *pWnd = GetDlgItem(IDC_TEXT_DISCUSSIONS_SELECTED);
  86.     CString strCountText;
  87.     CString strTemp;
  88.  
  89.     if (pWnd)
  90.     {
  91.         strTemp.LoadString(IDS_TEXT_DISCUSSIONS_SELECTED);
  92.         char buf[20];
  93.         strCountText = itoa(dlgSelectGroups.GetSelectionCount(),buf,10) + (CString)" "+ strTemp;
  94.         pWnd->SetWindowText(strCountText);    
  95.     }
  96.     
  97.     pWnd = GetDlgItem(IDC_TEXT_FOLDERS_SELECTED);
  98.     if (pWnd)
  99.     {
  100.         strTemp.LoadString(IDS_TEXT_FOLDERS_SELECTED);
  101.         char buf[20];
  102.         strCountText = itoa(dlgSelectGroups.GetMailSelectionCount(),buf,10) + (CString)" "+ strTemp;
  103.         pWnd->SetWindowText(strCountText);    
  104.     }
  105. }
  106.  
  107. void CDownLoadDlg::ShutDownFrameCallBack(HWND hwnd, MSG_Pane *pane, void * closure)
  108. {
  109.     if (::IsWindow(hwnd)) {
  110.         ::ShowWindow(hwnd,SW_SHOW);
  111.         ::UpdateWindow(hwnd);
  112.     }
  113.  
  114.     if (pane)
  115.     {
  116.         CDownLoadDlg *downloadDlg = (CDownLoadDlg *) closure;
  117.         MSG_GoOffline(WFE_MSGGetMaster(), pane, downloadDlg->m_bDownLoadDiscusions, downloadDlg->m_bDownLoadMail,
  118.             downloadDlg->m_bSendMessages);
  119.     }
  120. }
  121.  
  122. void CDownLoadDlg::OnOK() 
  123. {
  124.     // TODO: Add extra validation here
  125.     UpdateData();
  126.  
  127.     if ((m_bDownLoadDiscusions || m_bDownLoadMail || m_bSendMessages))
  128.     {
  129.           new CProgressDialog(NULL, NULL,ShutDownFrameCallBack,
  130.             this,szLoadString(IDS_DOWNLOADINGARTICLES));    // need correct window title
  131.             ;//DownLoad!!!!!!!
  132.  
  133.     }
  134.     else
  135.         PREF_SetBoolPref("network.online", m_bMode);
  136.  
  137.  
  138.     PREF_SetBoolPref("offline.download_discussions",(XP_Bool)m_bDownLoadDiscusions);
  139.     PREF_SetBoolPref("offline.download_mail",(XP_Bool)m_bDownLoadMail);
  140.     PREF_SetBoolPref("offline.download_messages",(XP_Bool)m_bSendMessages);
  141.  
  142.  
  143.     CDialog::OnOK();
  144. }
  145.  
  146. void CDownLoadDlg::OnHelp()
  147. {
  148.     NetHelp(HELP_OFFLINE_DOWNLOAD);
  149. }
  150.  
  151. void CDownLoadDlg::OnPaint() 
  152. {
  153.     CPaintDC dc(this); // device context for painting
  154.     CBitmap *poldbmp,*poldbmp2,*poldbmp3;
  155.     CBitmap m_bmp1,m_bmp2,m_bmp3;
  156.     CDC m_memdc,m_memdc2,m_memdc3;
  157.     CWnd *pWnd = NULL;
  158.     CRect rect(0,0,0,0);
  159.  
  160.     
  161.     //---------------------------------------------------
  162.     //BITMAP #1
  163.     pWnd = GetDlgItem(IDC_CHECK_DOWNLOAD_MAIL);
  164.     if (pWnd)
  165.     {
  166.         pWnd->GetWindowRect(&rect);
  167.         ScreenToClient(&rect);
  168.     }
  169.     // Load the bitmap resources
  170.     m_bmp1.LoadBitmap( IDB_MAIL );
  171.     // Create a compatible memory DC
  172.     m_memdc.CreateCompatibleDC( &dc );
  173.     // Select the bitmap into the DC
  174.     poldbmp = m_memdc.SelectObject( &m_bmp1 );
  175.     // Copy (BitBlt) bitmap from memory DC to screen DC
  176.     dc.BitBlt( rect.left -28 ,rect.top, 18, 17, &m_memdc, 0, 0, SRCCOPY );
  177.     m_memdc.SelectObject( poldbmp );
  178.  
  179.     //---------------------------------------------------
  180.     //BITMAP #2
  181.     pWnd = GetDlgItem(IDC_CHECK_DOWNLOAD_DISC);
  182.     if (pWnd)
  183.     {
  184.         pWnd->GetWindowRect(&rect);
  185.         ScreenToClient(&rect);
  186.     }
  187.  
  188.     m_bmp2.LoadBitmap( IDB_DISCUSSIONS_1 );
  189.     // Create a compatible memory DC
  190.     m_memdc2.CreateCompatibleDC( &dc );
  191.     // Select the bitmap into the DC
  192.     poldbmp2 = m_memdc2.SelectObject( &m_bmp2 );
  193.     // Copy (BitBlt) bitmap from memory DC to screen DC
  194.     dc.BitBlt( rect.left -28, rect.top, 17, 16, &m_memdc2, 0, 0, SRCCOPY );
  195.     m_memdc2.SelectObject( poldbmp2 );
  196.  
  197.     //---------------------------------------------------
  198.     //BITMAP #3
  199.     pWnd = GetDlgItem(IDC_CHECK_SEND_MESSAGES);
  200.     if (pWnd)
  201.     {
  202.         pWnd->GetWindowRect(&rect);
  203.         ScreenToClient(&rect);
  204.     }
  205.     m_bmp3.LoadBitmap( IDB_MESSAGE );
  206.     // Create a compatible memory DC
  207.     m_memdc3.CreateCompatibleDC( &dc );
  208.     // Select the bitmap into the DC
  209.     poldbmp3 = m_memdc3.SelectObject( &m_bmp3 );
  210.     // Copy (BitBlt) bitmap from memory DC to screen DC
  211.     dc.BitBlt( rect.left -28, rect.top, 19, 14, &m_memdc3, 0, 0, SRCCOPY );
  212.     m_memdc3.SelectObject( poldbmp3 );
  213. }
  214.  
  215.  
  216. BOOL CDownLoadDlg::OnInitDialog() 
  217. {
  218.     CDialog::OnInitDialog();
  219.  
  220.     CWnd *pWnd1 = GetDlgItem(IDC_TEXT_ACTION);
  221.     CWnd *pWnd2 = GetDlgItem(IDC_TEXT_ACTION2);
  222.     CWnd *pWnd3 = GetDlgItem(IDOK);
  223.     if (!pWnd1 || !pWnd2 || !pWnd3)
  224.         return FALSE;
  225.  
  226.     CString strText;
  227.     if (m_bMode)
  228.     {   //We are going Online!!
  229.         strText.LoadString(IDS_GO_ONLINE_NOW);
  230.         pWnd1->SetWindowText(strText);
  231.         strText.LoadString(IDS_ACTION_ONLINE);
  232.         pWnd2->SetWindowText(strText);
  233.         strText.LoadString(IDS_BUTTON_TEXT_CONNECT);
  234.         pWnd3->SetWindowText(strText);
  235.         
  236.     }
  237.     else
  238.     {   //We are going Offline!!
  239.         strText.LoadString(IDS_GO_OFFLINE_NOW);
  240.         pWnd1->SetWindowText(strText);
  241.         strText.LoadString(IDS_ACTION_OFFLINE);
  242.         pWnd2->SetWindowText(strText);
  243.         strText.LoadString(IDS_BUTTON_TEXT_DISCONNECT);
  244.         pWnd3->SetWindowText(strText);        
  245.     }
  246.  
  247.     HFONT hFont = (HFONT)this->SendMessage(WM_GETFONT);
  248.     if (hFont != NULL)
  249.     {   //make the title bold
  250.         VERIFY(::GetObject(hFont, sizeof(LOGFONT), &m_LogFont));
  251.         m_LogFont.lfWeight=FW_BOLD;
  252.         m_Font.CreateFontIndirect(&m_LogFont);
  253.         pWnd1->SetFont(&m_Font);
  254.     }
  255.  
  256.     return TRUE;  // return TRUE unless you set the focus to a control
  257. }
  258.  
  259.