Update of /cvsroot/htoolkit/port/src/cbits/Win32
In directory sc8-pr-cvs1:/tmp/cvs-serv9714/src/cbits/Win32
Modified Files:
ToolBar.c
Log Message:
Support for destroyToolbar and destroyToolItem
Index: ToolBar.c
===================================================================
RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ToolBar.c 10 Aug 2003 18:36:04 -0000 1.4
--- ToolBar.c 11 Aug 2003 17:28:38 -0000 1.5
***************
*** 2,5 ****
--- 2,6 ----
#include "ControlBar.h"
#include "Internals.h"
+ #include "Handlers_stub.h"
#include <windowsx.h>
***************
*** 134,138 ****
TBBUTTON button;
! // now hit test against CToolBar buttons
nButtons = (int) SendMessage(hToolBar, TB_BUTTONCOUNT, 0, 0);
for (i = 0; i < nButtons; i++)
--- 135,139 ----
TBBUTTON button;
! // now hit test against toolbar buttons
nButtons = (int) SendMessage(hToolBar, TB_BUTTONCOUNT, 0, 0);
for (i = 0; i < nButtons; i++)
***************
*** 194,198 ****
}
-
////////////////////////////////////////////
// The DockContext
--- 195,198 ----
***************
*** 484,488 ****
rect = pCtxt->rectDragVert;
! SetWindowLong(hToolBar, GWL_STYLE, lStyle & ~(VERT | HORZ | FLOAT) | pCtxt->dwOverDockStyle);
ScreenToClient(hControlBar, ((POINT *) &rect));
ScreenToClient(hControlBar, ((POINT *) &rect)+1);
--- 484,488 ----
rect = pCtxt->rectDragVert;
! SetWindowLong(hToolBar, GWL_STYLE, (lStyle & ~(VERT | HORZ | FLOAT)) | pCtxt->dwOverDockStyle);
ScreenToClient(hControlBar, ((POINT *) &rect));
ScreenToClient(hControlBar, ((POINT *) &rect)+1);
***************
*** 718,721 ****
--- 718,740 ----
}
break;
+ case WM_DESTROY:
+ {
+ int i, nButtons;
+ TBBUTTON tbb;
+
+ nButtons = (int) SendMessage(hWnd, TB_BUTTONCOUNT, 0, 0);
+
+ for (i = 0; i < nButtons; i++)
+ {
+ if (SendMessage(hWnd, TB_GETBUTTON, i, (LPARAM)&tbb) && (tbb.fsStyle & TBSTYLE_SEP) == 0)
+ {
+ handleToolDestroy((ToolHandle *) tbb.dwData);
+ free((ToolHandle *) tbb.dwData);
+ }
+ }
+
+ handleWindowDestroy(hWnd);
+ }
+ break;
}
***************
*** 779,782 ****
--- 798,803 ----
void osDestroyToolBar(WindowHandle toolbar)
{
+ UndockToolBar(GetParent(toolbar), toolbar);
+ DestroyWindow(toolbar);
}
***************
*** 803,807 ****
SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb);
else
! SendMessage(toolBar, TB_ADDBUTTONS, 1, (LPARAM)&tbb);
RelayoutFrameBars();
--- 824,828 ----
SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb);
else
! SendMessage(toolBar,TB_ADDBUTTONS, 1, (LPARAM)&tbb);
RelayoutFrameBars();
***************
*** 850,883 ****
void osSetToolButtonBitmap(ToolHandle toolButton, BitmapHandle bitmap)
{
TBBUTTONINFO tbbi;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_IMAGE;
! tbbi.iImage = I_IMAGENONE;
! SendMessage(toolButton->hToolBar, TB_GETBUTTONINFO, toolButton->nCommand, (LPARAM) &tbbi);
!
! if (tbbi.iImage == I_IMAGENONE)
! {
! TBADDBITMAP tbab;
!
! tbab.hInst = NULL;
! tbab.nID = (UINT) bitmap->hBitmap;
!
! tbbi.iImage = SendMessage(toolButton->hToolBar, TB_ADDBITMAP, 1, (LPARAM) &tbab);
!
! SendMessage(toolButton->hToolBar, TB_SETBUTTONINFO, toolButton->nCommand, (LPARAM) &tbbi);
! }
! else
! {
! TBREPLACEBITMAP tbrb;
!
! tbrb.hInstOld = NULL;
! tbrb.nIDOld = (UINT) toolButton->bitmap->hBitmap;
! tbrb.hInstNew = NULL;
! tbrb.nIDNew = (UINT) bitmap->hBitmap;
! tbrb.nButtons = 1;
!
! SendMessage(toolButton->hToolBar, TB_REPLACEBITMAP, 0, (LPARAM) &tbrb);
! }
toolButton->bitmap = bitmap;
--- 871,884 ----
void osSetToolButtonBitmap(ToolHandle toolButton, BitmapHandle bitmap)
{
+ TBADDBITMAP tbab;
TBBUTTONINFO tbbi;
+ int iOldImage = SendMessage(toolItem->hToolBar, TB_GETBITMAP, toolItem->nCommand, 0);
+ tbab.hInst = NULL;
+ tbab.nID = (UINT) bitmap->hBitmap;
tbbi.cbSize = sizeof(tbbi);
tbbi.dwMask = TBIF_IMAGE;
! tbbi.iImage = SendMessage(toolButton->hToolBar, TB_ADDBITMAP, 1, (LPARAM) &tbab);
! SendMessage(toolButton->hToolBar, TB_SETBUTTONINFO, toolButton->nCommand, (LPARAM) &tbbi);
toolButton->bitmap = bitmap;
***************
*** 971,973 ****
--- 972,981 ----
void osDestroyToolItem(ToolHandle toolItem)
{
+ int iOldImage = SendMessage(toolItem->hToolBar, TB_GETBITMAP, toolItem->nCommand, 0);
+
+ handleToolDestroy(toolItem);
+
+ SendMessage(toolItem->hToolBar, TB_DELETEBUTTON, osGetToolItemPos(toolItem), 0);
+
+ free(toolItem);
}
|