]> git.saurik.com Git - wxWidgets.git/blame - src/generic/progdlgg.cpp
remove incorrect cast of wxString to char* (unnecessary and breaks wxUSE_STL build)
[wxWidgets.git] / src / generic / progdlgg.cpp
CommitLineData
8fa2e6a2 1/////////////////////////////////////////////////////////////////////////////
9eddec69 2// Name: src/generic/progdlgg.cpp
8fa2e6a2 3// Purpose: wxProgressDialog class
9d55bfef 4// Author: Karsten Ballueder
8fa2e6a2
KB
5// Modified by:
6// Created: 09.05.1999
7// RCS-ID: $Id$
9d55bfef 8// Copyright: (c) Karsten Ballueder
65571936 9// Licence: wxWindows licence
8fa2e6a2
KB
10/////////////////////////////////////////////////////////////////////////////
11
0655ad29
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
8fa2e6a2
KB
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
f81a6620 24 #pragma hdrstop
8fa2e6a2
KB
25#endif
26
0655ad29
VZ
27#if wxUSE_PROGRESSDLG
28
8fa2e6a2 29#ifndef WX_PRECOMP
f81a6620
VZ
30 #include "wx/utils.h"
31 #include "wx/frame.h"
32 #include "wx/button.h"
33 #include "wx/stattext.h"
0ca3b64f 34 #include "wx/sizer.h"
f81a6620
VZ
35 #include "wx/event.h"
36 #include "wx/gauge.h"
37 #include "wx/intl.h"
720dcba6 38 #include "wx/dcclient.h"
9b61f868 39 #include "wx/timer.h"
9eddec69 40 #include "wx/settings.h"
731bcffc 41 #include "wx/app.h"
8fa2e6a2
KB
42#endif
43
fe8635a7 44#include "wx/progdlg.h"
8fa2e6a2 45
d2cdad17
WS
46// ---------------------------------------------------------------------------
47// macros
48// ---------------------------------------------------------------------------
49
50/* Macro for avoiding #ifdefs when value have to be different depending on size of
9a357011 51 device we display on - take it from something like wxDesktopPolicy in the future
d2cdad17
WS
52 */
53
54#if defined(__SMARTPHONE__)
55 #define wxLARGESMALL(large,small) small
56#else
57 #define wxLARGESMALL(large,small) large
58#endif
59
0655ad29
VZ
60// ----------------------------------------------------------------------------
61// constants
62// ----------------------------------------------------------------------------
63
d2cdad17 64#define LAYOUT_MARGIN wxLARGESMALL(8,2)
8fa2e6a2 65
ecda9475
WS
66static const int wxID_SKIP = 32000; // whatever
67
0655ad29
VZ
68// ----------------------------------------------------------------------------
69// private functions
70// ----------------------------------------------------------------------------
71
72// update the label to show the given time (in seconds)
73static void SetTimeLabel(unsigned long val, wxStaticText *label);
74
75// ----------------------------------------------------------------------------
76// event tables
77// ----------------------------------------------------------------------------
8fa2e6a2 78
1b6452df 79BEGIN_EVENT_TABLE(wxProgressDialog, wxDialog)
ef8698d6 80 EVT_BUTTON(wxID_CANCEL, wxProgressDialog::OnCancel)
ecda9475 81 EVT_BUTTON(wxID_SKIP, wxProgressDialog::OnSkip)
ef8698d6 82
ef8698d6 83 EVT_CLOSE(wxProgressDialog::OnClose)
1b6452df 84END_EVENT_TABLE()
8fa2e6a2 85
1b6452df 86IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
8fa2e6a2 87
0655ad29 88// ============================================================================
db1a42b8 89// wxProgressDialog implementation
0655ad29 90// ============================================================================
8fa2e6a2 91
0655ad29 92// ----------------------------------------------------------------------------
db1a42b8 93// wxProgressDialog creation
0655ad29 94// ----------------------------------------------------------------------------
f81a6620 95
695f550b
VZ
96wxProgressDialog::wxProgressDialog(const wxString& title,
97 const wxString& message,
0655ad29
VZ
98 int maximum,
99 wxWindow *parent,
100 int style)
2229243b 101 : wxDialog(GetParentForModalDialog(parent), wxID_ANY, title),
3786ce5a 102 m_skip(false),
69c69546
WS
103 m_delay(3),
104 m_hasAbortButton(false),
105 m_hasSkipButton(false)
0655ad29 106{
39cc7a0b
VZ
107 // we may disappear at any moment, let the others know about it
108 SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);
96becbd8
VS
109 m_windowStyle |= style;
110
69c69546
WS
111 m_hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
112 m_hasSkipButton = (style & wxPD_CAN_SKIP) != 0;
c4d305b7 113
cff7ef89 114#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
c4d305b7
VZ
115 // we have to remove the "Close" button from the title bar then as it is
116 // confusing to have it - it doesn't work anyhow
117 //
118 // FIXME: should probably have a (extended?) window style for this
69c69546 119 if ( !m_hasAbortButton )
c4d305b7 120 {
dabbc6a5 121 EnableCloseButton(false);
c4d305b7
VZ
122 }
123#endif // wxMSW
124
d2cdad17
WS
125#if defined(__SMARTPHONE__)
126 SetLeftMenu();
127#endif
128
69c69546 129 m_state = m_hasAbortButton ? Continue : Uncancelable;
0655ad29
VZ
130 m_maximum = maximum;
131
94640e04 132#if defined(__WXMSW__) || defined(__WXPM__)
7c349adb
VZ
133 // we can't have values > 65,536 in the progress control under Windows, so
134 // scale everything down
135 m_factor = m_maximum / 65536 + 1;
136 m_maximum /= m_factor;
137#endif // __WXMSW__
138
6258e418 139 m_parentTop = wxGetTopLevelParent(parent);
abceee76 140
0655ad29 141 wxClientDC dc(this);
a756f210 142 dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
e8a301af 143 wxCoord widthText = 0;
f1415824 144 dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL);
0655ad29 145
695f550b
VZ
146 // top-level sizerTop
147 wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
d2cdad17 148
dabbc6a5 149 m_msg = new wxStaticText(this, wxID_ANY, message);
695f550b 150 sizerTop->Add(m_msg, 0, wxLEFT | wxTOP, 2*LAYOUT_MARGIN);
0655ad29 151
0655ad29
VZ
152 if ( maximum > 0 )
153 {
ecda9475 154 int gauge_style = wxGA_HORIZONTAL;
695f550b 155 if ( style & wxPD_SMOOTH )
ecda9475 156 gauge_style |= wxGA_SMOOTH;
695f550b
VZ
157 m_gauge = new wxGauge
158 (
159 this,
160 wxID_ANY,
161 m_maximum,
162 wxDefaultPosition,
163 // make the progress bar sufficiently long
164 wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1),
165 gauge_style
166 );
167
168 sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN);
0655ad29 169 m_gauge->SetValue(0);
0655ad29
VZ
170 }
171 else
695f550b
VZ
172 {
173 m_gauge = NULL;
174 }
0655ad29
VZ
175
176 // create the estimated/remaining/total time zones if requested
695f550b
VZ
177 m_elapsed =
178 m_estimated =
179 m_remaining = NULL;
180 m_display_estimated =
181 m_last_timeupdate =
182 m_break = 0;
2c5ef4e2 183 m_ctdelay = 0;
0655ad29 184
8d6854a6
VZ
185 // also count how many labels we really have
186 size_t nTimeLabels = 0;
187
695f550b
VZ
188 wxSizer * const sizerLabels = new wxFlexGridSizer(2);
189
0655ad29
VZ
190 if ( style & wxPD_ELAPSED_TIME )
191 {
192 nTimeLabels++;
193
695f550b 194 m_elapsed = CreateLabel(_("Elapsed time:"), sizerLabels);
0655ad29
VZ
195 }
196
197 if ( style & wxPD_ESTIMATED_TIME )
198 {
199 nTimeLabels++;
200
695f550b 201 m_estimated = CreateLabel(_("Estimated time:"), sizerLabels);
0655ad29
VZ
202 }
203
204 if ( style & wxPD_REMAINING_TIME )
205 {
206 nTimeLabels++;
207
695f550b 208 m_remaining = CreateLabel(_("Remaining time:"), sizerLabels);
0655ad29 209 }
695f550b 210 sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN);
0655ad29
VZ
211
212 if ( nTimeLabels > 0 )
213 {
214 // set it to the current time
215 m_timeStart = wxGetCurrentTime();
0655ad29
VZ
216 }
217
d2cdad17 218#if defined(__SMARTPHONE__)
69c69546 219 if ( m_hasSkipButton )
ecda9475 220 SetRightMenu(wxID_SKIP, _("Skip"));
69c69546 221 if ( m_hasAbortButton )
ecda9475 222 SetLeftMenu(wxID_CANCEL);
d2cdad17 223#else
695f550b
VZ
224 m_btnAbort =
225 m_btnSkip = NULL;
226
ecda9475 227 wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
0655ad29 228
695f550b 229 // Windows dialogs usually have buttons in the lower right corner
3786ce5a 230 const int sizerFlags =
94640e04 231#if defined(__WXMSW__) || defined(__WXPM__)
ecda9475 232 wxALIGN_RIGHT | wxALL
0655ad29 233#else // !MSW
ecda9475 234 wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP
0655ad29 235#endif // MSW/!MSW
ecda9475
WS
236 ;
237
69c69546 238 if ( m_hasSkipButton )
ecda9475 239 {
695f550b 240 m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip"));
ecda9475 241
ecda9475 242 buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN);
0655ad29 243 }
ecda9475 244
69c69546 245 if ( m_hasAbortButton )
e269a9be 246 {
ecda9475
WS
247 m_btnAbort = new wxButton(this, wxID_CANCEL);
248
ecda9475 249 buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN);
e269a9be 250 }
0655ad29 251
695f550b 252 sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN );
ecda9475
WS
253#endif // __SMARTPHONE__/!__SMARTPHONE__
254
695f550b 255 SetSizerAndFit(sizerTop);
0655ad29
VZ
256
257 Centre(wxCENTER_FRAME | wxBOTH);
258
cbc66a27 259 if ( style & wxPD_APP_MODAL )
0655ad29 260 {
cbc66a27 261 m_winDisabler = new wxWindowDisabler(this);
0655ad29
VZ
262 }
263 else
264 {
cbc66a27 265 if ( m_parentTop )
dabbc6a5 266 m_parentTop->Disable();
cbc66a27 267 m_winDisabler = NULL;
0655ad29
VZ
268 }
269
dabbc6a5
DS
270 Show();
271 Enable();
33961d59 272
70f3fad6
VZ
273 // this one can be initialized even if the others are unknown for now
274 //
275 // NB: do it after calling Layout() to keep the labels correctly aligned
276 if ( m_elapsed )
277 {
278 SetTimeLabel(0, m_elapsed);
279 }
280
f89d65ea 281 Update();
8fa2e6a2
KB
282}
283
695f550b
VZ
284wxStaticText *
285wxProgressDialog::CreateLabel(const wxString& text, wxSizer *sizer)
0655ad29 286{
695f550b
VZ
287 wxStaticText *label = new wxStaticText(this, wxID_ANY, text);
288 wxStaticText *value = new wxStaticText(this, wxID_ANY, _("unknown"));
0655ad29 289
d2cdad17
WS
290 // select placement most native or nice on target GUI
291#if defined(__SMARTPHONE__)
695f550b
VZ
292 // value and time to the left in two rows
293 sizer->Add(label, 1, wxALIGN_LEFT);
294 sizer->Add(value, 1, wxALIGN_LEFT);
fe8635a7 295#elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXGTK20__)
695f550b
VZ
296 // value and time centered in one row
297 sizer->Add(label, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT) | wxTOP | wxRIGHT, LAYOUT_MARGIN);
298 sizer->Add(value, 1, wxALIGN_LEFT | wxTOP, LAYOUT_MARGIN);
d2cdad17 299#else
695f550b
VZ
300 // value and time to the right in one row
301 sizer->Add(label);
302 sizer->Add(value, 0, wxLEFT, LAYOUT_MARGIN);
d2cdad17 303#endif
0655ad29 304
695f550b 305 return value;
0655ad29 306}
8fa2e6a2 307
db1a42b8
VZ
308// ----------------------------------------------------------------------------
309// wxProgressDialog operations
310// ----------------------------------------------------------------------------
311
8fa2e6a2 312bool
ecda9475 313wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
8fa2e6a2 314{
abceee76 315 wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
7c349adb
VZ
316
317#ifdef __WXMSW__
318 value /= m_factor;
319#endif // __WXMSW__
320
abceee76
VZ
321 wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
322
c4c6ada9
VZ
323 if ( m_gauge )
324 m_gauge->SetValue(value);
abceee76 325
fe8635a7 326 UpdateMessage(newmsg);
abceee76
VZ
327
328 if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
329 {
330 unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
2c5ef4e2
VZ
331 if ( m_last_timeupdate < elapsed
332 || value == m_maximum
333 )
334 {
335 m_last_timeupdate = elapsed;
336 unsigned long estimated = m_break +
337 (unsigned long)(( (double) (elapsed-m_break) * m_maximum ) / ((double)value)) ;
338 if ( estimated > m_display_estimated
339 && m_ctdelay >= 0
340 )
341 {
342 ++m_ctdelay;
343 }
344 else if ( estimated < m_display_estimated
345 && m_ctdelay <= 0
346 )
347 {
348 --m_ctdelay;
349 }
350 else
351 {
352 m_ctdelay = 0;
353 }
354 if ( m_ctdelay >= m_delay // enough confirmations for a higher value
355 || m_ctdelay <= (m_delay*-1) // enough confirmations for a lower value
356 || value == m_maximum // to stay consistent
357 || elapsed > m_display_estimated // to stay consistent
358 || ( elapsed > 0 && elapsed < 4 ) // additional updates in the beginning
359 )
360 {
361 m_display_estimated = estimated;
362 m_ctdelay = 0;
363 }
364 }
365
ce07cd8a 366 long display_remaining = m_display_estimated - elapsed;
2c5ef4e2
VZ
367 if ( display_remaining < 0 )
368 {
369 display_remaining = 0;
370 }
abceee76
VZ
371
372 SetTimeLabel(elapsed, m_elapsed);
2c5ef4e2
VZ
373 SetTimeLabel(m_display_estimated, m_estimated);
374 SetTimeLabel(display_remaining, m_remaining);
abceee76
VZ
375 }
376
ff095200 377 if ( value == m_maximum )
abceee76 378 {
837adaa9
VZ
379 if ( m_state == Finished )
380 {
381 // ignore multiple calls to Update(m_maximum): it may sometimes be
382 // troublesome to ensure that Update() is not called twice with the
383 // same value (e.g. because of the rounding errors) and if we don't
384 // return now we're going to generate asserts below
385 return true;
386 }
387
dabbc6a5 388 // so that we return true below and that out [Cancel] handler knew what
1c79904b
MB
389 // to do
390 m_state = Finished;
f62c5581 391 if( !HasFlag(wxPD_AUTO_HIDE) )
abceee76 392 {
69c69546
WS
393 EnableClose();
394 DisableSkip();
cff7ef89 395#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
69c69546 396 EnableCloseButton();
c4d305b7 397#endif // __WXMSW__
abceee76 398
60ad766e 399 if ( newmsg.empty() )
1c79904b
MB
400 {
401 // also provide the finishing message if the application didn't
402 m_msg->SetLabel(_("Done."));
403 }
abceee76 404
d48b06bd 405 wxTheApp->YieldFor(wxEVT_CATEGORY_UI);
ff095200 406
1c79904b
MB
407 (void)ShowModal();
408 }
ff095200 409 else // auto hide
1c79904b 410 {
ff095200
VZ
411 // reenable other windows before hiding this one because otherwise
412 // Windows wouldn't give the focus back to the window which had
413 // been previously focused because it would still be disabled
1c79904b 414 ReenableOtherWindows();
ff095200
VZ
415
416 Hide();
1c79904b 417 }
abceee76 418 }
f4aa7ec3 419 else // not at maximum yet
abceee76 420 {
f4aa7ec3 421 return DoAfterUpdate(skip);
abceee76 422 }
1b6452df 423
1d1c3a9f 424 // update the display in case yielding above didn't do it
f89d65ea 425 Update();
0655ad29 426
abceee76 427 return m_state != Canceled;
8fa2e6a2
KB
428}
429
f4aa7ec3 430bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip)
fe8635a7
RR
431{
432 wxASSERT_MSG( m_gauge, wxT("cannot update non existent dialog") );
433
434 // show a bit of progress
435 m_gauge->Pulse();
436
437 UpdateMessage(newmsg);
438
439 if (m_elapsed || m_remaining || m_estimated)
440 {
441 unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
442
443 SetTimeLabel(elapsed, m_elapsed);
444 SetTimeLabel((unsigned long)-1, m_estimated);
445 SetTimeLabel((unsigned long)-1, m_remaining);
446 }
447
f4aa7ec3
VZ
448 return DoAfterUpdate(skip);
449}
450
451bool wxProgressDialog::DoAfterUpdate(bool *skip)
452{
fe8635a7
RR
453 // we have to yield because not only we want to update the display but
454 // also to process the clicks on the cancel and skip buttons
d48b06bd 455 wxTheApp->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT);
f4aa7ec3
VZ
456
457 Update();
fe8635a7 458
f4aa7ec3 459 if ( m_skip && skip && !*skip )
fe8635a7
RR
460 {
461 *skip = true;
462 m_skip = false;
463 EnableSkip();
464 }
465
466 return m_state != Canceled;
467}
468
db1a42b8
VZ
469void wxProgressDialog::Resume()
470{
471 m_state = Continue;
2c5ef4e2
VZ
472 m_ctdelay = m_delay; // force an update of the elapsed/estimated/remaining time
473 m_break += wxGetCurrentTime()-m_timeStop;
db1a42b8 474
69c69546
WS
475 EnableAbort();
476 EnableSkip();
ecda9475 477 m_skip = false;
db1a42b8
VZ
478}
479
7d1dcec2
JS
480bool wxProgressDialog::Show( bool show )
481{
482 // reenable other windows before hiding this one because otherwise
483 // Windows wouldn't give the focus back to the window which had
484 // been previously focused because it would still be disabled
485 if(!show)
486 ReenableOtherWindows();
487
488 return wxDialog::Show(show);
489}
490
af237ae4
FM
491int wxProgressDialog::GetValue() const
492{
493 if (m_gauge)
494 return m_gauge->GetValue();
495 return wxNOT_FOUND;
496}
497
498int wxProgressDialog::GetRange() const
499{
500 if (m_gauge)
501 return m_gauge->GetRange();
502 return wxNOT_FOUND;
503}
504
505wxString wxProgressDialog::GetMessage() const
506{
507 return m_msg->GetLabel();
508}
509
0655ad29
VZ
510// ----------------------------------------------------------------------------
511// event handlers
512// ----------------------------------------------------------------------------
513
514void wxProgressDialog::OnCancel(wxCommandEvent& event)
515{
516 if ( m_state == Finished )
517 {
518 // this means that the count down is already finished and we're being
519 // shown as a modal dialog - so just let the default handler do the job
520 event.Skip();
521 }
522 else
523 {
524 // request to cancel was received, the next time Update() is called we
525 // will handle it
526 m_state = Canceled;
1b6452df 527
69c69546 528 // update the buttons state immediately so that the user knows that the
1b6452df 529 // request has been noticed
69c69546
WS
530 DisableAbort();
531 DisableSkip();
2c5ef4e2
VZ
532
533 // save the time when the dialog was stopped
534 m_timeStop = wxGetCurrentTime();
0655ad29
VZ
535 }
536}
537
ecda9475
WS
538void wxProgressDialog::OnSkip(wxCommandEvent& WXUNUSED(event))
539{
69c69546 540 DisableSkip();
ecda9475
WS
541 m_skip = true;
542}
543
8fa2e6a2
KB
544void wxProgressDialog::OnClose(wxCloseEvent& event)
545{
0655ad29 546 if ( m_state == Uncancelable )
abceee76
VZ
547 {
548 // can't close this dialog
dabbc6a5 549 event.Veto();
abceee76
VZ
550 }
551 else if ( m_state == Finished )
552 {
553 // let the default handler close the window as we already terminated
554 event.Skip();
555 }
0655ad29 556 else
abceee76
VZ
557 {
558 // next Update() will notice it
0655ad29 559 m_state = Canceled;
69c69546
WS
560 DisableAbort();
561 DisableSkip();
ecda9475 562
2c5ef4e2 563 m_timeStop = wxGetCurrentTime();
abceee76 564 }
8fa2e6a2
KB
565}
566
0655ad29
VZ
567// ----------------------------------------------------------------------------
568// destruction
569// ----------------------------------------------------------------------------
8fa2e6a2
KB
570
571wxProgressDialog::~wxProgressDialog()
ef8698d6
VZ
572{
573 // normally this should have been already done, but just in case
574 ReenableOtherWindows();
575}
576
577void wxProgressDialog::ReenableOtherWindows()
8fa2e6a2 578{
f62c5581 579 if ( HasFlag(wxPD_APP_MODAL) )
0655ad29 580 {
cbc66a27 581 delete m_winDisabler;
d3b9f782 582 m_winDisabler = NULL;
0655ad29
VZ
583 }
584 else
585 {
cbc66a27 586 if ( m_parentTop )
dabbc6a5 587 m_parentTop->Enable();
0655ad29 588 }
8fa2e6a2 589}
ce4169a4 590
0655ad29
VZ
591// ----------------------------------------------------------------------------
592// private functions
593// ----------------------------------------------------------------------------
594
595static void SetTimeLabel(unsigned long val, wxStaticText *label)
596{
597 if ( label )
598 {
599 wxString s;
fe8635a7
RR
600
601 if (val != (unsigned long)-1)
602 {
f62c5581
FM
603 unsigned long hours = val / 3600;
604 unsigned long minutes = (val % 3600) / 60;
605 unsigned long seconds = val % 60;
606 s.Printf(wxT("%lu:%02lu:%02lu"), hours, minutes, seconds);
fe8635a7
RR
607 }
608 else
609 {
610 s = _("Unknown");
611 }
0655ad29
VZ
612
613 if ( s != label->GetLabel() )
614 label->SetLabel(s);
615 }
616}
617
69c69546
WS
618void wxProgressDialog::EnableSkip(bool enable)
619{
620 if(m_hasSkipButton)
621 {
622#ifdef __SMARTPHONE__
623 if(enable)
624 SetRightMenu(wxID_SKIP, _("Skip"));
625 else
626 SetRightMenu();
627#else
628 if(m_btnSkip)
629 m_btnSkip->Enable(enable);
630#endif
631 }
632}
633
634void wxProgressDialog::EnableAbort(bool enable)
635{
636 if(m_hasAbortButton)
637 {
638#ifdef __SMARTPHONE__
639 if(enable)
9a2256da 640 SetLeftMenu(wxID_CANCEL); // stock buttons makes Cancel label
69c69546
WS
641 else
642 SetLeftMenu();
643#else
644 if(m_btnAbort)
645 m_btnAbort->Enable(enable);
646#endif
647 }
648}
649
650void wxProgressDialog::EnableClose()
651{
652 if(m_hasAbortButton)
653 {
654#ifdef __SMARTPHONE__
655 SetLeftMenu(wxID_CANCEL, _("Close"));
656#else
657 if(m_btnAbort)
658 {
659 m_btnAbort->Enable();
660 m_btnAbort->SetLabel(_("Close"));
661 }
662#endif
663 }
664}
665
fe8635a7
RR
666void wxProgressDialog::UpdateMessage(const wxString &newmsg)
667{
668 if ( !newmsg.empty() && newmsg != m_msg->GetLabel() )
669 {
670 m_msg->SetLabel(newmsg);
671
c0b25bb2
FM
672 Fit(); // adapt to the new label size
673
d48b06bd 674 wxTheApp->YieldFor(wxEVT_CATEGORY_UI);
fe8635a7
RR
675 }
676}
677
0655ad29 678#endif // wxUSE_PROGRESSDLG