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