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