Changeset 267 for trunk/src/comctl32/toolbar.c
- Timestamp:
- Jul 4, 1999, 11:06:00 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/toolbar.c
r252 r267 1 /* $Id: toolbar.c,v 1. 8 1999-06-30 15:52:18cbratschi Exp $ */1 /* $Id: toolbar.c,v 1.9 1999-07-04 21:06:00 cbratschi Exp $ */ 2 2 /* 3 3 * Toolbar control … … 14 14 * - Fix TB_SETROWS. 15 15 * - Tooltip support (almost complete). 16 * - Unicode suppport.17 16 * - Internal COMMCTL32 bitmaps. 18 17 * - Fix TOOLBAR_SetButtonInfo32A. … … 36 35 37 36 #include "winbase.h" 38 #include "winuser.h"39 #include "wingdi.h"40 37 #include "commctrl.h" 41 38 #include "cache.h" 42 39 #include "comctl32.h" 43 40 #include "toolbar.h" 44 45 41 46 42 #define SEPARATOR_WIDTH 8 … … 732 728 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 733 729 { 734 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);730 TOOLBAR_INFO *infoPtr; 735 731 static HDSA hDsa = NULL; 736 732 … … 804 800 // lpdis->itemAction, lpdis->itemState); 805 801 802 infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER); 803 806 804 if (lpdis->itemState & ODS_FOCUS) 807 805 { … … 853 851 { 854 852 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 853 854 infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER); 855 855 856 856 if (infoPtr) … … 1014 1014 } 1015 1015 1016 1017 static LRESULT TOOLBAR_AddButtonsW(HWND hwnd,WPARAM wParam,LPARAM lParam) 1018 { 1019 //CB: just call AddButtonsA, no Unicode used?!? 1020 1021 return TOOLBAR_AddButtonsA(hwnd,wParam,lParam); 1022 } 1016 1023 1017 1024 /* << TOOLBAR_AddButtons32W >> */ … … 1306 1313 } 1307 1314 1308 1309 1315 static LRESULT 1310 1316 TOOLBAR_Customize (HWND hwnd) … … 1324 1330 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 1325 1331 1332 //load OS/2 dialog 1333 1334 ret = NativeDlgBoxIP(COMCTL32_hModule, 1335 GetWindowLongA(hwnd,GWL_HINSTANCE), 1336 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), 1337 hwnd, 1338 (DLGPROC)TOOLBAR_CustomizeDialogProc, 1339 (LPARAM)infoPtr); 1340 1341 if (ret == (INT)-1) return FALSE; 1342 1343 /* //original WINE code 1326 1344 if (!(hRes = FindResourceA (COMCTL32_hModule, 1327 1345 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), … … 1337 1355 (DLGPROC)TOOLBAR_CustomizeDialogProc, 1338 1356 (LPARAM)infoPtr); 1357 */ 1339 1358 1340 1359 /* send TBN_ENDADJUST notification */ … … 1516 1535 if (lpTbInfo->dwMask & TBIF_TEXT) { 1517 1536 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 1518 lstrcpyn A (lpTbInfo->pszText,1519 (LPSTR)infoPtr->strings[btnPtr->iString],1537 lstrcpynWtoA (lpTbInfo->pszText, 1538 infoPtr->strings[btnPtr->iString], 1520 1539 lpTbInfo->cchText); 1521 1540 } … … 1524 1543 } 1525 1544 1526 1527 /* << TOOLBAR_GetButtonInfo32W >> */ 1528 1529 1530 static LRESULT 1531 TOOLBAR_GetButtonSize (HWND hwnd) 1532 { 1533 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1534 1535 return MAKELONG((WORD)infoPtr->nButtonWidth, 1536 (WORD)infoPtr->nButtonHeight); 1537 } 1538 1539 1540 static LRESULT 1541 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1542 { 1543 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1544 INT nIndex, nStringIndex; 1545 static LRESULT TOOLBAR_GetButtonInfoW(HWND hwnd,WPARAM wParam,LPARAM lParam) 1546 { 1547 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1548 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam; 1549 TBUTTON_INFO *btnPtr; 1550 INT nIndex; 1551 1552 if (infoPtr == NULL) 1553 return -1; 1554 if (lpTbInfo == NULL) 1555 return -1; 1556 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW)) 1557 return -1; 1545 1558 1546 1559 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); … … 1548 1561 return -1; 1549 1562 1563 btnPtr = &infoPtr->buttons[nIndex]; 1564 1565 if (lpTbInfo->dwMask & TBIF_COMMAND) 1566 lpTbInfo->idCommand = btnPtr->idCommand; 1567 if (lpTbInfo->dwMask & TBIF_IMAGE) 1568 lpTbInfo->iImage = btnPtr->iBitmap; 1569 if (lpTbInfo->dwMask & TBIF_LPARAM) 1570 lpTbInfo->lParam = btnPtr->dwData; 1571 if (lpTbInfo->dwMask & TBIF_SIZE) 1572 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 1573 if (lpTbInfo->dwMask & TBIF_STATE) 1574 lpTbInfo->fsState = btnPtr->fsState; 1575 if (lpTbInfo->dwMask & TBIF_STYLE) 1576 lpTbInfo->fsStyle = btnPtr->fsStyle; 1577 if (lpTbInfo->dwMask & TBIF_TEXT) { 1578 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 1579 lstrcpynW (lpTbInfo->pszText, 1580 infoPtr->strings[btnPtr->iString], 1581 lpTbInfo->cchText); 1582 } 1583 1584 return nIndex; 1585 } 1586 1587 /* << TOOLBAR_GetButtonInfo32W >> */ 1588 1589 1590 static LRESULT 1591 TOOLBAR_GetButtonSize (HWND hwnd) 1592 { 1593 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1594 1595 return MAKELONG((WORD)infoPtr->nButtonWidth, 1596 (WORD)infoPtr->nButtonHeight); 1597 } 1598 1599 1600 static LRESULT 1601 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1602 { 1603 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1604 INT nIndex, nStringIndex; 1605 1606 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1607 if (nIndex == -1) 1608 return -1; 1609 1550 1610 nStringIndex = infoPtr->buttons[nIndex].iString; 1551 1611 … … 1557 1617 if (lParam == 0) return -1; 1558 1618 1559 lstrcpyA ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]); 1560 1561 return lstrlenA ((LPSTR)infoPtr->strings[nStringIndex]); 1562 } 1563 1619 lstrcpyWtoA ((LPSTR)lParam, infoPtr->strings[nStringIndex]); 1620 1621 return lstrlenW (infoPtr->strings[nStringIndex]); 1622 } 1623 1624 static LRESULT TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1625 { 1626 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1627 INT nIndex, nStringIndex; 1628 1629 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1630 if (nIndex == -1) 1631 return -1; 1632 1633 nStringIndex = infoPtr->buttons[nIndex].iString; 1634 1635 // TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex); 1636 1637 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 1638 return -1; 1639 1640 if (lParam == 0) return -1; 1641 1642 lstrcpyW ((LPWSTR)lParam, infoPtr->strings[nStringIndex]); 1643 1644 return lstrlenW (infoPtr->strings[nStringIndex]); 1645 } 1564 1646 1565 1647 /* << TOOLBAR_GetButtonText32W >> */ … … 1898 1980 } 1899 1981 1982 static LRESULT TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam) 1983 { 1984 //CB: just call InsertButtonA, no Unicode used?!? 1985 1986 return TOOLBAR_InsertButtonA(hwnd,wParam,lParam); 1987 } 1900 1988 1901 1989 /* << TOOLBAR_InsertButton32W >> */ … … 2051 2139 } 2052 2140 2141 static LRESULT TOOLBAR_SaveRestoreW(HWND hwnd,WPARAM wParam,LPARAM lParam) 2142 { 2143 #if 0 2144 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2145 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam; 2146 2147 if (lpSave == NULL) return 0; 2148 2149 if ((BOOL)wParam) { 2150 /* save toolbar information */ 2151 // FIXME (toolbar, "save to \"%s\" \"%s\"\n", 2152 // lpSave->pszSubKey, lpSave->pszValueName); 2153 2154 2155 } 2156 else { 2157 /* restore toolbar information */ 2158 2159 // FIXME (toolbar, "restore from \"%s\" \"%s\"\n", 2160 // lpSave->pszSubKey, lpSave->pszValueName); 2161 2162 2163 } 2164 #endif 2165 2166 return 0; 2167 } 2053 2168 2054 2169 /* << TOOLBAR_SaveRestore32W >> */ … … 2061 2176 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2062 2177 2063 if (( LOWORD(lParam) <= 0) || (HIWORD(lParam) <= 0)) return FALSE;2178 if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE; 2064 2179 2065 2180 infoPtr->nBitmapWidth = (INT)LOWORD(lParam); … … 2105 2220 (btnPtr->iString < infoPtr->nNumStrings)) { 2106 2221 #if 0 2107 CHAR **lpString = &infoPtr->strings[btnPtr->iString]; 2222 CHAR **lpString = &infoPtr->strings[btnPtr->iString]; //wrong, it's Unicode!!! 2108 2223 INT len = lstrlenA (lptbbi->pszText); 2109 2224 *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1)); … … 2118 2233 } 2119 2234 2235 static LRESULT TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) 2236 { 2237 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2238 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam; 2239 TBUTTON_INFO *btnPtr; 2240 INT nIndex; 2241 2242 if (lptbbi == NULL) 2243 return FALSE; 2244 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW)) 2245 return FALSE; 2246 2247 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2248 if (nIndex == -1) 2249 return FALSE; 2250 2251 btnPtr = &infoPtr->buttons[nIndex]; 2252 if (lptbbi->dwMask & TBIF_COMMAND) 2253 btnPtr->idCommand = lptbbi->idCommand; 2254 if (lptbbi->dwMask & TBIF_IMAGE) 2255 btnPtr->iBitmap = lptbbi->iImage; 2256 if (lptbbi->dwMask & TBIF_LPARAM) 2257 btnPtr->dwData = lptbbi->lParam; 2258 /* if (lptbbi->dwMask & TBIF_SIZE) */ 2259 /* btnPtr->cx = lptbbi->cx; */ 2260 if (lptbbi->dwMask & TBIF_STATE) 2261 btnPtr->fsState = lptbbi->fsState; 2262 if (lptbbi->dwMask & TBIF_STYLE) 2263 btnPtr->fsStyle = lptbbi->fsStyle; 2264 2265 if (lptbbi->dwMask & TBIF_TEXT) { 2266 if ((btnPtr->iString >= 0) || 2267 (btnPtr->iString < infoPtr->nNumStrings)) { 2268 #if 0 2269 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 2270 INT len = lstrlenW (lptbbi->pszText); 2271 *lpString = COMCTL32_ReAlloc (lpString, sizeof(wchar)*(len+1)); 2272 #endif 2273 2274 /* this is the ultimate sollution */ 2275 /* Str_SetPtrW (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 2276 } 2277 } 2278 2279 return TRUE; 2280 } 2120 2281 2121 2282 /* << TOOLBAR_SetButtonInfo32W >> */ … … 2127 2288 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2128 2289 2129 if (( LOWORD(lParam) <= 0) || (HIWORD(lParam) <= 0)) return FALSE;2290 if (((INT)LOWORD(lParam) <= 0) || ((INT)HIWORD(lParam) <= 0)) return FALSE; 2130 2291 2131 2292 infoPtr->nButtonWidth = (INT)LOWORD(lParam); … … 2966 3127 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam); 2967 3128 2968 /* case TB_ADDBUTTONSW: */ 3129 case TB_ADDBUTTONSW: 3130 return TOOLBAR_AddButtonsW(hwnd,wParam,lParam); 2969 3131 2970 3132 case TB_ADDSTRINGA: … … 3015 3177 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam); 3016 3178 3017 /* case TB_GETBUTTONINFOW: */ /* 4.71 */ 3179 case TB_GETBUTTONINFOW: /* 4.71 */ 3180 return TOOLBAR_GetButtonInfoW(hwnd,wParam,lParam); 3018 3181 3019 3182 case TB_GETBUTTONSIZE: … … 3023 3186 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam); 3024 3187 3025 /* case TB_GETBUTTONTEXTW: */ 3188 case TB_GETBUTTONTEXTW: 3189 return TOOLBAR_GetButtonTextW(hwnd,wParam,lParam); 3190 3026 3191 /* case TB_GETCOLORSCHEME: */ /* 4.71 */ 3027 3192 … … 3085 3250 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam); 3086 3251 3087 /* case TB_INSERTBUTTONW: */ 3252 case TB_INSERTBUTTONW: 3253 return TOOLBAR_InsertButtonW(hwnd,wParam,lParam); 3254 3088 3255 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */ 3089 3256 … … 3120 3287 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); 3121 3288 3122 /* case TB_SAVERESTOREW: */ 3289 case TB_SAVERESTOREW: 3290 return TOOLBAR_SaveRestoreW(hwnd,wParam,lParam); 3291 3123 3292 /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */ 3124 3293 … … 3129 3298 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam); 3130 3299 3131 /* case TB_SETBUTTONINFOW: */ /* 4.71 */ 3300 case TB_SETBUTTONINFOW: /* 4.71 */ 3301 return TOOLBAR_SetButtonInfoW(hwnd,wParam,lParam); 3132 3302 3133 3303 case TB_SETBUTTONSIZE:
Note:
See TracChangeset
for help on using the changeset viewer.