Ignore:
Timestamp:
Jan 19, 2003, 8:42:16 PM (23 years ago)
Author:
umoeller
Message:

First attempt at new container contol.

File:
1 edited

Legend:

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

    r240 r242  
    6161#endif
    6262#include "helpers\dosh.h"
     63#include "helpers\gpih.h"
    6364#include "helpers\winh.h"
    64 #include "helpers\gpih.h"
     65#include "helpers\stringh.h"
    6566
    6667#pragma hdrstop
     
    459460 */
    460461
    461 VOID gpihDrawThickFrame(HPS hps,              // in: presentation space for output
    462                         PRECTL prcl,          // in: rectangle to draw (inclusive)
    463                         ULONG ulWidth)       // in: line width (>= 1)
     462VOID gpihDrawThickFrame(HPS hps,            // in: presentation space for output
     463                        PRECTL prcl,        // in: rectangle to draw (inclusive)
     464                        ULONG ulWidth)      // in: line width (>= 1)
    464465{
    465466    ULONG ul = 0;
     
    506507 */
    507508
    508 VOID gpihDraw3DFrame2(HPS hps,
    509                       PRECTL prcl,       // in: rectangle (inclusive)
    510                       USHORT usWidth,    // in: line width (>= 1)
    511                       LONG lColorLeft,   // in: color to use for left and top; e.g. SYSCLR_BUTTONLIGHT
    512                       LONG lColorRight)  // in: color to use for right and bottom; e.g. SYSCLR_BUTTONDARK
     509VOID gpihDraw3DFrame2(HPS hps,              // in: presentation space for output
     510                      PRECTL prcl,          // in: rectangle (inclusive)
     511                      USHORT usWidth,       // in: line width (>= 1)
     512                      LONG lColorLeft,      // in: color to use for left and top; e.g. SYSCLR_BUTTONLIGHT
     513                      LONG lColorRight)     // in: color to use for right and bottom; e.g. SYSCLR_BUTTONDARK
    513514{
    514515    USHORT us;
     
    553554 */
    554555
    555 VOID gpihDraw3DFrame(HPS hps,
     556VOID gpihDraw3DFrame(HPS hps,           // in: presentation space for output
    556557                     PRECTL prcl,       // in: rectangle (inclusive)
    557558                     USHORT usWidth,    // in: line width (>= 1)
     
    576577 */
    577578
    578 LONG gpihCharStringPosAt(HPS hps,
     579LONG gpihCharStringPosAt(HPS hps,               // in: presentation space for output
    579580                         PPOINTL pptlStart,
    580581                         PRECTL prclRect,
     
    628629
    629630/*
     631 *@@ gpihCalcTextExtent:
     632 *
     633 *@@added V1.0.1 (2003-01-17) [umoeller]
     634 */
     635
     636VOID gpihCalcTextExtent(HPS hps,            // in: presentation space for output
     637                        PCSZ pcsz,          // in: string to test
     638                        PLONG pcx,          // out: max width occupied by a line in the string
     639                        PULONG pcLines)     // out: no. of lines
     640{
     641    LONG    cxLineThis;
     642    PCSZ    pThis = pcsz;
     643    *pcx = 0;
     644
     645    *pcLines = 0;
     646
     647    if (!pThis)
     648        return;
     649
     650    while (*pThis)
     651    {
     652        ULONG lenThis;
     653        PCSZ pNext = strhFindEOL(pThis, &lenThis);
     654
     655        ++(*pcLines);
     656
     657        if (lenThis)
     658        {
     659            POINTL aptl[TXTBOX_COUNT];
     660            GpiQueryTextBox(hps,
     661                            lenThis,
     662                            (PCH)pThis,
     663                            TXTBOX_COUNT,
     664                            aptl);
     665
     666            cxLineThis = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_BOTTOMLEFT].x;
     667
     668            if (cxLineThis > *pcx)
     669                *pcx = cxLineThis;
     670        }
     671
     672        if (*pNext == '\r')
     673            pNext++;
     674        pThis = pNext;
     675    }
     676}
     677
     678/*
     679 *@@ gpihDrawString:
     680 *      replacement for WinDrawText that can still align
     681 *      properly with multi-line strings.
     682 *
     683 *      fl works as with WinDrawText, that is:
     684 *
     685 *      --  specify one of DT_LEFT, DT_CENTER, DT_RIGHT;
     686 *
     687 *      --  specifiy one of DT_TOP, DT_VCENTER, DT_BOTTOM.
     688 *
     689 *      The alignment definitions are:
     690 *
     691 *      --  DT_LEFT                    0x00000000
     692 *      --  DT_CENTER                  0x00000100
     693 *      --  DT_RIGHT                   0x00000200
     694 *      --  DT_TOP                     0x00000000
     695 *      --  DT_VCENTER                 0x00000400
     696 *      --  DT_BOTTOM                  0x00000800
     697 *
     698 *      Other flags:
     699 *
     700 *      --  DT_QUERYEXTENT             0x00000002   (not supported)
     701 *      --  DT_UNDERSCORE              0x00000010   (not supported)
     702 *      --  DT_STRIKEOUT               0x00000020   (not supported)
     703 *      --  DT_TEXTATTRS               0x00000040   (always enabled)
     704 *      --  DT_EXTERNALLEADING         0x00000080   (not supported)
     705 *      --  DT_HALFTONE                0x00001000   (not supported)
     706 *      --  DT_MNEMONIC                0x00002000   (not supported)
     707 *      --  DT_WORDBREAK               0x00004000   (always enabled)
     708 *      --  DT_ERASERECT               0x00008000   (not supported)
     709 *
     710 *@@added V1.0.1 (2003-01-17) [umoeller]
     711 */
     712
     713VOID gpihDrawString(HPS hps,                // in: presentation space for output
     714                    PCSZ pcsz,              // in: string to test
     715                    PRECTL prcl,            // in: clipping rectangle (inclusive!)
     716                    ULONG fl,               // in: alignment flags
     717                    PFONTMETRICS pfm)
     718{
     719    PCSZ    pThis = pcsz;
     720    POINTL  ptlRun,
     721            ptlUse;
     722    LONG    cxRect,
     723            cyRect,
     724            cyString;
     725
     726    if (!pThis || !prcl || !pfm)
     727        return;
     728
     729    ptlRun.x = prcl->xLeft;
     730    ptlRun.y = prcl->yTop;
     731
     732    cxRect = prcl->xRight - prcl->xLeft + 1;
     733    cyRect = prcl->yTop - prcl->yBottom + 1;
     734
     735    // vertical alignment:
     736    if (fl & (DT_VCENTER | DT_BOTTOM))
     737    {
     738        ULONG cLines = strhCount(pcsz, '\n') + 1;
     739        cyString = cLines * (pfm->lMaxBaselineExt + pfm->lExternalLeading);
     740
     741        if (fl & DT_VCENTER)
     742            ptlRun.y += (cyRect - cyString) / 2;
     743        else
     744            ptlRun.y += cyRect - cyString;
     745    }
     746
     747    while (*pThis)
     748    {
     749        ULONG lenThis;
     750        PCSZ pNext = strhFindEOL(pThis, &lenThis);
     751
     752        ptlRun.y -= pfm->lMaxBaselineExt;
     753
     754        if (lenThis)
     755        {
     756            // horizontal alignment:
     757            if (!(fl & (DT_CENTER | DT_RIGHT)))
     758                ptlUse.x = ptlRun.x;
     759            else
     760            {
     761                POINTL  aptl[TXTBOX_COUNT];
     762                LONG    cxString;
     763                GpiQueryTextBox(hps,
     764                                lenThis,
     765                                (PCH)pThis,
     766                                TXTBOX_COUNT,
     767                                aptl);
     768
     769                cxString = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_BOTTOMLEFT].x;
     770
     771                if (fl & DT_CENTER)
     772                    ptlUse.x = ptlRun.x + (cxRect - cxString) / 2;
     773                else
     774                    // right
     775                    ptlUse.x = ptlRun.x + cxRect - cxString;
     776            }
     777
     778            ptlUse.y = ptlRun.y + pfm->lMaxDescender;
     779
     780            GpiCharStringPosAt(hps,
     781                               &ptlUse,
     782                               prcl,
     783                               CHS_CLIP,
     784                               lenThis,
     785                               (PCH)pThis,
     786                               NULL);
     787        }
     788
     789        ptlRun.y -= pfm->lExternalLeading;
     790
     791        if (*pNext == '\r')
     792            pNext++;
     793        pThis = pNext;
     794    }
     795}
     796
     797/*
    630798 *@@ gpihFillBackground:
    631799 *      fills the specified rectangle in the way
     
    647815 */
    648816
    649 VOID gpihFillBackground(HPS hps,            // in: PS to paint into
     817VOID gpihFillBackground(HPS hps,            // in: presentation space for output
    650818                        PRECTL prcl,        // in: rectangle (inclusive!)
    651819                        PBKGNDINFO pInfo)   // in: background into
     
    818986 */
    819987
    820 BOOL gpihMatchFont(HPS hps,
    821                    LONG lSize,            // in: font point size
    822                    BOOL fFamily,          // in: if TRUE, pszName specifies font family;
    823                                           //     if FALSE, pszName specifies font face
    824                    const char *pcszName,  // in: font family or face name (without point size)
    825                    USHORT usFormat,       // in: none, one or several of:
    826                                           // -- FATTR_SEL_ITALIC
    827                                           // -- FATTR_SEL_UNDERSCORE (underline)
    828                                           // -- FATTR_SEL_BOLD
    829                                           // -- FATTR_SEL_STRIKEOUT
    830                                           // -- FATTR_SEL_OUTLINE (hollow)
    831                    FATTRS *pfa,           // out: font attributes if found
     988BOOL gpihMatchFont(HPS hps,                 // in: presentation space for output
     989                   LONG lSize,              // in: font point size
     990                   BOOL fFamily,            // in: if TRUE, pszName specifies font family;
     991                                            //     if FALSE, pszName specifies font face
     992                   const char *pcszName,    // in: font family or face name (without point size)
     993                   USHORT usFormat,         // in: none, one or several of:
     994                                            // -- FATTR_SEL_ITALIC
     995                                            // -- FATTR_SEL_UNDERSCORE (underline)
     996                                            // -- FATTR_SEL_BOLD
     997                                            // -- FATTR_SEL_STRIKEOUT
     998                                            // -- FATTR_SEL_OUTLINE (hollow)
     999                   FATTRS *pfa,             // out: font attributes if found
    8321000                   PFONTMETRICS pFontMetrics) // out: font metrics of created font (optional)
    8331001{
     
    11301298 */
    11311299
    1132 LONG gpihQueryNextFontID(HPS hps)
     1300LONG gpihQueryNextFontID(HPS hps)       // in: presentation space for output
    11331301{
    11341302    LONG    lcidNext = -1;
     
    12281396 */
    12291397
    1230 LONG gpihCreateFont(HPS hps,
     1398LONG gpihCreateFont(HPS hps,            // in: presentation space for output
    12311399                    FATTRS *pfa)
    12321400{
     
    14041572 */
    14051573
    1406 LONG gpihFindFont(HPS hps,               // in: HPS for font selection
     1574LONG gpihFindFont(HPS hps,               // in: presentation space for output
    14071575                  LONG lSize,            // in: font point size
    14081576                  BOOL fFamily,          // in: if TRUE, pszName specifies font family;
     
    15951763 */
    15961764
    1597 LONG gpihQueryLineSpacing(HPS hps)
     1765LONG gpihQueryLineSpacing(HPS hps)      // in: presentation space for output
    15981766{
    15991767    FONTMETRICS fm;
Note: See TracChangeset for help on using the changeset viewer.