Changeset 53


Ignore:
Timestamp:
Apr 2, 2001, 12:38:55 PM (24 years ago)
Author:
umoeller
Message:

Dialog mgr.

Location:
trunk
Files:
3 added
10 edited

Legend:

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

    r48 r53  
    315315    BOOL doshQueryDirExist(const char *pcszDir);
    316316
    317     APIRET doshCreatePath(PSZ pszPath,
     317    APIRET doshCreatePath(const char *pcszPath,
    318318                          BOOL fHidden);
    319319
  • trunk/include/helpers/gpih.h

    r34 r53  
    136136    typedef GPIHSPLITPRESFONT *PGPIHSPLITPRESFONT;
    137137
     138    BOOL XWPENTRY gpihLockLCIDs(VOID);
     139    typedef BOOL XWPENTRY GPIHLOCKLCIDS(VOID);
     140    typedef GPIHLOCKLCIDS *PGPIHLOCKLCIDS;
     141
     142    VOID XWPENTRY gpihUnlockLCIDs(VOID);
     143    typedef VOID XWPENTRY GPIHUNLOCKLCIDS(VOID);
     144    typedef GPIHUNLOCKLCIDS *PGPIHUNLOCKLCIDS;
     145
    138146    LONG XWPENTRY gpihFindFont(HPS hps,
    139147                               LONG lSize,
     
    153161                                   BOOL fInherit,
    154162                                   HPS hps,
    155                                    PSZ pszDefaultFont,
     163                                   const char *pcszDefaultFont,
    156164                                   PFONTMETRICS pFontMetrics,
    157165                                   PLONG plSize);
     
    159167                                           BOOL fInherit,
    160168                                           HPS hps,
    161                                            PSZ pszDefaultFont,
     169                                           const char *pcszDefaultFont,
    162170                                           PFONTMETRICS pFontMetrics,
    163171                                           PLONG plSize);
  • trunk/include/helpers/linklist.h

    r41 r53  
    1010 */
    1111
    12 /*      Copyright (C) 1997-2000 Ulrich M”ller.
     12/*      Copyright (C) 1997-2001 Ulrich M”ller.
    1313 *      This file is part of the "XWorkplace helpers" source package.
    1414 *      This is free software; you can redistribute it and/or modify
     
    9898                            // changed V0.9.0 (99-10-22) [umoeller]
    9999    typedef FNSORTLIST *PFNSORTLIST;
     100
     101    /*
     102     *@@ FOR_ALL_NODES:
     103     *      helper macro to iterator over all nodes in
     104     *      a list.
     105     *
     106     *      Usage:
     107     +
     108     +          PLINKLIST pll = ...;
     109     +          PLISTNODE pNode;
     110     +
     111     +          FOR_ALL_NODES(pll, pNode)
     112     +          {
     113     +              PVOID pData = (PVOID)pNode->pItemData;
     114     +          }
     115     +
     116     *      This really is a "for" loop, so you can "break"
     117     *      out of the loop.
     118     *
     119     *@@added V0.9.9 (2001-04-01) [umoeller]
     120     */
     121
     122    #define FOR_ALL_NODES(pll, pNode) for (pNode = lstQueryFirstNode(pll); (pNode); pNode = pNode->pNext)
    100123
    101124    /* ******************************************************************
  • trunk/src/helpers/comctl.c

    r21 r53  
    584584             */
    585585
    586             case WM_TIMER: {
     586            case WM_TIMER:
     587            {
    587588                pa->usAniCurrent++;
    588589                if (pa->usAniCurrent >= pa->usAniCount)
     
    590591
    591592                WinSendMsg(hwndStatic,
    592                         SM_SETHANDLE,
    593                         (MPARAM)pa->ahptrAniIcons[pa->usAniCurrent],
    594                         (MPARAM)NULL);
     593                           SM_SETHANDLE,
     594                           (MPARAM)pa->ahptrAniIcons[pa->usAniCurrent],
     595                           (MPARAM)NULL);
    595596            break; }
    596597
     
    606607                SIZEL szlPage;
    607608
    608                 LONG lBkgndColor = winhQueryPresColor(
    609                                 WinQueryWindow(hwndStatic, QW_PARENT),
    610                                 PP_BACKGROUNDCOLOR,
    611                                 FALSE,
    612                                 SYSCLR_DIALOGBACKGROUND);
     609                LONG lBkgndColor
     610                    = winhQueryPresColor(WinQueryWindow(hwndStatic, QW_PARENT),
     611                                         PP_BACKGROUNDCOLOR,
     612                                         FALSE,
     613                                         SYSCLR_DIALOGBACKGROUND);
    613614
    614615                HPS hps = WinGetPS(hwndStatic);
     
    632633                szlPage.cx = pa->rclIcon.xRight - pa->rclIcon.xLeft;
    633634                szlPage.cy = pa->rclIcon.yTop - pa->rclIcon.yBottom;
    634                 if (gpihCreateMemPS(pa->hab, &szlPage, &hdcMem, &hpsMem))
     635                if (gpihCreateMemPS(pa->hab,
     636                                    &szlPage,
     637                                    &hdcMem,
     638                                    &hpsMem))
    635639                {
    636640                    // switch the memory PS to RGB mode too
     
    653657                            ptl.y = pa->rclIcon.yTop;
    654658                            GpiSetColor(hpsMem,
    655                                     lBkgndColor);
     659                                        lBkgndColor);
    656660                            GpiBox(hpsMem,
    657                                     DRO_FILL, // interior only
    658                                     &ptl,
    659                                     0, 0);    // no corner rounding
     661                                   DRO_FILL, // interior only
     662                                   &ptl,
     663                                   0, 0);    // no corner rounding
    660664
    661665                            /*
     
    689693
    690694                                if (hbmSource)
    691                                     gpihStretchBitmap(hpsMem,
    692                                                       hbmSource,
     695                                    gpihStretchBitmap(hpsMem,       // target
     696                                                      hbmSource,    // source
    693697                                                      NULL,     // use size of bitmap
    694                                                       &(pa->rclIcon),
     698                                                      &pa->rclIcon,
    695699                                                      ((pa->ulFlags & ANF_PROPORTIONAL)
    696700                                                            != 0));
     
    720724             */
    721725
    722             case WM_PAINT: {
     726            case WM_PAINT:
     727            {
    723728                RECTL rcl;
    724729                HPS hps = WinBeginPaint(hwndStatic, NULLHANDLE, &rcl);
  • trunk/src/helpers/dosh.c

    r52 r53  
    13441344 */
    13451345
    1346 APIRET doshCreatePath(PSZ pszPath,
     1346APIRET doshCreatePath(const char *pcszPath,
    13471347                      BOOL fHidden) // in: if TRUE, the new directories will get FILE_HIDDEN
    13481348{
     
    13521352    ULONG   cbPath;
    13531353
    1354     strcpy(path, pszPath);
     1354    strcpy(path, pcszPath);
    13551355    cbPath = strlen(path);
    13561356
  • trunk/src/helpers/gpih.c

    r46 r53  
    3333    // as unsigned char
    3434
     35#define INCL_DOSSEMAPHORES
    3536#define INCL_DOSERRORS
    3637
    3738#define INCL_WINWINDOWMGR
     39#define INCL_WINMESSAGEMGR
    3840#define INCL_WINPOINTERS
    3941#define INCL_WINSYS
     
    9294 *      By contrast, the GpiBox expects an inclusive-inclusive rectangle.
    9395 */
     96
     97/* ******************************************************************
     98 *
     99 *   Global variables
     100 *
     101 ********************************************************************/
     102
     103static HMTX     G_hmtxLCIDs = NULLHANDLE;
    94104
    95105/* ******************************************************************
     
    492502
    493503/*
     504 *@@ gpihLockLCIDs:
     505 *      requests the mutex for serializing the
     506 *      lcids.
     507 *
     508 *      With GPI, lcids are a process-wide resource and not
     509 *      guaranteed to be unique. In the worst case, while your
     510 *      font routines are running, another thread modifies the
     511 *      lcids and you get garbage. If your fonts suddenly
     512 *      turn to "System Proportional", you know this has
     513 *      happened.
     514 *
     515 *      As a result, whenever you work on lcids, request this
     516 *      mutex during your processing. If you do this consistently
     517 *      across all your code, you should be safe.
     518 *
     519 *      gpihFindFont uses this mutex. If you call GpiCreateLogFont
     520 *      yourself somewhere, do this after you called this function.
     521 *
     522 *      Call gpihUnlockLCIDs to unlock.
     523 *
     524 *@@added V0.9.9 (2001-04-01) [umoeller]
     525 */
     526
     527BOOL gpihLockLCIDs(VOID)
     528{
     529    BOOL brc = FALSE;
     530
     531    if (G_hmtxLCIDs == NULLHANDLE)
     532        // first call: create
     533        brc = !DosCreateMutexSem(NULL,
     534                                 &G_hmtxLCIDs,
     535                                 0,
     536                                 TRUE);     // request!
     537    else
     538        // subsequent calls: request
     539        brc = !WinRequestMutexSem(G_hmtxLCIDs, SEM_INDEFINITE_WAIT);
     540
     541    return (brc);
     542}
     543
     544/*
     545 *@@ UnlockLCIDs:
     546 *      releases the mutex for serializing the
     547 *      lcids.
     548 *
     549 *@@added V0.9.9 (2001-04-01) [umoeller]
     550 */
     551
     552VOID gpihUnlockLCIDs(VOID)
     553{
     554    DosReleaseMutexSem(G_hmtxLCIDs);
     555}
     556
     557/*
    494558 *@@ gpihQueryNextLCID:
    495559 *      returns the next available lcid for the given HPS.
     
    498562 *      Gets called by gpihFindFont automatically.
    499563 *
    500  *      This is possibly the sickest code I've ever written.
    501  *
    502  *      Warning: This function is _not_ thread-safe.
    503  *      We use GpiQueryNumberSetIds to find out the no. of
    504  *      LCID's in use by the process. In the worst case,
    505  *      between that call and the call to GpiCreateLogFont,
    506  *      another font has been created, and you'll get garbage.
     564 *      WARNING: This function by itself is not thread-safe.
     565 *      See gpihLockLCIDs for how to serialize this.
    507566 *
    508567 *@@added V0.9.3 (2000-05-06) [umoeller]
     568 *@@changed V0.9.9 (2001-04-01) [umoeller]: removed all those sick sub-allocs
    509569 */
    510570
     
    524584    else
    525585    {
    526         #define GQNCL_BLOCK_SIZE 400*sizeof(LONG)
     586        // #define GQNCL_BLOCK_SIZE 400*sizeof(LONG)
     587
     588        PLONG  alTypes = NULL;  // object types
     589        PSTR8  aNames = NULL;   // font names
     590        PLONG  allcids = NULL;  // local identifiers
     591
     592        if (    (alTypes = (PLONG)malloc(lCount * sizeof(LONG)))
     593             && (aNames = (PSTR8)malloc(lCount * sizeof(STR8)))
     594             && (allcids = (PLONG)malloc(lCount * sizeof(LONG)))
     595           )
     596        {
     597            if (GpiQuerySetIds(hps,
     598                               lCount,
     599                               alTypes,
     600                               aNames,
     601                               allcids))
     602            {
     603                // FINALLY we have all the lcids in use.
     604                BOOL    fContinue = TRUE;
     605                lcidNext = 1;
     606
     607                // now, check if this lcid is in use already:
     608                while (fContinue)
     609                {
     610                    BOOL fFound = FALSE;
     611                    ULONG ul;
     612                    fContinue = FALSE;
     613                    for (ul = 0;
     614                         ul < lCount;
     615                         ul++)
     616                    {
     617                        if (allcids[ul] == lcidNext)
     618                        {
     619                            fFound = TRUE;
     620                            break;
     621                        }
     622                    }
     623
     624                    if (fFound)
     625                    {
     626                        // lcid found:
     627                        // try next higher one
     628                        lcidNext++;
     629                        fContinue = TRUE;
     630                    }
     631                    // else: return that one
     632                }
     633            }
     634        }
     635
     636        if (alTypes)
     637            free(alTypes);
     638        if (aNames)
     639            free(aNames);
     640        if (allcids)
     641            free(allcids);
     642
     643/*
    527644        PLONG   pBase;
    528 
    529645        APIRET  arc;
    530646
     
    612728            arc = DosFreeMem(pBase);
    613729        }
     730        */
    614731    }
    615732
     
    744861 *          certain point sizes only.
    745862 *
    746  *      4)  <B>Warning: This function is _not_ thread-safe.</B>
    747  *          Since logical font IDs are shared across the
    748  *          process, this function should _not_ be called
    749  *          from several threads at the same time.
     863 *      4)  Since logical font IDs are shared across the
     864 *          process, a mutex is requested while the lcids are
     865 *          being queried and/or manipulated. In other words,
     866 *          this func is now thread-safe (V0.9.9).
    750867 *
    751868 *          This calls gpihQueryNextFontID in turn to find the
    752869 *          next free lcid. See remarks there.
    753  *          If your fonts suddenly change to "System Proportional"
    754  *          in your application, you probably have a serialization
    755  *          problem.
    756  *
    757  *          To make this thread-safe, create your own wrapper
    758  *          function which calls this function while a mutex
    759  *          semaphore is held by the wrapper. Then use only
    760  *          the wrapper in your code.
    761870 *
    762871 *      <B>Font metrics:</B>
     
    793902 *@@changed V0.9.3 (2000-05-06) [umoeller]: usFormat didn't work; fixed
    794903 *@@changed V0.9.4 (2000-08-08) [umoeller]: added fFamily
     904 *@@changed V0.9.9 (2001-04-01) [umoeller]: made this thread-safe, finally
    795905 */
    796906
     
    9811091    free(pfm);
    9821092
    983     // new logical font ID: last used plus one
    984     lLCIDReturn = gpihQueryNextFontID(hps);
    985 
    986     GpiCreateLogFont(hps,
    987                      NULL,  // don't create "logical font name" (STR8)
    988                      lLCIDReturn,
    989                      &FontAttrs);
     1093    if (gpihLockLCIDs())        // V0.9.9 (2001-04-01) [umoeller]
     1094    {
     1095        // new logical font ID: last used plus one
     1096        lLCIDReturn = gpihQueryNextFontID(hps);
     1097
     1098        GpiCreateLogFont(hps,
     1099                         NULL,  // don't create "logical font name" (STR8)
     1100                         lLCIDReturn,
     1101                         &FontAttrs);
     1102
     1103        gpihUnlockLCIDs();
     1104    }
    9901105
    9911106    return (lLCIDReturn);
     
    10251140 *
    10261141 *@@added V0.9.0 [umoeller]
    1027  */
    1028 
    1029 LONG gpihFindPresFont(HWND hwnd,          // in: window to search for presparam
     1142 *@@changed V0.9.9 (2001-04-01) [umoeller]: now supporting NULLHANDLE hwnd
     1143 */
     1144
     1145LONG gpihFindPresFont(HWND hwnd,          // in: window to search for presparam or NULLHANDLE
    10301146                      BOOL fInherit,      // in: search parent windows too?
    10311147                      HPS hps,            // in: HPS for font selection
    1032                       PSZ pszDefaultFont, // in: default font if not found (i.e. "8.Helv")
     1148                      const char *pcszDefaultFont, // in: default font if not found (i.e. "8.Helv")
    10331149                      PFONTMETRICS pFontMetrics, // out: font metrics of created font (optional)
    10341150                      PLONG plSize)       // out: presparam's point size (optional)
    10351151{
    10361152    CHAR    szPPFont[200] = "";
    1037     PSZ     pszFontFound = 0;
     1153    const char *pcszFontFound = 0;
    10381154    CHAR    szFaceName[300] = "";
    10391155    ULONG   ulFontSize = 0;
    10401156
    1041     if (WinQueryPresParam(hwnd,
    1042                           PP_FONTNAMESIZE,          // first PP to query
    1043                           0,                        // second PP to query
    1044                           NULL,                     // out: which one is returned
    1045                           (ULONG)sizeof(szPPFont),  // in: buffer size
    1046                           (PVOID)&szPPFont,         // out: PP value returned
    1047                           (fInherit)
    1048                                ? 0
    1049                                : QPF_NOINHERIT))
     1157    if (    (hwnd)        // V0.9.9 (2001-04-01) [umoeller]
     1158         && (WinQueryPresParam(hwnd,
     1159                               PP_FONTNAMESIZE,          // first PP to query
     1160                               0,                        // second PP to query
     1161                               NULL,                     // out: which one is returned
     1162                               (ULONG)sizeof(szPPFont),  // in: buffer size
     1163                               (PVOID)&szPPFont,         // out: PP value returned
     1164                               (fInherit)
     1165                                    ? 0
     1166                                    : QPF_NOINHERIT))
     1167       )
    10501168        // PP found:
    1051         pszFontFound = szPPFont;
     1169        pcszFontFound = szPPFont;
    10521170    else
    1053         pszFontFound = pszDefaultFont;
    1054 
    1055     if (pszFontFound)
     1171        pcszFontFound = pcszDefaultFont;
     1172
     1173    if (pcszFontFound)
    10561174    {
    1057         PCHAR   pcDot = strchr(pszFontFound, '.');
     1175        const char *pcDot = strchr(pcszFontFound, '.');
    10581176        if (pcDot)
    10591177        {
    10601178            // _Pmpf(("Found font PP: %s", pszFontFound));
    1061             sscanf(pszFontFound, "%lu", &ulFontSize);
     1179            sscanf(pcszFontFound, "%lu", &ulFontSize);
    10621180            if (plSize)
    10631181                *plSize = ulFontSize;
  • trunk/src/helpers/helpers_post.in

    r38 r53  
    8585               $(HLPINC)\dosh.h $(HLPINC)\stringh.h $(HLPINC)\xstring.h
    8686
     87$(OUTPUTDIR)\datetime.obj:          $(@B).c $(HLPINC)\$(@B).h \
     88               $(PROJECTINC)\setup.h
     89
     90$(OUTPUTDIR)\debug.obj:     $(@B).c $(HLPINC)\$(@B).h \
     91               $(PROJECTINC)\setup.h \
     92               $(HLPINC)\dosh.h
     93
     94$(OUTPUTDIR)\dialog.obj:     $(@B).c $(HLPINC)\$(@B).h \
     95               $(PROJECTINC)\setup.h \
     96               $(HLPINC)\comctl.h $(HLPINC)\gpih.h $(HLPINC)\linklist.h \
     97                $(HLPINC)\standards.h $(HLPINC)\stringh.h \
     98               $(HLPINC)\winh.h
     99
     100$(OUTPUTDIR)\dosh.obj:      $(@B).c $(HLPINC)\$(@B).h \
     101               $(PROJECTINC)\setup.h
     102
     103$(OUTPUTDIR)\dosh2.obj:      $(@B).c $(HLPINC)\dosh.h \
     104               $(PROJECTINC)\setup.h \
     105               $(HLPINC)\stringh.h
     106
     107$(OUTPUTDIR)\eah.obj:       $(@B).c $(HLPINC)\$(@B).h \
     108               $(PROJECTINC)\setup.h
     109
    87110$(OUTPUTDIR)\encodings.obj:         $(@B).c $(INC)\encodings\*.h \
    88                $(PROJECTINC)\setup.h
    89 
    90 $(OUTPUTDIR)\datetime.obj:          $(@B).c $(HLPINC)\$(@B).h \
    91                $(PROJECTINC)\setup.h
    92 
    93 $(OUTPUTDIR)\debug.obj:     $(@B).c $(HLPINC)\$(@B).h \
    94                $(PROJECTINC)\setup.h \
    95                $(HLPINC)\dosh.h
    96 
    97 $(OUTPUTDIR)\dosh.obj:      $(@B).c $(HLPINC)\$(@B).h \
    98                $(PROJECTINC)\setup.h
    99 
    100 $(OUTPUTDIR)\dosh2.obj:      $(@B).c $(HLPINC)\dosh.h \
    101                $(PROJECTINC)\setup.h \
    102                $(HLPINC)\stringh.h
    103 
    104 $(OUTPUTDIR)\eah.obj:       $(@B).c $(HLPINC)\$(@B).h \
    105111               $(PROJECTINC)\setup.h
    106112
  • trunk/src/helpers/helpers_pre.in

    r35 r53  
    8080$(OUTPUTDIR)\configsys.obj \
    8181$(OUTPUTDIR)\cnrh.obj \
     82$(OUTPUTDIR)\dialog.obj \
    8283$(OUTPUTDIR)\gpih.obj \
    8384$(OUTPUTDIR)\memdebug.obj \
  • trunk/src/helpers/linklist.c

    r47 r53  
    10711071 *      a pseudo-stack LIFO LINKLIST using lstPush.
    10721072 *
    1073  *      Note that to really "pop" the item, i.e. remove
    1074  *      it from the list, you MUST call lstRemoveNode
    1075  *      with the list node returned from this function,
    1076  *      or otherwise you keep getting the same last item
    1077  *      on subsequent calls.
     1073 *      If (fRemove == TRUE), the item is also removed
     1074 *      from the stack. Otherwise it remains there so the
     1075 *      next lstPop would return the next item.
    10781076 *
    10791077 *      Example:
     
    10811079 +          LINKLIST ll;
    10821080 +          PLISTNODE pNode;
    1083  +          lstInit(&ll, FALSE;
     1081 +          lstInit(&ll, FALSE);
    10841082 +
    10851083 +          lstPush(&ll, (PVOID)1);
    10861084 +          lstPush(&ll, (PVOID)2);
    10871085 +
    1088  +          pNode = lstPop(&ll);     // returns the node containing "2"
     1086 +          pNode = lstPop(&ll);  // returns the node containing "2"
    10891087 +          lstRemoveNode(pNode);
    1090  +          pNode = lstPop(&ll);     // returns the node containing "1"
    1091  +          lstRemoveNode(pNode);
     1088 +          pNode = lstPop(&ll);  // returns the node containing "1"
    10921089 *
    10931090 *@@added V0.9.3 (2000-05-18) [umoeller]
     
    10971094{
    10981095    return (pList->pLast);
    1099     /* unsigned long cItems = lstCountItems(pList);
    1100     if (cItems)
    1101     {
    1102         // list not empty:
    1103         // get last item on the list
    1104         pNodeReturn = lstNodeFromIndex(pList,
    1105                                        cItems - 1);
    1106     }
    1107     return (pNodeReturn); */
    1108 }
    1109 
     1096}
     1097
     1098
  • trunk/src/helpers/tmsgfile.c

    r47 r53  
    541541        GetTimeStamp(&fs3MessageFile, szFileStampCurrent, sizeof(szFileStampCurrent));
    542542
    543         _Pmpf(("    Timestamp for %s: '%s'", pszMessageFile, szFileStampCurrent));
     543        // _Pmpf(("    Timestamp for %s: '%s'", pszMessageFile, szFileStampCurrent));
    544544
    545545        // determine saved timestamp
     
    550550                          &ulStampLength);
    551551
    552         _Pmpf(("    Saved timestamp for %s: '%s'", pszMessageFile, szFileStampOld));
     552        // _Pmpf(("    Saved timestamp for %s: '%s'", pszMessageFile, szFileStampOld));
    553553
    554554        // compare timestamps
     
    587587            if (rc == NO_ERROR)
    588588            {
    589                 _Pmpf(("      --> using precompiled table"));
     589                // _Pmpf(("      --> using precompiled table"));
    590590                break;
    591591            }
    592592        } // end if
    593593
    594         _Pmpf(("      --> recompiling table"));
     594        // _Pmpf(("      --> recompiling table"));
    595595
    596596        // recompilation needed:
     
    735735                    ulCurrentMessageLen);
    736736
    737             _Pmpf(("Found %s at %d, length %d",
     737            /* _Pmpf(("Found %s at %d, length %d",
    738738                    pCurrentNameStart,
    739739                    ulCurrentMessagePos,
    740                     ulCurrentMessageLen));
     740                    ulCurrentMessageLen)); */
    741741
    742742            // need more space ?
     
    744744            {
    745745                PBYTE           pbTmp;
    746                 _Pmpf(("  Re-allocating!!"));
     746                // _Pmpf(("  Re-allocating!!"));
    747747
    748748                cbTableDataAllocated += ulFileDataLength / 2;
     
    790790                {
    791791                    // restore original "last write" date
    792                     _Pmpf(("Resetting file date"));
     792                    // _Pmpf(("Resetting file date"));
    793793                    fs3Tmp.fdateLastWrite = fs3MessageFile.fdateLastWrite;
    794794                    fs3Tmp.ftimeLastWrite = fs3MessageFile.ftimeLastWrite;
Note: See TracChangeset for help on using the changeset viewer.