#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
-#define wxPD_ELAPSED_TIME 0x0008
-#define wxPD_ESTIMATED_TIME 0x0010
-#define wxPD_SMOOTH 0x0020
-#define wxPD_REMAINING_TIME 0x0040
-#define wxPD_CAN_SKIP 0x0080
-
/*
* extended dialog specifiers. these values are stored in a different
#define wxGA_PROGRESSBAR 0
#endif // WXWIN_COMPATIBILITY_2_6
+// GTK and Mac always have native implementation of the indeterminate mode
+// wxMSW has native implementation only if comctl32.dll >= 6.00
+#if !defined(__WXGTK20__) && !defined(__WXMAC__) && !defined(__WXCOCOA__)
+ #define wxGAUGE_EMULATE_INDETERMINATE_MODE 1
+#else
+ #define wxGAUGE_EMULATE_INDETERMINATE_MODE 0
+#endif
extern WXDLLEXPORT_DATA(const wxChar) wxGaugeNameStr[];
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxGaugeNameStr);
+ // determinate mode API
+
// set/get the control range
virtual void SetRange(int range);
virtual int GetRange() const;
- // position
virtual void SetValue(int pos);
virtual int GetValue() const;
+ // indeterminate mode API
+ virtual void Pulse();
+
// simple accessors
bool IsVertical() const { return HasFlag(wxGA_VERTICAL); }
-
// appearance params (not implemented for most ports)
virtual void SetShadowWidth(int w);
virtual int GetShadowWidth() const;
// the current position
int m_gaugePos;
+#if wxGAUGE_EMULATE_INDETERMINATE_MODE
+ int m_nDirection; // can be wxRIGHT or wxLEFT
+#endif
+
DECLARE_NO_COPY_CLASS(wxGaugeBase)
};
#define __PROGDLGH_G__
#include "wx/defs.h"
+#include "wx/progdlg.h"
#if wxUSE_PROGRESSDLG
@returns true if ABORT button has not been pressed
*/
virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
+
+ /* Switches the dialog to use a gauge in indeterminate mode and calls
+ wxGauge::Pulse() to show to the user a bit of progress */
+ virtual bool UpdatePulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
+
// Must provide overload to avoid hiding it (and warnings about it)
virtual void Update() { wxDialog::Update(); }
// as the next windows in the sizer, returns the created control
wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer);
+ // updates the label message
+ void UpdateMessage(const wxString &newmsg);
+
// shortcuts for enabling buttons
void EnableClose();
void EnableSkip(bool enable=true);
void SetShadowWidth( int WXUNUSED(w) ) { }
void SetBezelFace( int WXUNUSED(w) ) { }
- void SetRange( int r );
- void SetValue( int pos );
int GetShadowWidth() const { return 0; };
int GetBezelFace() const { return 0; };
+
+ // determinate mode API
+ void SetRange( int r );
+ void SetValue( int pos );
+
int GetRange() const;
int GetValue() const;
+ // indeterminate mode API
+ virtual void Pulse();
+
bool IsVertical() const { return HasFlag(wxGA_VERTICAL); }
static wxVisualAttributes
virtual void SetRange(int range);
virtual void SetValue(int pos);
virtual int GetValue() const ;
+
+ void Pulse();
+
protected:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxGauge)
};
int GetRange() const ;
int GetValue() const ;
+ void Pulse();
+
virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ;
protected:
#include "wx/defs.h"
+/*
+ * wxProgressDialog flags
+ */
+#define wxPD_CAN_ABORT 0x0001
+#define wxPD_APP_MODAL 0x0002
+#define wxPD_AUTO_HIDE 0x0004
+#define wxPD_ELAPSED_TIME 0x0008
+#define wxPD_ESTIMATED_TIME 0x0010
+#define wxPD_SMOOTH 0x0020
+#define wxPD_REMAINING_TIME 0x0040
+#define wxPD_CAN_SKIP 0x0080
+
+
#ifdef __WXPALMOS__
#include "wx/palmos/progdlg.h"
#else
SetRange(range);
SetValue(0);
+#if wxGAUGE_EMULATE_INDETERMINATE_MODE
+ m_nDirection = wxRIGHT;
+#endif
return true;
}
// ----------------------------------------------------------------------------
-// wxGauge range/position
+// wxGauge determinate mode range/position
// ----------------------------------------------------------------------------
void wxGaugeBase::SetRange(int range)
return m_gaugePos;
}
+// ----------------------------------------------------------------------------
+// wxGauge indeterminate mode
+// ----------------------------------------------------------------------------
+
+void wxGaugeBase::Pulse()
+{
+#if wxGAUGE_EMULATE_INDETERMINATE_MODE
+ // simulate indeterminate mode
+ int curr = GetValue(), max = GetRange();
+
+ if (m_nDirection == wxRIGHT)
+ {
+ if (curr < max)
+ SetValue(curr + 1);
+ else
+ {
+ SetValue(max - 1);
+ m_nDirection = wxLEFT;
+ }
+ }
+ else
+ {
+ if (curr > 0)
+ SetValue(curr - 1);
+ else
+ {
+ SetValue(1);
+ m_nDirection = wxRIGHT;
+ }
+ }
+#endif
+}
+
// ----------------------------------------------------------------------------
// wxGauge appearance params
// ----------------------------------------------------------------------------
#include "wx/settings.h"
#endif
-#include "wx/generic/progdlgg.h"
+#include "wx/progdlg.h"
// ---------------------------------------------------------------------------
// macros
locsizer->Add(dummy, 1, wxALIGN_LEFT);
locsizer->Add(label, 1, wxALIGN_LEFT);
sizer->Add(locsizer, 0, wxALIGN_LEFT | wxTOP | wxLEFT, LAYOUT_MARGIN);
-#elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__)
+#elif defined(__WXMSW__) || defined(__WXPM__) || defined(__WXMAC__) || defined(__WXGTK20__)
// label and time centered in one row
locsizer->Add(dummy, 1, wxLARGESMALL(wxALIGN_RIGHT,wxALIGN_LEFT));
locsizer->Add(label, 1, wxALIGN_LEFT | wxLEFT, LAYOUT_MARGIN);
m_gauge->SetValue(value == m_maximum ? value : value + 1);
}
- if ( !newmsg.empty() && newmsg != m_msg->GetLabel() )
- {
- m_msg->SetLabel(newmsg);
-
- wxYieldIfNeeded() ;
- }
+ UpdateMessage(newmsg);
if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
{
return m_state != Canceled;
}
+bool
+wxProgressDialog::UpdatePulse(const wxString& newmsg, bool *skip)
+{
+ wxASSERT_MSG( m_gauge, wxT("cannot update non existent dialog") );
+
+ // show a bit of progress
+ m_gauge->Pulse();
+
+ UpdateMessage(newmsg);
+
+ if (m_elapsed || m_remaining || m_estimated)
+ {
+ unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
+
+ SetTimeLabel(elapsed, m_elapsed);
+ SetTimeLabel((unsigned long)-1, m_estimated);
+ SetTimeLabel((unsigned long)-1, m_remaining);
+ }
+
+ // we have to yield because not only we want to update the display but
+ // also to process the clicks on the cancel and skip buttons
+ wxYieldIfNeeded() ;
+
+ if ( (m_skip) && (skip != NULL) && (*skip == false) )
+ {
+ *skip = true;
+ m_skip = false;
+ EnableSkip();
+ }
+
+ return m_state != Canceled;
+}
+
void wxProgressDialog::Resume()
{
m_state = Continue;
if ( label )
{
wxString s;
+
+ if (val != (unsigned long)-1)
+ {
unsigned long hours = val / 3600;
unsigned long minutes = (val % 3600) / 60;
unsigned long seconds = val % 60;
s.Printf(wxT("%lu:%02lu:%02lu"), hours, minutes, seconds);
+ }
+ else
+ {
+ s = _("Unknown");
+ }
if ( s != label->GetLabel() )
label->SetLabel(s);
}
}
+void wxProgressDialog::UpdateMessage(const wxString &newmsg)
+{
+ if ( !newmsg.empty() && newmsg != m_msg->GetLabel() )
+ {
+ m_msg->SetLabel(newmsg);
+
+ wxYieldIfNeeded() ;
+ }
+}
+
#endif // wxUSE_PROGRESSDLG
GTK_PROGRESS_BOTTOM_TO_TOP );
}
+ // when using the gauge in indeterminate mode, we need this:
+ gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR (m_widget), 0.05);
+
m_parent->DoAddChild( this );
PostCreation(size);
return m_gaugePos;
}
+void wxGauge::Pulse()
+{
+ gtk_progress_bar_pulse(GTK_PROGRESS_BAR (m_widget));
+}
+
wxVisualAttributes wxGauge::GetDefaultAttributes() const
{
// Visible gauge colours use a different colour state
return m_gaugePos ;
}
+void wxGauge::Pulse()
+{
+ if ( m_peer && m_peer->Ok() )
+ {
+ // need to use the animate() method of NSProgressIndicator Class here
+ }
+}
+
#endif // wxUSE_GAUGE
::SetControl32BitValue( (ControlHandle) m_macControl , m_gaugePos ) ;
}
+void wxGauge::Pulse()
+{
+ // need to use the animate() method of NSProgressIndicator Class here
+}
+
int wxGauge::GetShadowWidth() const
{
return 0;
#define PBM_SETBKCOLOR 0x2001
#endif
+#ifndef PBS_MARQUEE
+ #define PBS_MARQUEE 0x08
+#endif
+
+#ifndef PBM_SETMARQUEE
+ #define PBM_SETMARQUEE (WM_USER+10)
+#endif
+
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
SetRange(range);
+ // in case we need to emulate indeterminate mode...
+ m_nDirection = wxRIGHT;
+
return true;
}
void wxGauge95::SetRange(int r)
{
+ // switch to determinate mode if required
+ SetDeterminateMode();
+
m_rangeMax = r;
#ifdef PBM_SETRANGE32
void wxGauge95::SetValue(int pos)
{
+ // switch to determinate mode if required
+ SetDeterminateMode();
+
m_gaugePos = pos;
::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0);
return true;
}
+void wxGauge95::SetIndeterminateMode()
+{
+ // add the PBS_MARQUEE style to the progress bar
+ LONG style = ::GetWindowLong(GetHwnd(), GWL_STYLE);
+ if ((style & PBS_MARQUEE) == 0)
+ ::SetWindowLong(GetHwnd(), GWL_STYLE, style|PBS_MARQUEE);
+
+ // now the control can only run in indeterminate mode
+}
+
+void wxGauge95::SetDeterminateMode()
+{
+ // remove the PBS_MARQUEE style to the progress bar
+ LONG style = ::GetWindowLong(GetHwnd(), GWL_STYLE);
+ if ((style & PBS_MARQUEE) != 0)
+ ::SetWindowLong(GetHwnd(), GWL_STYLE, style & ~PBS_MARQUEE);
+
+ // now the control can only run in determinate mode
+}
+
+void wxGauge95::Pulse()
+{
+ if (wxApp::GetComCtl32Version() >= 600)
+ {
+ // switch to indeterminate mode if required
+ SetIndeterminateMode();
+
+ // NOTE: when in indeterminate mode, the PBM_SETPOS message will just make
+ // the bar's blocks move a bit and the WPARAM value is just ignored
+ // so that we can safely use zero
+ SendMessage(GetHwnd(), (UINT) PBM_SETPOS, (WPARAM)0, (LPARAM)0);
+ }
+ else
+ {
+ // emulate indeterminate mode
+ wxGaugeBase::Pulse();
+ }
+}
+
#endif // wxUSE_GAUGE