]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/progdlg.cpp
document On{Open,Save}Document()
[wxWidgets.git] / src / palmos / progdlg.cpp
CommitLineData
555f645a
WS
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/palmos/progdlg.cpp
3// Purpose: wxProgressDialog implementation
4// Author: Wlodzimierz ABX Skiba
5// Modified by:
6// Created: 29.12.2004
7// RCS-ID: $Id$
8// Copyright: (c) Wlodzimierz Skiba
9// License: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
555f645a
WS
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
246c5004 16 #pragma hdrstop
555f645a
WS
17#endif
18
555f645a
WS
19#if wxUSE_PROGRESSDLG
20
555f645a 21#include "wx/progdlg.h"
246c5004
WS
22
23#ifndef WX_PRECOMP
24 #include "wx/string.h"
25 #include "wx/msgdlg.h"
26#endif //WX_PRECOMP
555f645a 27
20bc5ad8
WS
28#include <Progress.h>
29#include <SysEvtMgr.h>
30
555f645a
WS
31IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
32
33static Boolean wxProgressCallback(PrgCallbackData *data)
34{
35 if(!data)
36 return false;
37
38 wxProgressDialog *dialog = (wxProgressDialog *)data->userDataP;
39
40 if(!dialog)
41 return false;
42
7d81eb8c 43 return dialog->Callback(data);
555f645a
WS
44}
45
46wxProgressDialog::wxProgressDialog(const wxString &title,
47 wxString const &message,
48 int maximum,
49 wxWindow *parent,
50 int style)
51 :wxDialog(parent, wxID_ANY, title),
52 m_prgFrame(NULL),
53 m_msg(message),
54 m_cur(0),
7d81eb8c
WS
55 m_max(maximum),
56 m_canSkip((style & wxPD_CAN_SKIP )==wxPD_CAN_SKIP)
555f645a
WS
57{
58 wxString prgTitle = title.Mid(0, progressMaxTitle);
7d81eb8c 59
555f645a
WS
60 m_prgFrame = PrgStartDialog(prgTitle.ToAscii(), wxProgressCallback, this);
61}
62
63wxProgressDialog::~wxProgressDialog()
64{
65 if(m_prgFrame)
66 {
20bc5ad8 67 PrgStopDialog((ProgressType *)m_prgFrame, false);
555f645a
WS
68 m_prgFrame = NULL;
69 }
70}
71
72bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
73{
74 if(!m_prgFrame)
75 return false;
76 if(!newmsg.empty())
7d81eb8c 77 m_msg = newmsg;
555f645a 78 m_cur = value;
7d81eb8c
WS
79
80 EventType event;
81
20bc5ad8 82 ProgressType *prg = (ProgressType *)m_prgFrame;
7d81eb8c
WS
83 do
84 {
85 EvtGetEvent(&event, 0);
20bc5ad8
WS
86 Boolean handled = PrgHandleEvent(prg, &event);
87 if (!PrgHandleEvent(prg, &event))
88 if( PrgUserCancel(prg) )
7d81eb8c
WS
89 return false;
90 }
91 while(event.eType != sysEventNilEvent);
92
20bc5ad8 93 PrgUpdateDialog(prg, 0, 0, "", true);
7d81eb8c
WS
94
95 m_activeSkip = m_canSkip && true;
96
555f645a
WS
97 return true;
98}
99
100void wxProgressDialog::Resume()
101{
102}
103
104bool wxProgressDialog::Show(bool show)
105{
106 return false;
107}
108
20bc5ad8 109Boolean wxProgressDialog::Callback(void *data)
7d81eb8c 110{
20bc5ad8
WS
111 PrgCallbackData *palmData = (PrgCallbackData *)data;
112 strncpy( palmData->textP, m_msg.ToAscii() , palmData->textLen - 1 );
113 palmData->textChanged = true;
6afc1b46 114#ifdef __WXPALMOS6__
20bc5ad8 115 palmData->displaySkipBtn = m_canSkip;
6afc1b46 116#endif // __WXPALMOS6__
20bc5ad8
WS
117 palmData->barMaxValue = (uint32_t)m_max;
118 palmData->barCurValue = (uint32_t)m_cur;
119 palmData->delay = (m_max == m_cur);
7d81eb8c
WS
120
121 return true;
122}
123
555f645a 124#endif // wxUSE_PROGRESSDLG