summaryrefslogtreecommitdiff
path: root/win/cadbar.cpp
diff options
context:
space:
mode:
authorleo2003-09-18 16:50:52 +0000
committerleo2003-09-18 16:50:52 +0000
commit4bd07328df37f1bc8a16cdd77decf49467b6c4be (patch)
tree31c714fab1ece4cd75a3df66e10821a2a9394caf /win/cadbar.cpp
parent3df8b99fe7e3961006ab4cd4a3bdc33c7c2b7e51 (diff)
Added a progress bar for long operations.
git-svn-id: http://svn.leocad.org/trunk@349 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win/cadbar.cpp')
-rw-r--r--win/cadbar.cpp64
1 files changed, 63 insertions, 1 deletions
diff --git a/win/cadbar.cpp b/win/cadbar.cpp
index d40466d..80a1df3 100644
--- a/win/cadbar.cpp
+++ b/win/cadbar.cpp
@@ -13,10 +13,13 @@ static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
+#define ID_STATUS_PROGRESS 17234
+
BEGIN_MESSAGE_MAP(CCADStatusBar, CStatusBar)
//{{AFX_MSG_MAP(CCADStatusBar)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
+ ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -27,16 +30,32 @@ END_MESSAGE_MAP()
CCADStatusBar::CCADStatusBar()
{
m_pPopup = NULL;
+ m_nProgressWidth = 150;
+ m_bProgressVisible = FALSE;
}
CCADStatusBar::~CCADStatusBar()
{
+}
+
+BOOL CCADStatusBar::Create(CWnd *pParentWnd, DWORD dwStyle, UINT nID)
+{
+ // Default creation
+ BOOL bCreatedOK = CStatusBar::Create(pParentWnd,dwStyle,nID);
+
+ if (bCreatedOK)
+ {
+ // Also create the progress bar
+ m_Progress.Create(WS_CHILD | WS_EX_STATICEDGE | PBS_SMOOTH, CRect(0,0,m_nProgressWidth,10), this, ID_STATUS_PROGRESS);
+ }
+ return bCreatedOK;
}
void CCADStatusBar::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect rect;
+
GetItemRect(CommandToIndex(ID_INDICATOR_STEP), rect);
if (rect.PtInRect(point))
{
@@ -63,6 +82,49 @@ void CCADStatusBar::OnRButtonDown(UINT nFlags, CPoint point)
GetItemRect(CommandToIndex(ID_INDICATOR_STEP), rect);
if (rect.PtInRect(point))
AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_VIEW_STEP_CHOOSE);
-
+
CStatusBar::OnRButtonDown(nFlags, point);
}
+
+void CCADStatusBar::OnSize(UINT nType, int cx, int cy)
+{
+ CStatusBar::OnSize(nType, cx, cy);
+
+ if (m_bProgressVisible)
+ AdjustProgressBarPosition();
+}
+
+BOOL CCADStatusBar::ShowProgressBar(BOOL bShow)
+{
+ // Save old visible status
+ BOOL bOldVisible = m_bProgressVisible;
+
+ if ((bOldVisible != bShow) && ::IsWindow(m_Progress.m_hWnd))
+ {
+ // Show/hide
+ m_Progress.ShowWindow(bShow ? SW_SHOWNA : SW_HIDE);
+ m_bProgressVisible = bShow;
+
+ // If just shown, make sure it's in the right position
+ if (bShow)
+ {
+ AdjustProgressBarPosition();
+ RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
+ }
+ }
+
+ return bOldVisible;
+}
+
+void CCADStatusBar::AdjustProgressBarPosition()
+{
+ // Make sure the progress bar is created
+ if(!::IsWindow(m_Progress.m_hWnd))
+ return;
+
+ CRect Rect;
+ GetItemRect(0, Rect);
+ m_Progress.SetWindowPos(NULL, Rect.right - m_nProgressWidth, Rect.top,
+ m_nProgressWidth, Rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
+}
+