Update of /cvsroot/audacity/audacity-src/src/widgets
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv17596/widgets

Modified Files:
        ProgressDialog.cpp ProgressDialog.h 
Log Message:
TimerProgressDialog, new subclass of ProgressDialog, for progress that's just a 
countdown timer. Fixes problem of progress estimates sometimes causing 
remaining time calculation to go backward in TimerRecordDialog.

Index: ProgressDialog.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/ProgressDialog.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ProgressDialog.cpp  8 Mar 2009 05:17:06 -0000       1.17
+++ ProgressDialog.cpp  8 Jun 2009 08:01:25 -0000       1.18
@@ -3,8 +3,15 @@
   Audacity: A Digital Audio Editor
 
   ProgressDialog.cpp
+
+  Copyright
+     Leland Lucius
+     Vaughan Johnson
   
-  Leland Lucius
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
 
 *******************************************************************//**
 
@@ -1375,6 +1382,56 @@
    }
 }
 
+TimerProgressDialog::TimerProgressDialog(const wxLongLong_t duration, 
+                                          const wxString & title, 
+                                          const wxString & message /*= 
wxEmptyString*/, 
+                                          ProgressDialogFlags flags /*= 
pdlgEmptyFlags*/)
+: ProgressDialog(title, message, flags)
+{
+   mDuration = duration;
+}
+
+int TimerProgressDialog::Update(const wxString & message /*= wxEmptyString*/)
+{
+   if (mCancel)
+   {
+      // for compatibility with old Update, that returned false on cancel
+      return eProgressCancelled; 
+   }
+   else if (mStop)
+   {
+      return eProgressStopped;
+   }
+
+   SetMessage(message);
+
+   wxLongLong_t now = wxGetLocalTimeMillis().GetValue();
+   wxLongLong_t elapsed = now - mStartTime;
+   wxLongLong_t remains = mStartTime + mDuration - now;
+
+   if (!IsShown() && elapsed > 500)
+   {
+      Show(true);
+   }
+
+   // Only update if a full second has passed.
+   if (now - mLastUpdate > 1000)
+   {
+      wxTimeSpan tsElapsed(0, 0, 0, elapsed);
+      wxTimeSpan tsRemains(0, 0, 0, remains);
+
+      mElapsed->SetLabel(tsElapsed.Format(wxT("%H:%M:%S")));
+      mRemaining->SetLabel(tsRemains.Format(wxT("%H:%M:%S")));
+
+      mLastUpdate = now;
+   }
+
+   wxYieldIfNeeded();
+
+   return eProgressSuccess;
+}
+
+
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a
 // version control system. Please do not modify past this point.
 //

Index: ProgressDialog.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/ProgressDialog.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ProgressDialog.h    6 Feb 2009 18:45:28 -0000       1.10
+++ ProgressDialog.h    8 Jun 2009 08:01:25 -0000       1.11
@@ -3,8 +3,15 @@
   Audacity: A Digital Audio Editor
 
   ProgressDialog.h
+
+  Copyright
+     Leland Lucius
+     Vaughan Johnson
   
-  Leland Lucius
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
 
 *************************************************************************/
 
@@ -62,25 +69,41 @@
    void OnStop(wxCommandEvent & e);
    void Beep();
 
- private:
-   wxWindow *mHadFocus;
-   wxGauge *mGauge;
-   wxStaticText *mMessage;
+ protected:
    wxStaticText *mElapsed;
    wxStaticText *mRemaining;
-   wxWindowDisabler *mDisable;
 
    wxLongLong_t mStartTime;
-   wxLongLong_t mLastTime;
    wxLongLong_t mLastUpdate;
-   int mLastValue;
 
    bool mCancel;
    bool mStop;
+
+ private:
+   wxWindow *mHadFocus;
+   wxGauge *mGauge;
+   wxStaticText *mMessage;
+   wxWindowDisabler *mDisable;
+
+   int mLastValue;
+
    
    DECLARE_EVENT_TABLE();
 };
 
+class AUDACITY_DLL_API TimerProgressDialog : public ProgressDialog
+{
+ public:
+   TimerProgressDialog(const wxLongLong_t duration, 
+                        const wxString & title, 
+                        const wxString & message = wxEmptyString, 
+                        ProgressDialogFlags flags = pdlgEmptyFlags);
+   int Update(const wxString & message = wxEmptyString);
+
+ protected:
+   wxLongLong_t mDuration;
+};
+
 #endif
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to