From: Vadim Zeitlin Date: Thu, 27 May 1999 13:22:37 +0000 (+0000) Subject: 1. warning in wxDataObject fixed X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/be9abe3fd0edec7215fa00aa158f7581da4df2fe 1. warning in wxDataObject fixed 2. wxProgressDialog got a new style flag and updated docs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2582 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/generic/progdlgg.h b/include/wx/generic/progdlgg.h index e839b7fe35..b8f0a09f59 100644 --- a/include/wx/generic/progdlgg.h +++ b/include/wx/generic/progdlgg.h @@ -54,7 +54,7 @@ public: /** Can be called to continue after the cancel button has been pressed, but the program decided to continue the operation (e.g., user didn't - configrm it) + confirm it) */ void Resume() { m_state = Continue; } @@ -78,8 +78,13 @@ private: { Uncancelable = -1, // dialog can't be canceled Canceled, // can be cancelled and, in fact, was - Continue // can be cancelled but wasn't + Continue, // can be cancelled but wasn't + Finished // finished, waiting to be removed from screen } m_state; + /// the abort button (or NULL if none) + wxButton *m_btnAbort; + /// the maximum value + int m_maximum; DECLARE_EVENT_TABLE() }; diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 0101824412..282a5ef86c 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -1108,14 +1108,18 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) ) "An informative message", max, // range this, // parent - FALSE, // modal - TRUE); // has abort button + wxPD_CAN_ABORT | wxPD_APP_MODAL); + bool cont = TRUE; for ( int i = 0; i < max && cont; i++ ) { wxSleep(1); - if ( i == max / 2 ) + if ( i == max - 1 ) + { + cont = dialog.Update(i, "That's all, folks!"); + } + else if ( i == max / 2 ) { cont = dialog.Update(i, "Only a half left!"); } diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index 73f15139db..e12b7f5616 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -57,6 +57,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title, m_state = hasAbortButton ? Continue : Uncancelable; m_disableParentOnly = (style & wxPD_APP_MODAL) == 0; m_parent = parent; + m_maximum = maximum; int height = 70; // FIXME arbitrary numbers if ( hasAbortButton ) @@ -87,21 +88,23 @@ wxProgressDialog::wxProgressDialog(wxString const &title, m_gauge->SetValue(0); } else - m_gauge = NULL; + m_gauge = (wxGauge *)NULL; if ( hasAbortButton ) { - wxControl *ctrl = new wxButton(this, -1, _("Cancel")); + m_btnAbort = new wxButton(this, -1, _("Cancel")); c = new wxLayoutConstraints; c->centreX.SameAs(this, wxCentreX); if(m_gauge) c->top.Below(m_gauge, 2*LAYOUT_Y_MARGIN); else - c->top.Below(ctrl, 2*LAYOUT_Y_MARGIN); + c->top.Below(m_btnAbort, 2*LAYOUT_Y_MARGIN); c->width.AsIs(); c->height.AsIs(); - ctrl->SetConstraints(c); + m_btnAbort->SetConstraints(c); } + else + m_btnAbort = (wxButton *)NULL; SetAutoLayout(TRUE); Show(TRUE); @@ -120,13 +123,36 @@ bool wxProgressDialog::Update(int value, const wxString& newmsg) { wxASSERT_MSG( value == -1 || m_gauge, "can't update non existent dialog" ); + wxASSERT_MSG( value < m_maximum, "invalid progress value" ); if( m_gauge ) - m_gauge->SetValue(value); - if( !newmsg.IsNull() ) + m_gauge->SetValue(value + 1); + if( !newmsg.IsEmpty() ) m_msg->SetLabel(newmsg); wxYield(); + if ( (value == m_maximum - 1) && !(GetWindowStyleFlag() & wxPD_AUTO_HIDE) ) + { + if ( m_btnAbort ) + { + // tell the user what he should do... + m_btnAbort->SetLabel(_("Close")); + } + + if ( !newmsg ) + { + // also provide the finishing message if the application didn't + m_msg->SetLabel(_("Done.")); + } + + m_state = Finished; + while ( m_state != Canceled ) // set from OnClose() + wxYield(); + + // so that we return TRUE below + m_state = Finished; + } + return m_state != Canceled; } diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index 41d6b4faa5..bb9e817c05 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -62,7 +62,7 @@ wxDataFormat::wxDataFormat( const wxDataFormat &format ) m_type = format.GetType(); m_id = format.GetId(); m_hasAtom = TRUE; - m_atom = format.GetAtom(); + m_atom = ((wxDataFormat &)format).GetAtom(); // const_cast } wxDataFormat::wxDataFormat( const GdkAtom atom ) diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index 41d6b4faa5..bb9e817c05 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -62,7 +62,7 @@ wxDataFormat::wxDataFormat( const wxDataFormat &format ) m_type = format.GetType(); m_id = format.GetId(); m_hasAtom = TRUE; - m_atom = format.GetAtom(); + m_atom = ((wxDataFormat &)format).GetAtom(); // const_cast } wxDataFormat::wxDataFormat( const GdkAtom atom )