wxString GetId() const { return m_format.GetId(); }
// implement the base class pure virtuals
- virtual wxDataFormat GetPreferredFormat() const
+ virtual wxDataFormatId GetPreferredFormat() const
{ return m_format; }
virtual bool IsSupportedFormat(wxDataFormat format) const
{ return m_format == format; }
#define wxLI_HORIZONTAL wxHORIZONTAL
#define wxLI_VERTICAL wxVERTICAL
-
+/*
+ * wxProgressDialog flags
+ */
+#define wxPD_CAN_ABORT 0x0001
+#define wxPD_APP_MODAL 0x0002
+#define wxPD_AUTO_HIDE 0x0004
/*
* GDI descriptions
frames or parent frame to avoid recursion problems.
@param title title for window
@param message message to display in window
- @param maximum maximum value for status bar, if <= 0, no bar is shown
+ @param maximum value for status bar, if <= 0, no bar is shown
@param parent window or NULL
- @param disableParentOnly if true, only disable parent window's
- event handling
- @param abortButton if true, dialog will show an abort button
+ @param style is the bit mask of wxPD_XXX constants from wx/defs.h
*/
wxProgressDialog(const wxString &title, wxString const &message,
int maximum = 100,
wxWindow *parent = NULL,
- bool disableParentOnly = FALSE,
- bool abortButton = FALSE);
+ int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
/** Destructor.
Re-enables event handling for other windows.
*/
wxDataFormat( wxDataFormatId type );
wxDataFormat( const wxString &id );
wxDataFormat( const wxChar *id );
- wxDataFormat( wxDataFormat &format );
+ wxDataFormat( const wxDataFormat &format );
wxDataFormat( const GdkAtom atom );
void SetType( wxDataFormatId type );
GdkAtom GetAtom();
void SetAtom(GdkAtom atom) { m_hasAtom = TRUE; m_atom = atom; }
+ // implicit conversion to wxDataFormatId
+ operator wxDataFormatId() const { return m_type; }
+
+ bool operator==(wxDataFormatId type) const { return m_type == type; }
+ bool operator!=(wxDataFormatId type) const { return m_type != type; }
+
private:
wxDataFormatId m_type;
wxString m_id;
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
/* return preferrd/best supported format */
- virtual wxDataFormat &GetPreferredFormat() const;
+ virtual wxDataFormatId GetPreferredFormat() const;
/* search through m_dataObjects, return TRUE if found */
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
wxDataFormat( wxDataFormatId type );
wxDataFormat( const wxString &id );
wxDataFormat( const wxChar *id );
- wxDataFormat( wxDataFormat &format );
+ wxDataFormat( const wxDataFormat &format );
wxDataFormat( const GdkAtom atom );
void SetType( wxDataFormatId type );
GdkAtom GetAtom();
void SetAtom(GdkAtom atom) { m_hasAtom = TRUE; m_atom = atom; }
+ // implicit conversion to wxDataFormatId
+ operator wxDataFormatId() const { return m_type; }
+
+ bool operator==(wxDataFormatId type) const { return m_type == type; }
+ bool operator!=(wxDataFormatId type) const { return m_type != type; }
+
private:
wxDataFormatId m_type;
wxString m_id;
virtual wxDataFormat &GetNthFormat( size_t nth ) const;
/* return preferrd/best supported format */
- virtual wxDataFormat &GetPreferredFormat() const;
+ virtual wxDataFormatId GetPreferredFormat() const;
/* search through m_dataObjects, return TRUE if found */
virtual bool IsSupportedFormat( wxDataFormat &format ) const;
#include "icons/gauge.xpm"
#endif
+#ifdef __WIN16__
+ // Win16 doesn't have them
+ #undef wxUSE_SPINBUTTON
+ #define wxUSE_SPINBUTTON 0
+#endif // __WIN16__
+
+#include "wx/progdlg.h"
+
//----------------------------------------------------------------------
// class definitions
//----------------------------------------------------------------------
void OnPageChanged( wxNotebookEvent &event );
void OnPageChanging( wxNotebookEvent &event );
void OnSliderUpdate( wxCommandEvent &event );
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
void OnSpinUpdate( wxSpinEvent &event );
-#endif
+ void OnUpdateShowProgress( wxUpdateUIEvent& event );
+ void OnShowProgress( wxCommandEvent &event );
+#endif // wxUSE_SPINBUTTON
void OnPasteFromClipboard( wxCommandEvent &event );
void OnCopyToClipboard( wxCommandEvent &event );
void OnMoveToEndOfText( wxCommandEvent &event );
wxGauge *m_gauge;
wxSlider *m_slider;
wxButton *m_fontButton;
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
wxSpinButton *m_spinbutton;
+ wxButton *m_btnProgress;
#endif
wxTextCtrl *m_spintext;
MyTextCtrl *m_multitext;
const int ID_SLIDER = 181;
const int ID_SPIN = 182;
+const int ID_BTNPROGRESS = 183;
BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize)
EVT_CHECKBOX (ID_RADIOBOX_ENABLE, MyPanel::OnRadioButtons)
EVT_BUTTON (ID_SET_FONT, MyPanel::OnSetFont)
EVT_SLIDER (ID_SLIDER, MyPanel::OnSliderUpdate)
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
EVT_SPIN (ID_SPIN, MyPanel::OnSpinUpdate)
+EVT_UPDATE_UI (ID_BTNPROGRESS, MyPanel::OnUpdateShowProgress)
+EVT_BUTTON (ID_BTNPROGRESS, MyPanel::OnShowProgress)
#endif
EVT_BUTTON (ID_PASTE_TEXT, MyPanel::OnPasteFromClipboard)
EVT_BUTTON (ID_COPY_TEXT, MyPanel::OnCopyToClipboard)
);
#endif
m_spintext = new wxTextCtrl( panel, -1, "0", wxPoint(20,160), wxSize(80,-1) );
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,159), wxSize(-1,-1) );
m_spinbutton->SetRange(-10,30);
m_spinbutton->SetValue(-5);
+
+ m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, "Show progress dialog",
+ wxPoint(208, 159) );
#endif
m_notebook->AddPage(panel, "wxGauge", FALSE, Image_Gauge);
}
m_gauge->SetValue( m_slider->GetValue() );
}
-#ifndef __WIN16__
+#ifndef wxUSE_SPINBUTTON
void MyPanel::OnSpinUpdate( wxSpinEvent &event )
{
wxString value;
m_text->AppendText(value);
}
-#endif
+
+void MyPanel::OnUpdateShowProgress( wxUpdateUIEvent& event )
+{
+ event.Enable( m_spinbutton->GetValue() > 0 );
+}
+
+void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) )
+{
+ int max = m_spinbutton->GetValue();
+ wxProgressDialog dialog("Progress dialog example",
+ "An informative message",
+ max, // range
+ this, // parent
+ FALSE, // modal
+ TRUE); // has abort button
+
+ bool cont = TRUE;
+ for ( int i = 0; i < max && cont; i++ )
+ {
+ wxSleep(1);
+ if ( i == max / 2 )
+ {
+ cont = dialog.Update(i, "Only a half left!");
+ }
+ else
+ {
+ cont = dialog.Update(i);
+ }
+ }
+
+ if ( !cont )
+ {
+ *m_text << "Progress dialog aborted!\n";
+ }
+ else
+ {
+ *m_text << "Countdown from " << max << " finished.\n";
+ }
+}
+
+#endif // wxUSE_SPINBUTTON
MyPanel::~MyPanel()
{
// wxTextEntryDialog
#if !USE_SHARED_LIBRARY
-BEGIN_EVENT_TABLE(wxProgressDialog, wxFrame)
- EVT_BUTTON(-1, wxProgressDialog::OnCancel)
- EVT_CLOSE(wxProgressDialog::OnClose)
-END_EVENT_TABLE()
+ BEGIN_EVENT_TABLE(wxProgressDialog, wxFrame)
+ EVT_BUTTON(-1, wxProgressDialog::OnCancel)
+ EVT_CLOSE(wxProgressDialog::OnClose)
+ END_EVENT_TABLE()
- IMPLEMENT_CLASS(wxProgressDialog, wxFrame)
+ IMPLEMENT_CLASS(wxProgressDialog, wxFrame)
#endif
wxProgressDialog::wxProgressDialog(wxString const &title,
wxString const &message,
int maximum,
wxWindow *parent,
- bool parentOnly,
- bool abortButton)
+ int style)
{
- m_state = abortButton ? Continue : Uncancelable;
- m_disableParentOnly = parentOnly;
+ bool hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
+ m_state = hasAbortButton ? Continue : Uncancelable;
+ m_disableParentOnly = (style & wxPD_APP_MODAL) == 0;
m_parent = parent;
int height = 70; // FIXME arbitrary numbers
- if ( abortButton )
+ if ( hasAbortButton )
height += 35;
wxFrame::Create(m_parent, -1, title,
wxPoint(0, 0), wxSize(220, height),
c->height.AsIs();
m_msg->SetConstraints(c);
- if(maximum > 0)
+ if ( maximum > 0 )
{
m_gauge = new wxGauge(this, -1, maximum);
c = new wxLayoutConstraints;
else
m_gauge = NULL;
- if ( abortButton )
+ if ( hasAbortButton )
{
wxControl *ctrl = new wxButton(this, -1, _("Cancel"));
c = new wxLayoutConstraints;
Centre(wxCENTER_FRAME | wxBOTH);
if(m_disableParentOnly)
- m_parent->Enable(false);
+ m_parent->Enable(FALSE);
else
- wxEnableTopLevelWindows(false);
- Enable(true); // enable this window
+ wxEnableTopLevelWindows(FALSE);
+ Enable(TRUE); // enable this window
wxYield();
}
bool
wxProgressDialog::Update(int value, const wxString& newmsg)
{
- wxASSERT(value == -1 || m_gauge);
- if(m_gauge)
+ wxASSERT_MSG( value == -1 || m_gauge, "can't update non existent dialog" );
+
+ if( m_gauge )
m_gauge->SetValue(value);
- if(!newmsg.IsNull())
+ if( !newmsg.IsNull() )
m_msg->SetLabel(newmsg);
wxYield();
+
return m_state != Canceled;
}
wxProgressDialog::~wxProgressDialog()
{
- if(m_disableParentOnly)
- m_parent->Enable(true);
+ if ( m_disableParentOnly )
+ m_parent->Enable(TRUE);
else
- wxEnableTopLevelWindows(true);
+ wxEnableTopLevelWindows(TRUE);
}
SetId( id );
}
-wxDataFormat::wxDataFormat( wxDataFormat &format )
+wxDataFormat::wxDataFormat( const wxDataFormat &format )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
m_type = format.GetType();
return m_dataObjects.GetCount();
}
-wxDataFormat &wxDataBroker::GetPreferredFormat() const
+wxDataFormatId wxDataBroker::GetPreferredFormat() const
{
wxNode *node = m_dataObjects.Nth( m_preferred );
wxDataObject* data_obj = (wxDataObject*)node->Data();
- return data_obj->GetFormat();
+ return data_obj->GetFormat().GetType();
}
wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const
SetId( id );
}
-wxDataFormat::wxDataFormat( wxDataFormat &format )
+wxDataFormat::wxDataFormat( const wxDataFormat &format )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
m_type = format.GetType();
return m_dataObjects.GetCount();
}
-wxDataFormat &wxDataBroker::GetPreferredFormat() const
+wxDataFormatId wxDataBroker::GetPreferredFormat() const
{
wxNode *node = m_dataObjects.Nth( m_preferred );
wxDataObject* data_obj = (wxDataObject*)node->Data();
- return data_obj->GetFormat();
+ return data_obj->GetFormat().GetType();
}
wxDataFormat &wxDataBroker::GetNthFormat( size_t nth ) const