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