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