Changeset 111 for trunk/src/helpers


Ignore:
Timestamp:
Oct 18, 2001, 11:06:02 PM (24 years ago)
Author:
umoeller
Message:

misc changes

Location:
trunk/src/helpers
Files:
6 edited

Legend:

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

    r105 r111  
    219219}
    220220
    221 
     221/*
     222 *@@ apmhHasBattery:
     223 *      quick'n'dirty helper which returns TRUE only
     224 *      if APM is supported on the system and the
     225 *      system actually has a battery (i.e. is a laptop).
     226 *
     227 *@@added V0.9.16 (2001-10-15) [umoeller]
     228 */
     229
     230BOOL apmhHasBattery(VOID)
     231{
     232    BOOL brc = FALSE;
     233
     234    PAPM p = NULL;
     235    if (!apmhOpen(&p))
     236    {
     237        if (!apmhReadStatus(p, NULL))
     238            brc = (p->ulBatteryStatus != 0xFF);
     239
     240        apmhClose(&p);
     241    }
     242
     243    return brc;
     244}
  • trunk/src/helpers/comctl.c

    r91 r111  
    677677 *@@changed V0.9.0 [umoeller]: exported gpihIcon2Bitmap function to gpih.c
    678678 *@@changed V0.9.0 [umoeller]: fixed paint errors when SM_SETHANDLE had NULL argument in mp1
     679 *@@changed V0.9.16 (2001-10-15) [umoeller]: now centering icon in static properly
     680 *@@changed V0.9.16 (2001-10-15) [umoeller]: this always used the presparam colors of the parent instead of its own ones
    679681 */
    680682
     
    683685    PANIMATIONDATA pa = (PANIMATIONDATA)WinQueryWindowULong(hwndStatic, QWL_USER);
    684686                // animation data which was stored in window words
     687
    685688    PFNWP   OldStaticProc = NULL;
    686689    MRESULT mrc = NULL;
     
    726729
    727730                LONG lBkgndColor
    728                     = winhQueryPresColor(WinQueryWindow(hwndStatic, QW_PARENT),
     731                    /* = winhQueryPresColor(WinQueryWindow(hwndStatic, QW_PARENT),
    729732                                         PP_BACKGROUNDCOLOR,
    730733                                         FALSE,
     734                                         SYSCLR_DIALOGBACKGROUND); */
     735                    // fixed this... V0.9.16 (2001-10-15) [umoeller]
     736                    = winhQueryPresColor(hwndStatic,
     737                                         PP_BACKGROUNDCOLOR,
     738                                         TRUE,
    731739                                         SYSCLR_DIALOGBACKGROUND);
    732740
     
    792800
    793801                                if (pa->hptr)
     802                                {
     803                                    // center the icon in the bitmap
     804                                    // V0.9.16 (2001-10-15) [umoeller]
     805                                    POINTL ptlOfs;
     806                                    ptlOfs.x = (   (pa->rclIcon.xRight - pa->rclIcon.xLeft)
     807                                                 - pa->lIconSize
     808                                               ) / 2;
     809                                    ptlOfs.y = (   (pa->rclIcon.yTop - pa->rclIcon.yBottom)
     810                                                 - pa->lIconSize
     811                                               ) / 2;
     812
    794813                                    // paint icon into bitmap
    795814                                    gpihIcon2Bitmap(hpsMem,
    796815                                                    pa->hptr,
    797816                                                    lBkgndColor,
    798                                                     WinQuerySysValue(HWND_DESKTOP, SV_CXICON));
     817                                                    &ptlOfs,
     818                                                    pa->lIconSize);
     819                                }
    799820
    800821                            } // end if (pa->ulFlags & ANF_ICON)
     
    933954
    934955/*
     956 *@@ CreateAnimationData:
     957 *
     958 *@@added V0.9.16 (2001-10-15) [umoeller]
     959 */
     960
     961PANIMATIONDATA CreateAnimationData(HWND hwndStatic,
     962                                   USHORT cAnimations)
     963{
     964    PANIMATIONDATA pa = NULL;
     965
     966    if (cAnimations >= 1)
     967    {
     968        // create the ANIMATIONDATA structure,
     969        // initialize some fields,
     970        // and store it in QWL_USER of the static control
     971        ULONG   cbStruct =   sizeof(ANIMATIONDATA)
     972                           + ((cAnimations - 1) * sizeof(HPOINTER));
     973
     974        if (pa = (PANIMATIONDATA)malloc(cbStruct))
     975        {
     976            memset(pa, 0, cbStruct);
     977
     978            WinSetWindowULong(hwndStatic, QWL_USER, (ULONG)pa);
     979
     980            pa->hab = WinQueryAnchorBlock(hwndStatic);
     981            WinQueryWindowRect(hwndStatic, &pa->rclIcon);
     982            pa->OldStaticProc = WinSubclassWindow(hwndStatic, ctl_fnwpBitmapStatic);
     983            pa->lIconSize = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
     984        }
     985    }
     986
     987    return (pa);
     988}
     989
     990/*
    935991 *@@ ctlPrepareStaticIcon:
    936992 *      turns a static control into one which properly
     
    9711027                                                        // this must be at least 1
    9721028{
    973     PANIMATIONDATA pa = NULL;
    974     PFNWP OldStaticProc = WinSubclassWindow(hwndStatic, ctl_fnwpBitmapStatic);
    975     if (OldStaticProc)
     1029    PANIMATIONDATA pa;
     1030
     1031    if (pa = CreateAnimationData(hwndStatic,
     1032                                 usAnimCount))
    9761033    {
    977         // create the ANIMATIONDATA structure,
    978         // initialize some fields,
    979         // and store it in QWL_USER of the static control
    980         ULONG   cbStruct =   sizeof(ANIMATIONDATA)
    981                            + ((usAnimCount-1) * sizeof(HPOINTER));
    982         pa = (PANIMATIONDATA)malloc(cbStruct);
    983         memset(pa, 0, cbStruct);
    984 
    9851034        // switch static to icon mode
    9861035        pa->ulFlags = ANF_ICON;
    987         pa->OldStaticProc = OldStaticProc;
    988         WinQueryWindowRect(hwndStatic, &(pa->rclIcon));
    989         pa->hab = WinQueryAnchorBlock(hwndStatic);
    990 
    991         WinSetWindowULong(hwndStatic, QWL_USER, (ULONG)pa);
    9921036    }
     1037
    9931038    return (pa);
    9941039}
     
    10571102        paNew->usAniCurrent = 0;
    10581103        paNew->usAniCount = usAnimCount;
    1059         memcpy(&(paNew->ahptrAniIcons), pahptr,
    1060                         (usAnimCount * sizeof(HPOINTER)));
    1061 
    1062         if (fStartAnimation) {
     1104        memcpy(&paNew->ahptrAniIcons,
     1105               pahptr,
     1106               (usAnimCount * sizeof(HPOINTER)));
     1107
     1108        if (fStartAnimation)
     1109        {
    10631110            WinStartTimer(WinQueryAnchorBlock(hwndStatic), hwndStatic,
    10641111                    1, ulDelay);
     
    11551202 *
    11561203 *@@added V0.9.0 [umoeller]
     1204 *@@changed V0.9.16 (2001-10-15) [umoeller]: some cleanup
    11571205 */
    11581206
     
    11601208                                         BOOL fPreserveProportions)
    11611209{
    1162     PANIMATIONDATA pa = NULL;
    1163     PFNWP OldStaticProc = WinSubclassWindow(hwndStatic, ctl_fnwpBitmapStatic);
    1164     if (OldStaticProc)
     1210    PANIMATIONDATA pa;
     1211
     1212    if (pa = CreateAnimationData(hwndStatic, 1))
    11651213    {
    1166         // create the ANIMATIONDATA structure,
    1167         // initialize some fields,
    1168         // and store it in QWL_USER of the static control
    1169         ULONG   cbStruct =   sizeof(ANIMATIONDATA);
    1170         pa = (PANIMATIONDATA)malloc(cbStruct);
    1171         memset(pa, 0, cbStruct);
    1172 
    11731214        // switch static to bitmap mode
    11741215        pa->ulFlags = ANF_BITMAP;
    11751216        if (fPreserveProportions)
    11761217            pa->ulFlags |= ANF_PROPORTIONAL;
    1177 
    1178         pa->OldStaticProc = OldStaticProc;
    1179         WinQueryWindowRect(hwndStatic, &(pa->rclIcon));
    1180         pa->hab = WinQueryAnchorBlock(hwndStatic);
    1181 
    1182         WinSetWindowULong(hwndStatic, QWL_USER, (ULONG)pa);
    11831218    }
     1219
    11841220    return (pa);
    11851221}
  • trunk/src/helpers/dialog.c

    r108 r111  
    8686 *@@ DLGPRIVATE:
    8787 *      private data to the dlg manager, allocated
    88  *      by dlghCreateDlg. This is what is really
    89  *      used, even though the prototype only
    90  *      declares DIALOGDATA.
     88 *      by dlghCreateDlg.
    9189 *
    9290 *      This only exists while the dialog is being
     
    218216 ********************************************************************/
    219217
    220 #define PM_GROUP_SPACING_X          10
     218#define PM_GROUP_SPACING_X          16
    221219#define PM_GROUP_SPACING_TOP        20
    222220
     
    294292 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed broken fonts
    295293 *@@changed V0.9.14 (2001-08-01) [umoeller]: now caching fonts, which is significantly faster
    296  */
    297 
    298 VOID CalcAutoSizeText(PCONTROLDEF pControlDef,
    299                       BOOL fMultiLine,          // in: if TRUE, multiple lines
    300                       PSIZEL pszlAuto,          // out: computed size
    301                       PDLGPRIVATE pDlgData)
    302 {
     294 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET
     295 */
     296
     297APIRET CalcAutoSizeText(PCONTROLDEF pControlDef,
     298                        BOOL fMultiLine,          // in: if TRUE, multiple lines
     299                        PSIZEL pszlAuto,          // out: computed size
     300                        PDLGPRIVATE pDlgData)
     301{
     302    APIRET arc = NO_ERROR;
     303
    303304    SetDlgFont(pControlDef, pDlgData);
    304305
     
    308309    // ok, we FINALLY have a font now...
    309310    // get the control string and see how much space it needs
    310     if (pControlDef->pcszText)
     311    if (    (pControlDef->pcszText)
     312         && (pControlDef->pcszText != (PCSZ)-1)
     313       )
    311314    {
    312315        // do we have multiple lines?
     
    341344        }
    342345    }
     346    else
     347        arc = DLGERR_INVALID_CONTROL_TITLE;
     348
     349    return (arc);
    343350}
    344351
     
    347354 *
    348355 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
    349  */
    350 
    351 VOID CalcAutoSize(PCONTROLDEF pControlDef,
    352                   PSIZEL pszlAuto,          // out: computed size
    353                   PDLGPRIVATE pDlgData)
    354 {
     356 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET
     357 */
     358
     359APIRET CalcAutoSize(PCONTROLDEF pControlDef,
     360                    PSIZEL pszlAuto,          // out: computed size
     361                    PDLGPRIVATE pDlgData)
     362{
     363    APIRET arc = NO_ERROR;
     364
    355365    // dumb defaults
    356366    pszlAuto->cx = 100;
     
    360370    {
    361371        case 0xffff0003L: // WC_BUTTON:
    362             CalcAutoSizeText(pControlDef,
    363                              FALSE,         // no multiline
    364                              pszlAuto,
    365                              pDlgData);
    366             if (pControlDef->flStyle & (  BS_AUTOCHECKBOX
    367                                         | BS_AUTORADIOBUTTON
    368                                         | BS_AUTO3STATE
    369                                         | BS_3STATE
    370                                         | BS_CHECKBOX
    371                                         | BS_RADIOBUTTON))
     372            if (!(arc = CalcAutoSizeText(pControlDef,
     373                                         FALSE,         // no multiline
     374                                         pszlAuto,
     375                                         pDlgData)))
    372376            {
    373                 // give a little extra width for the box bitmap
    374                 pszlAuto->cx += 20;     // @@todo
    375                 // and height
    376                 pszlAuto->cy += 2;
    377             }
    378             else if (pControlDef->flStyle & BS_BITMAP)
    379                 ;
    380             else if (pControlDef->flStyle & (BS_ICON | BS_MINIICON))
    381                 ;
    382             // we can't test for BS_PUSHBUTTON because that's 0x0000
    383             else if (!(pControlDef->flStyle & BS_USERBUTTON))
    384             {
    385                 pszlAuto->cx += (2 * WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER) + 15);
    386                 pszlAuto->cy += (2 * WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER) + 15);
     377                if (pControlDef->flStyle & (  BS_AUTOCHECKBOX
     378                                            | BS_AUTORADIOBUTTON
     379                                            | BS_AUTO3STATE
     380                                            | BS_3STATE
     381                                            | BS_CHECKBOX
     382                                            | BS_RADIOBUTTON))
     383                {
     384                    // give a little extra width for the box bitmap
     385                    pszlAuto->cx += 20;     // @@todo
     386                    // and height
     387                    pszlAuto->cy += 2;
     388                }
     389                else if (pControlDef->flStyle & BS_BITMAP)
     390                    ;
     391                else if (pControlDef->flStyle & (BS_ICON | BS_MINIICON))
     392                    ;
     393                // we can't test for BS_PUSHBUTTON because that's 0x0000
     394                else if (!(pControlDef->flStyle & BS_USERBUTTON))
     395                {
     396                    pszlAuto->cx += (2 * WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER) + 15);
     397                    pszlAuto->cy += (2 * WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER) + 15);
     398                }
    387399            }
    388400        break;
     
    390402        case 0xffff0005L: // WC_STATIC:
    391403            if ((pControlDef->flStyle & 0x0F) == SS_TEXT)
    392                 CalcAutoSizeText(pControlDef,
    393                                  ((pControlDef->flStyle & DT_WORDBREAK) != 0),
    394                                  pszlAuto,
    395                                  pDlgData);
     404                arc = CalcAutoSizeText(pControlDef,
     405                                       ((pControlDef->flStyle & DT_WORDBREAK) != 0),
     406                                       pszlAuto,
     407                                       pDlgData);
    396408            else if ((pControlDef->flStyle & 0x0F) == SS_BITMAP)
    397409            {
    398                 HBITMAP hbm = (HBITMAP)pControlDef->pcszText;
    399                 if (hbm)
     410                HBITMAP hbm;
     411                if (hbm = (HBITMAP)pControlDef->pcszText)
    400412                {
    401413                    BITMAPINFOHEADER2 bmih2;
     
    408420                        pszlAuto->cy = bmih2.cy;
    409421                    }
     422                    else
     423                        arc = DLGERR_INVALID_STATIC_BITMAP;
    410424                }
    411425            }
     
    425439                           + 5;         // some space
    426440    }
     441
     442    return (arc);
    427443}
    428444
     
    433449 *
    434450 *@@added V0.9.15 (2001-08-26) [umoeller]
    435  */
    436 
    437 VOID ColumnCalcSizes(PCOLUMNDEF pColumnDef,
    438                      PDLGPRIVATE pDlgData)
    439 {
     451 *@@changed V0.9.16 (2001-10-15) [umoeller]: fixed ugly group table spacings
     452 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET
     453 */
     454
     455APIRET ColumnCalcSizes(PCOLUMNDEF pColumnDef,
     456                       PDLGPRIVATE pDlgData)
     457{
     458    APIRET arc = NO_ERROR;
     459
    440460    ULONG       ulXSpacing = 0,
    441461                ulYSpacing = 0;
     
    444464        // nested table: recurse!!
    445465        PTABLEDEF pTableDef = (PTABLEDEF)pColumnDef->pvDefinition;
    446         ProcessTable(pTableDef,
    447                      NULL,
    448                      PROCESS_CALC_SIZES,
    449                      pDlgData);
    450 
    451         // store the size of the sub-table
    452         pColumnDef->cpControl.cx = pTableDef->cpTable.cx;
    453         pColumnDef->cpControl.cy = pTableDef->cpTable.cy;
    454 
    455         // should we create a PM control around the table?
    456         if (pTableDef->pCtlDef)
    457         {
    458             // yes: make this wider
    459             ulXSpacing = (2 * PM_GROUP_SPACING_X);
    460             ulYSpacing = (PM_GROUP_SPACING_X + PM_GROUP_SPACING_TOP);
     466        if (!(arc = ProcessTable(pTableDef,
     467                                 NULL,
     468                                 PROCESS_CALC_SIZES,
     469                                 pDlgData)))
     470        {
     471            // store the size of the sub-table
     472            pColumnDef->cpControl.cx = pTableDef->cpTable.cx;
     473            pColumnDef->cpControl.cy = pTableDef->cpTable.cy;
     474
     475            // should we create a PM control around the table?
     476            if (pTableDef->pCtlDef)
     477            {
     478                // yes: make this wider
     479                ulXSpacing =    2 * PM_GROUP_SPACING_X;
     480                ulYSpacing =    // 3 * PM_GROUP_SPACING_X;
     481                            (PM_GROUP_SPACING_X + PM_GROUP_SPACING_TOP);
     482            }
    461483        }
    462484    }
     
    472494           )
    473495        {
    474             CalcAutoSize(pControlDef,
    475                          &szlAuto,
    476                          pDlgData);
    477         }
    478 
    479         if (pszl->cx == -1)
    480             pColumnDef->cpControl.cx = szlAuto.cx;
    481         else
    482             pColumnDef->cpControl.cx = pszl->cx;
    483 
    484         if (pszl->cy == -1)
    485             pColumnDef->cpControl.cy = szlAuto.cy;
    486         else
    487             pColumnDef->cpControl.cy = pszl->cy;
    488 
    489         // @@todo hack sizes
    490 
    491         ulXSpacing = ulYSpacing = (2 * pControlDef->ulSpacing);
     496            arc = CalcAutoSize(pControlDef,
     497                               &szlAuto,
     498                               pDlgData);
     499        }
     500
     501        if (!arc)
     502        {
     503            if (pszl->cx == -1)
     504                pColumnDef->cpControl.cx = szlAuto.cx;
     505            else
     506                pColumnDef->cpControl.cx = pszl->cx;
     507
     508            if (pszl->cy == -1)
     509                pColumnDef->cpControl.cy = szlAuto.cy;
     510            else
     511                pColumnDef->cpControl.cy = pszl->cy;
     512
     513            // @@todo hack sizes
     514
     515            ulXSpacing
     516            = ulYSpacing
     517            = (2 * pControlDef->ulSpacing);
     518        }
    492519    }
    493520
     
    496523    pColumnDef->cpColumn.cy =   pColumnDef->cpControl.cy
    497524                               + ulYSpacing;
     525
     526    return (arc);
    498527}
    499528
     
    504533 *
    505534 *@@added V0.9.15 (2001-08-26) [umoeller]
    506  */
    507 
    508 VOID ColumnCalcPositions(PCOLUMNDEF pColumnDef,
    509                          PROWDEF pOwningRow,          // in: current row from ProcessRow
    510                          PLONG plX,                   // in/out: PROCESS_CALC_POSITIONS only
    511                          PDLGPRIVATE pDlgData)
    512 {
     535 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET
     536 */
     537
     538APIRET ColumnCalcPositions(PCOLUMNDEF pColumnDef,
     539                           PROWDEF pOwningRow,          // in: current row from ProcessRow
     540                           PLONG plX,                   // in/out: PROCESS_CALC_POSITIONS only
     541                           PDLGPRIVATE pDlgData)
     542{
     543    APIRET arc = NO_ERROR;
     544
    513545    // calculate column position: this includes spacing
    514546    ULONG ulSpacing = 0;
     
    544576        if (pTableDef->pCtlDef)
    545577            // yes:
    546             ulSpacing = PM_GROUP_SPACING_X;
     578            ulSpacing = PM_GROUP_SPACING_X / 2;     // V0.9.16 (2001-10-15) [umoeller]
    547579    }
    548580    else
     
    568600
    569601        // recurse!! to create windows for the sub-table
    570         ProcessTable(pTableDef,
    571                      &pColumnDef->cpControl,   // start pos for new table
    572                      PROCESS_CALC_POSITIONS,
    573                      pDlgData);
    574     }
     602        arc = ProcessTable(pTableDef,
     603                           &pColumnDef->cpControl,   // start pos for new table
     604                           PROCESS_CALC_POSITIONS,
     605                           pDlgData);
     606    }
     607
     608    return (arc);
    575609}
    576610
     
    581615 *
    582616 *@@added V0.9.15 (2001-08-26) [umoeller]
     617 *@@changed V0.9.16 (2001-10-15) [umoeller]: fixed ugly group table spacings
    583618 */
    584619
     
    595630    ULONG       flOld = 0;
    596631
    597     LONG        y, cy;              // for combo box hacks
     632    LONG        x, cx, y, cy;              // for combo box hacks
    598633
    599634    if (pColumnDef->fIsNestedTable)
     
    619654                flStyle = pControlDef->flStyle;
    620655
     656                x = pcp->x + pDlgData->ptlTotalOfs.x;
     657                cx = pcp->cx - PM_GROUP_SPACING_X;
     658                    // note, just one spacing: for the _column_ size,
     659                    // we have specified 2 X spacings
    621660                y = pcp->y + pDlgData->ptlTotalOfs.y;
    622                 cy = pcp->cy;
     661                // cy = pcp->cy - PM_GROUP_SPACING_X;
     662                cy = pcp->cy - /* PM_GROUP_SPACING_X - */ PM_GROUP_SPACING_TOP / 2;
    623663            }
    624664        }
     
    632672        flStyle = pControlDef->flStyle;
    633673
     674        x = pcp->x + pDlgData->ptlTotalOfs.x;
     675        cx = pcp->cx;
    634676        y = pcp->y + pDlgData->ptlTotalOfs.y;
    635677        cy = pcp->cy;
     
    685727                                    : "",
    686728                              flStyle,      // hacked
    687                               pcp->x + pDlgData->ptlTotalOfs.x,
     729                              x,
    688730                              y,
    689                               pcp->cx,
     731                              cx,
    690732                              cy,
    691733                              pDlgData->hwndDlg,   // owner
     
    806848
    807849        case PROCESS_CALC_SIZES:
    808             ColumnCalcSizes(pColumnDef,
    809                             pDlgData);
     850            arc = ColumnCalcSizes(pColumnDef,
     851                                  pDlgData);
    810852        break;
    811853
     
    816858
    817859        case PROCESS_CALC_POSITIONS:
    818             ColumnCalcPositions(pColumnDef,
    819                                 pOwningRow,
    820                                 plX,
    821                                 pDlgData);
     860            arc = ColumnCalcPositions(pColumnDef,
     861                                      pOwningRow,
     862                                      plX,
     863                                      pDlgData);
    822864        break;
    823865
     
    11291171/* ******************************************************************
    11301172 *
    1131  *   Public APIs
     1173 *   Dialog formatter engine
    11321174 *
    11331175 ********************************************************************/
     
    14521494    }
    14531495}
     1496
     1497/* ******************************************************************
     1498 *
     1499 *   Dialog formatter entry points
     1500 *
     1501 ********************************************************************/
    14541502
    14551503/*
     
    19562004    return (arc);
    19572005}
     2006
     2007/* ******************************************************************
     2008 *
     2009 *   Dialog arrays
     2010 *
     2011 ********************************************************************/
     2012
     2013/*
     2014 *@@ dlghCreateArray:
     2015 *      creates a "dialog array" for dynamically
     2016 *      building a dialog template in memory.
     2017 *
     2018 *      A dialog array is simply an array of
     2019 *      DLGHITEM structures, as you would normally
     2020 *      define them statically in the source.
     2021 *      However, there are situations where you
     2022 *      might want to leave out certain controls
     2023 *      depending on certain conditions, which
     2024 *      can be difficult with static arrays.
     2025 *
     2026 *      As a result, these "array" functions have
     2027 *      been added to allow for adding static
     2028 *      DLGHITEM subarrays to a dynamic array in
     2029 *      memory, which can then be passed to the
     2030 *      formatter.
     2031 *
     2032 *      Usage:
     2033 *
     2034 *      1)  Call this function with the maximum
     2035 *          amount of DLGHITEM's that will need
     2036 *          to be allocated in cMaxItems. Set this
     2037 *          to the total sum of all DLGHITEM's
     2038 *          in all the subarrays.
     2039 *
     2040 *      2)  For each of the subarrays, call
     2041 *          dlghAppendToArray to have the subarray
     2042 *          appended to the dialog array.
     2043 *          After each call, DLGARRAY.cDlgItemsNow
     2044 *          will contain the actual total count of
     2045 *          DLGHITEM's that were added.
     2046 *
     2047 *      3)  Call dlghCreateDialog with the dialog
     2048 *          array.
     2049 *
     2050 *      4)  Call dlghFreeArray.
     2051 *
     2052 *      Sort of like this (error checking omitted):
     2053 *
     2054 +      DLGHITEM    dlgSampleFront =  ...   // always included
     2055 +      DLGHITEM    dlgSampleSometimes =  ...   // not always included
     2056 +      DLGHITEM    dlgSampleTail =  ...   // always included
     2057 +
     2058 +      PDLGARRAY pArraySample = NULL;
     2059 +      dlghCreateArray(   ARRAYITEMCOUNT(dlgSampleFront)
     2060 +                       + ARRAYITEMCOUNT(dlgSampleSometimes)
     2061 +                       + ARRAYITEMCOUNT(dlgSampleTail),
     2062 +                      &pArraySample);
     2063 +
     2064 +      // always include front
     2065 +      dlghAppendToArray(pArraySample,
     2066 +                        dlgSampleFront,
     2067 +                        ARRAYITEMCOUNT(dlgSampleFront));
     2068 +      // include "sometimes" conditionally
     2069 +      if (...)
     2070 +          dlghAppendToArray(pArraySample,
     2071 +                            dlgSampleSometimes,
     2072 +                            ARRAYITEMCOUNT(dlgSampleSometimes));
     2073 +      // include tail always
     2074 +      dlghAppendToArray(pArraySample,
     2075 +                        dlgSampleTail,
     2076 +                        ARRAYITEMCOUNT(dlgSampleTail));
     2077 +
     2078 +      // now create the dialog from the array
     2079 +      dlghCreateDialog(&hwndDlg,
     2080 +                       hwndOwner,
     2081 +                       FCF_ ...
     2082 +                       fnwpMyDialogProc,
     2083 +                       "Title",
     2084 +                       pArray->paDialogItems,     // dialog array!
     2085 +                       pArray->cDlgItemsNow,      // real count of items!
     2086 +                       NULL,
     2087 +                       NULL);
     2088 +
     2089 +      dlghFreeArray(&pArraySample);
     2090 *
     2091 *@@added V0.9.16 (2001-10-15) [umoeller]
     2092 */
     2093
     2094APIRET dlghCreateArray(ULONG cMaxItems,
     2095                       PDLGARRAY *ppArray)       // out: DLGARRAY
     2096{
     2097    APIRET arc = NO_ERROR;
     2098    PDLGARRAY pArray;
     2099
     2100    if (pArray = NEW(DLGARRAY))
     2101    {
     2102        ULONG cb;
     2103
     2104        ZERO(pArray);
     2105        if (    (cb = cMaxItems * sizeof(DLGHITEM))
     2106             && (pArray->paDlgItems = (DLGHITEM*)malloc(cb))
     2107           )
     2108        {
     2109            memset(pArray->paDlgItems, 0, cb);
     2110            pArray->cDlgItemsMax = cMaxItems;
     2111            *ppArray = pArray;
     2112        }
     2113        else
     2114            arc = ERROR_NOT_ENOUGH_MEMORY;
     2115
     2116        if (arc)
     2117            dlghFreeArray(&pArray);
     2118    }
     2119    else
     2120        arc = ERROR_NOT_ENOUGH_MEMORY;
     2121
     2122    return arc;
     2123}
     2124
     2125/*
     2126 *@@ dlghFreeArray:
     2127 *      frees a dialog array created by dlghCreateArray.
     2128 *
     2129 *@@added V0.9.16 (2001-10-15) [umoeller]
     2130 */
     2131
     2132APIRET dlghFreeArray(PDLGARRAY *ppArray)
     2133{
     2134    PDLGARRAY pArray;
     2135    if (    (ppArray)
     2136         && (pArray = *ppArray)
     2137       )
     2138    {
     2139        if (pArray->paDlgItems)
     2140            free(pArray->paDlgItems);
     2141        free(pArray);
     2142    }
     2143    else
     2144        return ERROR_INVALID_PARAMETER;
     2145
     2146    return NO_ERROR;
     2147}
     2148
     2149/*
     2150 *@@ dlghAppendToArray:
     2151 *      appends a subarray of DLGHITEM's to the
     2152 *      given DLGARRAY. See dlghCreateArray for
     2153 *      usage.
     2154 *
     2155 *      Returns:
     2156 *
     2157 *      --  NO_ERROR
     2158 *
     2159 *      --  ERROR_INVALID_PARAMETER
     2160 *
     2161 *      --  DLGERR_ARRAY_TOO_SMALL: pArray does not
     2162 *          have enough memory to hold the new items.
     2163 *          The cMaxItems parameter given to dlghCreateArray
     2164 *          wasn't large enough.
     2165 *
     2166 *@@added V0.9.16 (2001-10-15) [umoeller]
     2167 */
     2168
     2169APIRET dlghAppendToArray(PDLGARRAY pArray,      // in: dialog array created by dlghCreateArray
     2170                         DLGHITEM *paItems,     // in: subarray to be appended
     2171                         ULONG cItems)          // in: subarray item count (NOT array size)
     2172{
     2173    APIRET arc = NO_ERROR;
     2174    if (pArray)
     2175    {
     2176        if (    (pArray->cDlgItemsMax >= cItems)
     2177             && (pArray->cDlgItemsMax - pArray->cDlgItemsNow >= cItems)
     2178           )
     2179        {
     2180            // enough space left in the array:
     2181            memcpy(&pArray->paDlgItems[pArray->cDlgItemsNow],
     2182                   paItems,     // source
     2183                   cItems * sizeof(DLGHITEM));
     2184            pArray->cDlgItemsNow += cItems;
     2185        }
     2186        else
     2187            arc = DLGERR_ARRAY_TOO_SMALL;
     2188    }
     2189    else
     2190        arc = ERROR_INVALID_PARAMETER;
     2191
     2192    return (arc);
     2193}
     2194
     2195/* ******************************************************************
     2196 *
     2197 *   Standard dialogs
     2198 *
     2199 ********************************************************************/
    19582200
    19592201/*
     
    24622704}
    24632705
     2706/* ******************************************************************
     2707 *
     2708 *   Dialog input handlers
     2709 *
     2710 ********************************************************************/
     2711
    24642712/*
    24652713 *@@ dlghSetPrevFocus:
  • trunk/src/helpers/gpih.c

    r94 r111  
    305305    ptl1.y = prcl->yBottom;
    306306    GpiMove(hps, &ptl1);
    307     ptl1.y = prcl->yTop-1;
     307    ptl1.y = prcl->yTop - 1;
    308308    GpiLine(hps, &ptl1);
    309     ptl1.x = prcl->xRight-1;
     309    ptl1.x = prcl->xRight - 1;
    310310    GpiLine(hps, &ptl1);
    311311    ptl1.y = prcl->yBottom;
     
    19731973 *@@ gpihIcon2Bitmap:
    19741974 *      this paints the given icon/pointer into
    1975  *      a bitmap.
     1975 *      a bitmap. Note that if the bitmap is
     1976 *      larget than the system icon size, only
     1977 *      the rectangle of the icon will be filled
     1978 *      with lBkgndColor.
    19761979 *
    19771980 *      Returns FALSE upon errors.
    19781981 *
    19791982 *@@added V0.9.0 [umoeller]
     1983 *@@changed V0.9.16 (2001-10-15) [umoeller]: added pptlLowerLeft
     1984 *@@changed V0.9.16 (2001-10-15) [umoeller]: fixed inclusive/exclusive confusion (sigh...)
    19801985 */
    19811986
     
    19831988                     HPOINTER hptr,      // in: source icon
    19841989                     LONG lBkgndColor,   // in: background color for transparent areas
     1990                     PPOINTL pptlLowerLeft,   // in: lower left corner of where to paint (ptr can be NULL)
    19851991                     ULONG ulIconSize)   // in: icon size (should be the value of WinQuerySysValue(HWND_DESKTOP, SV_CXICON))
    19861992{
     
    20032009    if (WinQueryPointerInfo(hptr, &pi))
    20042010    {
     2011        POINTL  ptlLowerLeft = {0, 0};
    20052012        POINTL  aptl[4];
    20062013        memset(aptl, 0, sizeof(POINTL) * 4);
    20072014
     2015        if (pptlLowerLeft)
     2016            // lower left specified: V0.9.16 (2001-10-15) [umoeller]
     2017            memcpy(&ptlLowerLeft, pptlLowerLeft, sizeof(POINTL));
     2018
    20082019        // aptl[0]: target bottom-left, is all 0
     2020        aptl[0].x = ptlLowerLeft.x;
     2021        aptl[0].y = ptlLowerLeft.y;
    20092022
    20102023        // aptl[1]: target top-right (inclusive!)
    2011         aptl[1].x = ulIconSize;
    2012         aptl[1].y = ulIconSize;
     2024        // V0.9.16 (2001-10-15) [umoeller]: fixed rectangle confusion
     2025        aptl[1].x = ptlLowerLeft.x + ulIconSize - 1;
     2026        aptl[1].y = ptlLowerLeft.y + ulIconSize - 1;
    20132027
    20142028        // aptl[2]: source bottom-left, is all 0
    20152029
    20162030        // aptl[3]: source top-right (exclusive!)
    2017         aptl[3].x = ulIconSize + 1;
    2018         aptl[3].y = ulIconSize + 1;
     2031        // V0.9.16 (2001-10-15) [umoeller]: fixed rectangle confusion
     2032        aptl[3].x = ulIconSize; //  + 1;
     2033        aptl[3].y = ulIconSize; //  + 1;
    20192034
    20202035        GpiSetColor(hpsMem, CLR_WHITE);
     
    20242039
    20252040        // work on the AND image
    2026         GpiWCBitBlt(hpsMem,
    2027                     pi.hbmPointer,
     2041        GpiWCBitBlt(hpsMem,     // target
     2042                    pi.hbmPointer,  // src bmp
    20282043                    4L,         // must always be 4
    20292044                    &aptl[0],   // point array
     
    20422057        GpiSetColor(hpsMem, lBkgndColor);
    20432058        // work on the XOR image
    2044         aptl[2].y = ulIconSize;
    2045         aptl[3].y = (ulIconSize * 2) + 1;
     2059        aptl[2].y = ulIconSize;                 // exclusive
     2060        aptl[3].y = (ulIconSize * 2); //  /* + 1; */       // exclusive
     2061        // V0.9.16 (2001-10-15) [umoeller]: fixed rectangle confusion
    20462062        GpiWCBitBlt(hpsMem,
    20472063                    pi.hbmPointer,
  • trunk/src/helpers/winh.c

    r108 r111  
    7878#include <string.h>
    7979#include <stdio.h>
     80#include <stdarg.h>
    8081
    8182#include "setup.h"                      // code generation and debugging options
     
    28912892
    28922893/*
     2894 *@@ winhSetPresColor:
     2895 *      sets a color presparam. ulIndex specifies
     2896 *      the presparam to be set and would normally
     2897 *      be either PP_BACKGROUNDCOLOR or PP_FOREGROUNDCOLOR.
     2898 *
     2899 *@@added V0.9.16 (2001-10-15) [umoeller]
     2900 */
     2901
     2902BOOL winhSetPresColor(HWND hwnd,
     2903                      ULONG ulIndex,
     2904                      LONG lColor)
     2905{
     2906    return (WinSetPresParam(hwnd,
     2907                            ulIndex,
     2908                            sizeof(LONG),
     2909                            &lColor));
     2910}
     2911
     2912/*
    28932913 *@@category: Helpers\PM helpers\Help (IPF)
    28942914 */
  • trunk/src/helpers/xstring.c

    r110 r111  
    107107#include <stdio.h>
    108108#include <string.h>
    109 #include <ctype.h>
    110109
    111110#include "setup.h"                      // code generation and debugging options
Note: See TracChangeset for help on using the changeset viewer.