]> git.saurik.com Git - wxWidgets.git/blobdiff - src/palmos/progdlg.cpp
Rebake for new tar streams.
[wxWidgets.git] / src / palmos / progdlg.cpp
index 29da0fa77da3758ffa786ea4bcf07f9e60b7cc68..f2432a5450eebc8333806381082da75089f98397 100644 (file)
@@ -9,29 +9,24 @@
 // License:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "progdlg.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
+#if wxUSE_PROGRESSDLG
+
+#include "wx/progdlg.h"
+
 #ifndef WX_PRECOMP
     #include  "wx/string.h"
+    #include "wx/msgdlg.h"
 #endif //WX_PRECOMP
 
-#if wxUSE_PROGRESSDLG
-
-//****************
-//* NEEDS DEBUGING
-//****************
-
-#include "wx/progdlg.h"
-#include "wx/msgdlg.h"
+#include <Progress.h>
+#include <SysEvtMgr.h>
 
 IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
 
@@ -45,29 +40,7 @@ static Boolean wxProgressCallback(PrgCallbackData *data)
     if(!dialog)
         return false;
 
-//    /* uint16_t */  data->bitmapId = 0;
-//    /* DmOpenRef */ data->bitmapDatabase = 0;
-    /* char * */    data->textP = "test";
-//    /* status_t */  data->error;
-//    /* uint16_t */  data->canceled;
-    /* uint16_t */  data->textChanged = false;
-    /* uint16_t */  data->displaySkipBtn = true;
-//    /* uint16_t */  data->skipped:1;
-//    /* uint32_t */  data->timeout;
-    /* uint32_t */  data->barMaxValue = (uint32_t)dialog->GetMaxValue();
-    /* uint32_t */  data->barCurValue = (uint32_t)dialog->GetCurValue();
-    /* uint16_t */  data->delay = false ;
-
-    /* NOT USED
-    data->spareBits1:10;
-    data->padding1;
-    data->padding2;
-    data->barMessage;
-    data->barFlags;
-    data->spareBits2:15;
-    */
-
-    return true;
+    return dialog->Callback(data);
 }
 
 wxProgressDialog::wxProgressDialog(const wxString &title,
@@ -79,10 +52,11 @@ wxProgressDialog::wxProgressDialog(const wxString &title,
                   m_prgFrame(NULL),
                   m_msg(message),
                   m_cur(0),
-                  m_max(maximum)
+                  m_max(maximum),
+                  m_canSkip((style & wxPD_CAN_SKIP )==wxPD_CAN_SKIP)
 {
     wxString prgTitle = title.Mid(0, progressMaxTitle);
-    
+
     m_prgFrame = PrgStartDialog(prgTitle.ToAscii(), wxProgressCallback, this);
 }
 
@@ -90,7 +64,7 @@ wxProgressDialog::~wxProgressDialog()
 {
     if(m_prgFrame)
     {
-        PrgStopDialog(m_prgFrame, false);
+        PrgStopDialog((ProgressType *)m_prgFrame, false);
         m_prgFrame = NULL;
     }
 }
@@ -100,10 +74,26 @@ bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
     if(!m_prgFrame)
         return false;
     if(!newmsg.empty())
-        SetMessage(newmsg);
+        m_msg = newmsg;
     m_cur = value;
-    // PrgUpdateDialog crashes, needs debugging
-    // PrgUpdateDialog(m_prgFrame, 0, 1, newmsg.ToAscii(), true);
+
+    EventType event;
+
+    ProgressType *prg = (ProgressType *)m_prgFrame;
+    do
+    {
+        EvtGetEvent(&event, 0);
+        Boolean handled = PrgHandleEvent(prg, &event);
+        if (!PrgHandleEvent(prg, &event))
+            if( PrgUserCancel(prg) )
+                return false;
+    }
+    while(event.eType != sysEventNilEvent);
+
+    PrgUpdateDialog(prg, 0, 0, "", true);
+
+    m_activeSkip = m_canSkip && true;
+
     return true;
 }
 
@@ -116,4 +106,17 @@ bool wxProgressDialog::Show(bool show)
     return false;
 }
 
+Boolean wxProgressDialog::Callback(void *data)
+{
+    PrgCallbackData *palmData = (PrgCallbackData *)data;
+    strncpy( palmData->textP, m_msg.ToAscii() , palmData->textLen - 1 );
+    palmData->textChanged = true;
+    palmData->displaySkipBtn = m_canSkip;
+    palmData->barMaxValue = (uint32_t)m_max;
+    palmData->barCurValue = (uint32_t)m_cur;
+    palmData->delay = (m_max == m_cur);
+
+    return true;
+}
+
 #endif // wxUSE_PROGRESSDLG