Changeset 105 for trunk/src/helpers


Ignore:
Timestamp:
Sep 27, 2001, 10:29:02 PM (24 years ago)
Author:
umoeller
Message:

Misc changes.

Location:
trunk/src/helpers
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/apmh.c

    r93 r105  
    158158 *      After this, the status fields in APM
    159159 *      are valid (if NO_ERROR is returned).
    160  */
    161 
    162 APIRET apmhReadStatus(PAPM pApm)        // in: APM structure created by apmhOpen
    163 {
    164     APIRET arc = NO_ERROR;
     160 *      If the values changed since the previous
     161 *      call, *pfChanged is set to TRUE; FALSE
     162 *      otherwise.
     163 */
     164
     165APIRET apmhReadStatus(PAPM pApm,        // in: APM structure created by apmhOpen
     166                      PBOOL pfChanged)  // out: values changed (ptr can be NULL)
     167{
     168    APIRET  arc = NO_ERROR;
     169    BOOL    fChanged = FALSE;
    165170
    166171    if ((pApm) && (pApm->hfAPMSys))
     
    174179                              PowerStatus.ParmLength)))
    175180        {
    176             pApm->ulBatteryStatus = PowerStatus.BatteryStatus;
    177             pApm->ulBatteryLife = PowerStatus.BatteryLife;
     181            if (    (pApm->fAlreadyRead)
     182                 || (pApm->ulBatteryStatus != PowerStatus.BatteryStatus)
     183                 || (pApm->ulBatteryLife != PowerStatus.BatteryLife)
     184               )
     185            {
     186                pApm->ulBatteryStatus = PowerStatus.BatteryStatus;
     187                pApm->ulBatteryLife = PowerStatus.BatteryLife;
     188
     189                pApm->fAlreadyRead = FALSE;
     190                fChanged = TRUE;
     191            }
    178192        }
     193
     194        if (pfChanged)
     195            *pfChanged = fChanged;
    179196    }
    180197    else
  • trunk/src/helpers/apps.c

    r101 r105  
    744744 *          this uses the default Win-OS/2 environment.
    745745 *          See appQueryDefaultWin31Environment.
     746 *
     747 *      --  WARNING: Since this uses WinStartApp internally,
     748 *          and WinStartApp completely hangs PM if a Win-OS/2
     749 *          full-screen session is started from a thread that
     750 *          is NOT thread1, THIS SHOULD ONLY BE CALLED ON
     751 *          THREAD 1 of your application.
    746752 *
    747753 *      Even though this isn't clearly said in PMREF,
  • trunk/src/helpers/dialog.c

    r103 r105  
    4848#define INCL_WINDIALOGS
    4949#define INCL_WININPUT
     50#define INCL_WINSTATICS
    5051#define INCL_WINBUTTONS
    51 #define INCL_WINSTATICS
     52#define INCL_WINENTRYFIELDS
    5253#define INCL_WINSYS
    5354
     
    7071#include "helpers\stringh.h"
    7172#include "helpers\winh.h"
     73#include "helpers\xstring.h"
    7274
    7375/*
     
    21312133
    21322134/*
     2135 *@@ cmnTextEntryBox:
     2136 *      common dialog for entering a text string.
     2137 *      The dialog has a descriptive text on top
     2138 *      with an entry field below and "OK" and "Cancel"
     2139 *      buttons.
     2140 *
     2141 *      The string from the user is returned in a
     2142 *      new buffer, which must be free'd by the caller.
     2143 *      Returns NULL if the user pressed "Cancel".
     2144 *
     2145 *      fl can be any combination of the following
     2146 *      flags:
     2147 *
     2148 *      --  TEBF_REMOVETILDE: tilde ("~") characters
     2149 *          are removed from pcszTitle before setting
     2150 *          the title. Useful for reusing menu item
     2151 *          texts.
     2152 *
     2153 *      --  TEBF_REMOVEELLIPSE: ellipse ("...") strings
     2154 *          are removed from pcszTitle before setting
     2155 *          the title. Useful for reusing menu item
     2156 *          texts.
     2157 *
     2158 *      --  TEBF_SELECTALL: the default text in the
     2159 *          entry field is initially highlighted.
     2160 *
     2161 *@@added V0.9.15 (2001-09-14) [umoeller]
     2162 */
     2163
     2164PSZ dlghTextEntryBox(HWND hwndOwner,
     2165                     const char *pcszTitle,          // in: dlg title
     2166                     const char *pcszDescription,    // in: descriptive text above entry field
     2167                     const char *pcszDefault,        // in: default text for entry field or NULL
     2168                     const char *pcszOK,             // in: "OK" string
     2169                     const char *pcszCancel,         // in: "Cancel" string
     2170                     ULONG ulMaxLen,                 // in: maximum length for entry
     2171                     ULONG fl,                       // in: TEBF_* flags
     2172                     const char *pcszFont)           // in: font (e.g. "9.WarpSans")
     2173{
     2174    CONTROLDEF
     2175                Static = {
     2176                            WC_STATIC,
     2177                            NULL,
     2178                            WS_VISIBLE | SS_TEXT | DT_LEFT | DT_WORDBREAK,
     2179                            -1,
     2180                            CTL_COMMON_FONT,
     2181                            0,
     2182                            { 300, SZL_AUTOSIZE },     // size
     2183                            5               // spacing
     2184                         },
     2185                Entry = {
     2186                            WC_ENTRYFIELD,
     2187                            NULL,
     2188                            WS_VISIBLE | WS_TABSTOP | ES_LEFT | ES_MARGIN | ES_AUTOSCROLL,
     2189                            999,
     2190                            CTL_COMMON_FONT,
     2191                            0,
     2192                            { 300, 20 },     // size
     2193                            5               // spacing
     2194                         },
     2195                OKButton = {
     2196                            WC_BUTTON,
     2197                            NULL,
     2198                            WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON | BS_DEFAULT,
     2199                            DID_OK,
     2200                            CTL_COMMON_FONT,
     2201                            0,
     2202                            { 100, 30 },    // size
     2203                            5               // spacing
     2204                         },
     2205                CancelButton = {
     2206                            WC_BUTTON,
     2207                            NULL,
     2208                            WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
     2209                            DID_CANCEL,
     2210                            CTL_COMMON_FONT,
     2211                            0,
     2212                            { 100, 30 },    // size
     2213                            5               // spacing
     2214                         };
     2215    DLGHITEM DlgTemplate[] =
     2216        {
     2217            START_TABLE,
     2218                START_ROW(0),
     2219                    CONTROL_DEF(&Static),
     2220                START_ROW(0),
     2221                    CONTROL_DEF(&Entry),
     2222                START_ROW(0),
     2223                    CONTROL_DEF(&OKButton),
     2224                    CONTROL_DEF(&CancelButton),
     2225            END_TABLE
     2226        };
     2227
     2228    HWND hwndDlg = NULLHANDLE;
     2229    PSZ  pszReturn = NULL;
     2230    XSTRING strTitle;
     2231
     2232    xstrInitCopy(&strTitle, pcszTitle, 0);
     2233
     2234    if (fl & (TEBF_REMOVEELLIPSE | TEBF_REMOVETILDE))
     2235    {
     2236        ULONG ulOfs;
     2237        if (fl & TEBF_REMOVEELLIPSE)
     2238        {
     2239            ulOfs = 0;
     2240            while (xstrFindReplaceC(&strTitle,
     2241                                    &ulOfs,
     2242                                    "...",
     2243                                    ""))
     2244                ;
     2245        }
     2246
     2247        if (fl & TEBF_REMOVETILDE)
     2248        {
     2249            ulOfs = 0;
     2250            while (xstrFindReplaceC(&strTitle,
     2251                                    &ulOfs,
     2252                                    "~",
     2253                                    ""))
     2254                ;
     2255        }
     2256    }
     2257
     2258    Static.pcszText = pcszDescription;
     2259
     2260    OKButton.pcszText = pcszOK;
     2261    CancelButton.pcszText = pcszCancel;
     2262
     2263    if (NO_ERROR == dlghCreateDlg(&hwndDlg,
     2264                                  hwndOwner,
     2265                                  FCF_TITLEBAR | FCF_SYSMENU | FCF_DLGBORDER | FCF_NOBYTEALIGN,
     2266                                  WinDefDlgProc,
     2267                                  strTitle.psz,
     2268                                  DlgTemplate,      // DLGHITEM array
     2269                                  ARRAYITEMCOUNT(DlgTemplate),
     2270                                  NULL,
     2271                                  pcszFont))
     2272    {
     2273        HWND hwndEF = WinWindowFromID(hwndDlg, 999);
     2274        winhCenterWindow(hwndDlg);
     2275        winhSetEntryFieldLimit(hwndEF, ulMaxLen);
     2276        if (pcszDefault)
     2277        {
     2278            WinSetWindowText(hwndEF, (PSZ)pcszDefault);
     2279            if (fl & TEBF_SELECTALL)
     2280                winhEntryFieldSelectAll(hwndEF);
     2281        }
     2282        WinSetFocus(HWND_DESKTOP, hwndEF);
     2283        if (DID_OK == WinProcessDlg(hwndDlg))
     2284            pszReturn = winhQueryWindowText(hwndEF);
     2285
     2286        WinDestroyWindow(hwndDlg);
     2287    }
     2288
     2289    xstrClear(&strTitle);
     2290
     2291    return (pszReturn);
     2292}
     2293
     2294/*
    21332295 *@@ dlghSetPrevFocus:
    21342296 *      "backward" function for rotating the focus
     
    22462408    }
    22472409}
    2248 
    2249 /*
    2250  *@@ MatchMnemonic:
    2251  *      returns TRUE if the specified control matches
    2252  *
    2253  *
    2254  *@@added V0.9.9 (2001-03-17) [umoeller]
    2255  */
    22562410
    22572411/*
  • trunk/src/helpers/dosh.c

    r94 r105  
    814814                          &fFixed);    // V0.9.13 (2001-06-14) [umoeller]
    815815
    816     _Pmpf((__FUNCTION__ ": doshIsFixedDisk returned %d for disk %d", arc, ulLogicalDrive));
    817     _Pmpf(("   fFixed is %d", fFixed));
     816    // _Pmpf((__FUNCTION__ ": doshIsFixedDisk returned %d for disk %d", arc, ulLogicalDrive));
     817    // _Pmpf(("   fFixed is %d", fFixed));
    818818
    819819    if (!arc)
     
    825825            arc = doshQueryDiskParams(ulLogicalDrive,
    826826                                      &bpb);
    827             _Pmpf(("   doshQueryDiskParams returned %d", arc));
     827            // _Pmpf(("   doshQueryDiskParams returned %d", arc));
    828828
    829829            if (    (!arc)
     
    831831               )
    832832            {
    833                 _Pmpf(("   --> is CD-ROM"));
     833                // _Pmpf(("   --> is CD-ROM"));
    834834                fCDROM = TRUE;
    835835            }
  • trunk/src/helpers/stringh.c

    r94 r105  
    19141914/*
    19151915 * match_comp_os2:
    1916  *      Compare a single component (directory name or file name) of the
    1917  *      paths, for OS/2 and DOS styles.  MASK and NAME point into a
    1918  *      component of the wildcard and the name to be checked, respectively.
    1919  *      Comparing stops at the next separator.  The FLAGS argument is the
    1920  *      same as that of fnmatch().  HAS_DOT is true if a dot is in the
    1921  *      current component of NAME.  The number of dots is not restricted,
    1922  *      even in DOS style.  Return FNM_MATCH iff MASK and NAME match.
     1916 *      compares a single component (directory name or file name)
     1917 *      of the paths, for OS/2 and DOS styles. MASK and NAME point
     1918 *      into a component of the wildcard and the name to be checked,
     1919 *      respectively. Comparing stops at the next separator.
     1920 *      The FLAGS argument is the same as that of fnmatch().
     1921 *
     1922 *      HAS_DOT is true if a dot is in the current component of NAME.
     1923 *      The number of dots is not restricted, even in DOS style.
     1924 *
     1925 *      Returns FNM_MATCH iff MASK and NAME match.
     1926 *
    19231927 *      Note that this function is recursive.
    19241928 *
     
    19441948                if (*name == 0)
    19451949                    return FNM_MATCH;
    1946                 if ((flags & _FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name))
     1950                if ((flags & FNM_PATHPREFIX) && IS_OS2_COMP_SEP(*name))
    19471951                    return FNM_MATCH;
    19481952                return FNM_NOMATCH;
     
    19591963                 * is ignored at the end of NAME. */
    19601964
    1961                 if ((flags & _FNM_PATHPREFIX) && mask[1] == 0 && *name == 0)
     1965                if ((flags & FNM_PATHPREFIX) && mask[1] == 0 && *name == 0)
    19621966                    return FNM_MATCH;
    19631967
     
    19941998                    if (IS_OS2_COMP_END(*name))
    19951999                        return FNM_NOMATCH;
    1996                     if (*name == '.' && (flags & _FNM_STYLE_MASK) == _FNM_DOS)
     2000                    if (*name == '.' && (flags & FNM_STYLE_MASK) == FNM_DOS)
    19972001                        return FNM_NOMATCH;
    19982002                    ++name;
     
    20152019                /* All other characters match themselves. */
    20162020
    2017                 if (flags & _FNM_IGNORECASE)
     2021                if (flags & FNM_IGNORECASE)
    20182022                {
    20192023                    if (tolower(*mask) != tolower(*name))
     
    20332037/*
    20342038 * match_comp:
    2035  *      compare a single component (directory name or file name) of the
    2036  *      paths, for all styles which need component-by-component matching.
    2037  *      MASK and NAME point to the start of a component of the wildcard and
    2038  *      the name to be checked, respectively.  Comparing stops at the next
    2039  *      separator.  The FLAGS argument is the same as that of fnmatch().
     2039 *      compares a single component (directory name or file
     2040 *      name) of the paths, for all styles which need
     2041 *      component-by-component matching. MASK and NAME point
     2042 *      to the start of a component of the wildcard and the
     2043 *      name to be checked, respectively.  Comparing stops at
     2044 *      the next separator. The FLAGS argument is the same as
     2045 *      that of fnmatch().
     2046 *
    20402047 *      Return FNM_MATCH iff MASK and NAME match.
    20412048 *
     
    20492056    const unsigned char *s;
    20502057
    2051     switch (flags & _FNM_STYLE_MASK)
    2052     {
    2053         case _FNM_OS2:
    2054         case _FNM_DOS:
     2058    switch (flags & FNM_STYLE_MASK)
     2059    {
     2060        case FNM_OS2:
     2061        case FNM_DOS:
    20552062
    20562063            /* For OS/2 and DOS styles, we add an implicit dot at the end of
     
    20802087/*
    20812088 * match_unix:
    2082  *      match complete paths for Unix styles.  The FLAGS argument is the
    2083  *      same as that of fnmatch().  COMP points to the start of the current
    2084  *      component in NAME.  Return FNM_MATCH iff MASK and NAME match.  The
     2089 *      matches complete paths for Unix styles.
     2090 *
     2091 *      The FLAGS argument is the same as that of fnmatch().
     2092 *      COMP points to the start of the current component in
     2093 *      NAME.  Return FNM_MATCH iff MASK and NAME match.  The
    20852094 *      backslash character is used for escaping ? and * unless
    20862095 *      FNM_NOESCAPE is set.
     
    21102119                if (*name == 0)
    21112120                    return FNM_MATCH;
    2112                 if ((flags & _FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name))
     2121                if ((flags & FNM_PATHPREFIX) && IS_UNIX_COMP_SEP(*name))
    21132122                    return FNM_MATCH;
    21142123                return FNM_NOMATCH;
     
    21642173
    21652174                if (!(IS_UNIX_COMP_SEP(*name)
    2166                       || ((flags & _FNM_PATHPREFIX) && *name == 0
     2175                      || ((flags & FNM_PATHPREFIX) && *name == 0
    21672176                      && (mask[1] == 0
    21682177                          || (!(flags & FNM_NOESCAPE) && mask[1] == '\\'
     
    22922301                /* All other characters match themselves. */
    22932302
    2294                 if (flags & _FNM_IGNORECASE)
     2303                if (flags & FNM_IGNORECASE)
    22952304                {
    22962305                    if (tolower(*mask) != tolower(*name))
     
    23272336                             unsigned flags)
    23282337{
    2329     int             m_drive, n_drive,
    2330                     rc;
     2338    int     m_drive,
     2339            n_drive,
     2340            rc;
    23312341
    23322342    /* Match and skip the drive name if present. */
     
    23392349        if (m_drive == -1 || n_drive == -1)
    23402350            return FNM_NOMATCH;
    2341         if (!(flags & _FNM_IGNORECASE))
     2351        if (!(flags & FNM_IGNORECASE))
    23422352            return FNM_NOMATCH;
    23432353        if (tolower(m_drive) != tolower(n_drive))
     
    23592369     * "\*\server\path".  Ditto for /. */
    23602370
    2361     switch (flags & _FNM_STYLE_MASK)
    2362     {
    2363         case _FNM_OS2:
    2364         case _FNM_DOS:
     2371    switch (flags & FNM_STYLE_MASK)
     2372    {
     2373        case FNM_OS2:
     2374        case FNM_DOS:
    23652375
    23662376            if (IS_OS2_COMP_SEP(name[0]) && IS_OS2_COMP_SEP(name[1]))
     
    23732383            break;
    23742384
    2375         case _FNM_POSIX:
     2385        case FNM_POSIX:
    23762386
    23772387            if (name[0] == '/' && name[1] == '/')
     
    24042414         * is reached even if there are components left in NAME. */
    24052415
    2406         if (*mask == 0 && (flags & _FNM_PATHPREFIX))
     2416        if (*mask == 0 && (flags & FNM_PATHPREFIX))
    24072417            return FNM_MATCH;
    24082418
     
    24362446 */
    24372447
    2438 BOOL strhMatchOS2(const unsigned char* pcszMask,     // in: mask (e.g. "*.txt")
    2439                   const unsigned char* pcszName)     // in: string to check (e.g. "test.txt")
    2440 {
    2441     return ((BOOL)(_fnmatch_unsigned(pcszMask,
    2442                                      pcszName,
    2443                                      _FNM_OS2 | _FNM_IGNORECASE)
     2448BOOL strhMatchOS2(const char *pcszMask,     // in: mask (e.g. "*.txt")
     2449                  const char *pcszName)     // in: string to check (e.g. "test.txt")
     2450{
     2451    return ((BOOL)(_fnmatch_unsigned((const unsigned char *)pcszMask,
     2452                                     (const unsigned char *)pcszName,
     2453                                     FNM_OS2 | FNM_IGNORECASE)
     2454                   == FNM_MATCH)
     2455           );
     2456}
     2457
     2458/*
     2459 *@@ strhMatchExt:
     2460 *      like strhMatchOS2, but this takes all the flags
     2461 *      for input.
     2462 *
     2463 *@@added V0.9.15 (2001-09-14) [umoeller]
     2464 */
     2465
     2466BOOL strhMatchExt(const char *pcszMask,     // in: mask (e.g. "*.txt")
     2467                  const char *pcszName,     // in: string to check (e.g. "test.txt")
     2468                  unsigned flags)           // in: FNM_* flags
     2469{
     2470    return ((BOOL)(_fnmatch_unsigned((const unsigned char *)pcszMask,
     2471                                     (const unsigned char *)pcszName,
     2472                                     flags)
    24442473                   == FNM_MATCH)
    24452474           );
Note: See TracChangeset for help on using the changeset viewer.