Changeset 985 for trunk/dll/dirsize.c


Ignore:
Timestamp:
Mar 1, 2008, 2:37:14 AM (17 years ago)
Author:
Gregg Young
Message:

Update sizes dialog (ticket 44); Make max command line length user settable (ticket 199); use xfree for free in most cases (ticket 212); initial code to check for valid ini file (ticket 102); Some additional refactoring and structure rework; Some documentation updates;

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dirsize.c

    r959 r985  
    3131  13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat
    3232  26 Aug 07 GKY DosSleep(1) in loops changed to (0)
     33  29 Feb 08 GKY Use xfree where appropriate
     34  29 Feb 08 GKY Add presparams & update appearence of "Sizes" dialog
    3335
    3436***********************************************************************/
     
    150152      strlen(pszFileName) < 4) {
    151153    if (*pchStopFlag) {
    152       free(pffbArray);
     154      xfree(pffbArray);
    153155      return FALSE;
    154156    }
     
    157159    if (!pci) {
    158160      Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCRECORD");
    159       free(pffbArray);
     161      xfree(pffbArray);
    160162      return FALSE;
    161163    }
     
    173175  else {
    174176    // No match
    175     free(pffbArray);
     177    xfree(pffbArray);
    176178    Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    177179              GetPString(IDS_CANTFINDDIRTEXT), pszFileName);
     
    216218  ri.fInvalidateRecord = TRUE;
    217219  if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri))) {
    218     free(pffbArray);
     220    xfree(pffbArray);
    219221    return FALSE;
    220222  }
     
    278280  }
    279281
    280   free(pffbArray);
     282  xfree(pffbArray);
    281283
    282284  pci->cbFile = ullCurDirBytes;
     
    456458  PostMsg(WinQueryWindow(hwndCnr, QW_PARENT),
    457459          UM_CONTAINER_FILLED, MPVOID, MPVOID);
    458   free(dirsize);
     460  xfree(dirsize);
    459461}
    460462
     
    483485    {
    484486      CHAR s[CCHMAXPATH + 81];
    485 
     487      RestorePresParams(hwnd, "DirSizes");
    486488      sprintf(s, GetPString(IDS_DIRSIZETITLETEXT), pState->szDirName);
    487489      WinSetWindowText(hwnd, s);
     490    }
     491    {
     492      SWP swp;
     493      ULONG size = sizeof(SWP);
     494
     495      PrfQueryProfileData(fmprof, FM3Str, "DirSizes.Position", (PVOID) &swp, &size);
     496      WinSetWindowPos(hwnd,
     497                      HWND_TOP,
     498                      swp.x,
     499                      swp.y,
     500                      swp.cx,
     501                      swp.cy,
     502                      swp.fl);
    488503    }
    489504    {
     
    502517        Runtime_Error(pszSrcFile, __LINE__,
    503518                      GetPString(IDS_COULDNTSTARTTHREADTEXT));
    504         free(dirsize);
     519        xfree(dirsize);
    505520        WinDismissDlg(hwnd, 0);
    506521        break;
     
    614629    return 0;
    615630
     631  case WM_PRESPARAMCHANGED:
     632    PresParamChanged(hwnd, "DirSizes", mp1, mp2);
     633    break;
     634
    616635  case WM_DRAWITEM:
    617636    if (mp2) {
     
    638657            p = strchr(pci->pszFileName, '\r');
    639658            if (p) {
    640               // draw text
    641               if (!pci->cbFile)         // no size
     659              // draw text
     660              if (*(pci->pszLongName + 1) == 1)  // is root record
     661                GpiSetColor(oi->hps, CLR_DARKRED);
     662              else if (!pci->cbFile)            // no size
    642663                GpiSetColor(oi->hps, CLR_DARKGRAY);
    643664              else if (!pci->easize)    // no size below
     
    654675                              pci->pszFileName, TXTBOX_COUNT, aptl);
    655676              boxHeight = aptl[TXTBOX_TOPRIGHT].y - aptl[TXTBOX_BOTTOMRIGHT].y;
    656               boxHeight -= 6;
     677              boxHeight -= 4;
    657678
    658679              // Calculate nominal baseline of graph box
     
    662683              // Place text above graph box with a bit of whitespace between
    663684              ptl.x = oi->rclItem.xLeft;
    664               ptl.y = yBottom + boxHeight + 8;  // 03 Aug 07 SHL
     685              ptl.y = yBottom + boxHeight + 6;  // 03 Aug 07 SHL
    665686              // GpiMove(oi->hps, &ptl);
    666687              GpiCharStringAt(oi->hps, &ptl, strlen(pci->pszFileName),
     
    676697              ptl.y = yBottom + 2;
    677698              GpiMove(oi->hps, &ptl);
    678               ptl.x = oi->rclItem.xLeft + 101;
     699              ptl.x = oi->rclItem.xLeft + 201;
    679700              ptl.y = yBottom + boxHeight;
    680701              GpiBox(oi->hps, DRO_OUTLINE, &ptl, 0, 0);
     
    684705              ptl.y = yBottom + 3;
    685706              GpiMove(oi->hps, &ptl);
    686               ptl.x = oi->rclItem.xLeft + 100;
     707              ptl.x = oi->rclItem.xLeft + 200;
    687708              ptl.y = yBottom + boxHeight - 1;
    688709              GpiBox(oi->hps, DRO_OUTLINEFILL, &ptl, 0, 0);
     
    693714              ptl.y = yBottom + 3;
    694715              GpiMove(oi->hps, &ptl);
    695               ptl.x = oi->rclItem.xLeft + 100;
     716              ptl.x = oi->rclItem.xLeft + 200;
    696717              GpiLine(oi->hps, &ptl);
    697718              ptl.y = yBottom + boxHeight - 1;
     
    710731              ptl.y = yBottom + boxHeight;
    711732              GpiMove(oi->hps, &ptl);
    712               ptl.x = oi->rclItem.xLeft + 103;
     733              ptl.x = oi->rclItem.xLeft + 203;
    713734              GpiLine(oi->hps, &ptl);
    714735              ptl.y = yBottom + boxHeight - 2;
     
    727748                else
    728749                  GpiSetColor(oi->hps, CLR_RED);
    729                 ptl.x = oi->rclItem.xLeft + 1;
     750                ptl.x = oi->rclItem.xLeft + 2;
    730751                ptl.y = yBottom + 3;
    731752                GpiMove(oi->hps, &ptl);
    732                 ptl.x = oi->rclItem.xLeft + pci->flags;
     753                ptl.x = oi->rclItem.xLeft + pci->flags * 2;
    733754                ptl.y = yBottom + boxHeight - 1;
    734755                GpiBox(oi->hps, DRO_OUTLINEFILL, &ptl, 0, 0);
     
    750771                  GpiMove(oi->hps, &ptl);
    751772                }
    752                 ptl.x = oi->rclItem.xLeft + pci->flags;
     773                ptl.x = oi->rclItem.xLeft + pci->flags * 2;
    753774                GpiLine(oi->hps, &ptl);
    754775                if (*(pci->pszLongName + 1) != 1) {
     
    757778                  ptl.y = yBottom + 3;
    758779                  GpiMove(oi->hps, &ptl);
    759                   ptl.x = oi->rclItem.xLeft + pci->flags;
     780                  ptl.x = oi->rclItem.xLeft + pci->flags * 2;
    760781                  GpiLine(oi->hps, &ptl);
    761782                }
     
    765786              GpiSetColor(oi->hps, CLR_WHITE);
    766787              clr = CLR_WHITE;
    767               for (x = 1; x < 10; x++) {
    768                 if (clr == CLR_WHITE && x * 10 > pci->flags) {
     788              for (x = 1; x < 20; x++) {
     789                if (clr == CLR_WHITE && x * 10 > pci->flags * 2) {
    769790                  clr = CLR_BLACK;
    770791                  GpiSetColor(oi->hps, CLR_BLACK);
     
    775796                switch (x) {
    776797                case 1:
    777                 case 3:
     798                case 3:
     799                case 5:
    778800                case 7:
    779                 case 9:
     801                case 9:
     802                case 11:
     803                case 13:
     804                case 15:
     805                case 17:
     806                case 19:
    780807                  ptl.y -= 1;
    781808                  break;
    782                 case 5:
     809                case 10:
    783810                  ptl.y -= 4;
    784811                  break;
     
    786813                case 4:
    787814                case 6:
    788                 case 8:
     815                case 8:
     816                case 12:
     817                case 14:
     818                case 16:
     819                case 18:
    789820                  ptl.y -= 2;
    790821                  break;
     
    943974    case DID_OK:
    944975    case DID_CANCEL:
     976      {
     977        SWP swp;
     978        ULONG size = sizeof(SWP);
     979
     980        WinQueryWindowPos(hwnd, &swp);
     981        PrfWriteProfileData(fmprof, FM3Str, "DirSizes.Position", (PVOID) &swp,
     982                            size);
     983      }
    945984      pState = INSTDATA(hwnd);
    946985      if (!pState)
     
    9731012        WinDestroyPointer(pState->hptr);
    9741013      DosSleep(16); //05 Aug 07 GKY 33
    975       free(pState);                     // Let's hope no one is still looking
     1014      xfree(pState);                    // Let's hope no one is still looking
    9761015    }
    9771016    DosPostEventSem(CompactSem);
Note: See TracChangeset for help on using the changeset viewer.