Changeset 48


Ignore:
Timestamp:
Mar 14, 2001, 7:57:34 PM (24 years ago)
Author:
umoeller
Message:

misc changes

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/helpers/cnrh.h

    r46 r48  
    502502                                        ULONG fl);
    503503
     504    ULONG cnrhExpandFromRoot(HWND hwndCnr,
     505                             PRECORDCORE prec);
     506
    504507    ULONG cnrhScrollToRecord(HWND hwndCnr,
    505508                             PRECORDCORE pRec,
  • trunk/include/helpers/dosh.h

    r46 r48  
    237237     *
    238238     *@@added V0.9.7 (2000-12-02) [umoeller]
     239     *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
    239240     */
    240241
     
    246247        PLONG       palLoads;
    247248
     249        // output: one CPU interrupt load for each CPU
     250        PLONG       palIntrs;
     251
    248252        // each of the following ptrs points to an array of cProcessors items
    249253        PCPUUTIL    paCPUUtils;     // CPUUTIL structures
    250254        double      *padBusyPrev;   // previous "busy" calculations
    251255        double      *padTimePrev;   // previous "time" calculations
     256        double      *padIntrPrev;   // previous "intr" calculations
    252257
    253258        // private stuff
  • trunk/include/helpers/winh.h

    r46 r48  
    105105    /* ******************************************************************
    106106     *
     107     *   Rectangle helpers
     108     *
     109     ********************************************************************/
     110
     111    VOID XWPENTRY winhOffsetRect(PRECTL prcl, LONG lx, LONG ly);
     112
     113    /* ******************************************************************
     114     *
    107115     *   Menu helpers
    108116     *
     
    689697                                      PHWND phwndClient);
    690698
    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);
    693707
    694708    VOID XWPENTRY winhRepaintWindows(HWND hwndParent);
  • trunk/src/helpers/cnrh.c

    r46 r48  
    947947
    948948/*
     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
     958ULONG 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/*
    949982 *@@ cnrhScrollToRecord:
    950983 *      scrolls a given container control to make a given
     
    957990 *      --  3:       record is already visible (scrolling not necessary)
    958991 *      --  4:       cnrinfo query failed (error)
    959  *      --  5:       parent record rectangle query failed (error)
    960992 *
    961993 *      Note: All messages are _sent_ to the container, not posted.
     
    9681000 *
    9691001 *@@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
    9711004 */
    9721005
     
    9801013                                 // -- CMA_TEXT: the record text
    9811014                                 // -- CMA_TREEICON: the "+" sign in tree view
    982                          BOOL KeepParent)
     1015                         BOOL fKeepParent)
    9831016                                 // for tree views only: whether to keep
    9841017                                 // the parent record of pRec visible when scrolling.
     
    9891022
    9901023{
    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;
    9981029
    9991030    qRect.cb = sizeof(qRect);
    10001031    qRect.pRecord = (PRECORDCORE)pRec;
    10011032    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    }
    10021047
    10031048    // query record location and size of container
     
    10111056                    CM_QUERYVIEWPORTRECT,
    10121057                    &rclCnr,
    1013                     MPFROM2SHORT(CMA_WINDOW, FALSE)) )
     1058                    MPFROM2SHORT(CMA_WINDOW,
     1059                                    // returns the client area rectangle
     1060                                    // in container window coordinates
     1061                                 FALSE)) )
    10141062        return 2;
    10151063
    10161064    // 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]
    10501101        {
    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))
    10651110            {
    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
    10681132            }
    10691133        }
    10701134    }
    10711135
    1072     if (!KeepParent2)
     1136    if (lXOfs)
    10731137        // scroll horizontally
    10741138        WinPostMsg(hwndCnr,
    10751139                   CM_SCROLLWINDOW,
    10761140                   (MPARAM)CMA_HORIZONTAL,
    1077                    (MPARAM)(rclRecord.xLeft - rclCnr.xLeft));
     1141                   (MPARAM)lXOfs);
    10781142
    10791143    // 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);
    10841149
    10851150    return 0;
  • trunk/src/helpers/dosh.c

    r46 r48  
    16611661 *
    16621662 *@@added V0.9.7 (2000-12-02) [umoeller]
     1663 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt loads; thanks phaller
    16631664 */
    16641665
     
    17201721                                else
    17211722                                {
    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)
    17241726                                        arc = ERROR_NOT_ENOUGH_MEMORY;
    17251727                                    else
    17261728                                    {
    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
    17281733                                        {
    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                                            }
    17321751                                        }
    17331752                                    }
     
    17771796 *
    17781797 *@@added V0.9.7 (2000-12-02) [umoeller]
     1798 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt loads; thanks phaller
    17791799 */
    17801800
     
    18011821                double      dBusy = LL2F(pCPUUtilThis->ulBusyHigh,
    18021822                                         pCPUUtilThis->ulBusyLow);
     1823                double      dIntr = LL2F(pCPUUtilThis->ulIntrHigh,
     1824                                         pCPUUtilThis->ulIntrLow);
    18031825
    18041826                double      *pdBusyPrevThis = &pPerfSys->padBusyPrev[ul];
    18051827                double      *pdTimePrevThis = &pPerfSys->padTimePrev[ul];
     1828                double      *pdIntrPrevThis = &pPerfSys->padIntrPrev[ul];
    18061829
    18071830                // avoid division by zero
    18081831                double      dTimeDelta = (dTime - *pdTimePrevThis);
    18091832                if (dTimeDelta)
     1833                {
    18101834                    pPerfSys->palLoads[ul]
    18111835                        = (LONG)( (double)(   (dBusy - *pdBusyPrevThis)
     
    18141838                                          )
    18151839                                );
     1840                    pPerfSys->palIntrs[ul]
     1841                        = (LONG)( (double)(   (dIntr - *pdIntrPrevThis)
     1842                                            / dTimeDelta
     1843                                            * 1000.0
     1844                                          )
     1845                                );
     1846                }
    18161847                else
     1848                {
     1849                    // no clear readings are available
    18171850                    pPerfSys->palLoads[ul] = 0;
     1851                    pPerfSys->palIntrs[ul] = 0;
     1852                }
    18181853
    18191854                *pdTimePrevThis = dTime;
    18201855                *pdBusyPrevThis = dBusy;
     1856                *pdIntrPrevThis = dIntr;
    18211857            }
    18221858        }
     
    18321868 *@@added V0.9.7 (2000-12-02) [umoeller]
    18331869 *@@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
    18341872 */
    18351873
     
    18521890        if (pPerfSys->padTimePrev)
    18531891            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);
    18541898
    18551899        if (pPerfSys->hmod)
  • trunk/src/helpers/winh.c

    r47 r48  
    8686#include "helpers\undoc.h"
    8787#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
     110VOID 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}
    88119
    89120/*
     
    36823713
    36833714/*
     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
     3721HWND 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/*
    36843740 *@@ winhRepaintWindows:
    36853741 *      this repaints all children of hwndParent.
Note: See TracChangeset for help on using the changeset viewer.