- Timestamp:
- Jul 7, 1999, 7:08:43 PM (26 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/makefile
r190 r285 1 # $Id: makefile,v 1. 7 1999-06-25 15:49:02 achimhaExp $1 # $Id: makefile,v 1.8 1999-07-07 17:08:42 cbratschi Exp $ 2 2 # 3 # PD-Win32 API 3 # PD-Win32 API 4 4 # 5 # 6 # 5 # comctl32.dll makefile 6 # 7 7 8 8 PDWIN32_INCLUDE = ..\..\include … … 29 29 30 30 31 $(TARGET).dll: $(OBJS) $(TARGET).def 32 31 $(TARGET).dll: $(OBJS) $(TARGET).def 32 $(LD) $(LDFLAGS) -Fm -Fe$@ $(OBJS) $(TARGET).def \ 33 33 $(PDWIN32_LIB)/kernel32.lib \ 34 34 $(PDWIN32_LIB)/gdi32.lib \ … … 40 40 41 41 $(TARGET).lib: $(TARGET).dll 42 43 42 $(IMPLIB) $(IMPLIBFLAGS) $@ $(TARGET).dll 43 $(CP) $@ $(PDWIN32_LIB) 44 44 45 45 comctl32.obj: comctl32.c … … 72 72 73 73 clean: 74 $(RM) *.obj *.lib *.dll *~ *.map *.pch 75 76 74 $(RM) *.obj *.lib *.dll *~ *.map *.pch 75 $(RM) $(PDWIN32_BIN)\$(TARGET).dll 76 $(RM) $(PDWIN32_LIB)\$(TARGET).lib 77 77 -
trunk/src/comctl32/toolbar.c
r267 r285 1 /* $Id: toolbar.c,v 1. 9 1999-07-04 21:06:00cbratschi Exp $ */1 /* $Id: toolbar.c,v 1.10 1999-07-07 17:08:42 cbratschi Exp $ */ 2 2 /* 3 3 * Toolbar control … … 16 16 * - Internal COMMCTL32 bitmaps. 17 17 * - Fix TOOLBAR_SetButtonInfo32A. 18 * - Customize dialog (under construction). 18 * - Customize dialog (CB: under construction). 19 * - Drag & drop of buttons 19 20 * 20 21 * Testing: … … 720 721 } 721 722 723 static void TBCUSTOMIZE_GetToolNameA(TOOLBAR_INFO* infoPtr,TBUTTON_INFO* btnPtr,INT pos) 724 { 725 if (btnPtr->iString > -1 && btnPtr->iString < infoPtr->nNumStrings) 726 { 727 if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 728 lstrcpynW(btnPtr->pszName,infoPtr->strings[btnPtr->iString],MAXTOOLNAME*sizeof(WCHAR)); 729 730 return; 731 } 732 733 if (btnPtr->fsStyle & TBSTYLE_SEP) 734 { 735 if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 736 lstrcpyAtoW(btnPtr->pszName,"Separator"); 737 } else 738 { 739 TBNOTIFYA tbNotify; 740 741 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 742 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 743 tbNotify.hdr.code = TBN_GETBUTTONINFOA; 744 tbNotify.iItem = pos; 745 tbNotify.tbButton = (TBBUTTON*)btnPtr; 746 tbNotify.cchText = MAXTOOLNAME; 747 tbNotify.pszText = COMCTL32_Alloc(MAXTOOLNAME); 748 tbNotify.pszText[0] = 0; 749 750 if (!SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) 751 { //CB: failed, try other methods 752 if (infoPtr->hwndToolTip) 753 { //try to get tool tip text 754 TTTOOLINFOA ti; 755 756 ZeroMemory (&ti,sizeof(ti)); 757 ti.cbSize = sizeof(ti); 758 ti.hwnd = infoPtr->hwndToolbar; 759 ti.uId = btnPtr->idCommand; 760 ti.hinst = 0; 761 ti.lpszText = COMCTL32_Alloc(INFOTIPSIZE); 762 ti.lpszText[0] = 0; 763 764 SendMessageA(infoPtr->hwndToolTip,TTM_GETTEXTA,0,(LPARAM)&ti); 765 if (ti.lpszText[0] != 0) lstrcpynA(tbNotify.pszText,ti.lpszText,MAXTOOLNAME); 766 else strcpy(tbNotify.pszText,"Button"); 767 768 COMCTL32_Free(ti.lpszText); 769 770 } else strcpy(tbNotify.pszText,"Button"); 771 } 772 773 if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 774 lstrcpyAtoW(btnPtr->pszName,tbNotify.pszText); 775 COMCTL32_Free(tbNotify.pszText); 776 } 777 } 778 779 static void TBCUSTOMIZE_GetToolNameW(TOOLBAR_INFO* infoPtr,TBUTTON_INFO* btnPtr,INT pos) 780 { 781 if (btnPtr->iString > -1 && btnPtr->iString < infoPtr->nNumStrings) 782 { 783 if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 784 lstrcpynW(btnPtr->pszName,infoPtr->strings[btnPtr->iString],MAXTOOLNAME*sizeof(WCHAR)); 785 786 return; 787 } 788 789 if (btnPtr->fsStyle & TBSTYLE_SEP) 790 { 791 if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 792 lstrcpyAtoW(btnPtr->pszName,"Separator"); 793 } else 794 { 795 TBNOTIFYW tbNotify; 796 797 if (!btnPtr->pszName) btnPtr->pszName = COMCTL32_Alloc(MAXTOOLNAME*sizeof(WCHAR)); 798 btnPtr->pszName[0] = 0; 799 800 tbNotify.hdr.hwndFrom = infoPtr->hwndToolbar; 801 tbNotify.hdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 802 tbNotify.hdr.code = TBN_GETBUTTONINFOW; 803 tbNotify.iItem = pos; 804 tbNotify.tbButton = (TBBUTTON*)btnPtr; 805 tbNotify.cchText = MAXTOOLNAME; 806 tbNotify.pszText = btnPtr->pszName; 807 808 if (!SendMessageW(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)tbNotify.hdr.idFrom,(LPARAM)&tbNotify)) 809 { //CB: failed, try other methods 810 if (infoPtr->hwndToolTip) 811 { //try to get tool tip text 812 TTTOOLINFOW ti; 813 814 ZeroMemory (&ti,sizeof(ti)); 815 ti.cbSize = sizeof(ti); 816 ti.hwnd = infoPtr->hwndToolbar; 817 ti.uId = btnPtr->idCommand; 818 ti.hinst = 0; 819 ti.lpszText = COMCTL32_Alloc(INFOTIPSIZE*sizeof(WCHAR)); 820 ti.lpszText[0] = 0; 821 822 SendMessageA(infoPtr->hwndToolTip,TTM_GETTEXTW,0,(LPARAM)&ti); 823 if (ti.lpszText[0] != 0) lstrcpynW(btnPtr->pszName,ti.lpszText,MAXTOOLNAME); 824 else lstrcpyAtoW(btnPtr->pszName,"Button"); 825 826 COMCTL32_Free(ti.lpszText); 827 828 } else lstrcpyAtoW(btnPtr->pszName,"Button"); 829 } 830 } 831 } 832 833 static BOOL TBCUSTOMIZE_InitDialog(HWND hwnd,WPARAM wParam,LPARAM lParam) 834 { 835 TOOLBAR_INFO* infoPtr; 836 837 infoPtr = (TOOLBAR_INFO*)lParam; 838 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr); 839 840 if (infoPtr) 841 { 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++) 856 { 857 DSA_InsertItem (infoPtr->hDsa, i, btnPtr); 858 859 if (IsWindowUnicode(infoPtr->hwndNotify)) 860 { 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 886 } else 887 { 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); 912 } 913 914 if (btnPtr->fsState & TBSTATE_HIDDEN) 915 { 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++; 924 } 925 } 926 927 if (leftCount == 0 && rightCount == 0) 928 { 929 EndDialog(hwnd,FALSE); 930 931 return TRUE; 932 } 933 } 934 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 959 } 960 961 static VOID TBCUSTOMIZE_Help(HWND hwnd) 962 { 963 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 964 NMHDR nmhdr; 965 966 //Send TBN_CUSTHELP 967 nmhdr.hwndFrom = infoPtr->hwndToolbar; 968 nmhdr.idFrom = GetWindowLongA(infoPtr->hwndToolbar,GWL_ID); 969 nmhdr.code = TBN_CUSTHELP; 970 971 SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr); 972 } 973 974 static VOID TBCUSTOMIZE_MoveToolUp(HWND hwnd) 975 { 976 //CB: todo 977 } 978 979 static VOID TBCUSTOMIZE_MoveToolDown(HWND hwnd) 980 { 981 //CB: todo 982 } 983 984 static BOOL TBCUSTOMIZE_Command(HWND hwnd,WPARAM wParam,LPARAM lParam) 985 { 986 switch(LOWORD(wParam)) 987 { 988 case IDCANCEL: 989 EndDialog(hwnd,FALSE); 990 break; 991 case IDC_RESET_BTN: 992 TBCUSTOMIZE_Reset(hwnd); 993 break; 994 case IDOK: //== add tool 995 TBCUSTOMIZE_AddTool(hwnd); 996 break; 997 case IDC_REMOVE_BTN: 998 TBCUSTOMIZE_RemoveTool(hwnd); 999 break; 1000 case IDC_HELP_BTN: 1001 TBCUSTOMIZE_Help(hwnd); 1002 break; 1003 case IDC_MOVEUP_BTN: 1004 TBCUSTOMIZE_MoveToolUp(hwnd); 1005 break; 1006 case IDC_MOVEDN_BTN: 1007 TBCUSTOMIZE_MoveToolDown(hwnd); 1008 break; 1009 } 1010 1011 return TRUE; 1012 } 1013 1014 static BOOL TBCUSTOMIZE_Destroy(HWND hwnd,WPARAM wParam,LPARAM lParam) 1015 { 1016 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1017 INT x; 1018 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); 1026 1027 return TRUE; 1028 } 1029 1030 static BOOL TBCUSTOMIZE_DrawItem(HWND hwnd,WPARAM wParam,LPARAM lParam) 1031 { 1032 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1033 { 1034 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1035 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 1036 RECT rcButton; 1037 RECT rcText; 1038 HPEN hOldPen; 1039 HBRUSH hOldBrush; 1040 COLORREF oldText = 0; 1041 COLORREF oldBk = 0; 1042 TBUTTON_INFO* btnPtr; 1043 DWORD dwStyle = GetWindowLongA(infoPtr->hwndToolbar,GWL_STYLE); 1044 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) 1051 { 1052 if (lpdis->itemState & ODS_FOCUS) oldBk = SetBkColor(lpdis->hDC,GetSysColor(COLOR_HIGHLIGHT)); 1053 oldText = SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT)); 1054 } else if (lpdis->itemState & ODS_FOCUS) 1055 { 1056 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 1057 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 1058 } 1059 1060 1061 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1062 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1063 1064 /* fill background rectangle */ 1065 Rectangle (lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,lpdis->rcItem.right,lpdis->rcItem.bottom); 1066 1067 /* calculate button and text rectangles */ 1068 CopyRect (&rcButton, &lpdis->rcItem); 1069 InflateRect (&rcButton, -1, -1); 1070 CopyRect (&rcText, &rcButton); 1071 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6; 1072 rcText.left = rcButton.right + 2; 1073 1074 /* draw focus rectangle */ 1075 if (lpdis->itemState & ODS_FOCUS) DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1076 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) 1081 { 1082 if (dwStyle & TBSTYLE_FLAT) 1083 { 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); 1090 } else 1091 { 1092 /* normal state */ 1093 ImageList_Draw(infoPtr->himlStd,btnPtr->iBitmap,lpdis->hDC, 1094 rcButton.left+1,rcButton.top+1,ILD_NORMAL); 1095 } 1096 } else 1097 { //draw separator 1098 1099 } 1100 1101 /* draw text */ 1102 if (btnPtr == NULL) 1103 { //new separator 1104 DrawTextA(lpdis->hDC,"Separator",-1,&rcText,DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1105 } else if (btnPtr->pszName != NULL) 1106 { 1107 DrawTextW(lpdis->hDC,btnPtr->pszName,-1,&rcText,DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1108 } 1109 1110 if (lpdis->itemState & ODS_FOCUS) 1111 { 1112 SetBkColor (lpdis->hDC, oldBk); 1113 SetTextColor (lpdis->hDC, oldText); 1114 } 1115 1116 SelectObject (lpdis->hDC, hOldBrush); 1117 SelectObject (lpdis->hDC, hOldPen); 1118 1119 return TRUE; 1120 } 1121 1122 return FALSE; 1123 } 1124 1125 static BOOL TBCUSTOMIZE_MeasureItem(HWND hwnd,WPARAM wParam,LPARAM lParam) 1126 { 1127 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1128 { 1129 TOOLBAR_INFO* infoPtr = (TOOLBAR_INFO*)GetWindowLongA(hwnd,DWL_USER); 1130 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1131 1132 infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER); 1133 1134 if (infoPtr) 1135 lpmis->itemHeight = infoPtr->nBitmapHeight+8; 1136 else 1137 lpmis->itemHeight = 16+8; /* default height */ 1138 1139 return TRUE; 1140 } 1141 1142 return FALSE; 1143 } 722 1144 723 1145 /*********************************************************************** … … 729 1151 { 730 1152 TOOLBAR_INFO *infoPtr; 731 static HDSA hDsa = NULL;732 1153 733 1154 switch (uMsg) 734 1155 { 735 1156 case WM_INITDIALOG: 736 infoPtr = (TOOLBAR_INFO *)lParam; 737 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr); 738 739 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5); 740 741 if (infoPtr) 742 { 743 TBUTTON_INFO *btnPtr; 744 INT i; 745 746 /* insert 'virtual' separator button into 'available buttons' list */ 747 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 748 749 /* copy all buttons and append them to the right listbox */ 750 btnPtr = infoPtr->buttons; 751 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 752 { 753 DSA_InsertItem (hDsa, i, btnPtr); 754 755 if (btnPtr->fsState & TBSTATE_HIDDEN) 756 { 757 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 758 } 759 else 760 { 761 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 762 } 763 } 764 765 /* append 'virtual' sepatator button to the 'toolbar buttons' list */ 766 /* TODO */ 767 } 768 return TRUE; 1157 return TBCUSTOMIZE_InitDialog(hwnd,wParam,lParam); 769 1158 770 1159 case WM_CLOSE: 771 EndDialog(hwnd, FALSE); 772 return TRUE; 1160 return TBCUSTOMIZE_Close(hwnd,wParam,lParam); 773 1161 774 1162 case WM_COMMAND: 775 switch (LOWORD(wParam)) 776 { 777 case IDCANCEL: 778 EndDialog(hwnd, FALSE); 779 break; 780 } 781 return TRUE; 1163 return TBCUSTOMIZE_Command(hwnd,wParam,lParam); 782 1164 783 1165 case WM_DESTROY: 784 if (hDsa) 785 DSA_Destroy (hDsa); 786 return TRUE; 1166 return TBCUSTOMIZE_Destroy(hwnd,wParam,lParam); 787 1167 788 1168 case WM_DRAWITEM: 789 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 790 { 791 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 792 RECT rcButton; 793 RECT rcText; 794 HPEN hOldPen; 795 HBRUSH hOldBrush; 796 COLORREF oldText = 0; 797 COLORREF oldBk = 0; 798 799 // FIXME(toolbar, "action: %x itemState: %x\n", 800 // lpdis->itemAction, lpdis->itemState); 801 802 infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER); 803 804 if (lpdis->itemState & ODS_FOCUS) 805 { 806 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 807 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 808 } 809 810 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 811 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 812 813 /* fill background rectangle */ 814 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 815 lpdis->rcItem.right, lpdis->rcItem.bottom); 816 817 /* calculate button and text rectangles */ 818 CopyRect (&rcButton, &lpdis->rcItem); 819 InflateRect (&rcButton, -1, -1); 820 CopyRect (&rcText, &rcButton); 821 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6; 822 rcText.left = rcButton.right + 2; 823 824 /* draw focus rectangle */ 825 if (lpdis->itemState & ODS_FOCUS) 826 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 827 828 /* draw button */ 829 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 830 831 /* draw text */ 832 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0) 833 DrawTextA (lpdis->hDC, "Separator", -1, &rcText, 834 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 835 836 if (lpdis->itemState & ODS_FOCUS) 837 { 838 SetBkColor (lpdis->hDC, oldBk); 839 SetTextColor (lpdis->hDC, oldText); 840 } 841 842 SelectObject (lpdis->hDC, hOldBrush); 843 SelectObject (lpdis->hDC, hOldPen); 844 845 return TRUE; 846 } 847 return FALSE; 1169 return TBCUSTOMIZE_DrawItem(hwnd,wParam,lParam); 848 1170 849 1171 case WM_MEASUREITEM: 850 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 851 { 852 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 853 854 infoPtr = (TOOLBAR_INFO *)GetWindowLongA(hwnd,DWL_USER); 855 856 if (infoPtr) 857 lpmis->itemHeight = infoPtr->nBitmapHeight + 8; 858 else 859 lpmis->itemHeight = 16 + 8; /* default height */ 860 861 return TRUE; 862 } 863 return FALSE; 1172 return TBCUSTOMIZE_MeasureItem(hwnd,wParam,lParam); 864 1173 865 1174 default: … … 963 1272 nAddButtons = (UINT)wParam; 964 1273 nOldButtons = infoPtr->nNumButtons; 965 nNewButtons = nOldButtons + nAddButtons; 966 967 if (infoPtr->nNumButtons == 0) { 968 infoPtr->buttons = 969 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 970 } 971 else { 972 TBUTTON_INFO *oldButtons = infoPtr->buttons; 973 infoPtr->buttons = 974 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 975 memcpy (&infoPtr->buttons[0], &oldButtons[0], 976 nOldButtons * sizeof(TBUTTON_INFO)); 977 COMCTL32_Free (oldButtons); 1274 nNewButtons = nOldButtons+nAddButtons; 1275 1276 if (infoPtr->nNumButtons == 0) 1277 { 1278 infoPtr->buttons = COMCTL32_Alloc(sizeof(TBUTTON_INFO)*nNewButtons); 1279 } else 1280 { 1281 TBUTTON_INFO* oldButtons = infoPtr->buttons; 1282 1283 infoPtr->buttons = COMCTL32_Alloc(sizeof(TBUTTON_INFO)*nNewButtons); 1284 memcpy(&infoPtr->buttons[0], &oldButtons[0],nOldButtons * sizeof(TBUTTON_INFO)); 1285 COMCTL32_Free(oldButtons); 978 1286 } 979 1287 … … 983 1291 for (nCount = 0; nCount < nAddButtons; nCount++) 984 1292 { 985 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1293 TBUTTON_INFO* btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 1294 986 1295 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 987 1296 btnPtr->idCommand = lpTbb[nCount].idCommand; … … 991 1300 btnPtr->iString = lpTbb[nCount].iString; 992 1301 btnPtr->bHot = FALSE; 1302 btnPtr->bDelete = FALSE; //only used in customize 1303 btnPtr->pszName = NULL; 993 1304 994 1305 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) … … 1324 1635 /* send TBN_BEGINADJUST notification */ 1325 1636 nmhdr.hwndFrom = hwnd; 1326 nmhdr.idFrom = GetWindowLongA (hwnd,GWL_ID);1637 nmhdr.idFrom = GetWindowLongA(hwnd,GWL_ID); 1327 1638 nmhdr.code = TBN_BEGINADJUST; 1328 1639 1329 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 1330 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 1640 SendMessageA (infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr); 1331 1641 1332 1642 //load OS/2 dialog … … 1339 1649 (LPARAM)infoPtr); 1340 1650 1341 if (ret == (INT)-1) ret urn FALSE;1651 if (ret == (INT)-1) ret = 0; 1342 1652 1343 1653 /* //original WINE code … … 1360 1670 nmhdr.code = TBN_ENDADJUST; 1361 1671 1362 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 1363 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 1672 SendMessageA(infoPtr->hwndNotify,WM_NOTIFY,(WPARAM)nmhdr.idFrom,(LPARAM)&nmhdr); 1364 1673 1365 1674 return ret; … … 1388 1697 } 1389 1698 1390 if (infoPtr->nNumButtons == 1) { 1699 COMCTL32_Free(infoPtr->buttons[nIndex].pszName); 1700 1701 if (infoPtr->nNumButtons == 1) 1702 { 1391 1703 // TRACE (toolbar, " simple delete!\n"); 1392 1704 COMCTL32_Free (infoPtr->buttons); 1393 1705 infoPtr->buttons = NULL; 1394 1706 infoPtr->nNumButtons = 0; 1395 } 1396 else{1707 } else 1708 { 1397 1709 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1398 1710 // TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex); … … 2621 2933 infoPtr->dwDTFlags = DT_CENTER; 2622 2934 2935 infoPtr->hDsa = NULL; 2936 infoPtr->hwndToolbar = hwnd; 2937 2623 2938 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); 2624 2939 infoPtr->hFont = CreateFontIndirectA (&logFont); … … 2662 2977 /* delete button data */ 2663 2978 if (infoPtr->buttons) 2664 COMCTL32_Free (infoPtr->buttons); 2979 { 2980 INT x; 2981 2982 for (x = 0;x < infoPtr->nNumButtons;x++) COMCTL32_Free(infoPtr->buttons[x].pszName); 2983 COMCTL32_Free(infoPtr->buttons); 2984 } 2665 2985 2666 2986 /* delete strings */ -
trunk/src/comctl32/tooltips.c
r267 r285 1 /* $Id: tooltips.c,v 1.1 0 1999-07-04 21:06:00cbratschi Exp $ */1 /* $Id: tooltips.c,v 1.11 1999-07-07 17:08:43 cbratschi Exp $ */ 2 2 /* 3 3 * Tool tip control … … 1133 1133 if (nTool == -1) return 0; 1134 1134 1135 lstrcpyWtoA (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText); 1135 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); 1136 1137 lstrcpyWtoA(lpToolInfo->lpszText,infoPtr->szTipText); 1136 1138 1137 1139 return 0; … … 1154 1156 if (nTool == -1) return 0; 1155 1157 1156 lstrcpyW (lpToolInfo->lpszText, infoPtr->tools[nTool].lpszText); 1158 TOOLTIPS_GetTipText(hwnd,infoPtr,nTool); 1159 1160 lstrcpyW(lpToolInfo->lpszText,infoPtr->szTipText); 1157 1161 1158 1162 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.