Changeset 48
- Timestamp:
- Mar 14, 2001, 7:57:34 PM (24 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/cnrh.h
r46 r48 502 502 ULONG fl); 503 503 504 ULONG cnrhExpandFromRoot(HWND hwndCnr, 505 PRECORDCORE prec); 506 504 507 ULONG cnrhScrollToRecord(HWND hwndCnr, 505 508 PRECORDCORE pRec, -
trunk/include/helpers/dosh.h
r46 r48 237 237 * 238 238 *@@added V0.9.7 (2000-12-02) [umoeller] 239 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load 239 240 */ 240 241 … … 246 247 PLONG palLoads; 247 248 249 // output: one CPU interrupt load for each CPU 250 PLONG palIntrs; 251 248 252 // each of the following ptrs points to an array of cProcessors items 249 253 PCPUUTIL paCPUUtils; // CPUUTIL structures 250 254 double *padBusyPrev; // previous "busy" calculations 251 255 double *padTimePrev; // previous "time" calculations 256 double *padIntrPrev; // previous "intr" calculations 252 257 253 258 // private stuff -
trunk/include/helpers/winh.h
r46 r48 105 105 /* ****************************************************************** 106 106 * 107 * Rectangle helpers 108 * 109 ********************************************************************/ 110 111 VOID XWPENTRY winhOffsetRect(PRECTL prcl, LONG lx, LONG ly); 112 113 /* ****************************************************************** 114 * 107 115 * Menu helpers 108 116 * … … 689 697 PHWND phwndClient); 690 698 691 HWND winhCreateObjectWindow(const char *pcszWindowClass, 692 PVOID pvCreateParam); 699 HWND XWPENTRY winhCreateObjectWindow(const char *pcszWindowClass, 700 PVOID pvCreateParam); 701 702 HWND XWPENTRY winhCreateControl(HWND hwndParentAndOwner, 703 const char *pcszClass, 704 const char *pcszText, 705 ULONG ulStyle, 706 ULONG ulID); 693 707 694 708 VOID XWPENTRY winhRepaintWindows(HWND hwndParent); -
trunk/src/helpers/cnrh.c
r46 r48 947 947 948 948 /* 949 *@@ cnrhExpandFromRoot: 950 * expands prec and climbs up all parent 951 * records and expands them all as well. 952 * 953 * Returns the no. of records expanded. 954 * 955 *@@added V0.9.9 (2001-03-13) [umoeller] 956 */ 957 958 ULONG cnrhExpandFromRoot(HWND hwndCnr, 959 PRECORDCORE prec) 960 { 961 ULONG ul = 0; 962 PRECORDCORE preccParent = prec; 963 while (preccParent) 964 { 965 WinSendMsg(hwndCnr, CM_EXPANDTREE, (MPARAM)preccParent, MPNULL); 966 ul++; 967 968 preccParent = (PRECORDCORE)WinSendMsg(hwndCnr, 969 CM_QUERYRECORD, 970 (MPARAM)preccParent, 971 MPFROM2SHORT(CMA_PARENT, 972 CMA_ITEMORDER)); 973 974 if (preccParent == (PRECORDCORE)-1) 975 preccParent = NULL; 976 } 977 978 return (ul); 979 } 980 981 /* 949 982 *@@ cnrhScrollToRecord: 950 983 * scrolls a given container control to make a given … … 957 990 * -- 3: record is already visible (scrolling not necessary) 958 991 * -- 4: cnrinfo query failed (error) 959 * -- 5: parent record rectangle query failed (error)960 992 * 961 993 * Note: All messages are _sent_ to the container, not posted. … … 968 1000 * 969 1001 *@@changed V0.9.4 (2000-08-07) [umoeller]: now posting scroll messages to avoid sync errors 970 *@@changed V0.9.9 (2001-03-12) [umoeller]: this never worked for root records in tree view if KeepParent == TRUE, fixed 1002 *@@changed V0.9.9 (2001-03-12) [umoeller]: this never scrolled for root records in tree view if KeepParent == TRUE, fixed 1003 *@@changed V0.9.9 (2001-03-13) [umoeller]: largely rewritten; this now scrolls x properly too and is faster 971 1004 */ 972 1005 … … 980 1013 // -- CMA_TEXT: the record text 981 1014 // -- CMA_TREEICON: the "+" sign in tree view 982 BOOL KeepParent)1015 BOOL fKeepParent) 983 1016 // for tree views only: whether to keep 984 1017 // the parent record of pRec visible when scrolling. … … 989 1022 990 1023 { 991 QUERYRECORDRECT qRect, qRect2; 992 RECTL rclRecord, rclParentRecord, rclCnr, rclCnr2; 993 POINTL ptlRecord, ptlParentRecord; 994 CNRINFO CnrInfo; 995 HAB hab = WinQueryAnchorBlock(hwndCnr); 996 BOOL KeepParent2; 997 LONG lYOfs; 1024 QUERYRECORDRECT qRect; 1025 RECTL rclRecord, 1026 rclCnr; 1027 LONG lXOfs = 0, 1028 lYOfs = 0; 998 1029 999 1030 qRect.cb = sizeof(qRect); 1000 1031 qRect.pRecord = (PRECORDCORE)pRec; 1001 1032 qRect.fsExtent = fsExtent; 1033 1034 if (fKeepParent) 1035 { 1036 CNRINFO CnrInfo; 1037 // this is only valid in tree view, so check 1038 if (!WinSendMsg(hwndCnr, 1039 CM_QUERYCNRINFO, 1040 (MPARAM)&CnrInfo, 1041 (MPARAM)sizeof(CnrInfo))) 1042 return 4; 1043 else 1044 // disable if not tree view 1045 fKeepParent = ((CnrInfo.flWindowAttr & CV_TREE) != 0); 1046 } 1002 1047 1003 1048 // query record location and size of container … … 1011 1056 CM_QUERYVIEWPORTRECT, 1012 1057 &rclCnr, 1013 MPFROM2SHORT(CMA_WINDOW, FALSE)) ) 1058 MPFROM2SHORT(CMA_WINDOW, 1059 // returns the client area rectangle 1060 // in container window coordinates 1061 FALSE)) ) 1014 1062 return 2; 1015 1063 1016 1064 // check if left bottom point of pRec is currently visible in container 1017 ptlRecord.x = (rclRecord.xLeft); 1018 ptlRecord.y = (rclRecord.yBottom); 1019 // ptlRecord.x = (rclRecord.xLeft + rclRecord.xRight) / 2; 1020 // ptlRecord.y = (rclRecord.yBottom + rclRecord.yTop) / 2; 1021 if (WinPtInRect(hab, &rclCnr, &ptlRecord)) 1022 return 3; 1023 1024 if (KeepParent) 1025 { 1026 if (!WinSendMsg(hwndCnr, 1027 CM_QUERYCNRINFO, 1028 (MPARAM)&CnrInfo, 1029 (MPARAM)sizeof(CnrInfo))) 1030 return 4; 1031 else 1032 KeepParent2 = (CnrInfo.flWindowAttr & CV_TREE); 1033 } 1034 else 1035 KeepParent2 = FALSE; 1036 1037 // calculate offset to scroll to make pRec visible 1038 lYOfs = (rclCnr.yBottom - rclRecord.yBottom) // this would suffice 1039 + (rclRecord.yTop - rclRecord.yBottom); // but we make the next rcl visible too 1040 1041 if (KeepParent2) 1042 { 1043 qRect2.cb = sizeof(qRect2); 1044 qRect2.pRecord = (PRECORDCORE)WinSendMsg(hwndCnr, 1045 CM_QUERYRECORD, 1046 (MPARAM)pRec, 1047 MPFROM2SHORT(CMA_PARENT, 1048 CMA_ITEMORDER)); 1049 if (qRect2.pRecord) // V0.9.9 (2001-03-12) [umoeller] 1065 1066 #define IS_BETWEEN(a, b, c) (((a) >= (b)) && ((a) <= (c))) 1067 1068 // 1) set lXOfs if we need to scroll horizontally 1069 if (!IS_BETWEEN(rclRecord.xLeft, rclCnr.xLeft, rclCnr.xRight)) 1070 // record xLeft is outside viewport: 1071 // scroll horizontally so that xLeft is exactly on left of viewport 1072 lXOfs = (rclRecord.xLeft - rclCnr.xLeft); 1073 else if (!IS_BETWEEN(rclRecord.xRight, rclCnr.xLeft, rclCnr.xRight)) 1074 // record xRight is outside viewport: 1075 // scroll horizontally so that xRight is exactly on right of viewport 1076 lXOfs = (rclRecord.xRight - rclCnr.xRight); 1077 1078 // 2) set lYOfs if we need to scroll vertically 1079 if (!IS_BETWEEN(rclRecord.yBottom, rclCnr.yBottom, rclCnr.yTop)) 1080 // record yBottom is outside viewport: 1081 // scroll horizontally so that yBottom is exactly on bottom of viewport 1082 lYOfs = (rclCnr.yBottom - rclRecord.yBottom) // this would suffice 1083 + (rclRecord.yTop - rclRecord.yBottom); 1084 // but we make the next rcl visible too 1085 else if (!IS_BETWEEN(rclRecord.yTop, rclCnr.yBottom, rclCnr.yTop)) 1086 // record yTop is outside viewport: 1087 // scroll horizontally so that yTop is exactly on top of viewport 1088 lYOfs = (rclRecord.yTop - rclCnr.yTop); 1089 1090 if (fKeepParent && (lXOfs || lYOfs)) 1091 { 1092 // keep parent enabled, and we're scrolling: 1093 // find the parent record then 1094 qRect.cb = sizeof(qRect); 1095 qRect.pRecord = (PRECORDCORE)WinSendMsg(hwndCnr, 1096 CM_QUERYRECORD, 1097 (MPARAM)pRec, 1098 MPFROM2SHORT(CMA_PARENT, 1099 CMA_ITEMORDER)); 1100 if (qRect.pRecord) // V0.9.9 (2001-03-12) [umoeller] 1050 1101 { 1051 qRect2.fsExtent = fsExtent; 1052 1053 // now query PARENT record location and size of container 1054 if (!WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, &rclParentRecord, &qRect2)) 1055 return 5; 1056 1057 ptlParentRecord.x = (rclParentRecord.xLeft); 1058 ptlParentRecord.y = (rclParentRecord.yTop); 1059 // ptlParentRecord.x = (rclParentRecord.xLeft + rclParentRecord.xRight) / 2; 1060 // ptlParentRecord.y = (rclParentRecord.yBottom + rclParentRecord.yTop) / 2; 1061 rclCnr2 = rclCnr; 1062 WinOffsetRect(hab, &rclCnr2, 0, -lYOfs); 1063 // if ( (rclParentRecord.yBottom - rclRecord.yBottom) > (rclCnr.yTop - rclCnr.yBottom) ) 1064 if (!(WinPtInRect(hab, &rclCnr2, &ptlParentRecord))) 1102 // parent exists: 1103 // get PARENT record rectangle then 1104 RECTL rclParentRecord; 1105 qRect.fsExtent = fsExtent; 1106 if (WinSendMsg(hwndCnr, 1107 CM_QUERYRECORDRECT, 1108 &rclParentRecord, 1109 &qRect)) 1065 1110 { 1066 lYOfs = (rclCnr.yTop - rclParentRecord.yTop) // this would suffice 1067 - (rclRecord.yTop - rclRecord.yBottom); // but we make the previous rcl visible too 1111 // check if parent record WOULD still be visible 1112 // if we scrolled what we calculated above 1113 RECTL rclCnr2; 1114 memcpy(&rclCnr2, &rclCnr, sizeof(rclCnr2)); 1115 winhOffsetRect(&rclCnr2, lXOfs, -lYOfs); 1116 1117 if ( lXOfs 1118 && (!IS_BETWEEN(rclParentRecord.xLeft, rclCnr2.xLeft, rclCnr2.xRight)) 1119 ) 1120 // record xLeft is outside viewport: 1121 // scroll horizontally so that xLeft is exactly on left of viewport 1122 lXOfs = (rclParentRecord.xLeft - rclCnr.xLeft); 1123 1124 if ( lYOfs 1125 && (!IS_BETWEEN(rclParentRecord.yBottom, rclCnr2.yBottom, rclCnr2.yTop)) 1126 ) 1127 // record yBottom is outside viewport: 1128 // recalculate y ofs so that we scroll so 1129 // that parent record is on top of cnr viewport 1130 lYOfs = (rclCnr.yTop - rclParentRecord.yTop) // this would suffice 1131 - (rclRecord.yTop - rclRecord.yBottom); // but we make the previous rcl visible too 1068 1132 } 1069 1133 } 1070 1134 } 1071 1135 1072 if ( !KeepParent2)1136 if (lXOfs) 1073 1137 // scroll horizontally 1074 1138 WinPostMsg(hwndCnr, 1075 1139 CM_SCROLLWINDOW, 1076 1140 (MPARAM)CMA_HORIZONTAL, 1077 (MPARAM) (rclRecord.xLeft - rclCnr.xLeft));1141 (MPARAM)lXOfs); 1078 1142 1079 1143 // scroll vertically 1080 WinPostMsg(hwndCnr, 1081 CM_SCROLLWINDOW, 1082 (MPARAM)CMA_VERTICAL, 1083 (MPARAM)lYOfs); 1144 if (lYOfs) 1145 WinPostMsg(hwndCnr, 1146 CM_SCROLLWINDOW, 1147 (MPARAM)CMA_VERTICAL, 1148 (MPARAM)lYOfs); 1084 1149 1085 1150 return 0; -
trunk/src/helpers/dosh.c
r46 r48 1661 1661 * 1662 1662 *@@added V0.9.7 (2000-12-02) [umoeller] 1663 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt loads; thanks phaller 1663 1664 */ 1664 1665 … … 1720 1721 else 1721 1722 { 1722 pPerfSys->palLoads = (PLONG)malloc(pPerfSys->cProcessors * sizeof(LONG)); 1723 if (!pPerfSys->palLoads) 1723 pPerfSys->padIntrPrev 1724 = (double*)malloc(pPerfSys->cProcessors * sizeof(double)); 1725 if (!pPerfSys->padIntrPrev) 1724 1726 arc = ERROR_NOT_ENOUGH_MEMORY; 1725 1727 else 1726 1728 { 1727 for (ul = 0; ul < pPerfSys->cProcessors; ul++) 1729 pPerfSys->palLoads = (PLONG)malloc(pPerfSys->cProcessors * sizeof(LONG)); 1730 if (!pPerfSys->palLoads) 1731 arc = ERROR_NOT_ENOUGH_MEMORY; 1732 else 1728 1733 { 1729 pPerfSys->padBusyPrev[ul] = 0.0; 1730 pPerfSys->padTimePrev[ul] = 0.0; 1731 pPerfSys->palLoads[ul] = 0; 1734 // **patrick, this was missing... 1735 // wonder if you ever tested this, this crashes in 1736 // doshPerfGet otherwise ;-) 1737 /* -----------> */ pPerfSys->palIntrs = (PLONG)malloc(pPerfSys->cProcessors * sizeof(LONG)); 1738 if (!pPerfSys->palIntrs) 1739 arc = ERROR_NOT_ENOUGH_MEMORY; 1740 else 1741 { 1742 for (ul = 0; ul < pPerfSys->cProcessors; ul++) 1743 { 1744 pPerfSys->padBusyPrev[ul] = 0.0; 1745 pPerfSys->padTimePrev[ul] = 0.0; 1746 pPerfSys->padIntrPrev[ul] = 0.0; 1747 pPerfSys->palLoads[ul] = 0; 1748 /* and this one too */ pPerfSys->palIntrs[ul] = 0; 1749 } 1750 } 1732 1751 } 1733 1752 } … … 1777 1796 * 1778 1797 *@@added V0.9.7 (2000-12-02) [umoeller] 1798 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt loads; thanks phaller 1779 1799 */ 1780 1800 … … 1801 1821 double dBusy = LL2F(pCPUUtilThis->ulBusyHigh, 1802 1822 pCPUUtilThis->ulBusyLow); 1823 double dIntr = LL2F(pCPUUtilThis->ulIntrHigh, 1824 pCPUUtilThis->ulIntrLow); 1803 1825 1804 1826 double *pdBusyPrevThis = &pPerfSys->padBusyPrev[ul]; 1805 1827 double *pdTimePrevThis = &pPerfSys->padTimePrev[ul]; 1828 double *pdIntrPrevThis = &pPerfSys->padIntrPrev[ul]; 1806 1829 1807 1830 // avoid division by zero 1808 1831 double dTimeDelta = (dTime - *pdTimePrevThis); 1809 1832 if (dTimeDelta) 1833 { 1810 1834 pPerfSys->palLoads[ul] 1811 1835 = (LONG)( (double)( (dBusy - *pdBusyPrevThis) … … 1814 1838 ) 1815 1839 ); 1840 pPerfSys->palIntrs[ul] 1841 = (LONG)( (double)( (dIntr - *pdIntrPrevThis) 1842 / dTimeDelta 1843 * 1000.0 1844 ) 1845 ); 1846 } 1816 1847 else 1848 { 1849 // no clear readings are available 1817 1850 pPerfSys->palLoads[ul] = 0; 1851 pPerfSys->palIntrs[ul] = 0; 1852 } 1818 1853 1819 1854 *pdTimePrevThis = dTime; 1820 1855 *pdBusyPrevThis = dBusy; 1856 *pdIntrPrevThis = dIntr; 1821 1857 } 1822 1858 } … … 1832 1868 *@@added V0.9.7 (2000-12-02) [umoeller] 1833 1869 *@@changed V0.9.9 (2001-02-06) [umoeller]: removed disable; this broke the WarpCenter 1870 *@@changed V0.9.9 (2001-03-14) [umoeller]: fixed memory leak 1871 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt loads; thanks phaller 1834 1872 */ 1835 1873 … … 1852 1890 if (pPerfSys->padTimePrev) 1853 1891 free(pPerfSys->padTimePrev); 1892 if (pPerfSys->padIntrPrev) 1893 free(pPerfSys->padIntrPrev); 1894 if (pPerfSys->palLoads) // was missing V0.9.9 (2001-03-14) [umoeller] 1895 free(pPerfSys->palLoads); 1896 if (pPerfSys->palIntrs) 1897 free(pPerfSys->palIntrs); 1854 1898 1855 1899 if (pPerfSys->hmod) -
trunk/src/helpers/winh.c
r47 r48 86 86 #include "helpers\undoc.h" 87 87 #include "helpers\xstring.h" // extended string helpers 88 89 /* 90 *@@category: Helpers\PM helpers\Rectangle helpers 91 */ 92 93 /* ****************************************************************** 94 * 95 * Rectangle helpers 96 * 97 ********************************************************************/ 98 99 /* 100 *@@ winhOffsetRect: 101 * like WinOffsetRect, but doesn't require 102 * an anchor block to be passed in. Why 103 * the original would need an anchor block 104 * for this awfully complicated task is 105 * a mystery to me anyway. 106 * 107 *@@added V0.9.9 (2001-03-13) [umoeller] 108 */ 109 110 VOID winhOffsetRect(PRECTL prcl, 111 LONG lx, 112 LONG ly) 113 { 114 prcl->xLeft += lx; 115 prcl->xRight += lx; 116 prcl->yBottom += ly; 117 prcl->yTop += ly; 118 } 88 119 89 120 /* … … 3682 3713 3683 3714 /* 3715 *@@ winhCreateControl: 3716 * creates a control with a size and position of 0. 3717 * 3718 *@@added V0.9.9 (2001-03-13) [umoeller] 3719 */ 3720 3721 HWND winhCreateControl(HWND hwndParentAndOwner, // in: owner and parent window 3722 const char *pcszClass, // in: window class (e.g. WC_BUTTON) 3723 const char *pcszText, // in: window title 3724 ULONG ulStyle, // in: control style 3725 ULONG ulID) // in: control ID 3726 { 3727 return (WinCreateWindow(hwndParentAndOwner, 3728 (PSZ)pcszClass, 3729 (PSZ)pcszText, 3730 ulStyle, 3731 0, 0, 0, 0, 3732 hwndParentAndOwner, 3733 HWND_TOP, 3734 ulID, 3735 NULL, 3736 NULL)); 3737 } 3738 3739 /* 3684 3740 *@@ winhRepaintWindows: 3685 3741 * this repaints all children of hwndParent.
Note:
See TracChangeset
for help on using the changeset viewer.