Changeset 295 for trunk/src/comctl32/toolbar.c
- Timestamp:
- Jul 12, 1999, 5:58:51 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/toolbar.c
r285 r295 1 /* $Id: toolbar.c,v 1.1 0 1999-07-07 17:08:42cbratschi Exp $ */1 /* $Id: toolbar.c,v 1.11 1999-07-12 15:58:49 cbratschi Exp $ */ 2 2 /* 3 3 * Toolbar control … … 16 16 * - Internal COMMCTL32 bitmaps. 17 17 * - Fix TOOLBAR_SetButtonInfo32A. 18 * - Customize dialog (CB: under construction).19 18 * - Drag & drop of buttons 20 19 * … … 30 29 31 30 /* CB: Odin32/WINE bugs 32 - IMAGELIST_Draw draws a line too much at the bottom of the bitmap 31 - IMAGELIST_Draw draws a line too at the bottom of the bitmap (toolbar.exe) 32 imagelist uses default size values instead of real bitmap values 33 33 */ 34 34 … … 132 132 HDC hdcImageList = CreateCompatibleDC (0); 133 133 HDC hdcMask = CreateCompatibleDC (0); 134 HIMAGELIST himl = infoPtr->himl Std;134 HIMAGELIST himl = infoPtr->himlDef; 135 135 HBITMAP hbmMask; 136 136 … … 182 182 { 183 183 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0)) 184 TOOLBAR_DrawFlatSeparator (& btnPtr->rect, hdc);184 TOOLBAR_DrawFlatSeparator (&rc, hdc); 185 185 return; 186 186 } … … 189 189 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 190 190 { 191 DrawEdge (hdc, &rc, EDGE_RAISED, 191 if (!(dwStyle & TBSTYLE_FLAT)) 192 DrawEdge (hdc, &rc, EDGE_RAISED, 192 193 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 193 194 194 if (dwStyle & TBSTYLE_FLAT) 195 { 196 /* if (infoPtr->himlDis) */ 197 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 198 rc.left+1, rc.top+1, ILD_NORMAL); 199 /* else */ 200 /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */ 201 } else 195 if (infoPtr->himlDis) 196 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 197 rc.left+1, rc.top+1, ILD_NORMAL); 198 else 202 199 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 203 200 … … 210 207 { 211 208 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 212 ImageList_Draw (infoPtr->himl Std, btnPtr->iBitmap, hdc,209 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 213 210 rc.left+2, rc.top+2, ILD_NORMAL); 214 211 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); … … 227 224 228 225 TOOLBAR_DrawPattern (hdc, &rc); 229 if (dwStyle & TBSTYLE_FLAT) 230 { 231 if (infoPtr->himlDef != NULL) 232 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 233 rc.left+2, rc.top+2, ILD_NORMAL); 234 else 235 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 236 rc.left+2, rc.top+2, ILD_NORMAL); 237 } else 238 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 239 rc.left+2, rc.top+2, ILD_NORMAL); 226 227 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 228 rc.left+2, rc.top+2, ILD_NORMAL); 229 240 230 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 241 231 return; … … 254 244 } 255 245 246 /* normal state */ 256 247 if (dwStyle & TBSTYLE_FLAT) 257 248 { … … 260 251 BF_RECT | BF_MIDDLE | BF_SOFT); 261 252 262 if( infoPtr->himlDef != NULL)263 ImageList_Draw (infoPtr->himl Def, btnPtr->iBitmap, hdc,253 if(btnPtr->bHot && infoPtr->himlHot) 254 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc, 264 255 rc.left +2, rc.top +2, ILD_NORMAL); 265 256 else 266 ImageList_Draw (infoPtr->himl Std, btnPtr->iBitmap, hdc,257 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 267 258 rc.left +2, rc.top +2, ILD_NORMAL); 268 259 } else 269 260 { 270 /* normal state */271 261 DrawEdge (hdc, &rc, EDGE_RAISED, 272 262 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 273 263 274 ImageList_Draw (infoPtr->himl Std, btnPtr->iBitmap, hdc,264 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 275 265 rc.left+1, rc.top+1, ILD_NORMAL); 276 266 } … … 831 821 } 832 822 823 static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd); 824 static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd); 825 826 static BOOL TBCUSTOMIZE_FillData(HWND hwnd,TOOLBAR_INFO* infoPtr) 827 { 828 TBUTTON_INFO* btnPtr; 829 INT i; 830 INT leftCount = 0; 831 INT rightCount = 0; 832 INT nItem; 833 834 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_RESETCONTENT,0,0); 835 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_RESETCONTENT,0,0); 836 837 /* insert 'virtual' separator button into 'available buttons' list */ 838 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"Separator"); 839 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,0); 840 841 /* copy all buttons and append them to the listboxes */ 842 btnPtr = infoPtr->buttons; 843 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 844 { 845 if (IsWindowUnicode(infoPtr->hwndNotify)) 846 { 847 TBNOTIFYW tbNotify; 848 849 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 850 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 851 tbNotify.iItem = i; 852 tbNotify.tbButton = (TBBUTTON*)btnPtr; 853 tbNotify.cchText = 0; 854 tbNotify.pszText = NULL; 855 856 // send TBN_QUERYINSERT notification 857 858 tbNotify.hdr.code = TBN_QUERYINSERT; 859 860 if (!SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 861 862 // send TBN_QUERYDELETE notification 863 864 tbNotify.hdr.code = TBN_QUERYDELETE; 865 866 btnPtr->bDelete = (BOOL)SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 867 868 //get tool name 869 870 TBCUSTOMIZE_GetToolNameW(infoPtr,btnPtr,i); 871 872 } else 873 { 874 TBNOTIFYA tbNotify; 875 876 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 877 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 878 tbNotify.iItem = i; 879 tbNotify.tbButton = (TBBUTTON*)btnPtr; 880 tbNotify.cchText = 0; 881 tbNotify.pszText = NULL; 882 883 // send TBN_QUERYINSERT notification 884 885 tbNotify.hdr.code = TBN_QUERYINSERT; 886 887 if (!SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 888 889 // send TBN_QUERYDELETE notification 890 891 tbNotify.hdr.code = TBN_QUERYDELETE; 892 893 btnPtr->bDelete = (BOOL)SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 894 895 //get tool name 896 897 TBCUSTOMIZE_GetToolNameA(infoPtr,btnPtr,i); 898 } 899 900 if (btnPtr->fsState & TBSTATE_HIDDEN) 901 { 902 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 903 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID); 904 leftCount++; 905 } else 906 { 907 nItem = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 908 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,nItem,btnPtr->nCustomID); 909 rightCount++; 910 } 911 } 912 913 if (leftCount == 0 && rightCount == 0) return FALSE; 914 915 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,0,0); 916 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,(rightCount > 0) ? 0:(WPARAM)-1,0); 917 918 TBCUSTOMIZE_AvailSelChange(hwnd); 919 TBCUSTOMIZE_VisSelChange(hwnd); 920 921 return TRUE; 922 } 923 833 924 static BOOL TBCUSTOMIZE_InitDialog(HWND hwnd,WPARAM wParam,LPARAM lParam) 834 925 { … … 836 927 837 928 infoPtr = (TOOLBAR_INFO*)lParam; 838 SetWindowLongA (hwnd, DWL_USER,(DWORD)infoPtr);929 SetWindowLongA(hwnd,DWL_USER,(DWORD)infoPtr); 839 930 840 931 if (infoPtr) 841 932 { 842 TBUTTON_INFO* btnPtr; 843 INT i; 844 INT leftCount = 0; 845 INT rightCount = 0; 846 INT nItem; 847 848 infoPtr->hDsa = DSA_Create(sizeof(TBUTTON_INFO),5); 849 850 /* insert 'virtual' separator button into 'available buttons' list */ 851 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)"Separator"); 852 853 /* copy all buttons and append them to the right listbox */ 854 btnPtr = infoPtr->buttons; 855 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 933 INT x; 934 935 //custom ID: 1-nNumButtons, 0 == new separator 936 for (x = 0;x < infoPtr->nNumButtons;x++) 856 937 { 857 DSA_InsertItem (infoPtr->hDsa, i, btnPtr); 858 859 if (IsWindowUnicode(infoPtr->hwndNotify)) 938 infoPtr->buttons[x].nCustomID = x+1; 939 infoPtr->buttons[x].pszName = NULL; 940 } 941 infoPtr->nMaxCustomID = infoPtr->nNumButtons; 942 943 //save tools 944 infoPtr->nNumOldButtons = infoPtr->nNumButtons; 945 infoPtr->oldButtons = COMCTL32_Alloc(infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO)); 946 memcpy(&infoPtr->oldButtons[0],&infoPtr->buttons[0],infoPtr->nNumOldButtons*sizeof(TBUTTON_INFO)); 947 948 if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE); 949 } 950 951 return TRUE; 952 } 953 954 static BOOL TBCUSTOMIZE_Close(HWND hwnd,WPARAM wParam,LPARAM lParam) 955 { 956 EndDialog(hwnd,FALSE); 957 958 return TRUE; 959 } 960 961 static VOID TBCUSTOMIZE_Reset(HWND hwnd) 962 { 963 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 964 NMHDR nmhdr; 965 INT x; 966 967 //Send TBN_RESET 968 nmhdr.hwndFrom = infoPtr->hwndToolbar; 969 nmhdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 970 nmhdr.code = TBN_RESET; 971 972 SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr); 973 974 for (x = 0;x < infoPtr->nNumOldButtons;x++) COMCTL32_Free(infoPtr->oldButtons[x].pszName); 975 976 //restore data 977 if (infoPtr->nNumButtons != infoPtr->nNumOldButtons) 978 { 979 COMCTL32_Free(infoPtr->buttons); 980 infoPtr->nNumButtons = infoPtr->nNumOldButtons; 981 infoPtr->buttons = COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 982 } 983 memcpy(&infoPtr->buttons[0],&infoPtr->oldButtons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 984 985 if (!TBCUSTOMIZE_FillData(hwnd,infoPtr)) EndDialog(hwnd,FALSE); 986 987 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 988 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 989 } 990 991 static TBUTTON_INFO* TBCUSTOMIZE_GetBtnPtr(TOOLBAR_INFO* infoPtr,INT customID) 992 { 993 INT x; 994 TBUTTON_INFO* btnPtr = infoPtr->buttons; 995 996 if (customID == 0) return NULL; 997 998 for (x = 0;x < infoPtr->nNumButtons;btnPtr++) 999 if (btnPtr->nCustomID == customID) return btnPtr; 1000 1001 return NULL; 1002 } 1003 1004 static VOID TBCUSTOMIZE_AddTool(HWND hwnd) 1005 { 1006 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1007 LRESULT pos,count; 1008 INT customID; 1009 TBUTTON_INFO* btnPtr; 1010 LRESULT rightSel,rightCount,rightPos; 1011 1012 pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1013 if (pos == (LRESULT)-1) return; 1014 1015 count = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0); 1016 1017 customID = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,pos,0); 1018 if (customID == 0) btnPtr = NULL; else 1019 { 1020 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1021 if (btnPtr == NULL) return; 1022 1023 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_DELETESTRING,pos,0); 1024 } 1025 1026 rightSel = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1027 rightCount = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1028 1029 if (rightSel != (LRESULT)-1) 1030 rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_INSERTSTRING,rightSel,(LPARAM)""); 1031 else 1032 rightPos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 1033 if (!btnPtr) 1034 { //new separator 1035 TBUTTON_INFO* newButtons; 1036 1037 newButtons = COMCTL32_Alloc((infoPtr->nNumButtons+1)*sizeof(TBUTTON_INFO)); 1038 memcpy(&newButtons[0],&infoPtr->buttons[0],infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 1039 COMCTL32_Free(infoPtr->buttons); 1040 1041 infoPtr->buttons = newButtons; 1042 infoPtr->nNumButtons++; 1043 1044 btnPtr = &infoPtr->buttons[infoPtr->nNumButtons-1]; 1045 ZeroMemory(btnPtr,sizeof(TBUTTON_INFO)); 1046 btnPtr->fsStyle = TBSTYLE_SEP; 1047 btnPtr->bDelete = TRUE; 1048 1049 customID = ++infoPtr->nMaxCustomID; 1050 btnPtr->nCustomID = customID; 1051 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID); 1052 } else 1053 { 1054 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,rightPos,customID); 1055 btnPtr->fsState &= ~TBSTATE_HIDDEN; 1056 } 1057 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,rightPos,0); 1058 TBCUSTOMIZE_VisSelChange(hwnd); 1059 1060 if (rightCount > 0) 1061 { //change order 1062 TBUTTON_INFO* btnPtr2; 1063 INT customID2,pos1,pos2; 1064 1065 pos1 = 0; 1066 while (infoPtr->buttons[pos1].nCustomID != customID) pos1++; 1067 if (rightPos < rightCount) 1068 { //insert before 1069 customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos+1,0); 1070 pos2 = 0; 1071 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1072 } else 1073 { //insert behind 1074 INT x; 1075 1076 customID2 = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,rightPos-1,0); 1077 pos2 = 0; 1078 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1079 //exchange to use first alogrithm 1080 x = pos1; 1081 pos1 = pos2; 1082 pos2 = x; 1083 } 1084 1085 if (pos1+1 != pos2) 1086 { 1087 TBUTTON_INFO temp; 1088 INT x; 1089 1090 memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO)); 1091 if (pos1 < pos2) 860 1092 { 861 TBNOTIFYW tbNotify; 862 863 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 864 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 865 tbNotify.iItem = i; 866 tbNotify.tbButton = (TBBUTTON*)btnPtr; 867 tbNotify.cchText = 0; 868 tbNotify.pszText = NULL; 869 870 // send TBN_QUERYINSERT notification 871 872 tbNotify.hdr.code = TBN_QUERYINSERT; 873 874 if (!SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 875 876 // send TBN_QUERYDELETE notification 877 878 tbNotify.hdr.code = TBN_QUERYDELETE; 879 880 btnPtr->bDelete = (BOOL)SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 881 882 //get tool name 883 884 TBCUSTOMIZE_GetToolNameW(infoPtr,btnPtr,i); 885 1093 for (x = pos1;x < pos2;x++) 1094 memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO)); 1095 memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO)); 886 1096 } else 887 1097 { 888 TBNOTIFYA tbNotify; 889 890 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 891 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 892 tbNotify.iItem = i; 893 tbNotify.tbButton = (TBBUTTON*)btnPtr; 894 tbNotify.cchText = 0; 895 tbNotify.pszText = NULL; 896 897 // send TBN_QUERYINSERT notification 898 899 tbNotify.hdr.code = TBN_QUERYINSERT; 900 901 if (!SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) continue; 902 903 // send TBN_QUERYDELETE notification 904 905 tbNotify.hdr.code = TBN_QUERYDELETE; 906 907 btnPtr->bDelete = (BOOL)SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify); 908 909 //get tool name 910 911 TBCUSTOMIZE_GetToolNameA(infoPtr,btnPtr,i); 1098 for (x = pos1-1;x >= pos2;x--) 1099 memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO)); 1100 memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO)); 912 1101 } 913 914 if (btnPtr->fsState & TBSTATE_HIDDEN) 1102 } 1103 } 1104 1105 if (pos == count-1 && pos > 0) pos--; 1106 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,pos,0); 1107 TBCUSTOMIZE_AvailSelChange(hwnd); 1108 1109 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1110 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1111 } 1112 1113 static VOID TBCUSTOMIZE_RemoveTool(HWND hwnd) 1114 { 1115 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1116 LRESULT pos,count; 1117 INT customID; 1118 TBUTTON_INFO* btnPtr; 1119 1120 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1121 if (pos == (LRESULT)-1) return; 1122 1123 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1124 1125 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1126 if (customID == 0) return; //no allowed 1127 1128 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1129 if (btnPtr == NULL || !btnPtr->bDelete) return; 1130 1131 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_DELETESTRING,pos,0); 1132 1133 if (btnPtr->fsStyle & TBSTYLE_SEP) 1134 { //remove separator 1135 TBUTTON_INFO* newButtons; 1136 INT nIndex,x; 1137 1138 //find pos 1139 for (x = 0;x < infoPtr->nNumButtons;x++) if (&infoPtr->buttons[x] == btnPtr) 1140 { 1141 nIndex = x; 1142 break; 1143 } 1144 1145 infoPtr->nNumButtons--; 1146 newButtons = COMCTL32_Alloc(infoPtr->nNumButtons*sizeof(TBUTTON_INFO)); 1147 1148 if (nIndex > 0) 1149 memcpy(&newButtons[0],&infoPtr->buttons[0],nIndex*sizeof(TBUTTON_INFO)); 1150 1151 if (nIndex < infoPtr->nNumButtons) 1152 memcpy (&newButtons[nIndex],&infoPtr->buttons[nIndex+1],(infoPtr->nNumButtons-nIndex)*sizeof(TBUTTON_INFO)); 1153 1154 COMCTL32_Free(infoPtr->buttons); 1155 infoPtr->buttons = newButtons; 1156 } else 1157 { 1158 LRESULT leftSel,leftCount,leftPos; 1159 1160 leftSel = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1161 leftCount = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCOUNT,0,0); 1162 1163 if (leftSel == 0) 1164 if (leftCount > 1) leftSel++; else leftSel = -1; 1165 1166 if (leftSel != (LRESULT)-1) 1167 leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_INSERTSTRING,leftSel,(LPARAM)""); 1168 else 1169 leftPos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 1170 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,leftPos,customID); 1171 1172 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETCURSEL,leftPos,0); 1173 TBCUSTOMIZE_AvailSelChange(hwnd); 1174 1175 btnPtr->fsState |= TBSTATE_HIDDEN; 1176 1177 if (leftCount > 1) 1178 { //change order 1179 TBUTTON_INFO* btnPtr2; 1180 INT customID2,pos1,pos2; 1181 1182 pos1 = 0; 1183 while (infoPtr->buttons[pos1].nCustomID != customID) pos1++; 1184 if (leftPos < leftCount) 1185 { //insert before 1186 customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos+1,0); 1187 pos2 = 0; 1188 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1189 } else 1190 { //insert behind 1191 INT x; 1192 1193 customID2 = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETITEMDATA,leftPos-1,0); 1194 pos2 = 0; 1195 while (infoPtr->buttons[pos2].nCustomID != customID2) pos2++; 1196 //exchange to use first alogrithm 1197 x = pos1; 1198 pos1 = pos2; 1199 pos2 = x; 1200 } 1201 1202 if (pos1+1 != pos2) 915 1203 { 916 nItem = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 917 SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_SETITEMDATA,nItem,(LPARAM)btnPtr); 918 leftCount++; 919 } else 920 { 921 nItem = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_ADDSTRING,0,(LPARAM)""); 922 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,nItem,(LPARAM)btnPtr); 923 rightCount++; 1204 TBUTTON_INFO temp; 1205 INT x; 1206 1207 memcpy(&temp,&infoPtr->buttons[pos1],sizeof(TBUTTON_INFO)); 1208 if (pos1 < pos2) 1209 { 1210 for (x = pos1;x < pos2;x++) 1211 memcpy(&infoPtr->buttons[x],&infoPtr->buttons[x+1],sizeof(TBUTTON_INFO)); 1212 memcpy(&infoPtr->buttons[pos2-1],&temp,sizeof(TBUTTON_INFO)); 1213 } else 1214 { 1215 for (x = pos1-1;x >= pos2;x--) 1216 memcpy(&infoPtr->buttons[x+1],&infoPtr->buttons[x],sizeof(TBUTTON_INFO)); 1217 memcpy(&infoPtr->buttons[pos2],&temp,sizeof(TBUTTON_INFO)); 1218 } 924 1219 } 925 1220 } 926 927 if (leftCount == 0 && rightCount == 0)928 {929 EndDialog(hwnd,FALSE);930 931 return TRUE;932 }933 1221 } 934 1222 935 return TRUE; 936 } 937 938 static BOOL TBCUSTOMIZE_Close(HWND hwnd,WPARAM wParam,LPARAM lParam) 939 { 940 EndDialog(hwnd,FALSE); 941 942 return TRUE; 943 } 944 945 static VOID TBCUSTOMIZE_Reset(HWND hwnd) 946 { 947 //CB: todo 948 //Send TBN_RESET 949 } 950 951 static VOID TBCUSTOMIZE_AddTool(HWND hwnd) 952 { 953 //CB: todo 954 } 955 956 static VOID TBCUSTOMIZE_RemoveTool(HWND hwnd) 957 { 958 //CB: todo 1223 if (pos == count-1) pos--; 1224 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos,0); 1225 TBCUSTOMIZE_VisSelChange(hwnd); 1226 1227 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1228 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 959 1229 } 960 1230 … … 974 1244 static VOID TBCUSTOMIZE_MoveToolUp(HWND hwnd) 975 1245 { 976 //CB: todo 1246 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1247 LRESULT pos; 1248 TBUTTON_INFO button; 1249 INT customID; 1250 TBUTTON_INFO* btnPtr1,* btnPtr2; 1251 1252 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1253 if (pos == (LRESULT)-1 || pos == 0) return; 1254 1255 //update listbox 1256 1257 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1258 btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1259 if (btnPtr1 == NULL) return; 1260 1261 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos-1,0); 1262 btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1263 if (btnPtr2 == NULL) return; 1264 1265 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID); 1266 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos-1,btnPtr1->nCustomID); 1267 1268 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos-1,0); 1269 TBCUSTOMIZE_VisSelChange(hwnd); 1270 1271 //update buttons 1272 memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO)); 1273 memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO)); 1274 memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO)); 1275 1276 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1277 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 977 1278 } 978 1279 979 1280 static VOID TBCUSTOMIZE_MoveToolDown(HWND hwnd) 980 1281 { 981 //CB: todo 1282 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1283 LRESULT pos,count; 1284 TBUTTON_INFO button; 1285 INT customID; 1286 TBUTTON_INFO* btnPtr1,* btnPtr2; 1287 1288 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1289 if (pos == (LRESULT)-1) return; 1290 1291 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1292 if (pos == count-1) return; 1293 1294 //update listbox 1295 1296 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1297 btnPtr1 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1298 if (btnPtr1 == NULL) return; 1299 1300 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos+1,0); 1301 btnPtr2 = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1302 if (btnPtr2 == NULL) return; 1303 1304 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos,btnPtr2->nCustomID); 1305 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETITEMDATA,pos+1,btnPtr1->nCustomID); 1306 1307 SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_SETCURSEL,pos+1,0); 1308 TBCUSTOMIZE_VisSelChange(hwnd); 1309 1310 //update buttons 1311 memcpy(&button,btnPtr1,sizeof(TBUTTON_INFO)); 1312 memcpy(btnPtr1,btnPtr2,sizeof(TBUTTON_INFO)); 1313 memcpy(btnPtr2,&button,sizeof(TBUTTON_INFO)); 1314 1315 TOOLBAR_CalcToolbar(infoPtr->hwndToolbar); 1316 InvalidateRect(infoPtr->hwndToolbar,NULL,TRUE); 1317 } 1318 1319 static VOID TBCUSTOMIZE_AvailSelChange(HWND hwnd) 1320 { 1321 LRESULT pos; 1322 HWND hwndBtn; 1323 1324 pos = SendDlgItemMessageA(hwnd,IDC_AVAILBTN_LBOX,LB_GETCURSEL,0,0); 1325 1326 hwndBtn = GetDlgItem(hwnd,IDOK); 1327 EnableWindow(hwndBtn,(pos == (LRESULT)-1) ? FALSE:TRUE); 1328 } 1329 1330 static VOID TBCUSTOMIZE_VisSelChange(HWND hwnd) 1331 { 1332 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1333 LRESULT pos; 1334 1335 pos = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCURSEL,0,0); 1336 1337 if (pos == (LRESULT)-1) 1338 { 1339 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),FALSE); 1340 EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),FALSE); 1341 EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),FALSE); 1342 } else 1343 { 1344 INT customID; 1345 TBUTTON_INFO* btnPtr; 1346 LRESULT count; 1347 1348 customID = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETITEMDATA,pos,0); 1349 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1350 count = SendDlgItemMessageA(hwnd,IDC_TOOLBARBTN_LBOX,LB_GETCOUNT,0,0); 1351 1352 if (btnPtr) 1353 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),btnPtr->bDelete); 1354 else 1355 EnableWindow(GetDlgItem(hwnd,IDC_REMOVE_BTN),TRUE); 1356 EnableWindow(GetDlgItem(hwnd,IDC_MOVEUP_BTN),!(pos == 0)); 1357 EnableWindow(GetDlgItem(hwnd,IDC_MOVEDN_BTN),!(pos == count-1)); 1358 } 982 1359 } 983 1360 … … 1007 1384 TBCUSTOMIZE_MoveToolDown(hwnd); 1008 1385 break; 1386 case IDC_AVAILBTN_LBOX: 1387 switch(HIWORD(wParam)) 1388 { 1389 case LBN_SELCHANGE: 1390 TBCUSTOMIZE_AvailSelChange(hwnd); 1391 break; 1392 case LBN_DBLCLK: 1393 TBCUSTOMIZE_AddTool(hwnd); 1394 break; 1395 } 1396 break; 1397 case IDC_TOOLBARBTN_LBOX: 1398 switch(HIWORD(wParam)) 1399 { 1400 case LBN_SELCHANGE: 1401 TBCUSTOMIZE_VisSelChange(hwnd); 1402 break; 1403 case LBN_DBLCLK: 1404 TBCUSTOMIZE_RemoveTool(hwnd); 1405 break; 1406 } 1407 break; 1009 1408 } 1010 1409 … … 1017 1416 INT x; 1018 1417 1019 for (x = 0;x < infoPtr->nNumButtons;x++) 1020 { 1021 COMCTL32_Free(infoPtr->buttons[x].pszName); 1022 infoPtr->buttons[x].pszName = NULL; 1023 } 1024 1025 if (infoPtr->hDsa) DSA_Destroy(infoPtr->hDsa); 1418 for (x = 0;x < infoPtr->nNumOldButtons;x++) 1419 COMCTL32_Free(infoPtr->oldButtons[x].pszName); 1420 COMCTL32_Free(infoPtr->oldButtons); 1421 infoPtr->oldButtons = NULL; 1422 infoPtr->nNumOldButtons = 0; 1026 1423 1027 1424 return TRUE; … … 1040 1437 COLORREF oldText = 0; 1041 1438 COLORREF oldBk = 0; 1439 INT customID; 1042 1440 TBUTTON_INFO* btnPtr; 1043 1441 DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE); 1044 1442 1045 btnPtr = (TBUTTON_INFO*)SendDlgItemMessageA(hwnd,wParam,LB_GETITEMDATA,lpdis->itemID,0); 1046 1047 // FIXME(toolbar, "action: %x itemState: %x\n", 1048 // lpdis->itemAction, lpdis->itemState); 1049 1050 if (btnPtr != NULL && !btnPtr->bDelete) 1443 customID = SendDlgItemMessageA(hwnd,wParam,LB_GETITEMDATA,lpdis->itemID,0); 1444 btnPtr = TBCUSTOMIZE_GetBtnPtr(infoPtr,customID); 1445 1446 if (btnPtr != NULL && !btnPtr->bDelete) 1051 1447 { 1052 1448 if (lpdis->itemState & ODS_FOCUS) oldBk = SetBkColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHT)); … … 1075 1471 if (lpdis->itemState & ODS_FOCUS) DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1076 1472 1077 /* draw button */ 1078 DrawEdge(lpdis->hDC,&rcButton,EDGE_RAISED,BF_RECT|BF_MIDDLE|BF_SOFT|BF_ADJUST); 1079 1080 if (btnPtr && !btnPtr->fsStyle & TBSTYLE_SEP) 1473 //draw tool 1474 if (btnPtr && !(btnPtr->fsStyle & TBSTYLE_SEP)) 1081 1475 { 1476 //draw button 1082 1477 if (dwStyle & TBSTYLE_FLAT) 1083 1478 { 1084 if(infoPtr->himlDef != NULL) 1085 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC, 1086 rcButton.left+2,rcButton.top+2,ILD_NORMAL); 1087 else 1088 ImageList_Draw(infoPtr->himlStd,btnPtr->iBitmap,lpdis->hDC, 1089 rcButton.left+2,rcButton.top+2,ILD_NORMAL); 1479 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+2,rcButton.top+2,ILD_NORMAL); 1090 1480 } else 1091 1481 { 1092 /* normal state */1093 ImageList_Draw(infoPtr->himlStd,btnPtr->iBitmap,lpdis->hDC, 1094 1482 DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 1483 1484 ImageList_Draw(infoPtr->himlDef,btnPtr->iBitmap,lpdis->hDC,rcButton.left+1,rcButton.top+1,ILD_NORMAL); 1095 1485 } 1486 1096 1487 } else 1097 1488 { //draw separator 1098 1489 if (!(dwStyle & TBSTYLE_FLAT)) 1490 DrawEdge (lpdis->hDC,&rcButton,EDGE_RAISED,BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 1491 1492 TOOLBAR_DrawFlatSeparator(&rcButton,lpdis->hDC); 1099 1493 } 1100 1494 … … 1130 1524 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1131 1525 1132 infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER);1133 1134 1526 if (infoPtr) 1135 lpmis->itemHeight = infoPtr->nBitmapHeight+8; 1136 else 1137 lpmis->itemHeight = 16+8; /* default height */ 1527 { 1528 DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE); 1529 1530 if (dwStyle & TBSTYLE_FLAT) 1531 lpmis->itemHeight = infoPtr->nBitmapHeight+4; 1532 else 1533 lpmis->itemHeight = infoPtr->nBitmapHeight+8; 1534 } else lpmis->itemHeight = 16+8; 1138 1535 1139 1536 return TRUE; … … 1187 1584 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1188 1585 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam; 1189 INT nIndex = 0 ;1190 1191 if ( (!lpAddBmp) || ((INT)wParam <= 0))1586 INT nIndex = 0,nButtons; 1587 1588 if (!lpAddBmp) 1192 1589 return -1; 1193 1590 1194 // TRACE (toolbar, "adding %d bitmaps!\n", wParam); 1195 1196 if (!(infoPtr->himlStd)) { 1197 /* create new standard image list */ 1198 1199 // TRACE (toolbar, "creating standard image list!\n"); 1200 1591 if (lpAddBmp->hInst == HINST_COMMCTRL) 1592 { 1593 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR) 1594 nButtons = 15; 1595 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR) 1596 nButtons = 13; 1597 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR) 1598 nButtons = 5; 1599 else 1600 return -1; 1601 1602 // TRACE ("adding %d internal bitmaps!\n", nButtons); 1201 1603 1202 1604 /* Windows resize all the buttons to the size of a newly added STandard Image*/ 1203 /* TODO: The resizing should be done each time a standard image is added*/ 1204 if (lpAddBmp->hInst == HINST_COMMCTRL) 1605 if (lpAddBmp->nID & 1) 1205 1606 { 1206 1207 if (lpAddBmp->nID & 1) 1208 { 1209 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1210 MAKELPARAM((WORD)26, (WORD)26)); 1211 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1212 MAKELPARAM((WORD)33, (WORD)33)); 1213 } 1214 else 1215 { 1216 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1217 MAKELPARAM((WORD)16, (WORD)16)); 1218 1219 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1220 MAKELPARAM((WORD)22, (WORD)22)); 1221 } 1222 1223 TOOLBAR_CalcToolbar (hwnd); 1607 /* large icons */ 1608 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1609 MAKELPARAM((WORD)26, (WORD)26)); 1610 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1611 MAKELPARAM((WORD)33, (WORD)33)); 1224 1612 } 1225 1226 infoPtr->himlStd = 1613 else 1614 { 1615 /* small icons */ 1616 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1617 MAKELPARAM((WORD)16, (WORD)16)); 1618 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1619 MAKELPARAM((WORD)22, (WORD)22)); 1620 } 1621 1622 TOOLBAR_CalcToolbar (hwnd); 1623 } 1624 else 1625 { 1626 nButtons = (INT)wParam; 1627 if (nButtons <= 0) 1628 return -1; 1629 1630 // TRACE ("adding %d bitmaps!\n", nButtons); 1631 } 1632 1633 if (!(infoPtr->himlDef)) { 1634 /* create new default image list */ 1635 // TRACE ("creating default image list!\n"); 1636 1637 infoPtr->himlDef = 1227 1638 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, 1228 ILC_COLOR | ILC_MASK, (INT)wParam, 2); 1229 } 1230 1231 /* Add bitmaps to the standard image list */ 1232 if (lpAddBmp->hInst == (HINSTANCE)0) { 1639 ILC_COLOR | ILC_MASK, nButtons, 2); 1640 infoPtr->himlInt = infoPtr->himlDef; 1641 } 1642 1643 /* Add bitmaps to the default image list */ 1644 if (lpAddBmp->hInst == (HINSTANCE)0) 1645 { 1233 1646 nIndex = 1234 ImageList_AddMasked (infoPtr->himl Std, (HBITMAP)lpAddBmp->nID,1647 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID, 1235 1648 CLR_DEFAULT); 1236 1649 } 1237 else if (lpAddBmp->hInst == HINST_COMMCTRL) { 1650 else if (lpAddBmp->hInst == HINST_COMMCTRL) 1651 { 1238 1652 /* add internal bitmaps */ 1239 1240 // FIXME (toolbar, "internal bitmaps not supported!\n"); 1241 /* TODO: Resize all the buttons when a new standard image is added */ 1653 // FIXME ("internal bitmaps not supported!\n"); 1242 1654 1243 1655 /* Hack to "add" some reserved images within the image list 1244 1656 to get the right image indices */ 1245 nIndex = ImageList_GetImageCount (infoPtr->himl Std);1246 ImageList_SetImageCount (infoPtr->himl Std, nIndex + (INT)wParam);1247 1248 }1249 else{1657 nIndex = ImageList_GetImageCount (infoPtr->himlDef); 1658 ImageList_SetImageCount (infoPtr->himlDef, nIndex + nButtons); 1659 } 1660 else 1661 { 1250 1662 HBITMAP hBmp = 1251 1663 LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1252 nIndex = ImageList_AddMasked (infoPtr->himl Std, hBmp, CLR_DEFAULT);1664 nIndex = ImageList_AddMasked (infoPtr->himlDef, hBmp, CLR_DEFAULT); 1253 1665 1254 1666 DeleteObject (hBmp); 1255 1667 } 1256 1668 1257 infoPtr->nNumBitmaps += (INT)wParam;1669 infoPtr->nNumBitmaps += nButtons; 1258 1670 1259 1671 return nIndex; … … 1632 2044 HRSRC hRes; 1633 2045 NMHDR nmhdr; 2046 2047 if (infoPtr->nNumButtons == 0) return 0; 1634 2048 1635 2049 /* send TBN_BEGINADJUST notification */ … … 1966 2380 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1967 2381 1968 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 1969 return (LRESULT)infoPtr->himlDis; 1970 else 1971 return 0; 2382 return (LRESULT)infoPtr->himlDis; 1972 2383 } 1973 2384 … … 1987 2398 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1988 2399 1989 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 1990 return (LRESULT)infoPtr->himlHot; 1991 else 1992 return 0; 2400 return (LRESULT)infoPtr->himlHot; 1993 2401 } 1994 2402 … … 2002 2410 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2003 2411 2004 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 2005 return (LRESULT)infoPtr->himlDef; 2006 else 2007 return 0; 2412 return (LRESULT)infoPtr->himlDef; 2008 2413 } 2009 2414 … … 2654 3059 HIMAGELIST himlTemp; 2655 3060 2656 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))2657 return 0;2658 2659 3061 himlTemp = infoPtr->himlDis; 2660 3062 infoPtr->himlDis = (HIMAGELIST)lParam; … … 2699 3101 HIMAGELIST himlTemp; 2700 3102 2701 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))2702 return 0;2703 2704 3103 himlTemp = infoPtr->himlHot; 2705 3104 infoPtr->himlHot = (HIMAGELIST)lParam; … … 2719 3118 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2720 3119 HIMAGELIST himlTemp; 2721 2722 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))2723 return 0;2724 3120 2725 3121 himlTemp = infoPtr->himlDef; … … 2933 3329 infoPtr->dwDTFlags = DT_CENTER; 2934 3330 2935 infoPtr->hDsa = NULL;2936 3331 infoPtr->hwndToolbar = hwnd; 3332 infoPtr->oldButtons = NULL; 3333 infoPtr->nNumOldButtons = 0; 2937 3334 2938 3335 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); … … 2994 3391 } 2995 3392 2996 /* destroy default image list */ 2997 if (infoPtr->himlDef) 2998 ImageList_Destroy (infoPtr->himlDef); 2999 3000 /* destroy disabled image list */ 3001 if (infoPtr->himlDis) 3002 ImageList_Destroy (infoPtr->himlDis); 3003 3004 /* destroy hot image list */ 3005 if (infoPtr->himlHot) 3006 ImageList_Destroy (infoPtr->himlHot); 3393 /* destroy internal image list */ 3394 if (infoPtr->himlInt) 3395 ImageList_Destroy (infoPtr->himlInt); 3007 3396 3008 3397 /* delete default font */ … … 3192 3581 { 3193 3582 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 3194 if (oldBtnPtr->bHot) 3583 if (oldBtnPtr->bHot) //CB: dynamic buttons 3195 3584 { 3196 3585 oldBtnPtr->bHot = FALSE;
Note:
See TracChangeset
for help on using the changeset viewer.