diff options
author | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2005-04-17 11:54:31 +0000 |
---|---|---|
committer | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2005-04-17 11:54:31 +0000 |
commit | 448fd3cc2d5532eaeb2f9e60e3cc9b4baf9a809b (patch) | |
tree | e6966f7350050f5febac21bf697f3f2af27b8312 /rfbplayer/ToolBar.cxx | |
parent | 01b119e2b11cab6bb845f42e2529df2e15fb2188 (diff) | |
download | tigervnc-448fd3cc2d5532eaeb2f9e60e3cc9b4baf9a809b.tar.gz tigervnc-448fd3cc2d5532eaeb2f9e60e3cc9b4baf9a809b.zip |
Added ToolBar::getButtonsWidth(), ToolBar::getButtonsHeight().
Modifed ToolBar::autoSize().
If toolbar has CCS_NORESIZE style, then autoSize() resizes toolbar itself
else it resizes by TB_AUTOSIZE message.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@291 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'rfbplayer/ToolBar.cxx')
-rw-r--r-- | rfbplayer/ToolBar.cxx | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/rfbplayer/ToolBar.cxx b/rfbplayer/ToolBar.cxx index c4808cc1..d92d5849 100644 --- a/rfbplayer/ToolBar.cxx +++ b/rfbplayer/ToolBar.cxx @@ -33,7 +33,8 @@ ToolBar::~ToolBar() { DestroyWindow(getHandle()); } -bool ToolBar::create(int _tbID, HWND parentHwnd, DWORD dwStyle) { +bool ToolBar::create(int _tbID, HWND _parentHwnd, DWORD dwStyle) { + parentHwnd = _parentHwnd; dwStyle |= WS_CHILD; // Create the ToolBar window @@ -124,6 +125,14 @@ int ToolBar::getButtonInfo(int idButton, TBBUTTONINFO *btnInfo) { return SendMessage(getHandle(), TB_GETBUTTONINFO, idButton, (LPARAM)btnInfo); } +int ToolBar::getButtonsHeight() { + return HIWORD(SendMessage(getHandle(), TB_GETBUTTONSIZE, 0, 0)); +} + +int ToolBar::getButtonsWidth() { + return LOWORD(SendMessage(getHandle(), TB_GETBUTTONSIZE, 0, 0)); +} + bool ToolBar::setButtonInfo(int idButton, TBBUTTONINFO* btnInfo) { assert(idButton >= 0); assert(btnInfo > 0); @@ -172,5 +181,21 @@ bool ToolBar::setButtonSize(int width, int height) { } void ToolBar::autoSize() { - SendMessage(getHandle(), TB_AUTOSIZE, 0, 0); + DWORD style = SendMessage(getHandle(), TB_GETSTYLE, 0, 0); + if (style & CCS_NORESIZE) { + RECT r, btnRect; + GetClientRect(parentHwnd, &r); + getButtonRect(0, &btnRect); + int height = getButtonsHeight() + btnRect.top * 2 + 1; + SetWindowPos(getHandle(), HWND_TOP, 0, 0, r.right - r.left, height, + SWP_NOMOVE); + } else { + SendMessage(getHandle(), TB_AUTOSIZE, 0, 0); + } +} + +int ToolBar::getHeight() { + RECT r; + GetWindowRect(getHandle(), &r); + return r.bottom - r.top + 1; } |