]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/progdlg.cpp
release does not assert on empty bitmaps anymore
[wxWidgets.git] / src / palmos / progdlg.cpp
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
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "progdlg.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/string.h"
25 #endif //WX_PRECOMP
26
27 #if wxUSE_PROGRESSDLG
28
29 #include "wx/progdlg.h"
30 #include "wx/msgdlg.h"
31
32 IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
33
34 static Boolean wxProgressCallback(PrgCallbackData *data)
35 {
36 if(!data)
37 return false;
38
39 wxProgressDialog *dialog = (wxProgressDialog *)data->userDataP;
40
41 if(!dialog)
42 return false;
43
44 return dialog->Callback(data);
45 }
46
47 wxProgressDialog::wxProgressDialog(const wxString &title,
48 wxString const &message,
49 int maximum,
50 wxWindow *parent,
51 int style)
52 :wxDialog(parent, wxID_ANY, title),
53 m_prgFrame(NULL),
54 m_msg(message),
55 m_cur(0),
56 m_max(maximum),
57 m_canSkip((style & wxPD_CAN_SKIP )==wxPD_CAN_SKIP)
58 {
59 wxString prgTitle = title.Mid(0, progressMaxTitle);
60
61 m_prgFrame = PrgStartDialog(prgTitle.ToAscii(), wxProgressCallback, this);
62 }
63
64 wxProgressDialog::~wxProgressDialog()
65 {
66 if(m_prgFrame)
67 {
68 PrgStopDialog(m_prgFrame, false);
69 m_prgFrame = NULL;
70 }
71 }
72
73 bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
74 {
75 if(!m_prgFrame)
76 return false;
77 if(!newmsg.empty())
78 m_msg = newmsg;
79 m_cur = value;
80
81 EventType event;
82
83 do
84 {
85 EvtGetEvent(&event, 0);
86 Boolean handled = PrgHandleEvent(m_prgFrame, &event);
87 if (!PrgHandleEvent(m_prgFrame, &event))
88 if( PrgUserCancel(m_prgFrame) )
89 return false;
90 }
91 while(event.eType != sysEventNilEvent);
92
93 PrgUpdateDialog(m_prgFrame, 0, 0, "", true);
94
95 m_activeSkip = m_canSkip && true;
96
97 return true;
98 }
99
100 void wxProgressDialog::Resume()
101 {
102 }
103
104 bool wxProgressDialog::Show(bool show)
105 {
106 return false;
107 }
108
109 Boolean wxProgressDialog::Callback(PrgCallbackData *data)
110 {
111 strncpy( data->textP, m_msg.ToAscii() , data->textLen - 1 );
112 data->textChanged = true;
113 data->displaySkipBtn = m_canSkip;
114 data->barMaxValue = (uint32_t)m_max;
115 data->barCurValue = (uint32_t)m_cur;
116 data->delay = (m_max == m_cur);
117
118 return true;
119 }
120
121 #endif // wxUSE_PROGRESSDLG