]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/progdlg.cpp
64 bit compilation fix (pointer can't be cast to int); code simplification (don't...
[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
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
555f645a
WS
29#include "wx/progdlg.h"
30#include "wx/msgdlg.h"
31
20bc5ad8
WS
32#include <Progress.h>
33#include <SysEvtMgr.h>
34
555f645a
WS
35IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
36
37static 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
7d81eb8c 47 return dialog->Callback(data);
555f645a
WS
48}
49
50wxProgressDialog::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),
7d81eb8c
WS
59 m_max(maximum),
60 m_canSkip((style & wxPD_CAN_SKIP )==wxPD_CAN_SKIP)
555f645a
WS
61{
62 wxString prgTitle = title.Mid(0, progressMaxTitle);
7d81eb8c 63
555f645a
WS
64 m_prgFrame = PrgStartDialog(prgTitle.ToAscii(), wxProgressCallback, this);
65}
66
67wxProgressDialog::~wxProgressDialog()
68{
69 if(m_prgFrame)
70 {
20bc5ad8 71 PrgStopDialog((ProgressType *)m_prgFrame, false);
555f645a
WS
72 m_prgFrame = NULL;
73 }
74}
75
76bool wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
77{
78 if(!m_prgFrame)
79 return false;
80 if(!newmsg.empty())
7d81eb8c 81 m_msg = newmsg;
555f645a 82 m_cur = value;
7d81eb8c
WS
83
84 EventType event;
85
20bc5ad8 86 ProgressType *prg = (ProgressType *)m_prgFrame;
7d81eb8c
WS
87 do
88 {
89 EvtGetEvent(&event, 0);
20bc5ad8
WS
90 Boolean handled = PrgHandleEvent(prg, &event);
91 if (!PrgHandleEvent(prg, &event))
92 if( PrgUserCancel(prg) )
7d81eb8c
WS
93 return false;
94 }
95 while(event.eType != sysEventNilEvent);
96
20bc5ad8 97 PrgUpdateDialog(prg, 0, 0, "", true);
7d81eb8c
WS
98
99 m_activeSkip = m_canSkip && true;
100
555f645a
WS
101 return true;
102}
103
104void wxProgressDialog::Resume()
105{
106}
107
108bool wxProgressDialog::Show(bool show)
109{
110 return false;
111}
112
20bc5ad8 113Boolean wxProgressDialog::Callback(void *data)
7d81eb8c 114{
20bc5ad8
WS
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);
7d81eb8c
WS
122
123 return true;
124}
125
555f645a 126#endif // wxUSE_PROGRESSDLG