From: <kr_...@us...> - 2003-08-17 18:15:12
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv6679/port/src/cbits/Win32 Modified Files: DockBar.c Internals.h ToolBar.c Log Message: Add support for ToolDropDownButton Index: DockBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/DockBar.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DockBar.c 17 Aug 2003 17:10:37 -0000 1.4 --- DockBar.c 17 Aug 2003 18:15:08 -0000 1.5 *************** *** 171,175 **** handle = (ToolHandle) tbbi.lParam; ! osActivateToolItem(handle); } break; --- 171,194 ---- handle = (ToolHandle) tbbi.lParam; ! if (handle) osActivateToolItem(handle); ! } ! break; ! case WM_NOTIFY: ! { ! ToolHandle handle; ! TBBUTTONINFO tbbi; ! LPNMTOOLBAR lpNMToolBar = (LPNMTOOLBAR) lParam; ! ! if (lpNMToolBar->hdr.code == TBN_DROPDOWN) ! { ! tbbi.cbSize = sizeof(tbbi); ! tbbi.dwMask = TBIF_LPARAM; ! tbbi.lParam = 0; ! SendMessage(lpNMToolBar->hdr.hwndFrom, TB_GETBUTTONINFO, lpNMToolBar->iItem, (LPARAM) &tbbi); ! ! handle = (ToolHandle) tbbi.lParam; ! if (handle) ! osActivateToolItem(handle); ! } } break; Index: Internals.h =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Internals.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Internals.h 12 Aug 2003 19:09:56 -0000 1.5 --- Internals.h 17 Aug 2003 18:15:08 -0000 1.6 *************** *** 44,47 **** --- 44,55 ---- #endif + #ifndef BTNS_WHOLEDROPDOWN + #define BTNS_WHOLEDROPDOWN 0x0080 + #endif + + #ifndef TBN_DROPDOWN + #define TBN_DROPDOWN (TBN_FIRST - 10) + #endif + extern HMODULE ghModule; extern HWND ghWndFrame; Index: ToolBar.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/ToolBar.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ToolBar.c 16 Aug 2003 20:48:54 -0000 1.14 --- ToolBar.c 17 Aug 2003 18:15:08 -0000 1.15 *************** *** 20,23 **** --- 20,31 ---- static int nNextToolButtonID = 0; + enum TOOL_TYPE + { TOOL_SUBMENU = 1 + , TOOL_SEPARATOR = 2 + , TOOL_ITEM = 4 + , TOOL_CHECK_ITEM = 8 + , TOOL_RADIO_ITEM = 16 + }; + struct ToolHandle { *************** *** 25,30 **** HWND hToolBar; BitmapHandle bitmap; ! BOOL bRadio; ToolHandle nextInGroup; }; --- 33,39 ---- HWND hToolBar; BitmapHandle bitmap; ! enum TOOL_TYPE type; ToolHandle nextInGroup; + MenuHandle menu; }; *************** *** 815,820 **** btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; btn->bitmap = NULL; ! btn->bRadio = FALSE; btn->nextInGroup = btn; --- 824,830 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; ! btn->type = TOOL_ITEM; btn->nextInGroup = btn; *************** *** 845,850 **** btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; btn->bitmap = NULL; ! btn->bRadio = FALSE; btn->nextInGroup = btn; --- 855,861 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; ! btn->type = TOOL_CHECK_ITEM; btn->nextInGroup = btn; *************** *** 875,880 **** btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; btn->bitmap = NULL; ! btn->bRadio = TRUE; btn->nextInGroup = btn; --- 886,892 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; ! btn->type = TOOL_RADIO_ITEM; btn->nextInGroup = btn; *************** *** 920,929 **** } void osActivateToolItem(ToolHandle toolButton) { ! if (toolButton->bRadio) osSetToolButtonChecked(toolButton, TRUE); ! else handleToolCommand(toolButton); } --- 932,992 ---- } + ToolHandle osInsertToolDropDownButton(WindowHandle toolBar, MenuHandle hmenu, int pos) + { + TBBUTTON tbb; + ToolHandle btn; + + btn = malloc(sizeof(struct ToolHandle)); + if (!btn) return NULL; + + btn->nCommand = ++nNextToolButtonID; + btn->hToolBar = toolBar; + btn->menu = hmenu; + btn->bitmap = NULL; + btn->type = TOOL_SUBMENU; + btn->nextInGroup = btn; + + tbb.iBitmap = I_IMAGENONE; + tbb.idCommand = btn->nCommand; + tbb.fsState = TBSTATE_ENABLED; + tbb.fsStyle = TBSTYLE_BUTTON | BTNS_WHOLEDROPDOWN; + 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 osActivateToolItem(ToolHandle toolButton) { ! switch (toolButton->type) ! { ! case TOOL_RADIO_ITEM: osSetToolButtonChecked(toolButton, TRUE); ! break; ! case TOOL_SUBMENU: ! { ! RECT rect; ! int nBtnPos; ! ! memset(&rect, 0, sizeof(rect)); ! nBtnPos = SendMessage(toolButton->hToolBar, TB_COMMANDTOINDEX, toolButton->nCommand, 0); ! SendMessage(toolButton->hToolBar, TB_GETITEMRECT, nBtnPos, (LPARAM)&rect); ! ! ClientToScreen(toolButton->hToolBar, ((POINT *) &rect)); ! ClientToScreen(toolButton->hToolBar, ((POINT *) &rect)+1); ! ! TrackPopupMenu(toolButton->menu->hMenu, TPM_LEFTALIGN | TPM_TOPALIGN, rect.left, rect.bottom, 0, ghWndFrame, NULL); ! } ! break; ! default: handleToolCommand(toolButton); + break; + } } *************** *** 939,942 **** --- 1002,1006 ---- btn->nCommand = ++nNextToolButtonID; btn->hToolBar = toolBar; + btn->menu = NULL; btn->bitmap = NULL; btn->nextInGroup = btn; |