summaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorleo2005-06-01 21:54:51 +0000
committerleo2005-06-01 21:54:51 +0000
commit4a9460797182054c981d7d2f3fdfb113dc74be9e (patch)
treebdc2bf9fd70edbb21af29cc49c23a20e74c9fcc4 /win
parent26885315bc07017948d54962b5d585b8bc666b24 (diff)
Automatically resize status bar panes to fit their text.
git-svn-id: http://svn.leocad.org/trunk@394 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win')
-rw-r--r--win/Mainfrm.cpp28
-rw-r--r--win/Mainfrm.h1
-rw-r--r--win/System.cpp20
3 files changed, 29 insertions, 20 deletions
diff --git a/win/Mainfrm.cpp b/win/Mainfrm.cpp
index 6ff0d44..195ad92 100644
--- a/win/Mainfrm.cpp
+++ b/win/Mainfrm.cpp
@@ -431,13 +431,39 @@ LONG CMainFrame::OnUpdateInfo(UINT lParam, LONG wParam)
char str[128];
float pos[3];
+
project->GetFocusPosition(pos);
sprintf (str, "X: %.2f Y: %.2f Z: %.2f", pos[0], pos[1], pos[2]);
- m_wndStatusBar.SetPaneText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_POSITION), str);
+
+ SetStatusBarPane(ID_INDICATOR_POSITION, str);
return TRUE;
}
+// Helper function change the text of a status bar pane and resize it.
+void CMainFrame::SetStatusBarPane(UINT ID, const char* Text)
+{
+ // Set the pane text.
+ int Index = m_wndStatusBar.CommandToIndex(ID);
+ m_wndStatusBar.SetPaneText(Index, Text);
+
+ // Resize the pane to fit the text.
+ UINT nID, nStyle; int cxWidth;
+ HFONT hFont = (HFONT)m_wndStatusBar.SendMessage(WM_GETFONT);
+ CClientDC dcScreen(NULL);
+ HGDIOBJ hOldFont = NULL;
+
+ if (hFont != NULL)
+ hOldFont = dcScreen.SelectObject(hFont);
+
+ m_wndStatusBar.GetPaneInfo(Index, nID, nStyle, cxWidth);
+ cxWidth = dcScreen.GetTextExtent(Text).cx;
+ m_wndStatusBar.SetPaneInfo(Index, nID, nStyle, cxWidth);
+
+ if (hOldFont != NULL)
+ dcScreen.SelectObject(hOldFont);
+}
+
LONG CMainFrame::OnPopupClose(UINT /*lParam*/, LONG /*wParam*/)
{
m_wndStatusBar.m_pPopup = NULL;
diff --git a/win/Mainfrm.h b/win/Mainfrm.h
index 2024c93..4566950 100644
--- a/win/Mainfrm.h
+++ b/win/Mainfrm.h
@@ -58,6 +58,7 @@ public:
CSplitterWnd m_wndSplitter;
void UpdateMenuAccelerators();
+ void SetStatusBarPane(UINT ID, const char* Text);
void SetStatusBarMessage(const char* Message)
{ m_strStatusBar = Message; }
diff --git a/win/System.cpp b/win/System.cpp
index 6d951ce..ec016fd 100644
--- a/win/System.cpp
+++ b/win/System.cpp
@@ -669,31 +669,13 @@ void SystemUpdateSnap(unsigned short MoveSnap, unsigned short RotateSnap)
{
// Status bar
char snap[256];
- CFrameWnd* pFrame = (CFrameWnd*)AfxGetMainWnd();
- CStatusBar* pStatusBar = (CStatusBar*)pFrame->GetControlBar(AFX_IDW_STATUS_BAR);
if (MoveSnap)
wsprintf(snap, " M: %d R: %d ", MoveSnap, RotateSnap);
else
wsprintf(snap, " M: /2 R: %d ", RotateSnap);
- int Index = pStatusBar->CommandToIndex(ID_INDICATOR_SNAP);
- pStatusBar->SetPaneText(Index, LPCSTR(snap));
-
- // Resize the pane to fit the text.
- UINT nID, nStyle; int cxWidth;
- HFONT hFont = (HFONT)pStatusBar->SendMessage(WM_GETFONT);
- CClientDC dcScreen(NULL);
- HGDIOBJ hOldFont = NULL;
- if (hFont != NULL)
- hOldFont = dcScreen.SelectObject(hFont);
-
- pStatusBar->GetPaneInfo(Index, nID, nStyle, cxWidth);
- cxWidth = dcScreen.GetTextExtent(snap).cx;
- pStatusBar->SetPaneInfo(Index, nID, nStyle, cxWidth);
-
- if (hOldFont != NULL)
- dcScreen.SelectObject(hOldFont);
+ ((CMainFrame*)AfxGetMainWnd())->SetStatusBarPane(ID_INDICATOR_SNAP, snap);
}
void SystemUpdatePaste(bool enable)