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
This commit is contained in:
Vadim Zeitlin
1999-05-27 13:22:37 +00:00
parent 6453876e12
commit be9abe3fd0
5 changed files with 48 additions and 13 deletions

View File

@@ -54,7 +54,7 @@ public:
/** Can be called to continue after the cancel button has been pressed, but /** 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 the program decided to continue the operation (e.g., user didn't
configrm it) confirm it)
*/ */
void Resume() { m_state = Continue; } void Resume() { m_state = Continue; }
@@ -78,8 +78,13 @@ private:
{ {
Uncancelable = -1, // dialog can't be canceled Uncancelable = -1, // dialog can't be canceled
Canceled, // can be cancelled and, in fact, was 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; } m_state;
/// the abort button (or NULL if none)
wxButton *m_btnAbort;
/// the maximum value
int m_maximum;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -1108,14 +1108,18 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
"An informative message", "An informative message",
max, // range max, // range
this, // parent this, // parent
FALSE, // modal wxPD_CAN_ABORT | wxPD_APP_MODAL);
TRUE); // has abort button
bool cont = TRUE; bool cont = TRUE;
for ( int i = 0; i < max && cont; i++ ) for ( int i = 0; i < max && cont; i++ )
{ {
wxSleep(1); 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!"); cont = dialog.Update(i, "Only a half left!");
} }

View File

@@ -57,6 +57,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
m_state = hasAbortButton ? Continue : Uncancelable; m_state = hasAbortButton ? Continue : Uncancelable;
m_disableParentOnly = (style & wxPD_APP_MODAL) == 0; m_disableParentOnly = (style & wxPD_APP_MODAL) == 0;
m_parent = parent; m_parent = parent;
m_maximum = maximum;
int height = 70; // FIXME arbitrary numbers int height = 70; // FIXME arbitrary numbers
if ( hasAbortButton ) if ( hasAbortButton )
@@ -87,21 +88,23 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
m_gauge->SetValue(0); m_gauge->SetValue(0);
} }
else else
m_gauge = NULL; m_gauge = (wxGauge *)NULL;
if ( hasAbortButton ) if ( hasAbortButton )
{ {
wxControl *ctrl = new wxButton(this, -1, _("Cancel")); m_btnAbort = new wxButton(this, -1, _("Cancel"));
c = new wxLayoutConstraints; c = new wxLayoutConstraints;
c->centreX.SameAs(this, wxCentreX); c->centreX.SameAs(this, wxCentreX);
if(m_gauge) if(m_gauge)
c->top.Below(m_gauge, 2*LAYOUT_Y_MARGIN); c->top.Below(m_gauge, 2*LAYOUT_Y_MARGIN);
else else
c->top.Below(ctrl, 2*LAYOUT_Y_MARGIN); c->top.Below(m_btnAbort, 2*LAYOUT_Y_MARGIN);
c->width.AsIs(); c->width.AsIs();
c->height.AsIs(); c->height.AsIs();
ctrl->SetConstraints(c); m_btnAbort->SetConstraints(c);
} }
else
m_btnAbort = (wxButton *)NULL;
SetAutoLayout(TRUE); SetAutoLayout(TRUE);
Show(TRUE); Show(TRUE);
@@ -120,13 +123,36 @@ bool
wxProgressDialog::Update(int value, const wxString& newmsg) wxProgressDialog::Update(int value, const wxString& newmsg)
{ {
wxASSERT_MSG( value == -1 || m_gauge, "can't update non existent dialog" ); wxASSERT_MSG( value == -1 || m_gauge, "can't update non existent dialog" );
wxASSERT_MSG( value < m_maximum, "invalid progress value" );
if( m_gauge ) if( m_gauge )
m_gauge->SetValue(value); m_gauge->SetValue(value + 1);
if( !newmsg.IsNull() ) if( !newmsg.IsEmpty() )
m_msg->SetLabel(newmsg); m_msg->SetLabel(newmsg);
wxYield(); 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; return m_state != Canceled;
} }

View File

@@ -62,7 +62,7 @@ wxDataFormat::wxDataFormat( const wxDataFormat &format )
m_type = format.GetType(); m_type = format.GetType();
m_id = format.GetId(); m_id = format.GetId();
m_hasAtom = TRUE; m_hasAtom = TRUE;
m_atom = format.GetAtom(); m_atom = ((wxDataFormat &)format).GetAtom(); // const_cast
} }
wxDataFormat::wxDataFormat( const GdkAtom atom ) wxDataFormat::wxDataFormat( const GdkAtom atom )

View File

@@ -62,7 +62,7 @@ wxDataFormat::wxDataFormat( const wxDataFormat &format )
m_type = format.GetType(); m_type = format.GetType();
m_id = format.GetId(); m_id = format.GetId();
m_hasAtom = TRUE; m_hasAtom = TRUE;
m_atom = format.GetAtom(); m_atom = ((wxDataFormat &)format).GetAtom(); // const_cast
} }
wxDataFormat::wxDataFormat( const GdkAtom atom ) wxDataFormat::wxDataFormat( const GdkAtom atom )