static wxString GetRemainingLabel() { return _("Remaining time:"); }
+ // Similar to wxWindow::HasFlag() but tests for a presence of a wxPD_XXX
+ // flag in our (separate) flags instead of using m_windowStyle.
+ bool HasPDFlag(int flag) const { return (m_pdStyle & flag) != 0; }
+
+ // Return the progress dialog style. Prefer to use HasPDFlag() if possible.
+ int GetPDStyle() const { return m_pdStyle; }
+
+
// Updates estimated times from a given progress bar value and stores the
// results in provided arguments.
void UpdateTimeEstimates(int value,
// parent top level window (may be NULL)
wxWindow *m_parentTop;
+ // Progress dialog styles: this is not the same as m_windowStyle because
+ // wxPD_XXX constants clash with the existing TLW styles so to be sure we
+ // don't have any conflicts we just use a separate variable for storing
+ // them.
+ int m_pdStyle;
+
// skip some portion
bool m_skip;
int m_ctdelay;
unsigned long m_display_estimated;
- bool m_hasAbortButton,
- m_hasSkipButton;
-
// for wxPD_APP_MODAL case
wxWindowDisabler *m_winDisabler;
// we may disappear at any moment, let the others know about it
SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);
- m_windowStyle |= style;
+ m_pdStyle = style;
m_parentTop = wxGetTopLevelParent(parent);
m_delay = 3;
- m_hasAbortButton =
- m_hasSkipButton = false;
-
m_winDisabler = NULL;
m_tempEventLoop = NULL;
}
wxEventLoop::SetActive(m_tempEventLoop);
}
- m_hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
- m_hasSkipButton = (style & wxPD_CAN_SKIP) != 0;
-
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
// we have to remove the "Close" button from the title bar then as it is
// confusing to have it - it doesn't work anyhow
//
// FIXME: should probably have a (extended?) window style for this
- if ( !m_hasAbortButton )
+ if ( !HasPDFlag(wxPD_CAN_ABORT) )
{
EnableCloseButton(false);
}
SetLeftMenu();
#endif
- m_state = m_hasAbortButton ? Continue : Uncancelable;
+ m_state = HasPDFlag(wxPD_CAN_ABORT) ? Continue : Uncancelable;
// top-level sizerTop
wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN);
#if defined(__SMARTPHONE__)
- if ( m_hasSkipButton )
+ if ( HasPDFlag(wxPD_CAN_SKIP) )
SetRightMenu(wxID_SKIP, _("Skip"));
- if ( m_hasAbortButton )
+ if ( HasPDFlag(wxPD_CAN_ABORT) )
SetLeftMenu(wxID_CANCEL);
#else
m_btnAbort =
#endif // MSW/!MSW
;
- if ( m_hasSkipButton )
+ if ( HasPDFlag(wxPD_CAN_SKIP) )
{
m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip"));
buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN);
}
- if ( m_hasAbortButton )
+ if ( HasPDFlag(wxPD_CAN_ABORT) )
{
m_btnAbort = new wxButton(this, wxID_CANCEL);
buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN);
}
- if (!m_hasSkipButton && !m_hasAbortButton)
+ if ( !HasPDFlag(wxPD_CAN_SKIP | wxPD_CAN_ABORT) )
buttonSizer->AddSpacer(LAYOUT_MARGIN);
sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN );
// so that we return true below and that out [Cancel] handler knew what
// to do
m_state = Finished;
- if( !HasFlag(wxPD_AUTO_HIDE) )
+ if( !HasPDFlag(wxPD_AUTO_HIDE) )
{
EnableClose();
DisableSkip();
bool wxGenericProgressDialog::WasCancelled() const
{
- return m_hasAbortButton && m_state == Canceled;
+ return HasPDFlag(wxPD_CAN_ABORT) && m_state == Canceled;
}
bool wxGenericProgressDialog::WasSkipped() const
{
- return m_hasSkipButton && m_skip;
+ return HasPDFlag(wxPD_CAN_SKIP) && m_skip;
}
// static
void wxGenericProgressDialog::DisableOtherWindows()
{
- if ( HasFlag(wxPD_APP_MODAL) )
+ if ( HasPDFlag(wxPD_APP_MODAL) )
{
m_winDisabler = new wxWindowDisabler(this);
}
void wxGenericProgressDialog::ReenableOtherWindows()
{
- if ( HasFlag(wxPD_APP_MODAL) )
+ if ( HasPDFlag(wxPD_APP_MODAL) )
{
wxDELETE(m_winDisabler);
}
void wxGenericProgressDialog::EnableSkip(bool enable)
{
- if(m_hasSkipButton)
+ if ( HasPDFlag(wxPD_CAN_SKIP) )
{
#ifdef __SMARTPHONE__
if(enable)
void wxGenericProgressDialog::EnableAbort(bool enable)
{
- if(m_hasAbortButton)
+ if( HasPDFlag(wxPD_CAN_ABORT) )
{
#ifdef __SMARTPHONE__
if(enable)
void wxGenericProgressDialog::EnableClose()
{
- if(m_hasAbortButton)
+ if(HasPDFlag(wxPD_CAN_ABORT))
{
#ifdef __SMARTPHONE__
SetLeftMenu(wxID_CANCEL, _("Close"));
namespace
{
+// This function returns true if the progress dialog with the given style
+// (combination of wxPD_XXX constants) needs the "Close" button and this button
+// only, i.e. not a "Cancel" one.
bool UsesCloseButtonOnly(long style)
{
- return !((style & wxPD_CAN_ABORT) || (style & wxPD_AUTO_HIDE));
+ return !(style & (wxPD_CAN_ABORT | wxPD_AUTO_HIDE));
}
BOOL CALLBACK DisplayCloseButton(HWND hwnd, LPARAM lParam)
m_state = Finished;
m_sharedData->m_state = Finished;
m_sharedData->m_notifications |= wxSPDD_FINISHED;
- if( !HasFlag(wxPD_AUTO_HIDE) && newmsg.empty() )
+ if( !HasPDFlag(wxPD_AUTO_HIDE) && newmsg.empty() )
{
// Provide the finishing message if the application didn't.
m_message = _("Done.");
// it now.
m_sharedData->m_notifications |= wxSPDD_ENABLE_SKIP;
- if ( !UsesCloseButtonOnly(m_windowStyle) )
+ if ( !UsesCloseButtonOnly(GetPDStyle()) )
m_sharedData->m_notifications |= wxSPDD_ENABLE_ABORT;
hwnd = m_sharedData->m_hwnd;
m_sharedData->m_message = m_message;
m_sharedData->m_range = m_maximum;
m_sharedData->m_state = Uncancelable;
- m_sharedData->m_style = m_windowStyle;
+ m_sharedData->m_style = GetPDStyle();
- if ( HasFlag(wxPD_CAN_ABORT) )
+ if ( HasPDFlag(wxPD_CAN_ABORT) )
{
m_sharedData->m_state = Continue;
m_sharedData->m_labelCancel = _("Cancel");
}
- else if ( !HasFlag(wxPD_AUTO_HIDE) )
+ else if ( !HasPDFlag(wxPD_AUTO_HIDE) )
{
m_sharedData->m_labelCancel = _("Close");
}
- if ( m_windowStyle & (wxPD_ELAPSED_TIME
- | wxPD_ESTIMATED_TIME
- | wxPD_REMAINING_TIME) )
+ if ( HasPDFlag(wxPD_ELAPSED_TIME |
+ wxPD_ESTIMATED_TIME |
+ wxPD_REMAINING_TIME) )
{
// Use a non-empty string just to have the collapsible pane shown.
m_sharedData->m_expandedInformation = " ";
return false;
}
- if ( !HasFlag(wxPD_APP_MODAL) )
- {
- wxWindow * const parent = GetTopParent();
- if ( parent )
- {
- parent->Disable();
- }
- else
- {
- wxFAIL_MSG( "Progress dialog must have a valid parent if "
- "wxPD_APP_MODAL is not used." );
- }
- }
- //else: otherwise all windows will be disabled by m_taskDialogRunner
-
// Do not show the underlying dialog.
return false;
}
bool wxProgressDialog::HasNativeProgressDialog() const
{
#ifdef wxHAS_MSW_TASKDIALOG
- // For a native implementation task dialogs are required, which
- // also require at least one button to be present so the flags needs
- // to be checked as well to see if this is the case.
+ // Native task dialog, if available, can't be used without any buttons so
+ // we fall back to the generic one if none of "Skip", "Cancel" and "Close"
+ // buttons is used.
return HasNativeTaskDialog()
- && ((m_windowStyle & (wxPD_CAN_SKIP | wxPD_CAN_ABORT))
- || !(m_windowStyle & wxPD_AUTO_HIDE));
+ && (HasPDFlag(wxPD_CAN_SKIP | wxPD_CAN_ABORT) ||
+ !HasPDFlag(wxPD_AUTO_HIDE));
#else // !wxHAS_MSW_TASKDIALOG
// This shouldn't be even called in !wxHAS_MSW_TASKDIALOG case but as we
// still must define the function as returning something, return false.
wxString expandedInformation;
// Calculate the three different timing values.
- if ( m_windowStyle & wxPD_ELAPSED_TIME )
+ if ( HasPDFlag(wxPD_ELAPSED_TIME) )
{
expandedInformation << GetElapsedLabel()
<< " "
<< GetFormattedTime(elapsedTime);
}
- if ( m_windowStyle & wxPD_ESTIMATED_TIME )
+ if ( HasPDFlag(wxPD_ESTIMATED_TIME) )
{
if ( !expandedInformation.empty() )
expandedInformation += "\n";
<< GetFormattedTime(realEstimatedTime);
}
- if ( m_windowStyle & wxPD_REMAINING_TIME )
+ if ( HasPDFlag(wxPD_REMAINING_TIME) )
{
if ( !expandedInformation.empty() )
expandedInformation += "\n";