]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/progdlg.cpp
use libtool versioning of shared libs on Unix
[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 #include <Progress.h>
33 #include <SysEvtMgr.h>
34
35 IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
36
37 static Boolean wxProgressCallback(PrgCallbackData *data)
38 {
39 if(!data)
40 return false;
41
42 wxProgressDialog *dialog = (wxProgressDialog *)data->userDataP;
43
44 if(!dialog)
45 return false;
46
47 return dialog->Callback(data);
48 }
49
50 wxProgressDialog::wxProgressDialog(const wxString &title,
51 wxString const &message,
52 int maximum,
53 wxWindow *parent,
54 int style)
55 :wxDialog(parent, wxID_ANY, title),
56 m_prgFrame(NULL),
57 m_msg(message),
58 m_cur(0),
59 m_max(maximum),
60 m_canSkip((style & wxPD_CAN_SKIP )==wxPD_CAN_SKIP)
61 {
62 wxString prgTitle = title.Mid(0, progressMaxTitle);
63
64 m_prgFrame = PrgStartDialog(prgTitle.ToAscii(), wxProgressCallback, this);
65 }
66
67 wxProgressDialog::~wxProgressDialog()
68 {
69 if(m_prgFrame)
70 {
71 PrgStopDialog((ProgressType *)m_prgFrame, false);
72 m_prgFrame = NULL;
73 }
74 }
75
76 bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
77 {
78 if(!m_prgFrame)
79 return false;
80 if(!newmsg.empty())
81 m_msg = newmsg;
82 m_cur = value;
83
84 EventType event;
85
86 ProgressType *prg = (ProgressType *)m_prgFrame;
87 do
88 {
89 EvtGetEvent(&event, 0);
90 Boolean handled = PrgHandleEvent(prg, &event);
91 if (!PrgHandleEvent(prg, &event))
92 if( PrgUserCancel(prg) )
93 return false;
94 }
95 while(event.eType != sysEventNilEvent);
96
97 PrgUpdateDialog(prg, 0, 0, "", true);
98
99 m_activeSkip = m_canSkip && true;
100
101 return true;
102 }
103
104 void wxProgressDialog::Resume()
105 {
106 }
107
108 bool wxProgressDialog::Show(bool show)
109 {
110 return false;
111 }
112
113 Boolean wxProgressDialog::Callback(void *data)
114 {
115 PrgCallbackData *palmData = (PrgCallbackData *)data;
116 strncpy( palmData->textP, m_msg.ToAscii() , palmData->textLen - 1 );
117 palmData->textChanged = true;
118 palmData->displaySkipBtn = m_canSkip;
119 palmData->barMaxValue = (uint32_t)m_max;
120 palmData->barCurValue = (uint32_t)m_cur;
121 palmData->delay = (m_max == m_cur);
122
123 return true;
124 }
125
126 #endif // wxUSE_PROGRESSDLG