home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / progress / src / pw_win.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.1 KB  |  157 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. /* pw_win.cpp
  19.  * Windows implementation of progress interface
  20.  */
  21.  
  22. #ifdef _WINDOWS
  23. #include "tooltip.h"
  24. #include <afxwin.h>
  25. #include "resource.h"
  26. #include "pw_public.h"
  27. #include "pw_win.h"
  28. #include "winli.h"
  29. #include "cast.h"
  30.  
  31. pw_ptr PW_Create( MWContext * parent,         /* Parent window, can be NULL */
  32.                 PW_WindowType type            /* What kind of window ? Modality, etc */
  33.                 )
  34. {
  35.     CXPProgressDialog * dlg;    
  36.            
  37.     dlg = new CXPProgressDialog();
  38.  
  39. #ifndef XP_WIN16
  40.     /* REMIND: need to fix for win16 */
  41.     if (dlg) dlg->Create(IDD_XPPROGRESS,NULL);
  42. #endif
  43.  
  44.     return dlg;
  45. }
  46.  
  47. void PW_SetCancelCallback(pw_ptr pw,
  48.                             PW_CancelCallback cancelcb,
  49.                             void * cancelClosure)
  50. {}
  51.  
  52.  
  53. void PW_Show(pw_ptr pw)
  54. {
  55.     CXPProgressDialog * dlg;
  56.  
  57.     if (pw) {
  58.         dlg = (CXPProgressDialog *)pw;
  59.  
  60.         dlg->ShowWindow(SW_SHOW);
  61.     }
  62. }
  63.  
  64. void PW_Hide(pw_ptr pw)
  65. {
  66.     CXPProgressDialog * dlg;
  67.  
  68.     if (pw) {
  69.         dlg = (CXPProgressDialog *)pw;
  70.  
  71.         dlg->ShowWindow(SW_HIDE);
  72.     }
  73. }
  74.  
  75. void PW_Destroy(pw_ptr pw)
  76. {
  77.     CXPProgressDialog * dlg;
  78.  
  79.     if (pw) {
  80.         dlg = (CXPProgressDialog *)pw;
  81.  
  82.         dlg->DestroyWindow();
  83.     }
  84. }
  85.  
  86. void PW_SetWindowTitle(pw_ptr pw, const char * title)
  87. {
  88.     CXPProgressDialog * dlg;
  89.  
  90.     if (pw) {
  91.         dlg = (CXPProgressDialog *)pw;
  92.  
  93.         dlg->SetWindowText(title);
  94.     }
  95. }
  96.  
  97. void PW_SetLine1(pw_ptr pw, const char * text)
  98. {
  99.     CXPProgressDialog * dlg;
  100.  
  101.     if (pw) {
  102.         dlg = (CXPProgressDialog *)pw;
  103.  
  104.         dlg->GetDlgItem(IDC_LINE1)->SetWindowText(text);
  105.     }
  106.  
  107. }
  108.  
  109. void PW_SetLine2(pw_ptr pw, const char * text)
  110. {
  111.     CXPProgressDialog * dlg;
  112.  
  113.     if (pw) {
  114.         dlg = (CXPProgressDialog *)pw;
  115.  
  116.         dlg->GetDlgItem(IDC_LINE2)->SetWindowText(text);
  117.     }
  118. }
  119.  
  120. void PW_SetProgressText(pw_ptr pw, const char * text)
  121. {
  122.     CXPProgressDialog * dlg;
  123.  
  124.     if (pw) dlg = (CXPProgressDialog *)pw;
  125. }
  126.  
  127. void PW_SetProgressRange(pw_ptr pw, int32 minimum, int32 maximum)
  128. {
  129.     CXPProgressDialog * dlg;
  130.  
  131.     if (pw) {
  132.         dlg = (CXPProgressDialog *)pw;
  133.  
  134.         dlg->m_Min = minimum;
  135.         dlg->m_Max = maximum;
  136.         dlg->m_Range = 100;
  137.     }
  138. }
  139.  
  140. void PW_SetProgressValue(pw_ptr pw, int32 value)
  141. {
  142.     CXPProgressDialog * dlg;
  143.  
  144.     if (pw) {
  145.         dlg = (CXPProgressDialog *)pw;
  146.  
  147. //        dlg->m_ProgressMeter.StepItTo(CASTINT((value*100)/dlg->m_Range));
  148.  
  149. //        char szPercent[10];
  150. //        PR_snprintf(szPercent,sizeof(szPercent),"%ld%%",(value*100)/dlg->m_Range);
  151. //        dlg->m_PercentComplete.SetWindowText(szPercent);
  152.     }
  153. }
  154.  
  155. #endif 
  156.  
  157.