Create temporary wxEventLoop in wxGenericProgressDialog if needed.
[wxWidgets.git] / src / generic / progdlgg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/progdlgg.cpp
3 // Purpose: wxGenericProgressDialog class
4 // Author: Karsten Ballueder
5 // Modified by:
6 // Created: 09.05.1999
7 // RCS-ID: $Id$
8 // Copyright: (c) Karsten Ballueder
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_PROGRESSDLG
28
29 #ifndef WX_PRECOMP
30 #include "wx/utils.h"
31 #include "wx/frame.h"
32 #include "wx/button.h"
33 #include "wx/stattext.h"
34 #include "wx/sizer.h"
35 #include "wx/event.h"
36 #include "wx/gauge.h"
37 #include "wx/intl.h"
38 #include "wx/dcclient.h"
39 #include "wx/timer.h"
40 #include "wx/settings.h"
41 #include "wx/app.h"
42 #endif
43
44 #include "wx/progdlg.h"
45 #include "wx/evtloop.h"
46
47 // ---------------------------------------------------------------------------
48 // macros
49 // ---------------------------------------------------------------------------
50
51 /* Macro for avoiding #ifdefs when value have to be different depending on size of
52 device we display on - take it from something like wxDesktopPolicy in the future
53 */
54
55 #if defined(__SMARTPHONE__)
56 #define wxLARGESMALL(large,small) small
57 #else
58 #define wxLARGESMALL(large,small) large
59 #endif
60
61 // ----------------------------------------------------------------------------
62 // constants
63 // ----------------------------------------------------------------------------
64
65 #define LAYOUT_MARGIN wxLARGESMALL(8,2)
66
67 static const int wxID_SKIP = 32000; // whatever
68
69 // ----------------------------------------------------------------------------
70 // event tables
71 // ----------------------------------------------------------------------------
72
73 BEGIN_EVENT_TABLE(wxGenericProgressDialog, wxDialog)
74 EVT_BUTTON(wxID_CANCEL, wxGenericProgressDialog::OnCancel)
75 EVT_BUTTON(wxID_SKIP, wxGenericProgressDialog::OnSkip)
76
77 EVT_CLOSE(wxGenericProgressDialog::OnClose)
78 END_EVENT_TABLE()
79
80 // ============================================================================
81 // wxGenericProgressDialog implementation
82 // ============================================================================
83
84 wxIMPLEMENT_CLASS(wxProgressDialog, wxDialog)
85
86 // ----------------------------------------------------------------------------
87 // wxGenericProgressDialog creation
88 // ----------------------------------------------------------------------------
89
90 void wxGenericProgressDialog::Init(wxWindow *parent, int maximum, int style)
91 {
92 // Initialize the inherited members that we always use (even when we don't
93 // create a valid window here).
94
95 // we may disappear at any moment, let the others know about it
96 SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);
97 m_windowStyle |= style;
98
99 m_parentTop = wxGetTopLevelParent(parent);
100
101
102 // Initialize our own members.
103 m_state = Uncancelable;
104 m_maximum = maximum;
105
106 #if defined(__WXMSW__) || defined(__WXPM__)
107 // we can't have values > 65,536 in the progress control under Windows, so
108 // scale everything down
109 m_factor = m_maximum / 65536 + 1;
110 m_maximum /= m_factor;
111 #endif // __WXMSW__
112
113
114 m_timeStart = wxGetCurrentTime();
115 m_timeStop = (unsigned long)-1;
116 m_break = 0;
117
118 m_skip = false;
119
120 m_display_estimated =
121 m_last_timeupdate =
122 m_ctdelay = 0;
123
124 m_delay = 3;
125
126 m_hasAbortButton =
127 m_hasSkipButton = false;
128
129 m_winDisabler = NULL;
130 m_tempEventLoop = NULL;
131 }
132
133 wxGenericProgressDialog::wxGenericProgressDialog(wxWindow *parent,
134 int maximum,
135 int style)
136 : wxDialog()
137 {
138 Init(parent, maximum, style);
139 }
140
141 wxGenericProgressDialog::wxGenericProgressDialog(const wxString& title,
142 const wxString& message,
143 int maximum,
144 wxWindow *parent,
145 int style)
146 : wxDialog()
147 {
148 Init(parent, maximum, style);
149
150 Create( title, message, maximum, parent, style );
151 }
152
153 void wxGenericProgressDialog::Create( const wxString& title,
154 const wxString& message,
155 int maximum,
156 wxWindow *parent,
157 int style )
158 {
159 wxDialog::Create(GetParentForModalDialog(parent, style), wxID_ANY, title);
160
161 SetParent( GetParentForModalDialog(parent, style) );
162 SetTitle( title );
163
164 // We need a running event loop in order to update the dialog and be able
165 // to process clicks on its buttons, so ensure that there is one running
166 // even if this means we have to start it ourselves (this happens most
167 // commonly during the program initialization, e.g. for the progress
168 // dialogs shown from overridden wxApp::OnInit()).
169 if ( !wxEventLoopBase::GetActive() )
170 {
171 m_tempEventLoop = new wxEventLoop;
172 wxEventLoop::SetActive(m_tempEventLoop);
173 }
174
175 m_hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
176 m_hasSkipButton = (style & wxPD_CAN_SKIP) != 0;
177
178 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
179 // we have to remove the "Close" button from the title bar then as it is
180 // confusing to have it - it doesn't work anyhow
181 //
182 // FIXME: should probably have a (extended?) window style for this
183 if ( !m_hasAbortButton )
184 {
185 EnableCloseButton(false);
186 }
187 #endif // wxMSW
188
189 #if defined(__SMARTPHONE__)
190 SetLeftMenu();
191 #endif
192
193 m_state = m_hasAbortButton ? Continue : Uncancelable;
194
195 // top-level sizerTop
196 wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
197
198 m_msg = new wxStaticText(this, wxID_ANY, message);
199 sizerTop->Add(m_msg, 0, wxLEFT | wxTOP, 2*LAYOUT_MARGIN);
200
201 if ( maximum > 0 )
202 {
203 int gauge_style = wxGA_HORIZONTAL;
204 if ( style & wxPD_SMOOTH )
205 gauge_style |= wxGA_SMOOTH;
206 m_gauge = new wxGauge
207 (
208 this,
209 wxID_ANY,
210 m_maximum,
211 wxDefaultPosition,
212 // make the progress bar sufficiently long
213 wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1),
214 gauge_style
215 );
216
217 sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN);
218 m_gauge->SetValue(0);
219 }
220 else
221 {
222 m_gauge = NULL;
223 }
224
225 // create the estimated/remaining/total time zones if requested
226 m_elapsed =
227 m_estimated =
228 m_remaining = NULL;
229
230 // also count how many labels we really have
231 size_t nTimeLabels = 0;
232
233 wxSizer * const sizerLabels = new wxFlexGridSizer(2);
234
235 if ( style & wxPD_ELAPSED_TIME )
236 {
237 nTimeLabels++;
238
239 m_elapsed = CreateLabel(GetElapsedLabel(), sizerLabels);
240 }
241
242 if ( style & wxPD_ESTIMATED_TIME )
243 {
244 nTimeLabels++;
245
246 m_estimated = CreateLabel(GetEstimatedLabel(), sizerLabels);
247 }
248
249 if ( style & wxPD_REMAINING_TIME )
250 {
251 nTimeLabels++;
252
253 m_remaining = CreateLabel(GetRemainingLabel(), sizerLabels);
254 }
255 sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN);
256
257 #if defined(__SMARTPHONE__)
258 if ( m_hasSkipButton )
259 SetRightMenu(wxID_SKIP, _("Skip"));
260 if ( m_hasAbortButton )
261 SetLeftMenu(wxID_CANCEL);
262 #else
263 m_btnAbort =
264 m_btnSkip = NULL;
265
266 wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
267
268 // Windows dialogs usually have buttons in the lower right corner
269 const int sizerFlags =
270 #if defined(__WXMSW__) || defined(__WXPM__)
271 wxALIGN_RIGHT | wxALL
272 #else // !MSW
273 wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP
274 #endif // MSW/!MSW
275 ;
276
277 if ( m_hasSkipButton )
278 {
279 m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip"));
280
281 buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN);
282 }
283
284 if ( m_hasAbortButton )
285 {
286 m_btnAbort = new wxButton(this, wxID_CANCEL);
287
288 buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN);
289 }
290
291 if (!m_hasSkipButton && !m_hasAbortButton)
292 buttonSizer->AddSpacer(LAYOUT_MARGIN);
293
294 sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN );
295 #endif // __SMARTPHONE__/!__SMARTPHONE__
296
297 SetSizerAndFit(sizerTop);
298
299 Centre(wxCENTER_FRAME | wxBOTH);
300
301 DisableOtherWindows();
302
303 Show();
304 Enable();
305
306 // this one can be initialized even if the others are unknown for now
307 //
308 // NB: do it after calling Layout() to keep the labels correctly aligned
309 if ( m_elapsed )
310 {
311 SetTimeLabel(0, m_elapsed);
312 }
313
314 Update();
315 }
316
317 void wxGenericProgressDialog::UpdateTimeEstimates(int value,
318 unsigned long &elapsedTime,
319 unsigned long &estimatedTime,
320 unsigned long &remainingTime)
321 {
322 unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
323 if ( value != 0 && (m_last_timeupdate < elapsed || value == m_maximum) )
324 {
325 m_last_timeupdate = elapsed;
326 unsigned long estimated = m_break +
327 (unsigned long)(( (double) (elapsed-m_break) * m_maximum ) / ((double)value)) ;
328 if ( estimated > m_display_estimated
329 && m_ctdelay >= 0
330 )
331 {
332 ++m_ctdelay;
333 }
334 else if ( estimated < m_display_estimated
335 && m_ctdelay <= 0
336 )
337 {
338 --m_ctdelay;
339 }
340 else
341 {
342 m_ctdelay = 0;
343 }
344 if ( m_ctdelay >= m_delay // enough confirmations for a higher value
345 || m_ctdelay <= (m_delay*-1) // enough confirmations for a lower value
346 || value == m_maximum // to stay consistent
347 || elapsed > m_display_estimated // to stay consistent
348 || ( elapsed > 0 && elapsed < 4 ) // additional updates in the beginning
349 )
350 {
351 m_display_estimated = estimated;
352 m_ctdelay = 0;
353 }
354 }
355
356 if ( value != 0 )
357 {
358 long display_remaining = m_display_estimated - elapsed;
359 if ( display_remaining < 0 )
360 {
361 display_remaining = 0;
362 }
363
364 estimatedTime = m_display_estimated;
365 remainingTime = display_remaining;
366 }
367
368 elapsedTime = elapsed;
369 }
370
371 // static
372 wxString wxGenericProgressDialog::GetFormattedTime(unsigned long timeInSec)
373 {
374 wxString timeAsHMS;
375
376 if ( timeInSec == (unsigned long)-1 )
377 {
378 timeAsHMS = _("Unknown");
379 }
380 else
381 {
382 unsigned hours = timeInSec / 3600;
383 unsigned minutes = (timeInSec % 3600) / 60;
384 unsigned seconds = timeInSec % 60;
385 timeAsHMS.Printf("%u:%02u:%02u", hours, minutes, seconds);
386 }
387
388 return timeAsHMS;
389 }
390
391 wxStaticText *
392 wxGenericProgressDialog::CreateLabel(const wxString& text, wxSizer *sizer)
393 {
394 wxStaticText *label = new wxStaticText(this, wxID_ANY, text);
395 wxStaticText *value = new wxStaticText(this, wxID_ANY, _("unknown"));
396
397 // select placement most native or nice on target GUI
398 #if defined(__SMARTPHONE__)
399 // value and time to the left in two rows
400 sizer->Add(label, 1, wxALIGN_LEFT);
401 sizer->Add(value, 1, wxALIGN_LEFT);
402 #elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXGTK20__)
403 // value and time centered in one row
404 sizer->Add(label, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT) | wxTOP | wxRIGHT, LAYOUT_MARGIN);
405 sizer->Add(value, 1, wxALIGN_LEFT | wxTOP, LAYOUT_MARGIN);
406 #else
407 // value and time to the right in one row
408 sizer->Add(label);
409 sizer->Add(value, 0, wxLEFT, LAYOUT_MARGIN);
410 #endif
411
412 return value;
413 }
414
415 // ----------------------------------------------------------------------------
416 // wxGenericProgressDialog operations
417 // ----------------------------------------------------------------------------
418
419 bool
420 wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
421 {
422 if ( !DoBeforeUpdate(skip) )
423 return false;
424
425 wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
426
427 #ifdef __WXMSW__
428 value /= m_factor;
429 #endif // __WXMSW__
430
431 wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
432
433 if ( m_gauge )
434 m_gauge->SetValue(value);
435
436 UpdateMessage(newmsg);
437
438 if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
439 {
440 unsigned long elapsed;
441 unsigned long display_remaining;
442
443 UpdateTimeEstimates( value,
444 elapsed,
445 m_display_estimated,
446 display_remaining );
447
448 SetTimeLabel(elapsed, m_elapsed);
449 SetTimeLabel(m_display_estimated, m_estimated);
450 SetTimeLabel(display_remaining, m_remaining);
451 }
452
453 if ( value == m_maximum )
454 {
455 if ( m_state == Finished )
456 {
457 // ignore multiple calls to Update(m_maximum): it may sometimes be
458 // troublesome to ensure that Update() is not called twice with the
459 // same value (e.g. because of the rounding errors) and if we don't
460 // return now we're going to generate asserts below
461 return true;
462 }
463
464 // so that we return true below and that out [Cancel] handler knew what
465 // to do
466 m_state = Finished;
467 if( !HasFlag(wxPD_AUTO_HIDE) )
468 {
469 EnableClose();
470 DisableSkip();
471 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
472 EnableCloseButton();
473 #endif // __WXMSW__
474
475 if ( newmsg.empty() )
476 {
477 // also provide the finishing message if the application didn't
478 m_msg->SetLabel(_("Done."));
479 }
480
481 // allow the window to repaint:
482 // NOTE: since we yield only for UI events with this call, there
483 // should be no side-effects
484 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
485
486 // NOTE: this call results in a new event loop being created
487 // and to a call to ProcessPendingEvents() (which may generate
488 // unwanted re-entrancies).
489 (void)ShowModal();
490 }
491 else // auto hide
492 {
493 // reenable other windows before hiding this one because otherwise
494 // Windows wouldn't give the focus back to the window which had
495 // been previously focused because it would still be disabled
496 ReenableOtherWindows();
497
498 Hide();
499 }
500 }
501 else // not at maximum yet
502 {
503 DoAfterUpdate();
504 }
505
506 // update the display in case yielding above didn't do it
507 Update();
508
509 return m_state != Canceled;
510 }
511
512 bool wxGenericProgressDialog::Pulse(const wxString& newmsg, bool *skip)
513 {
514 if ( !DoBeforeUpdate(skip) )
515 return false;
516
517 wxASSERT_MSG( m_gauge, wxT("cannot update non existent dialog") );
518
519 // show a bit of progress
520 m_gauge->Pulse();
521
522 UpdateMessage(newmsg);
523
524 if (m_elapsed || m_remaining || m_estimated)
525 {
526 unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
527
528 SetTimeLabel(elapsed, m_elapsed);
529 SetTimeLabel((unsigned long)-1, m_estimated);
530 SetTimeLabel((unsigned long)-1, m_remaining);
531 }
532
533 DoAfterUpdate();
534
535 return m_state != Canceled;
536 }
537
538 bool wxGenericProgressDialog::DoBeforeUpdate(bool *skip)
539 {
540 // we have to yield because not only we want to update the display but
541 // also to process the clicks on the cancel and skip buttons
542 // NOTE: using YieldFor() this call shouldn't give re-entrancy problems
543 // for event handlers not interested to UI/user-input events.
544 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT);
545
546 Update();
547
548 if ( m_skip && skip && !*skip )
549 {
550 *skip = true;
551 m_skip = false;
552 EnableSkip();
553 }
554
555 return m_state != Canceled;
556 }
557
558 void wxGenericProgressDialog::DoAfterUpdate()
559 {
560 // allow the window to repaint:
561 // NOTE: since we yield only for UI events with this call, there
562 // should be no side-effects
563 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
564 }
565
566 void wxGenericProgressDialog::Resume()
567 {
568 m_state = Continue;
569 m_ctdelay = m_delay; // force an update of the elapsed/estimated/remaining time
570 m_break += wxGetCurrentTime()-m_timeStop;
571
572 EnableAbort();
573 EnableSkip();
574 m_skip = false;
575 }
576
577 bool wxGenericProgressDialog::Show( bool show )
578 {
579 // reenable other windows before hiding this one because otherwise
580 // Windows wouldn't give the focus back to the window which had
581 // been previously focused because it would still be disabled
582 if(!show)
583 ReenableOtherWindows();
584
585 return wxDialog::Show(show);
586 }
587
588 int wxGenericProgressDialog::GetValue() const
589 {
590 if (m_gauge)
591 return m_gauge->GetValue();
592 return wxNOT_FOUND;
593 }
594
595 int wxGenericProgressDialog::GetRange() const
596 {
597 if (m_gauge)
598 return m_gauge->GetRange();
599 return wxNOT_FOUND;
600 }
601
602 wxString wxGenericProgressDialog::GetMessage() const
603 {
604 return m_msg->GetLabel();
605 }
606
607 void wxGenericProgressDialog::SetRange(int maximum)
608 {
609 wxASSERT_MSG(m_gauge, "The dialog should have been constructed with a range > 0");
610 wxASSERT_MSG(maximum > 0, "Invalid range");
611
612 m_gauge->SetRange(maximum);
613 m_maximum = maximum;
614
615 #if defined(__WXMSW__) || defined(__WXPM__)
616 // we can't have values > 65,536 in the progress control under Windows, so
617 // scale everything down
618 m_factor = m_maximum / 65536 + 1;
619 m_maximum /= m_factor;
620 #endif // __WXMSW__
621 }
622
623
624 bool wxGenericProgressDialog::WasCancelled() const
625 {
626 return m_hasAbortButton && m_state == Canceled;
627 }
628
629 bool wxGenericProgressDialog::WasSkipped() const
630 {
631 return m_hasSkipButton && m_skip;
632 }
633
634 // static
635 void wxGenericProgressDialog::SetTimeLabel(unsigned long val,
636 wxStaticText *label)
637 {
638 if ( label )
639 {
640 wxString s;
641
642 if (val != (unsigned long)-1)
643 {
644 s = GetFormattedTime(val);
645 }
646 else
647 {
648 s = _("Unknown");
649 }
650
651 if ( s != label->GetLabel() )
652 label->SetLabel(s);
653 }
654 }
655
656 // ----------------------------------------------------------------------------
657 // event handlers
658 // ----------------------------------------------------------------------------
659
660 void wxGenericProgressDialog::OnCancel(wxCommandEvent& event)
661 {
662 if ( m_state == Finished )
663 {
664 // this means that the count down is already finished and we're being
665 // shown as a modal dialog - so just let the default handler do the job
666 event.Skip();
667 }
668 else
669 {
670 // request to cancel was received, the next time Update() is called we
671 // will handle it
672 m_state = Canceled;
673
674 // update the buttons state immediately so that the user knows that the
675 // request has been noticed
676 DisableAbort();
677 DisableSkip();
678
679 // save the time when the dialog was stopped
680 m_timeStop = wxGetCurrentTime();
681 }
682 }
683
684 void wxGenericProgressDialog::OnSkip(wxCommandEvent& WXUNUSED(event))
685 {
686 DisableSkip();
687 m_skip = true;
688 }
689
690 void wxGenericProgressDialog::OnClose(wxCloseEvent& event)
691 {
692 if ( m_state == Uncancelable )
693 {
694 // can't close this dialog
695 event.Veto();
696 }
697 else if ( m_state == Finished )
698 {
699 // let the default handler close the window as we already terminated
700 event.Skip();
701 }
702 else
703 {
704 // next Update() will notice it
705 m_state = Canceled;
706 DisableAbort();
707 DisableSkip();
708
709 m_timeStop = wxGetCurrentTime();
710 }
711 }
712
713 // ----------------------------------------------------------------------------
714 // destruction
715 // ----------------------------------------------------------------------------
716
717 wxGenericProgressDialog::~wxGenericProgressDialog()
718 {
719 // normally this should have been already done, but just in case
720 ReenableOtherWindows();
721
722 if ( m_tempEventLoop )
723 {
724 wxEventLoopBase::SetActive(NULL);
725 delete m_tempEventLoop;
726 }
727 }
728
729 void wxGenericProgressDialog::DisableOtherWindows()
730 {
731 if ( HasFlag(wxPD_APP_MODAL) )
732 {
733 m_winDisabler = new wxWindowDisabler(this);
734 }
735 else
736 {
737 if ( m_parentTop )
738 m_parentTop->Disable();
739 m_winDisabler = NULL;
740 }
741 }
742
743 void wxGenericProgressDialog::ReenableOtherWindows()
744 {
745 if ( HasFlag(wxPD_APP_MODAL) )
746 {
747 wxDELETE(m_winDisabler);
748 }
749 else
750 {
751 if ( m_parentTop )
752 m_parentTop->Enable();
753 }
754 }
755
756 // ----------------------------------------------------------------------------
757 // private functions
758 // ----------------------------------------------------------------------------
759
760 void wxGenericProgressDialog::EnableSkip(bool enable)
761 {
762 if(m_hasSkipButton)
763 {
764 #ifdef __SMARTPHONE__
765 if(enable)
766 SetRightMenu(wxID_SKIP, _("Skip"));
767 else
768 SetRightMenu();
769 #else
770 if(m_btnSkip)
771 m_btnSkip->Enable(enable);
772 #endif
773 }
774 }
775
776 void wxGenericProgressDialog::EnableAbort(bool enable)
777 {
778 if(m_hasAbortButton)
779 {
780 #ifdef __SMARTPHONE__
781 if(enable)
782 SetLeftMenu(wxID_CANCEL); // stock buttons makes Cancel label
783 else
784 SetLeftMenu();
785 #else
786 if(m_btnAbort)
787 m_btnAbort->Enable(enable);
788 #endif
789 }
790 }
791
792 void wxGenericProgressDialog::EnableClose()
793 {
794 if(m_hasAbortButton)
795 {
796 #ifdef __SMARTPHONE__
797 SetLeftMenu(wxID_CANCEL, _("Close"));
798 #else
799 if(m_btnAbort)
800 {
801 m_btnAbort->Enable();
802 m_btnAbort->SetLabel(_("Close"));
803 }
804 #endif
805 }
806 }
807
808 void wxGenericProgressDialog::UpdateMessage(const wxString &newmsg)
809 {
810 if ( !newmsg.empty() && newmsg != m_msg->GetLabel() )
811 {
812 m_msg->SetLabel(newmsg);
813
814 // allow the window to repaint:
815 // NOTE: since we yield only for UI events with this call, there
816 // should be no side-effects
817 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
818 }
819 }
820
821 #endif // wxUSE_PROGRESSDLG