]> git.saurik.com Git - wxWidgets.git/blame - src/generic/progdlgg.cpp
don't access inexistent column in wxDataViewTreeCtrl::OnSize() (this bug also probabl...
[wxWidgets.git] / src / generic / progdlgg.cpp
CommitLineData
8fa2e6a2 1/////////////////////////////////////////////////////////////////////////////
9eddec69 2// Name: src/generic/progdlgg.cpp
8fa2e6a2 3// Purpose: wxProgressDialog class
9d55bfef 4// Author: Karsten Ballueder
8fa2e6a2
KB
5// Modified by:
6// Created: 09.05.1999
7// RCS-ID: $Id$
9d55bfef 8// Copyright: (c) Karsten Ballueder
65571936 9// Licence: wxWindows licence
8fa2e6a2
KB
10/////////////////////////////////////////////////////////////////////////////
11
0655ad29
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
8fa2e6a2
KB
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
f81a6620 24 #pragma hdrstop
8fa2e6a2
KB
25#endif
26
0655ad29
VZ
27#if wxUSE_PROGRESSDLG
28
8fa2e6a2 29#ifndef WX_PRECOMP
f81a6620
VZ
30 #include "wx/utils.h"
31 #include "wx/frame.h"
32 #include "wx/button.h"
33 #include "wx/stattext.h"
0ca3b64f 34 #include "wx/sizer.h"
f81a6620
VZ
35 #include "wx/event.h"
36 #include "wx/gauge.h"
37 #include "wx/intl.h"
720dcba6 38 #include "wx/dcclient.h"
9b61f868 39 #include "wx/timer.h"
9eddec69 40 #include "wx/settings.h"
8fa2e6a2
KB
41#endif
42
fe8635a7 43#include "wx/progdlg.h"
8fa2e6a2 44
d2cdad17
WS
45// ---------------------------------------------------------------------------
46// macros
47// ---------------------------------------------------------------------------
48
49/* Macro for avoiding #ifdefs when value have to be different depending on size of
9a357011 50 device we display on - take it from something like wxDesktopPolicy in the future
d2cdad17
WS
51 */
52
53#if defined(__SMARTPHONE__)
54 #define wxLARGESMALL(large,small) small
55#else
56 #define wxLARGESMALL(large,small) large
57#endif
58
0655ad29
VZ
59// ----------------------------------------------------------------------------
60// constants
61// ----------------------------------------------------------------------------
62
d2cdad17 63#define LAYOUT_MARGIN wxLARGESMALL(8,2)
8fa2e6a2 64
ecda9475
WS
65static const int wxID_SKIP = 32000; // whatever
66
0655ad29
VZ
67// ----------------------------------------------------------------------------
68// private functions
69// ----------------------------------------------------------------------------
70
71// update the label to show the given time (in seconds)
72static void SetTimeLabel(unsigned long val, wxStaticText *label);
73
74// ----------------------------------------------------------------------------
75// event tables
76// ----------------------------------------------------------------------------
8fa2e6a2 77
1b6452df 78BEGIN_EVENT_TABLE(wxProgressDialog, wxDialog)
ef8698d6 79 EVT_BUTTON(wxID_CANCEL, wxProgressDialog::OnCancel)
ecda9475 80 EVT_BUTTON(wxID_SKIP, wxProgressDialog::OnSkip)
ef8698d6 81
ef8698d6 82 EVT_CLOSE(wxProgressDialog::OnClose)
1b6452df 83END_EVENT_TABLE()
8fa2e6a2 84
1b6452df 85IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
8fa2e6a2 86
0655ad29 87// ============================================================================
db1a42b8 88// wxProgressDialog implementation
0655ad29 89// ============================================================================
8fa2e6a2 90
0655ad29 91// ----------------------------------------------------------------------------
db1a42b8 92// wxProgressDialog creation
0655ad29 93// ----------------------------------------------------------------------------
f81a6620 94
695f550b
VZ
95wxProgressDialog::wxProgressDialog(const wxString& title,
96 const wxString& message,
0655ad29
VZ
97 int maximum,
98 wxWindow *parent,
99 int style)
2229243b 100 : wxDialog(GetParentForModalDialog(parent), wxID_ANY, title),
3786ce5a 101 m_skip(false),
69c69546
WS
102 m_delay(3),
103 m_hasAbortButton(false),
104 m_hasSkipButton(false)
0655ad29 105{
39cc7a0b
VZ
106 // we may disappear at any moment, let the others know about it
107 SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);
96becbd8
VS
108 m_windowStyle |= style;
109
69c69546
WS
110 m_hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
111 m_hasSkipButton = (style & wxPD_CAN_SKIP) != 0;
c4d305b7 112
cff7ef89 113#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
c4d305b7
VZ
114 // we have to remove the "Close" button from the title bar then as it is
115 // confusing to have it - it doesn't work anyhow
116 //
117 // FIXME: should probably have a (extended?) window style for this
69c69546 118 if ( !m_hasAbortButton )
c4d305b7 119 {
dabbc6a5 120 EnableCloseButton(false);
c4d305b7
VZ
121 }
122#endif // wxMSW
123
d2cdad17
WS
124#if defined(__SMARTPHONE__)
125 SetLeftMenu();
126#endif
127
69c69546 128 m_state = m_hasAbortButton ? Continue : Uncancelable;
0655ad29
VZ
129 m_maximum = maximum;
130
94640e04 131#if defined(__WXMSW__) || defined(__WXPM__)
7c349adb
VZ
132 // we can't have values > 65,536 in the progress control under Windows, so
133 // scale everything down
134 m_factor = m_maximum / 65536 + 1;
135 m_maximum /= m_factor;
136#endif // __WXMSW__
137
6258e418 138 m_parentTop = wxGetTopLevelParent(parent);
abceee76 139
0655ad29 140 wxClientDC dc(this);
a756f210 141 dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
e8a301af 142 wxCoord widthText = 0;
f1415824 143 dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL);
0655ad29 144
695f550b
VZ
145 // top-level sizerTop
146 wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
d2cdad17 147
dabbc6a5 148 m_msg = new wxStaticText(this, wxID_ANY, message);
695f550b 149 sizerTop->Add(m_msg, 0, wxLEFT | wxTOP, 2*LAYOUT_MARGIN);
0655ad29 150
0655ad29
VZ
151 if ( maximum > 0 )
152 {
ecda9475 153 int gauge_style = wxGA_HORIZONTAL;
695f550b 154 if ( style & wxPD_SMOOTH )
ecda9475 155 gauge_style |= wxGA_SMOOTH;
695f550b
VZ
156 m_gauge = new wxGauge
157 (
158 this,
159 wxID_ANY,
160 m_maximum,
161 wxDefaultPosition,
162 // make the progress bar sufficiently long
163 wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1),
164 gauge_style
165 );
166
167 sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN);
0655ad29 168 m_gauge->SetValue(0);
0655ad29
VZ
169 }
170 else
695f550b
VZ
171 {
172 m_gauge = NULL;
173 }
0655ad29
VZ
174
175 // create the estimated/remaining/total time zones if requested
695f550b
VZ
176 m_elapsed =
177 m_estimated =
178 m_remaining = NULL;
179 m_display_estimated =
180 m_last_timeupdate =
181 m_break = 0;
2c5ef4e2 182 m_ctdelay = 0;
0655ad29 183
8d6854a6
VZ
184 // also count how many labels we really have
185 size_t nTimeLabels = 0;
186
695f550b
VZ
187 wxSizer * const sizerLabels = new wxFlexGridSizer(2);
188
0655ad29
VZ
189 if ( style & wxPD_ELAPSED_TIME )
190 {
191 nTimeLabels++;
192
695f550b 193 m_elapsed = CreateLabel(_("Elapsed time:"), sizerLabels);
0655ad29
VZ
194 }
195
196 if ( style & wxPD_ESTIMATED_TIME )
197 {
198 nTimeLabels++;
199
695f550b 200 m_estimated = CreateLabel(_("Estimated time:"), sizerLabels);
0655ad29
VZ
201 }
202
203 if ( style & wxPD_REMAINING_TIME )
204 {
205 nTimeLabels++;
206
695f550b 207 m_remaining = CreateLabel(_("Remaining time:"), sizerLabels);
0655ad29 208 }
695f550b 209 sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN);
0655ad29
VZ
210
211 if ( nTimeLabels > 0 )
212 {
213 // set it to the current time
214 m_timeStart = wxGetCurrentTime();
0655ad29
VZ
215 }
216
d2cdad17 217#if defined(__SMARTPHONE__)
69c69546 218 if ( m_hasSkipButton )
ecda9475 219 SetRightMenu(wxID_SKIP, _("Skip"));
69c69546 220 if ( m_hasAbortButton )
ecda9475 221 SetLeftMenu(wxID_CANCEL);
d2cdad17 222#else
695f550b
VZ
223 m_btnAbort =
224 m_btnSkip = NULL;
225
ecda9475 226 wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
0655ad29 227
695f550b 228 // Windows dialogs usually have buttons in the lower right corner
3786ce5a 229 const int sizerFlags =
94640e04 230#if defined(__WXMSW__) || defined(__WXPM__)
ecda9475 231 wxALIGN_RIGHT | wxALL
0655ad29 232#else // !MSW
ecda9475 233 wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP
0655ad29 234#endif // MSW/!MSW
ecda9475
WS
235 ;
236
69c69546 237 if ( m_hasSkipButton )
ecda9475 238 {
695f550b 239 m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip"));
ecda9475 240
ecda9475 241 buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN);
0655ad29 242 }
ecda9475 243
69c69546 244 if ( m_hasAbortButton )
e269a9be 245 {
ecda9475
WS
246 m_btnAbort = new wxButton(this, wxID_CANCEL);
247
ecda9475 248 buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN);
e269a9be 249 }
0655ad29 250
695f550b 251 sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN );
ecda9475
WS
252#endif // __SMARTPHONE__/!__SMARTPHONE__
253
695f550b 254 SetSizerAndFit(sizerTop);
0655ad29
VZ
255
256 Centre(wxCENTER_FRAME | wxBOTH);
257
cbc66a27 258 if ( style & wxPD_APP_MODAL )
0655ad29 259 {
cbc66a27 260 m_winDisabler = new wxWindowDisabler(this);
0655ad29
VZ
261 }
262 else
263 {
cbc66a27 264 if ( m_parentTop )
dabbc6a5 265 m_parentTop->Disable();
cbc66a27 266 m_winDisabler = NULL;
0655ad29
VZ
267 }
268
dabbc6a5
DS
269 Show();
270 Enable();
33961d59 271
70f3fad6
VZ
272 // this one can be initialized even if the others are unknown for now
273 //
274 // NB: do it after calling Layout() to keep the labels correctly aligned
275 if ( m_elapsed )
276 {
277 SetTimeLabel(0, m_elapsed);
278 }
279
f89d65ea 280 Update();
8fa2e6a2
KB
281}
282
695f550b
VZ
283wxStaticText *
284wxProgressDialog::CreateLabel(const wxString& text, wxSizer *sizer)
0655ad29 285{
695f550b
VZ
286 wxStaticText *label = new wxStaticText(this, wxID_ANY, text);
287 wxStaticText *value = new wxStaticText(this, wxID_ANY, _("unknown"));
0655ad29 288
d2cdad17
WS
289 // select placement most native or nice on target GUI
290#if defined(__SMARTPHONE__)
695f550b
VZ
291 // value and time to the left in two rows
292 sizer->Add(label, 1, wxALIGN_LEFT);
293 sizer->Add(value, 1, wxALIGN_LEFT);
fe8635a7 294#elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXGTK20__)
695f550b
VZ
295 // value and time centered in one row
296 sizer->Add(label, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT) | wxTOP | wxRIGHT, LAYOUT_MARGIN);
297 sizer->Add(value, 1, wxALIGN_LEFT | wxTOP, LAYOUT_MARGIN);
d2cdad17 298#else
695f550b
VZ
299 // value and time to the right in one row
300 sizer->Add(label);
301 sizer->Add(value, 0, wxLEFT, LAYOUT_MARGIN);
d2cdad17 302#endif
0655ad29 303
695f550b 304 return value;
0655ad29 305}
8fa2e6a2 306
db1a42b8
VZ
307// ----------------------------------------------------------------------------
308// wxProgressDialog operations
309// ----------------------------------------------------------------------------
310
8fa2e6a2 311bool
ecda9475 312wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
8fa2e6a2 313{
abceee76 314 wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
7c349adb
VZ
315
316#ifdef __WXMSW__
317 value /= m_factor;
318#endif // __WXMSW__
319
abceee76
VZ
320 wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
321
c4c6ada9
VZ
322 if ( m_gauge )
323 m_gauge->SetValue(value);
abceee76 324
fe8635a7 325 UpdateMessage(newmsg);
abceee76
VZ
326
327 if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
328 {
329 unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
2c5ef4e2
VZ
330 if ( m_last_timeupdate < elapsed
331 || value == m_maximum
332 )
333 {
334 m_last_timeupdate = elapsed;
335 unsigned long estimated = m_break +
336 (unsigned long)(( (double) (elapsed-m_break) * m_maximum ) / ((double)value)) ;
337 if ( estimated > m_display_estimated
338 && m_ctdelay >= 0
339 )
340 {
341 ++m_ctdelay;
342 }
343 else if ( estimated < m_display_estimated
344 && m_ctdelay <= 0
345 )
346 {
347 --m_ctdelay;
348 }
349 else
350 {
351 m_ctdelay = 0;
352 }
353 if ( m_ctdelay >= m_delay // enough confirmations for a higher value
354 || m_ctdelay <= (m_delay*-1) // enough confirmations for a lower value
355 || value == m_maximum // to stay consistent
356 || elapsed > m_display_estimated // to stay consistent
357 || ( elapsed > 0 && elapsed < 4 ) // additional updates in the beginning
358 )
359 {
360 m_display_estimated = estimated;
361 m_ctdelay = 0;
362 }
363 }
364
ce07cd8a 365 long display_remaining = m_display_estimated - elapsed;
2c5ef4e2
VZ
366 if ( display_remaining < 0 )
367 {
368 display_remaining = 0;
369 }
abceee76
VZ
370
371 SetTimeLabel(elapsed, m_elapsed);
2c5ef4e2
VZ
372 SetTimeLabel(m_display_estimated, m_estimated);
373 SetTimeLabel(display_remaining, m_remaining);
abceee76
VZ
374 }
375
ff095200 376 if ( value == m_maximum )
abceee76 377 {
837adaa9
VZ
378 if ( m_state == Finished )
379 {
380 // ignore multiple calls to Update(m_maximum): it may sometimes be
381 // troublesome to ensure that Update() is not called twice with the
382 // same value (e.g. because of the rounding errors) and if we don't
383 // return now we're going to generate asserts below
384 return true;
385 }
386
dabbc6a5 387 // so that we return true below and that out [Cancel] handler knew what
1c79904b
MB
388 // to do
389 m_state = Finished;
390 if( !(GetWindowStyle() & wxPD_AUTO_HIDE) )
abceee76 391 {
69c69546
WS
392 EnableClose();
393 DisableSkip();
cff7ef89 394#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
69c69546 395 EnableCloseButton();
c4d305b7 396#endif // __WXMSW__
abceee76 397
60ad766e 398 if ( newmsg.empty() )
1c79904b
MB
399 {
400 // also provide the finishing message if the application didn't
401 m_msg->SetLabel(_("Done."));
402 }
abceee76 403
822fc380 404 wxYieldIfNeeded() ;
ff095200 405
1c79904b
MB
406 (void)ShowModal();
407 }
ff095200 408 else // auto hide
1c79904b 409 {
ff095200
VZ
410 // reenable other windows before hiding this one because otherwise
411 // Windows wouldn't give the focus back to the window which had
412 // been previously focused because it would still be disabled
1c79904b 413 ReenableOtherWindows();
ff095200
VZ
414
415 Hide();
1c79904b 416 }
abceee76 417 }
f4aa7ec3 418 else // not at maximum yet
abceee76 419 {
f4aa7ec3 420 return DoAfterUpdate(skip);
abceee76 421 }
1b6452df 422
1d1c3a9f 423 // update the display in case yielding above didn't do it
f89d65ea 424 Update();
0655ad29 425
abceee76 426 return m_state != Canceled;
8fa2e6a2
KB
427}
428
f4aa7ec3 429bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip)
fe8635a7
RR
430{
431 wxASSERT_MSG( m_gauge, wxT("cannot update non existent dialog") );
432
433 // show a bit of progress
434 m_gauge->Pulse();
435
436 UpdateMessage(newmsg);
437
438 if (m_elapsed || m_remaining || m_estimated)
439 {
440 unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
441
442 SetTimeLabel(elapsed, m_elapsed);
443 SetTimeLabel((unsigned long)-1, m_estimated);
444 SetTimeLabel((unsigned long)-1, m_remaining);
445 }
446
f4aa7ec3
VZ
447 return DoAfterUpdate(skip);
448}
449
450bool wxProgressDialog::DoAfterUpdate(bool *skip)
451{
fe8635a7
RR
452 // we have to yield because not only we want to update the display but
453 // also to process the clicks on the cancel and skip buttons
f4aa7ec3
VZ
454 wxYieldIfNeeded();
455
456 Update();
fe8635a7 457
f4aa7ec3 458 if ( m_skip && skip && !*skip )
fe8635a7
RR
459 {
460 *skip = true;
461 m_skip = false;
462 EnableSkip();
463 }
464
465 return m_state != Canceled;
466}
467
db1a42b8
VZ
468void wxProgressDialog::Resume()
469{
470 m_state = Continue;
2c5ef4e2
VZ
471 m_ctdelay = m_delay; // force an update of the elapsed/estimated/remaining time
472 m_break += wxGetCurrentTime()-m_timeStop;
db1a42b8 473
69c69546
WS
474 EnableAbort();
475 EnableSkip();
ecda9475 476 m_skip = false;
db1a42b8
VZ
477}
478
7d1dcec2
JS
479bool wxProgressDialog::Show( bool show )
480{
481 // reenable other windows before hiding this one because otherwise
482 // Windows wouldn't give the focus back to the window which had
483 // been previously focused because it would still be disabled
484 if(!show)
485 ReenableOtherWindows();
486
487 return wxDialog::Show(show);
488}
489
af237ae4
FM
490int wxProgressDialog::GetValue() const
491{
492 if (m_gauge)
493 return m_gauge->GetValue();
494 return wxNOT_FOUND;
495}
496
497int wxProgressDialog::GetRange() const
498{
499 if (m_gauge)
500 return m_gauge->GetRange();
501 return wxNOT_FOUND;
502}
503
504wxString wxProgressDialog::GetMessage() const
505{
506 return m_msg->GetLabel();
507}
508
0655ad29
VZ
509// ----------------------------------------------------------------------------
510// event handlers
511// ----------------------------------------------------------------------------
512
513void wxProgressDialog::OnCancel(wxCommandEvent& event)
514{
515 if ( m_state == Finished )
516 {
517 // this means that the count down is already finished and we're being
518 // shown as a modal dialog - so just let the default handler do the job
519 event.Skip();
520 }
521 else
522 {
523 // request to cancel was received, the next time Update() is called we
524 // will handle it
525 m_state = Canceled;
1b6452df 526
69c69546 527 // update the buttons state immediately so that the user knows that the
1b6452df 528 // request has been noticed
69c69546
WS
529 DisableAbort();
530 DisableSkip();
2c5ef4e2
VZ
531
532 // save the time when the dialog was stopped
533 m_timeStop = wxGetCurrentTime();
0655ad29
VZ
534 }
535}
536
ecda9475
WS
537void wxProgressDialog::OnSkip(wxCommandEvent& WXUNUSED(event))
538{
69c69546 539 DisableSkip();
ecda9475
WS
540 m_skip = true;
541}
542
8fa2e6a2
KB
543void wxProgressDialog::OnClose(wxCloseEvent& event)
544{
0655ad29 545 if ( m_state == Uncancelable )
abceee76
VZ
546 {
547 // can't close this dialog
dabbc6a5 548 event.Veto();
abceee76
VZ
549 }
550 else if ( m_state == Finished )
551 {
552 // let the default handler close the window as we already terminated
553 event.Skip();
554 }
0655ad29 555 else
abceee76
VZ
556 {
557 // next Update() will notice it
0655ad29 558 m_state = Canceled;
69c69546
WS
559 DisableAbort();
560 DisableSkip();
ecda9475 561
2c5ef4e2 562 m_timeStop = wxGetCurrentTime();
abceee76 563 }
8fa2e6a2
KB
564}
565
0655ad29
VZ
566// ----------------------------------------------------------------------------
567// destruction
568// ----------------------------------------------------------------------------
8fa2e6a2
KB
569
570wxProgressDialog::~wxProgressDialog()
ef8698d6
VZ
571{
572 // normally this should have been already done, but just in case
573 ReenableOtherWindows();
574}
575
576void wxProgressDialog::ReenableOtherWindows()
8fa2e6a2 577{
cbc66a27 578 if ( GetWindowStyle() & wxPD_APP_MODAL )
0655ad29 579 {
cbc66a27 580 delete m_winDisabler;
ef8698d6 581 m_winDisabler = (wxWindowDisabler *)NULL;
0655ad29
VZ
582 }
583 else
584 {
cbc66a27 585 if ( m_parentTop )
dabbc6a5 586 m_parentTop->Enable();
0655ad29 587 }
8fa2e6a2 588}
ce4169a4 589
0655ad29
VZ
590// ----------------------------------------------------------------------------
591// private functions
592// ----------------------------------------------------------------------------
593
594static void SetTimeLabel(unsigned long val, wxStaticText *label)
595{
596 if ( label )
597 {
598 wxString s;
fe8635a7
RR
599
600 if (val != (unsigned long)-1)
601 {
0655ad29
VZ
602 unsigned long hours = val / 3600;
603 unsigned long minutes = (val % 3600) / 60;
604 unsigned long seconds = val % 60;
223d09f6 605 s.Printf(wxT("%lu:%02lu:%02lu"), hours, minutes, seconds);
fe8635a7
RR
606 }
607 else
608 {
609 s = _("Unknown");
610 }
0655ad29
VZ
611
612 if ( s != label->GetLabel() )
613 label->SetLabel(s);
614 }
615}
616
69c69546
WS
617void wxProgressDialog::EnableSkip(bool enable)
618{
619 if(m_hasSkipButton)
620 {
621#ifdef __SMARTPHONE__
622 if(enable)
623 SetRightMenu(wxID_SKIP, _("Skip"));
624 else
625 SetRightMenu();
626#else
627 if(m_btnSkip)
628 m_btnSkip->Enable(enable);
629#endif
630 }
631}
632
633void wxProgressDialog::EnableAbort(bool enable)
634{
635 if(m_hasAbortButton)
636 {
637#ifdef __SMARTPHONE__
638 if(enable)
9a2256da 639 SetLeftMenu(wxID_CANCEL); // stock buttons makes Cancel label
69c69546
WS
640 else
641 SetLeftMenu();
642#else
643 if(m_btnAbort)
644 m_btnAbort->Enable(enable);
645#endif
646 }
647}
648
649void wxProgressDialog::EnableClose()
650{
651 if(m_hasAbortButton)
652 {
653#ifdef __SMARTPHONE__
654 SetLeftMenu(wxID_CANCEL, _("Close"));
655#else
656 if(m_btnAbort)
657 {
658 m_btnAbort->Enable();
659 m_btnAbort->SetLabel(_("Close"));
660 }
661#endif
662 }
663}
664
fe8635a7
RR
665void wxProgressDialog::UpdateMessage(const wxString &newmsg)
666{
667 if ( !newmsg.empty() && newmsg != m_msg->GetLabel() )
668 {
669 m_msg->SetLabel(newmsg);
670
c0b25bb2
FM
671 Fit(); // adapt to the new label size
672
fe8635a7
RR
673 wxYieldIfNeeded() ;
674 }
675}
676
0655ad29 677#endif // wxUSE_PROGRESSDLG