From: <kr_...@us...> - 2003-08-16 10:32:46
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv3981/port/src/cbits/Win32 Modified Files: DockBar.c ToolBar.c Log Message: Added support for ToolRadioButton Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DockBar.c 15 Aug 2003 16:40:01 -0000 1.1 --- DockBar.c 16 Aug 2003 09:59:41 -0000 1.2 *************** *** 109,113 **** SetWindowPos(pData->hClientWnd,NULL,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),SWP_NOZORDER); } ! LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { --- 109,115 ---- SetWindowPos(pData->hClientWnd,NULL,nLeft,nTop,nWidth-(nRight+nLeft),nHeight-(nBottom+nTop),SWP_NOZORDER); } ! ! extern void osAlterToolRadioGroup(ToolHandle toolButton); ! LRESULT CALLBACK HDockBarFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { *************** *** 159,162 **** --- 161,165 ---- case WM_COMMAND: { + ToolHandle handle; TBBUTTONINFO tbbi; HWND hToolBar = (HWND) lParam; *************** *** 166,170 **** tbbi.lParam = 0; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! handleToolCommand((WindowHandle) tbbi.lParam); } break; --- 169,176 ---- tbbi.lParam = 0; SendMessage(hToolBar, TB_GETBUTTONINFO, LOWORD(wParam), (LPARAM) &tbbi); ! ! handle = (ToolHandle) tbbi.lParam; ! osAlterToolRadioGroup(handle); ! handleToolCommand(handle); } break; Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ToolBar.c 15 Aug 2003 16:40:01 -0000 1.12 --- ToolBar.c 16 Aug 2003 09:59:41 -0000 1.13 *************** *** 25,28 **** --- 25,30 ---- HWND hToolBar; BitmapHandle bitmap; + BOOL bRadio; + ToolHandle nextInGroup; }; *************** *** 811,817 **** if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; tbb.iBitmap = I_IMAGENONE; --- 813,821 ---- if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; ! btn->bRadio = FALSE; ! btn->nextInGroup = btn; tbb.iBitmap = I_IMAGENONE; *************** *** 839,845 **** if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; tbb.iBitmap = I_IMAGENONE; --- 843,851 ---- if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; ! btn->bRadio = FALSE; ! btn->nextInGroup = btn; tbb.iBitmap = I_IMAGENONE; *************** *** 859,862 **** --- 865,929 ---- } + ToolHandle osInsertToolRadioButton(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; + btn->bRadio = TRUE; + btn->nextInGroup = btn; + + tbb.iBitmap = I_IMAGENONE; + tbb.idCommand = btn->nCommand; + tbb.fsState = TBSTATE_ENABLED; + tbb.fsStyle = TBSTYLE_BUTTON; + 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; + } + + void osSetToolRadioGroup(ToolHandle *handles) + { + ToolHandle next, handle, *phandle; + + phandle=handles; + for (;;) + { + handle = *phandle; + + next = handle->nextInGroup; + while (next->nextInGroup != handle) + next = next->nextInGroup; + next->nextInGroup = handle->nextInGroup; + + phandle++; + if (*phandle) + handle->nextInGroup = *phandle; + else + { + handle->nextInGroup = *handles; + break; + } + } + } + + void osAlterToolRadioGroup(ToolHandle toolButton) + { + if (toolButton->bRadio) + osSetToolButtonChecked(toolButton, TRUE); + } + ToolHandle osInsertToolLine(WindowHandle toolBar, int pos) { *************** *** 868,874 **** if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; tbb.iBitmap = 1; --- 935,942 ---- if (!btn) return NULL; ! btn->nCommand = ++nNextToolButtonID; ! btn->hToolBar = toolBar; ! btn->bitmap = NULL; ! btn->nextInGroup = btn; tbb.iBitmap = 1; *************** *** 1007,1015 **** if (bState) ! nState = nState | TBSTATE_CHECKED; else nState = nState & ~TBSTATE_CHECKED; ! ! SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); }; --- 1075,1099 ---- if (bState) ! { ! ToolHandle next; ! ! nState = nState | TBSTATE_CHECKED; ! SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); ! ! next = toolButton->nextInGroup; ! while (next != toolButton) ! { ! nState = SendMessage(next->hToolBar, TB_GETSTATE, next->nCommand, 0); ! nState = nState & ~TBSTATE_CHECKED; ! SendMessage(next->hToolBar,TB_SETSTATE,next->nCommand,MAKELONG(nState, 0)); ! ! next = next->nextInGroup; ! } ! } else + { nState = nState & ~TBSTATE_CHECKED; ! SendMessage(toolButton->hToolBar,TB_SETSTATE,toolButton->nCommand,MAKELONG(nState, 0)); ! } }; *************** *** 1026,1032 **** --- 1110,1123 ---- void osDestroyToolItem(ToolHandle toolItem) { + ToolHandle next; + handleToolDestroy(toolItem); SendMessage(toolItem->hToolBar, TB_DELETEBUTTON, osGetToolItemPos(toolItem), 0); + + next = toolItem->nextInGroup; + while (next->nextInGroup != toolItem) + next = next->nextInGroup; + next->nextInGroup = toolItem->nextInGroup; free(toolItem); |