barber pole type progress bar
barber pole type progress bar
Anyone have code to create a progress dialog that shows a barber pole (or similar animated graphic) for when you dont know how long and operation might take?
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
Re: barber pole type progress bar
Sure enough, someone already implement just what you ask... Just check under the Code Dump section:bobmanc wrote:Anyone have code to create a progress dialog that shows a barber pole (or similar animated graphic) for when you dont know how long and operation might take?
http://forums.wxwidgets.org/viewtopic.php?t=3655
Regards
Back, just not as often
Windows Vista SP1, Ubuntu 8.04
MinGW 3.4.5, GCC 4.2.1
Code::Blocks
wxWidgets 2.8.9
Windows Vista SP1, Ubuntu 8.04
MinGW 3.4.5, GCC 4.2.1
Code::Blocks
wxWidgets 2.8.9
-
- wxWorld Domination!
- Posts: 1339
- Joined: Wed Aug 03, 2005 8:10 am
- Location: BANGALORE, INDIA
- Contact:
I had also quickly written one, its very poor, but shows you how to write your own custom one:
wxProgressBar.h
wxProgressBar.cpp
To use it:
Put this in the .h file:
Put this in the .cpp file:

wxProgressBar.h
Code: Select all
#pragma once
#include "stdwx.h"
class wxProgressBar : public wxControl
{
private:
//Start of Enum
enum
{
//GUI Enum Control ID Start
ID_CALL_TIMER = 1234,
//GUI Enum Control ID End
ID_DUMMY_VALUE_ //Dont Delete this DummyValue
};
//End of Enum
wxBitmap m_bitmap;
wxTimer* m_pCallTimer;
int nPos;
bool m_bAdd;
public:
wxProgressBar( wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = "Progress Bar");
virtual ~wxProgressBar(void);
private:
void OnPaint(wxPaintEvent & event);
void OnCallTimer(wxTimerEvent& WXUNUSED(event));
private:
DECLARE_EVENT_TABLE()
};
Code: Select all
#include "wxprogressbar.h"
BEGIN_EVENT_TABLE(wxProgressBar, wxControl)
EVT_PAINT(wxProgressBar::OnPaint)
EVT_TIMER(ID_CALL_TIMER, wxProgressBar::OnCallTimer)
END_EVENT_TABLE()
wxProgressBar::wxProgressBar( wxWindow* parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name)
{
wxControl::Create(parent, id, pos, size, style, validator, name);
m_bitmap = bitmap;
nPos = 0;
m_bAdd = true;
m_pCallTimer = new wxTimer(this, ID_CALL_TIMER);
m_pCallTimer->Start(350);
}
wxProgressBar::~wxProgressBar(void)
{
m_pCallTimer->Stop();
delete m_pCallTimer;
}
void wxProgressBar::OnCallTimer(wxTimerEvent& WXUNUSED(event))
{
wxSize appSize = this->GetSize();
if((nPos+m_bitmap.GetWidth()) > appSize.GetWidth())
m_bAdd = false;
else if((nPos-m_bitmap.GetWidth()) < 0)
m_bAdd = true;
if(m_bAdd)
nPos += m_bitmap.GetWidth();
else
nPos -= m_bitmap.GetWidth();
Refresh();
}
void wxProgressBar::OnPaint(wxPaintEvent & event)
{
wxPaintDC dc(this);
dc.DrawBitmap(m_bitmap, nPos, 0);
}
Put this in the .h file:
Code: Select all
wxProgressBar *m_pProgressBar;
enum
{
//GUI Enum Control ID Start
ID_WXPROGRESSBAR = 1000,
};
Code: Select all
m_pProgressBar = new wxProgressBar(this, ID_WXPROGRESSBAR, wxBitmap("res\\progressbar.png", wxBITMAP_TYPE_PNG), wxPoint(20, 40), wxSize(100, 22));
