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