Full support to the native progress dialog.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31218 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba 2005-01-03 07:08:17 +00:00
parent 974c2a5904
commit 7d81eb8cee
3 changed files with 38 additions and 37 deletions

View File

@ -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(); }

View File

@ -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

View File

@ -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