From: <kr_...@us...> - 2003-08-12 21:36:39
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv20936/src/cbits/Win32 Modified Files: ToolBar.c Log Message: Support for checked buttons Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ToolBar.c 12 Aug 2003 20:01:32 -0000 1.10 --- ToolBar.c 12 Aug 2003 21:10:08 -0000 1.11 *************** *** 833,837 **** ToolHandle osInsertToolCheckButton(WindowHandle toolBar, int pos) { ! return NULL; } --- 833,860 ---- ToolHandle osInsertToolCheckButton(WindowHandle toolBar, int pos) { ! TBBUTTON tbb; ! ToolHandle btn; ! ! btn = malloc(sizeof(struct ToolHandle)); ! if (!btn) return NULL; ! ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; ! ! tbb.iBitmap = I_IMAGENONE; ! tbb.idCommand = btn->nCommand; ! tbb.fsState = TBSTATE_ENABLED; ! tbb.fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECK; ! tbb.dwData = (DWORD)btn; ! tbb.iString = 0; ! ! if (pos > 0) ! SendMessage(toolBar,TB_INSERTBUTTON,pos,(LPARAM)&tbb); ! else ! SendMessage(toolBar,TB_ADDBUTTONS, 1, (LPARAM)&tbb); ! ! RelayoutFrameBars(); ! return btn; } *************** *** 951,956 **** TBBUTTONINFO tbbi; tbbi.cbSize = sizeof(tbbi); ! tbbi.dwMask = TBIF_TEXT | TBIF_STYLE; ! tbbi.fsStyle = TBSTYLE_BUTTON | ((text && *text) ? BTNS_SHOWTEXT : 0); tbbi.pszText = text; tbbi.cchText = strlen(text); --- 974,984 ---- TBBUTTONINFO tbbi; tbbi.cbSize = sizeof(tbbi); ! ! tbbi.dwMask = TBIF_STYLE; ! tbbi.fsStyle = TBSTYLE_BUTTON; ! SendMessage(toolButton->hToolBar, TB_GETBUTTONINFO, toolButton->nCommand, (LPARAM) &tbbi); ! ! tbbi.dwMask = TBIF_TEXT | TBIF_STYLE; ! tbbi.fsStyle = (text && *text) ? (tbbi.fsStyle | BTNS_SHOWTEXT) : (tbbi.fsStyle & ~BTNS_SHOWTEXT); tbbi.pszText = text; tbbi.cchText = strlen(text); *************** *** 976,984 **** void osSetToolButtonChecked(ToolHandle toolButton, BOOL bState) { }; BOOL osGetToolButtonChecked(ToolHandle toolButton) { ! return FALSE; } --- 1004,1020 ---- void osSetToolButtonChecked(ToolHandle toolButton, BOOL bState) { + int nState = SendMessage(toolButton->hToolBar, TB_GETSTATE, toolButton->nCommand, 0); + + if (bState) + nState = nState | TBSTATE_CHECKED; + else + nState = nState & ~TBSTATE_CHECKED; + + SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); }; BOOL osGetToolButtonChecked(ToolHandle toolButton) { ! return SendMessage(toolButton->hToolBar, TB_GETSTATE, toolButton->nCommand, 0) & TBSTATE_CHECKED; } |