From 7d81eb8cee209240b37421ae4f7dfe7a3f07a4fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Mon, 3 Jan 2005 07:08:17 +0000 Subject: [PATCH] Full support to the native progress dialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/palmos/progdlg.h | 7 ++-- include/wx/palmos/setup0.h | 2 +- src/palmos/progdlg.cpp | 66 +++++++++++++++++++------------------ 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/include/wx/palmos/progdlg.h b/include/wx/palmos/progdlg.h index 8381b44bcf..7e9e4fd746 100644 --- a/include/wx/palmos/progdlg.h +++ b/include/wx/palmos/progdlg.h @@ -37,16 +37,15 @@ public: void Resume(); virtual bool Show( bool show = true ); - wxString GetMessage(){return m_msg;} - void SetMessage(wxString const &message){m_msg = message;} + Boolean Callback(PrgCallbackData *data); - int GetMaxValue(){return m_max;} - int GetCurValue(){return m_cur;} private: ProgressType *m_prgFrame; wxString m_msg; int m_max,m_cur; + bool m_canSkip; + bool m_activeSkip; // Virtual function hiding supression virtual void Update() { wxDialog::Update(); } diff --git a/include/wx/palmos/setup0.h b/include/wx/palmos/setup0.h index 5718b61ca1..306b1cd17d 100644 --- a/include/wx/palmos/setup0.h +++ b/include/wx/palmos/setup0.h @@ -746,7 +746,7 @@ #define wxUSE_MSGDLG 1 // progress dialog class for lengthy operations -#define wxUSE_PROGRESSDLG 0 +#define wxUSE_PROGRESSDLG 1 // support for startup tips (wxShowTip &c) #define wxUSE_STARTUP_TIPS 0 diff --git a/src/palmos/progdlg.cpp b/src/palmos/progdlg.cpp index 29da0fa77d..9641659886 100644 --- a/src/palmos/progdlg.cpp +++ b/src/palmos/progdlg.cpp @@ -26,10 +26,6 @@ #if wxUSE_PROGRESSDLG -//**************** -//* NEEDS DEBUGING -//**************** - #include "wx/progdlg.h" #include "wx/msgdlg.h" @@ -45,29 +41,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 +53,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); } @@ -100,10 +75,25 @@ 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; + + do + { + EvtGetEvent(&event, 0); + Boolean handled = PrgHandleEvent(m_prgFrame, &event); + if (!PrgHandleEvent(m_prgFrame, &event)) + if( PrgUserCancel(m_prgFrame) ) + return false; + } + while(event.eType != sysEventNilEvent); + + PrgUpdateDialog(m_prgFrame, 0, 0, "", true); + + m_activeSkip = m_canSkip && true; + return true; } @@ -116,4 +106,16 @@ bool wxProgressDialog::Show(bool show) return false; } +Boolean wxProgressDialog::Callback(PrgCallbackData *data) +{ + strncpy( data->textP, m_msg.ToAscii() , data->textLen - 1 ); + data->textChanged = true; + data->displaySkipBtn = m_canSkip; + data->barMaxValue = (uint32_t)m_max; + data->barCurValue = (uint32_t)m_cur; + data->delay = (m_max == m_cur); + + return true; +} + #endif // wxUSE_PROGRESSDLG -- 2.45.2