Changeset 178


Ignore:
Timestamp:
Jun 20, 2002, 10:46:29 PM (23 years ago)
Author:
umoeller
Message:

More pager fixes.

Location:
trunk
Files:
9 edited

Legend:

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

    r168 r178  
    560560     *
    561561     *@@changed V0.9.0: added fields for bitmap support
    562      *@@changed V0.9.16 (2001-10-15) [umoeller]: added ulIconSize
     562     *@@changed V0.9.16 (2001-10-15) [umoeller]: added lIconSize
     563     *@@changed V0.9.19 (2002-06-18) [umoeller]: added szlIcon
    563564     */
    564565
     
    573574                // -- ANF_BITMAP: display bitmaps
    574575                // -- ANF_BITMAP | ANF_PROPORTIONAL: display bitmaps, but preserve proportions
    575         LONG        lIconSize;         // system icon size V0.9.16 (2001-10-15) [umoeller]
     576        SIZEL       szlIcon;            // system icon size V0.9.19 (2002-06-18) [umoeller]
    576577        RECTL       rclIcon;            // size of static control
    577578        PFNWP       OldStaticProc;      // original WC_STATIC wnd proc
  • trunk/include/helpers/dialog.h

    r168 r178  
    261261    #define DEFAULT_TABLE_WIDTH             150
    262262
     263    #define MSGBOX_TEXTWIDTH                200
     264
    263265    // the following require INCL_WINSTATICS
    264266
  • trunk/include/helpers/gpih.h

    r167 r178  
    338338    typedef GPIHSTRETCHBITMAP *PGPIHSTRETCHBITMAP;
    339339
    340     BOOL XWPENTRY gpihIcon2Bitmap(HPS hpsMem,
     340    /* BOOL XWPENTRY gpihIcon2Bitmap(HPS hpsMem,
    341341                                  HPOINTER hptr,
    342342                                  LONG lBkgndColor,
    343343                                  PPOINTL pptlLowerLeft,
    344                                   ULONG ulIconSize);
     344                                  ULONG ulIconSize); */
     345
     346    BOOL gpihDrawPointer(HPS hps,
     347                         LONG x,
     348                         LONG y,
     349                         HPOINTER hptr,
     350                         PSIZEL pszlIcon,
     351                         PRECTL prclClip,
     352                         ULONG fl);
    345353
    346354    /* ******************************************************************
  • trunk/include/helpers/stringh.h

    r161 r178  
    133133    PSZ XWPENTRY strhFindNextLine(PSZ pszSearchIn, PULONG pulOffset);
    134134
    135     BOOL XWPENTRY strhBeautifyTitle(PSZ psz);
     135    ULONG XWPENTRY strhBeautifyTitle(PSZ psz);
     136
     137    ULONG strhBeautifyTitle2(PSZ pszTarget,
     138                             PCSZ pcszSource);
    136139
    137140    PSZ XWPENTRY strhFindAttribValue(const char *pszSearchIn, const char *pszAttrib);
  • trunk/src/helpers/comctl.c

    r169 r178  
    823823                                // center the icon in the bitmap
    824824                                // V0.9.16 (2001-10-15) [umoeller]
    825                                 POINTL ptlOfs;
    826                                 ptlOfs.x = (   (pa->rclIcon.xRight - pa->rclIcon.xLeft)
    827                                              - pa->lIconSize
    828                                            ) / 2;
    829                                 ptlOfs.y = (   (pa->rclIcon.yTop - pa->rclIcon.yBottom)
    830                                              - pa->lIconSize
    831                                            ) / 2;
    832 
    833                                 // paint icon into bitmap
    834                                 gpihIcon2Bitmap(hpsMem,
     825
     826                                // replaced call V0.9.19 (2002-06-18) [umoeller]
     827                                gpihDrawPointer(hpsMem,
     828                                                (   (pa->rclIcon.xRight - pa->rclIcon.xLeft)
     829                                                  - pa->szlIcon.cx
     830                                                ) / 2,
     831                                                (   (pa->rclIcon.yTop - pa->rclIcon.yBottom)
     832                                                  - pa->szlIcon.cy
     833                                                ) / 2,
    835834                                                pa->hptr,
    836                                                 lBkgndColor,
    837                                                 &ptlOfs,
    838                                                 pa->lIconSize);
     835                                                &pa->szlIcon,
     836                                                NULL,       // no clipping
     837                                                0);         // no mini
    839838                            }
    840839
     
    10011000            WinQueryWindowRect(hwndStatic, &pa->rclIcon);
    10021001            pa->OldStaticProc = WinSubclassWindow(hwndStatic, ctl_fnwpBitmapStatic);
    1003             pa->lIconSize = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
     1002            pa->szlIcon.cx = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
     1003            pa->szlIcon.cy = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
    10041004        }
    10051005    }
  • trunk/src/helpers/dialog.c

    r167 r178  
    27562756        Icon = CONTROLDEF_ICON(NULLHANDLE, 0),
    27572757        Spacing = CONTROLDEF_TEXT(NULL, 0, 1, 1),
    2758         InfoText = CONTROLDEF_TEXT_WORDBREAK(NULL, 10, 200),
     2758        InfoText = CONTROLDEF_TEXT_WORDBREAK(NULL, 10, MSGBOX_TEXTWIDTH),
    27592759        Buttons[] =
    27602760        {
  • trunk/src/helpers/gpih.c

    r173 r178  
    17471747    HPS     hpsMem;
    17481748    BITMAPINFOHEADER2 bmi;
    1749     // RECTL   rclSource;
    17501749
    17511750    if (hbmSource)
     
    23422341
    23432342/*
    2344  *@@ gpihIcon2Bitmap:
     2343 * gpihIcon2Bitmap:
    23452344 *      this paints the given icon/pointer into
    23462345 *      a bitmap. Note that if the bitmap is
     
    23512350 *      Returns FALSE upon errors.
    23522351 *
    2353  *@@added V0.9.0 [umoeller]
    2354  *@@changed V0.9.16 (2001-10-15) [umoeller]: added pptlLowerLeft
    2355  *@@changed V0.9.16 (2001-10-15) [umoeller]: fixed inclusive/exclusive confusion (sigh...)
    2356  *@@changed V0.9.19 (2002-06-13) [umoeller]: fixed funny colors when scaling
    2357  */
     2352 *added V0.9.0 [umoeller]
     2353 *changed V0.9.16 (2001-10-15) [umoeller]: added pptlLowerLeft
     2354 *changed V0.9.16 (2001-10-15) [umoeller]: fixed inclusive/exclusive confusion (sigh...)
     2355 *changed V0.9.19 (2002-06-13) [umoeller]: fixed funny colors when scaling
     2356 *removed V0.9.19 (2002-06-18) [umoeller]
     2357 */
     2358
     2359#if 0
    23582360
    23592361BOOL gpihIcon2Bitmap(HPS hpsMem,         // in: target memory PS with bitmap selected into it
     
    24492451}
    24502452
     2453#endif
     2454
     2455/*
     2456 *@@ gpihDrawPointer:
     2457 *      replacement for WinDrawPointer that can do clipping.
     2458 *
     2459 *      To do clipping with WinDrawPointer, one has to
     2460 *      limit the clip rectangle for the current HPS,
     2461 *      which is quite an overhead. This function instead
     2462 *      allows for specifying a clip rectangle directly.
     2463 *      Besides, since it uses GpiWCBitBlt, it should
     2464 *      probably work with all types of device contexts.
     2465 *
     2466 *      This also replaces gpihIcon2Bitmap, which wasn't quite
     2467 *      working in the first place and couldn't to clipping
     2468 *      either.
     2469 *
     2470 *      If you don't need clipping and are drawing to the
     2471 *      screen only, this function has no advantage over
     2472 *      WinDrawPointer because it's presumably slower.
     2473 *
     2474 *      Flags presently supported in fl:
     2475 *
     2476 *      --  DP_MINI (not DP_MINIICON, as stated in PMREF):
     2477 *          use mini-icon.
     2478 *
     2479 *      Preconditions:
     2480 *
     2481 *      --  The hps is assumed to be in RGB mode.
     2482 *
     2483 *      Post conditions:
     2484 *
     2485 *      --  This uses GpiSet(Back)Color, so the foreground
     2486 *          and background colors are undefined after the
     2487 *          call.
     2488 *
     2489 *@@added V0.9.19 (2002-06-18) [umoeller]
     2490 */
     2491
     2492BOOL gpihDrawPointer(HPS hps,           // in: target presentation space
     2493                     LONG x,            // in: lower left target position of icon
     2494                     LONG y,            // in: lower left target position of icon
     2495                     HPOINTER hptr,     // in: icon to be drawn
     2496                     PSIZEL pszlIcon,   // in: icon size (req., should be sysvalues SV_CXICON, SV_CYICON always)
     2497                     PRECTL prclClip,   // in: clip rectangle (inclusive!) or NULL
     2498                     ULONG fl)          // in: DP_* flags
     2499{
     2500    POINTERINFO pi;
     2501
     2502    if (    (pszlIcon)
     2503         && (hptr)
     2504         && (WinQueryPointerInfo(hptr, &pi))
     2505       )
     2506    {
     2507        POINTL  aptl[4];
     2508        HBITMAP hbmThis;
     2509        BITMAPINFOHEADER2 bmi;
     2510
     2511        // A HPOINTER really consists of two bitmaps,
     2512        // one monochrome bitmap that has twice the icon
     2513        // height and contains an AND mask in the upper
     2514        // half and an XOR mask in the lower half, and
     2515        // a (probably color) bitmap with the regular
     2516        // icon height.
     2517
     2518        // Drawing the icon means (1) blitting the AND
     2519        // mask with ROP_SRCAND, (2) blitting the color
     2520        // bitmap with ROP_SRCPAINT, (3) blitting the
     2521        // XOR mask with ROP_SRCINVERT. Hence the slightly
     2522        // complicated code that follows.
     2523
     2524        /*
     2525         * 0)   preparations
     2526         */
     2527
     2528        // set up a bunch of variables that are used
     2529        // by the below calculations. We use cx|yIcon
     2530        // to quickly get the system icon dimensions
     2531        // and set up the clip offsets here too,
     2532        // if a clip rectangle is specified.
     2533
     2534        LONG    cxIcon = pszlIcon->cx,
     2535                cyIcon = pszlIcon->cy,
     2536                cySrc,
     2537                xRight,
     2538                yTop,
     2539        // clip "rectangle"... this is not really a
     2540        // recangle because it specifies _offsets_
     2541        // towards the center of the icon to be
     2542        // clipped
     2543                lClipLeft = 0,
     2544                lClipBottom = 0,
     2545                lClipRight = 0,
     2546                lClipTop = 0;
     2547
     2548        BOOL    fMini;
     2549
     2550        if (fMini = !!(fl & DP_MINI))
     2551        {
     2552            cxIcon /= 2;
     2553            cyIcon /= 2;
     2554        }
     2555
     2556        // target top right (inclusive)
     2557        xRight = x + cxIcon - 1;
     2558        yTop = y + cyIcon - 1;
     2559
     2560        if (prclClip)
     2561        {
     2562            // we have a clip rectangle:
     2563            // set up the clip offsets that are used
     2564            // in both the target and source coordinates
     2565            // for blitting
     2566            if (x < prclClip->xLeft)
     2567                lClipLeft = prclClip->xLeft - x;
     2568            if (xRight > prclClip->xRight)
     2569                lClipRight = xRight - prclClip->xRight;
     2570            if (y < prclClip->yBottom)
     2571                lClipBottom = prclClip->yBottom - y;
     2572            if (yTop > prclClip->yTop)
     2573                lClipTop = yTop - prclClip->yTop;
     2574        }
     2575
     2576        // set up target coordinates that are constant
     2577        // for all the three blits
     2578
     2579        // aptl[0]: target bottom-left
     2580        aptl[0].x = x + lClipLeft;
     2581        aptl[0].y = y + lClipBottom;
     2582
     2583        // aptl[1]: target top-right (inclusive!)
     2584        aptl[1].x = xRight - lClipRight;
     2585        aptl[1].y = yTop - lClipTop;
     2586
     2587        if (    (aptl[0].x < aptl[1].x)
     2588             && (aptl[0].y < aptl[1].y)
     2589           )
     2590        {
     2591            // colors are constant too
     2592            GpiSetColor(hps, RGBCOL_WHITE);
     2593            GpiSetBackColor(hps, RGBCOL_BLACK);
     2594
     2595            /*
     2596             * 1)   work on the AND image
     2597             *      (upper part of the monochrome image)
     2598             */
     2599
     2600            if (    (    (fMini)
     2601                      && (hbmThis = pi.hbmMiniPointer)
     2602                    )
     2603                 || (hbmThis = pi.hbmPointer)
     2604               )
     2605            {
     2606                bmi.cbFix = sizeof(bmi);
     2607                GpiQueryBitmapInfoHeader(hbmThis, &bmi);
     2608
     2609                // use only half the bitmap height
     2610                cySrc = bmi.cy / 2;
     2611
     2612                // aptl[2]: source bottom-left
     2613                aptl[2].x =   0
     2614                            + lClipLeft   * bmi.cx / cxIcon;
     2615                aptl[2].y =   cySrc
     2616                            + lClipBottom * cySrc / cyIcon;
     2617
     2618                // aptl[3]: source top-right (exclusive!)
     2619                aptl[3].x =   bmi.cx
     2620                            - lClipRight  * bmi.cx / cxIcon;
     2621                aptl[3].y =   bmi.cy
     2622                            - lClipTop    * cySrc / cyIcon;
     2623
     2624                GpiWCBitBlt(hps,        // target
     2625                            hbmThis,    // src bmp
     2626                            4L,         // must always be 4
     2627                            aptl,       // point array
     2628                            ROP_SRCAND,   // source AND target
     2629                            BBO_IGNORE);
     2630            }
     2631
     2632            /*
     2633             * 2)   paint the color image; the parts that
     2634             *      are to be transparent are black
     2635             */
     2636
     2637            if (    (    (fMini)
     2638                      && (hbmThis = pi.hbmMiniColor)
     2639                    )
     2640                 || (hbmThis = pi.hbmColor)
     2641               )
     2642            {
     2643                bmi.cbFix = sizeof(bmi);
     2644                GpiQueryBitmapInfoHeader(hbmThis, &bmi);
     2645
     2646                // aptl[2]: source bottom-left
     2647                aptl[2].x =   0
     2648                            + lClipLeft   * bmi.cx / cxIcon;
     2649                aptl[2].y =   0
     2650                            + lClipBottom * bmi.cy / cyIcon;
     2651
     2652                // aptl[3]: source top-right (exclusive!)
     2653                aptl[3].x =   bmi.cx
     2654                            - lClipRight  * bmi.cx / cxIcon;
     2655                aptl[3].y =   bmi.cy
     2656                            - lClipTop    * bmi.cy / cyIcon;
     2657
     2658                GpiWCBitBlt(hps,        // target
     2659                            hbmThis,    // src bmp
     2660                            4L,         // must always be 4
     2661                            aptl,       // point array
     2662                            ROP_SRCPAINT,
     2663                            BBO_IGNORE);
     2664            }
     2665
     2666            /*
     2667             *  3)  work on the XOR image:
     2668             *      (lower part of monochrome bitmap)
     2669             */
     2670
     2671            if (    (    (fMini)
     2672                      && (hbmThis = pi.hbmMiniPointer)
     2673                    )
     2674                 || (hbmThis = pi.hbmPointer)
     2675               )
     2676            {
     2677                bmi.cbFix = sizeof(bmi);
     2678                GpiQueryBitmapInfoHeader(hbmThis, &bmi);
     2679
     2680                // use only half the bitmap height
     2681                cySrc = bmi.cy / 2;
     2682
     2683                // aptl[2]: source bottom-left
     2684                aptl[2].x =   0
     2685                            + lClipLeft   * bmi.cx / cxIcon;
     2686                aptl[2].y =   0
     2687                            + lClipBottom * cySrc / cyIcon;
     2688
     2689                // aptl[3]: source top-right (exclusive!)
     2690                aptl[3].x =   bmi.cx
     2691                            - lClipRight  * bmi.cx / cxIcon;
     2692                aptl[3].y =   cySrc
     2693                            - lClipTop    * cySrc / cyIcon;
     2694
     2695                GpiWCBitBlt(hps,        // target
     2696                            hbmThis,    // src bmp
     2697                            4L,         // must always be 4
     2698                            aptl,       // point array
     2699                            ROP_SRCINVERT,   // source XOR target
     2700                            BBO_IGNORE);
     2701            }
     2702
     2703            return TRUE;
     2704        }
     2705    }
     2706
     2707    return FALSE;
     2708}
     2709
    24512710/*
    24522711 *@@category: Helpers\PM helpers\GPI helpers\XBitmaps
  • trunk/src/helpers/regexp.c

    r155 r178  
    25242524 */
    25252525
    2526 BOOLEAN rxpMatch_fwd(const ERE * ere,
    2527                      int eremf,
     2526BOOLEAN rxpMatch_fwd(const ERE *ere,        // in: compiled ERE (from rxpCompile)
     2527                     int eremf,             // in: EREMF_* flags
    25282528                     const char *str,       // in: string to test
    25292529                     int pos,               // in: start position
    25302530                     int *pos_match,        // out: position of match
    25312531                     int *len_match,        // out: length of match
    2532                      ERE_MATCHINFO * mi)
     2532                     ERE_MATCHINFO *mi)     // out: match info (for rxpSubsWith)
    25332533{
    25342534    int len = pos + strlen(str + pos);
     
    25772577 */
    25782578
    2579 BOOLEAN rxpMatch_bwd(const ERE * ere,
    2580                      int eremf,
    2581                      const char *str, int pos,
    2582                      int *pos_match, int *len_match,
    2583                      ERE_MATCHINFO * mi)
     2579BOOLEAN rxpMatch_bwd(const ERE *ere,        // in: compiled ERE (from rxpCompile)
     2580                     int eremf,             // in: EREMF_* flags
     2581                     const char *str,       // in: string to test
     2582                     int pos,               // in: start position
     2583                     int *pos_match,        // out: position of match
     2584                     int *len_match,        // out: length of match
     2585                     ERE_MATCHINFO * mi)    // out: match info (for rxpSubsWith)
    25842586{
    25852587    int i;
     
    26302632 *@@ rxpSubsWith:
    26312633 *      perform a substitution based upon an earlier found match.
    2632  */
    2633 
    2634 BOOLEAN rxpSubsWith(const char *str,    // Original string searched
    2635                     int pos, int len,   // Span of the entire match
    2636                     ERE_MATCHINFO * mi,     // Details of sub-spans of match
    2637                     const char *with,   // Specification of replacement
    2638                     char *out,  // Substituted string buffer
    2639                     int len_out,    // How much room in output buffer
    2640                     int *rc     // Error, if FALSE returned
    2641 )
     2634 *      This allows for implementing a "find and replace" function.
     2635 */
     2636
     2637BOOLEAN rxpSubsWith(const char *str,    // in: original string searched (same as str given to rxpMatch_fwd)
     2638                    int pos,            // in: span of the entire match (pos_match from rxpMatch_fwd)
     2639                    int len,            // in: span of the entire match (len_match from rxpMatch_fwd)
     2640                    ERE_MATCHINFO *mi,  // in: details of match sub-spans (as from rxpMatch_fwd)
     2641                    const char *with,   // in: replacement string with \1 etc.
     2642                    char *out,          // out: buffer for string substitutions
     2643                    int len_out,        // in: sizeof *out
     2644                    int *rc)            // out: error, if FALSE returned
    26422645{
    26432646    int i = 0;
  • trunk/src/helpers/stringh.c

    r174 r178  
    10561056 *@@ strhBeautifyTitle:
    10571057 *      replaces all line breaks (0xd, 0xa) with spaces.
     1058 *      Returns the new length of the string or 0 on
     1059 *      errors.
    10581060 *
    10591061 *@@changed V0.9.12 (2001-05-17) [pr]: multiple line break chars. end up as only 1 space
    1060  */
    1061 
    1062 BOOL strhBeautifyTitle(PSZ psz)
    1063 {
    1064     BOOL rc = FALSE;
    1065     CHAR *p = psz;
    1066 
    1067     while(*p)
     1062 *@@changed V0.9.19 (2002-06-18) [umoeller]: now returning length
     1063 */
     1064
     1065ULONG strhBeautifyTitle(PSZ psz)
     1066{
     1067    ULONG   ulrc;
     1068    PSZ     p = psz;
     1069
     1070    while (*p)
     1071    {
    10681072        if (    (*p == '\r')
    10691073             || (*p == '\n')
    10701074           )
    10711075        {
    1072             rc = TRUE;
    1073             if (   (p != psz)
    1074                 && (p[-1] == ' ')
     1076            if (    (p != psz)
     1077                 && (p[-1] == ' ')
    10751078               )
    10761079                memmove(p, p + 1, strlen(p));
     
    10801083        else
    10811084            p++;
    1082 
    1083     return rc;
     1085    }
     1086
     1087    return (p - psz);
     1088}
     1089
     1090/*
     1091 *@@ strhBeautifyTitle:
     1092 *      like strhBeautifyTitle, but copies into
     1093 *      a new buffer. More efficient.
     1094 *
     1095 *@@added V0.9.19 (2002-06-18) [umoeller]
     1096 */
     1097
     1098ULONG strhBeautifyTitle2(PSZ pszTarget,     // out: beautified string
     1099                         PCSZ pcszSource)   // in: string to be beautified (can be NULL)
     1100{
     1101    ULONG   ulrc;
     1102    PCSZ    pSource = pcszSource;
     1103    PSZ     pTarget = pszTarget;
     1104    CHAR    c;
     1105    if (!pcszSource)
     1106    {
     1107        *pszTarget = '\0';
     1108        return 0;
     1109    }
     1110
     1111    while (c = *pSource++)
     1112    {
     1113        if (    (c == '\r')
     1114             || (c == '\n')
     1115           )
     1116        {
     1117            if (    (pTarget == pszTarget)
     1118                 || (pTarget[-1] != ' ')
     1119               )
     1120                *pTarget++ = ' ';
     1121        }
     1122        else
     1123            *pTarget++ = c;
     1124    }
     1125
     1126    // null-terminate
     1127    *pTarget = '\0';
     1128
     1129    return (pTarget - pszTarget);
    10841130}
    10851131
Note: See TracChangeset for help on using the changeset viewer.