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