Changeset 242


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

First attempt at new container contol.

Location:
trunk
Files:
4 added
24 edited

Legend:

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

    r223 r242  
    7676
    7777    #ifdef INCL_WINPROGRAMLIST
    78         // additional PROG_* flags for appQueryAppType
    79         // #define PROG_XWP_DLL            998      // dynamic link library
    80                     // removed, PROG_DLL exists already
    81                     // V0.9.16 (2001-10-06)
    82 
    83         #define PROG_WIN32              990     // added V0.9.16 (2001-12-08) [umoeller]
     78        // moved extra PROG_* defs to exeh.h V1.0.1 (2003-01-17) [umoeller]
    8479
    8580        APIRET appQueryAppType(const char *pcszExecutable,
    8681                               PULONG pulDosAppType,
    8782                               PULONG pulWinAppType);
    88 
    89         PCSZ appDescribeAppType(PROGCATEGORY progc);
    9083
    9184        ULONG appIsWindowsApp(ULONG ulProgCategory);
  • trunk/include/helpers/comctl.h

    r233 r242  
    11951195
    11961196    MRESULT ctlFormatExtFrame(HWND hwndFrame,
    1197                               PXFRAMECONTROLS pxfc,
     1197                              const XFRAMECONTROLS *pxfc,
    11981198                              MPARAM mp1,
    11991199                              MPARAM mp2);
    12001200
    1201     VOID ctlCalcExtFrameRect(MPARAM mp1,
    1202                              MPARAM mp2,
    1203                              LONG lStatusBarHeight);
     1201    MRESULT ctlCalcExtFrameRect(HWND hwndFrame,
     1202                                const XFRAMECONTROLS *pxfc,
     1203                                MPARAM mp1,
     1204                                MPARAM mp2);
    12041205
    12051206    HWND ctlCreateStatusBar(HWND hwndFrame,
     
    14011402    typedef CTLMAKECOLORRECT *PCTLMAKECOLORRECT;
    14021403
     1404    /* ******************************************************************
     1405     *
     1406     *   Container control replacement
     1407     *
     1408     ********************************************************************/
     1409
     1410    #define WC_CCTL_CNR             "ComctlCnr"
     1411
     1412    MRESULT EXPENTRY fnwpCnr(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     1413
     1414    BOOL ctlRegisterXCnr(HAB hab);
     1415
     1416
    14031417#endif
    14041418
  • trunk/include/helpers/exeh.h

    r136 r242  
    77 *            numbering.
    88 *
     9 *@@include #define INCL_WINPROGRAMLIST         // for some funcs only
    910 *@@include #include <os2.h>
    1011 *@@include #include "helpers\dosh.h"
     
    231232    typedef struct _LXHEADER
    232233    {
    233         CHAR        achLX[2];           // 00: e32_magic  "LX" or "LE" magic
     234        CHAR      achLX[2];             // 00: e32_magic  "LX" or "LE" magic
    234235            // this is "LX" for 32-bit OS/2 programs, but
    235236            // "LE" for MS-DOS progs which use this format
     
    245246        ULONG     ulFlags;              // 10: e32_mflags module flags
    246247                #ifndef E32NOTP // do not conflict with toolkit exe defs
    247                     #define E32NOTP          0x8000L        // Library Module - used as NENOTP
    248                     #define E32NOLOAD        0x2000L        // Module not Loadable
    249                     #define E32PMAPI         0x0300L        // Uses PM Windowing API
    250                     #define E32PMW           0x0200L        // Compatible with PM Windowing
    251                     #define E32NOPMW         0x0100L        // Incompatible with PM Windowing
    252                     #define E32NOEXTFIX      0x0020L        // NO External Fixups in .EXE
    253                     #define E32NOINTFIX      0x0010L        // NO Internal Fixups in .EXE
    254                     #define E32SYSDLL        0x0008L        // System DLL, Internal Fixups discarded
    255                     #define E32LIBINIT       0x0004L        // Per-Process Library Initialization
     248                    #define E32NOTP          0x00008000L    // Library Module - used as NENOTP
     249                    #define E32NOLOAD        0x00002000L    // Module not Loadable
     250                    #define E32PMAPI         0x00000300L    // Uses PM Windowing API
     251                    #define E32PMW           0x00000200L    // Compatible with PM Windowing
     252                    #define E32NOPMW         0x00000100L    // Incompatible with PM Windowing
     253                    #define E32NOEXTFIX      0x00000020L    // NO External Fixups in .EXE
     254                    #define E32NOINTFIX      0x00000010L    // NO Internal Fixups in .EXE
     255                    #define E32SYSDLL        0x00000008L    // System DLL, Internal Fixups discarded
     256                    #define E32LIBINIT       0x00000004L    // Per-Process Library Initialization
    256257                    #define E32LIBTERM       0x40000000L    // Per-Process Library Termination
    257                     #define E32APPMASK       0x0300L        // Application Type Mask
     258
     259                    #define E32APPMASK       0x00000300L    // Application Type Mask
     260
     261                    // hiword defs added V1.0.1 (2003-01-17) [umoeller]
     262                    #define E32PROTDLL       0x00010000L    // Protected memory library module *
     263                    #define E32DEVICE        0x00020000L    // Device driver                   *
     264                    #define E32MODEXE        0x00000000L    // .EXE module                     *
     265                    #define E32MODDLL        0x00008000L    // .DLL module                     *
     266                    #define E32MODPROTDLL    0x00018000L    // Protected memory library module *
     267                    #define E32MODPDEV       0x00020000L    // Physical device driver          *
     268                    #define E32MODVDEV       0x00028000L    // Virtual device driver           *
     269                    #define E32MODMASK       0x00038000L    // Module type mask                *
     270                    #define E32NOTMPSAFE     0x00080000L    // Process is multi-processor unsafe *
    258271                #endif
    259272        ULONG     ulPageCount;          // 14: e32_mpages no. of pages in module
     
    12431256    APIRET exehQueryBldLevel(PEXECUTABLE pExec);
    12441257
     1258    #ifdef INCL_WINPROGRAMLIST
     1259
     1260        // additional PROG_* flags for exehQueryProgType; moved these here
     1261        // from app.h V1.0.1 (2003-01-17) [umoeller]
     1262
     1263        // #define PROG_XWP_DLL            998      // dynamic link library
     1264                    // removed, PROG_DLL exists already
     1265                    // V0.9.16 (2001-10-06)
     1266
     1267        #define PROG_WIN32              990     // added V0.9.16 (2001-12-08) [umoeller]
     1268
     1269        APIRET exehQueryProgType(const EXECUTABLE *pExec,
     1270                                 PROGCATEGORY *pulProgType);
     1271
     1272        PCSZ exehDescribeProgType(PROGCATEGORY progc);
     1273
     1274    #endif
     1275
    12451276    /*
    12461277     *@@ FSYSMODULE:
  • trunk/include/helpers/gpih.h

    r232 r242  
    194194                                              PCH pchString);
    195195    typedef GPIHCHARSTRINGPOSAT *PGPIHCHARSTRINGPOSAT;
     196
     197    VOID XWPENTRY gpihCalcTextExtent(HPS hps,
     198                                     PCSZ pcsz,
     199                                     PLONG pcx,
     200                                     PULONG pcLines);
     201
     202    VOID XWPENTRY gpihDrawString(HPS hps,
     203                                 PCSZ pcsz,
     204                                 PRECTL prcl,
     205                                 ULONG fl,
     206                                 PFONTMETRICS pfm);
    196207
    197208    /*
  • trunk/include/helpers/linklist.h

    r174 r242  
    134134                                          const char *function);
    135135        typedef PLINKLIST XWPENTRY LSTCREATEDEBUG(BOOL fItemsFreeable,
    136                                           const char *file,
    137                                           unsigned long line,
    138                                           const char *function);
     136                                                  const char *file,
     137                                                  unsigned long line,
     138                                                  const char *function);
    139139        typedef LSTCREATEDEBUG *PLSTCREATEDEBUG;
    140140
     
    199199                                           unsigned long ulIndex);
    200200    typedef PLISTNODE XWPENTRY LSTINSERTITEMBEFORE(PLINKLIST pList,
    201                                            void* pNewItemData,
    202                                            unsigned long ulIndex);
     201                                                   void* pNewItemData,
     202                                                   unsigned long ulIndex);
    203203    typedef LSTINSERTITEMBEFORE *PLSTINSERTITEMBEFORE;
     204
     205    PLISTNODE XWPENTRY lstInsertItemAfterNode(PLINKLIST pList,
     206                                              void* pNewItemData,
     207                                              PLISTNODE pNodeInsertAfter);
     208    typedef PLISTNODE XWPENTRY LSTINSERTITEMAFTERNODE(PLINKLIST pList,
     209                                                      void* pNewItemData,
     210                                                      PLISTNODE pNodeInsertAfter);
     211    typedef LSTINSERTITEMAFTERNODE *PLSTINSERTITEMAFTERNODE;
    204212
    205213    BOOL XWPENTRY lstRemoveNode(PLINKLIST pList, PLISTNODE pRemoveNode);
  • trunk/include/helpers/nls.h

    r194 r242  
    9090        } COUNTRYSETTINGS, *PCOUNTRYSETTINGS;
    9191
    92         VOID XWPENTRY nlsQueryCountrySettings(PCOUNTRYSETTINGS pcs);
     92        /*
     93         *@@ COUNTRYAMPM:
     94         *
     95         *@@added V1.0.1 (2003-01-17) [umoeller]
     96         */
     97
     98        typedef struct _COUNTRYAMPM
     99        {
     100            CHAR            sz2359[10],
     101                            sz1159[10];
     102        } COUNTRYAMPM, *PCOUNTRYAMPM;
     103
     104        /*
     105         *@@ COUNTRYSETTINGS:
     106         *      second structure to finally get the AM/PM
     107         *      stuff right too. I suspect people have used
     108         *      this structure in XCenter DLLs and such so
     109         *      I cannot easily change it... hence a second
     110         *      one.
     111         *
     112         *@@changed V1.0.1 (2003-01-17) [umoeller]
     113         */
     114
     115        typedef struct _COUNTRYSETTINGS2
     116        {
     117            COUNTRYSETTINGS cs;
     118            COUNTRYAMPM     ampm;
     119        } COUNTRYSETTINGS2, *PCOUNTRYSETTINGS2;
     120
     121        VOID XWPENTRY nlsQueryCountrySettings(PCOUNTRYSETTINGS2 pcs);
    93122
    94123        PSZ XWPENTRY nlsThousandsULong(PSZ pszTarget, ULONG ul, CHAR cThousands);
     
    103132                                       CHAR cThousands);
    104133
     134        VOID XWPENTRY nlsDate(const COUNTRYSETTINGS2 *pcs2,
     135                              PSZ pszDate,
     136                              USHORT year,
     137                              BYTE month,
     138                              BYTE day);
     139
     140        VOID XWPENTRY nlsTime(const COUNTRYSETTINGS2 *pcs,
     141                              PSZ pszTime,
     142                              BYTE hours,
     143                              BYTE minutes,
     144                              BYTE seconds);
     145
    105146        VOID XWPENTRY nlsFileDate(PSZ pszBuf,
    106                                   FDATE *pfDate,
    107                                   ULONG ulDateFormat,
    108                                   CHAR cDateSep);
     147                                  const FDATE *pfDate,
     148                                  const COUNTRYSETTINGS2 *pcs);
    109149
    110150        VOID XWPENTRY nlsFileTime(PSZ pszBuf,
    111                                   FTIME *pfTime,
    112                                   ULONG ulTimeFormat,
    113                                   CHAR cTimeSep);
     151                                  const FTIME *pfTime,
     152                                  const COUNTRYSETTINGS2 *pcs);
    114153
    115154        VOID XWPENTRY nlsDateTime(PSZ pszDate,
    116155                                  PSZ pszTime,
    117                                   DATETIME *pDateTime,
     156                                  const DATETIME *pDateTime,
    118157                                  ULONG ulDateFormat,
    119158                                  CHAR cDateSep,
     
    122161        typedef VOID XWPENTRY NLSDATETIME(PSZ pszDate,
    123162                                          PSZ pszTime,
    124                                           DATETIME *pDateTime,
     163                                          const DATETIME *pDateTime,
    125164                                          ULONG ulDateFormat,
    126165                                          CHAR cDateSep,
     
    129168        typedef NLSDATETIME *PNLSDATETIME;
    130169
    131         ULONG nlsUpper(PSZ psz);
     170        VOID XWPENTRY nlsDateTime2(PSZ pszDate,
     171                                   PSZ pszTime,
     172                                   const DATETIME *pDateTime,
     173                                   const COUNTRYSETTINGS2 *pcs2);
     174        typedef VOID XWPENTRY NLSDATETIME2(PSZ pszDate,
     175                                           PSZ pszTime,
     176                                           const DATETIME *pDateTime,
     177                                           const COUNTRYSETTINGS2 *pcs2);
     178        typedef NLSDATETIME2 *PNLSDATETIME2;
    132179
    133180    #endif
     181
     182    ULONG nlsUpper(PSZ psz);
    134183
    135184#endif
  • trunk/include/helpers/standards.h

    r232 r242  
    126126    #define STOREIFMAX(a, b) if ((a) > (b)) { b = a; }
    127127
     128    #ifdef _PMPRINTF_
     129        #define PMPF_RECT(s, prect) _PmpfF(("%s: xLeft %d, xRight %d, yBottom %d, yTop %d", (s), (prect)->xLeft, (prect)->xRight, (prect)->yBottom, (prect)->yTop))
     130    #else
     131        #define PMPF_RECT(s, prect)
     132    #endif
     133
    128134#endif
    129135
  • trunk/include/helpers/winh.h

    r239 r242  
    673673     ********************************************************************/
    674674
     675    #define ID_VSCROLL      100
     676    #define ID_HSCROLL      101
     677
     678    BOOL XWPENTRY winhCreateScrollBars(HWND hwndParent,
     679                                       HWND *phwndV,
     680                                       HWND *phwndH);
     681
    675682    BOOL XWPENTRY winhUpdateScrollBar(HWND hwndScrollBar,
    676683                                      ULONG ulWinPels,
     
    687694                                      ULONG msg,
    688695                                      MPARAM mp2);
     696
     697    LONG XWPENTRY winhHandleScrollMsg2(HWND hwndScrollBar,
     698                                       PLONG plCurPelsOfs,
     699                                       LONG lWindowPels,
     700                                       LONG lWorkareaPels,
     701                                       USHORT usLineStepPels,
     702                                       ULONG msg,
     703                                       MPARAM mp2);
     704    BOOL XWPENTRY winhScrollWindow(HWND hwnd2Scroll,
     705                                   PRECTL prclClip,
     706                                   PPOINTL pptlScroll);
    689707
    690708    BOOL XWPENTRY winhProcessScrollChars(HWND hwndClient,
     
    951969                                    ULONG ulID);
    952970
     971    BOOL XWPENTRY winhSetParentAndOwner(HWND hwnd,
     972                                        HWND hwndNewParent,
     973                                        BOOL fRedraw);
     974
    953975    VOID XWPENTRY winhRepaintWindows(HWND hwndParent);
    954976
  • trunk/src/helpers/_call_filedlg.c

    r238 r242  
    1313#define INCL_WINBUTTONS
    1414#define INCL_WINPOINTERS
     15#define INCL_WINSTDCNR
    1516#define INCL_WINSTDFILE
    1617
     
    2627
    2728#include "helpers\call_file_dlg.c"
     29#include "helpers\cnrh.h"
    2830#include "helpers\comctl.h"
    2931#include "helpers\standards.h"
     
    9092
    9193/*
    92  *@@ fnwpClient:
     94 *@@ GROUPRECORD:
    9395 *
    9496 */
    9597
    96 MRESULT EXPENTRY fnwpClient(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     98typedef struct _GROUPRECORD
    9799{
    98     MRESULT mrc = 0;
    99 
    100     switch (msg)
    101     {
    102         case WM_PAINT:
    103         {
    104             HPS hps;
    105             RECTL rcl;
    106             if (hps = WinBeginPaint(hwnd, NULLHANDLE, &rcl))
    107             {
    108                 gpihSwitchToRGB(hps);
    109                 WinFillRect(hps, &rcl, RGBCOL_DARKGRAY);
    110                 WinEndPaint(hps);
    111             }
    112         }
    113         break;
    114 
    115         default:
    116             mrc = WinDefWindowProc(hwnd, msg, mp1, mp2);
    117     }
    118 
    119     return mrc;
    120 }
     100    RECORDCORE      recc;
     101
     102    ULONG           gid;
     103    CHAR            szGroupName[100];    // group name
     104    PSZ             pszMembers;
     105
     106} GROUPRECORD, *PGROUPRECORD;
    121107
    122108/*
     
    217203                  | FCF_SHELLPOSITION
    218204                  | FCF_TASKLIST,
    219             XFCF_TOOLBAR | XFCF_FORCETBOWNER | XFCF_STATUSBAR,
     205            0, // XFCF_TOOLBAR | XFCF_FORCETBOWNER | XFCF_STATUSBAR,
    220206            WS_VISIBLE,                         // ulFrameStyle
    221207            "Test File Dialog",                 // pcszFrameTitle
    222208            0,                                  // ulResourcesID
    223             WC_CLIENT,                          // pcszClassClient
     209#if 1
     210            WC_CCTL_CNR,
     211#else
     212            WC_CONTAINER,
     213#endif
    224214            WS_VISIBLE,                         // flStyleClient
    225215            0,                                  // ulID
     
    248238    ctlRegisterToolbar(hab);
    249239    ctlRegisterSeparatorLine(hab);
    250 
    251     WinRegisterClass(hab,
    252                      (PSZ)WC_CLIENT,
    253                      fnwpClient,
    254                      0,
    255                      4);
     240    ctlRegisterXCnr(hab);
    256241
    257242    sprintf(szOpen,
     
    275260    WinSetWindowText(hwndStatusBar, "Status bar");
    276261
    277     /* hwndMenu = WinCreateMenu(hwndFrame,
    278                              NULL);
    279 
    280     hwndSubmenu = winhInsertSubmenu(hwndMenu,
    281                                     MIT_END,
    282                                     1,
    283                                     "~File",
    284                                     MIS_TEXT | MIS_SUBMENU,
    285                                     1000,
    286                                     "Open...",
    287                                     MIS_TEXT,
    288                                     0);
    289 
    290     winhInsertMenuItem(hwndSubmenu,
    291                        MIT_END,
    292                        SC_CLOSE,
    293                        "~Quit",
    294                        MIS_SYSCOMMAND | MIS_TEXT,
    295                        0);
    296     */
    297 
    298262    WinSendMsg(hwndFrame, WM_UPDATEFRAME, MPNULL, MPNULL);
     263
     264    {
     265        XFIELDINFO  xfi[4];
     266        PFIELDINFO      pfi = NULL;
     267        int i = 0;
     268        PGROUPRECORD preccFirst;
     269
     270        // set up cnr details view
     271        xfi[i].ulFieldOffset = FIELDOFFSET(GROUPRECORD, gid);
     272        xfi[i].pszColumnTitle = "Group ID";     // @@todo localize
     273        xfi[i].ulDataType = CFA_ULONG;
     274        xfi[i++].ulOrientation = CFA_RIGHT;
     275
     276        xfi[i].ulFieldOffset = FIELDOFFSET(GROUPRECORD, recc.pszIcon);
     277        xfi[i].pszColumnTitle = "Group name";   // @@todo localize
     278        xfi[i].ulDataType = CFA_STRING;
     279        xfi[i++].ulOrientation = CFA_CENTER;
     280
     281        xfi[i].ulFieldOffset = FIELDOFFSET(GROUPRECORD, pszMembers);
     282        xfi[i].pszColumnTitle = "Members";   // @@todo localize
     283        xfi[i].ulDataType = CFA_STRING;
     284        xfi[i++].ulOrientation = CFA_LEFT;
     285
     286        pfi = cnrhSetFieldInfos(hwndClient,
     287                                xfi,
     288                                i,             // array item count
     289                                TRUE,          // draw lines
     290                                0);            // return first column
     291
     292        BEGIN_CNRINFO()
     293        {
     294            cnrhSetView(CV_DETAIL | CA_DETAILSVIEWTITLES);
     295            CnrInfo_.cyLineSpacing = 10;
     296            ulSendFlags_ |= CMA_LINESPACING;
     297        } END_CNRINFO(hwndClient);
     298
     299        #define RECORD_COUNT        200
     300
     301        if (preccFirst = (PGROUPRECORD)cnrhAllocRecords(hwndClient,
     302                                                        sizeof(GROUPRECORD),
     303                                                        RECORD_COUNT))
     304        {
     305            PGROUPRECORD preccThis = preccFirst;
     306            ULONG   ul = 0;
     307            while (preccThis)
     308            {
     309                preccThis->gid = ul++;
     310                sprintf(preccThis->szGroupName, "group %d", preccThis->gid);
     311                preccThis->recc.pszIcon = preccThis->szGroupName;
     312
     313                preccThis->pszMembers = "longer string than title";
     314
     315                preccThis = (PGROUPRECORD)preccThis->recc.preccNextRecord;
     316            }
     317
     318            cnrhInsertRecords(hwndClient,
     319                              NULL,
     320                              (PRECORDCORE)preccFirst,
     321                              TRUE,
     322                              NULL,
     323                              CRA_RECORDREADONLY,
     324                              RECORD_COUNT);
     325        }
     326    }
    299327
    300328    while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
  • trunk/src/helpers/_test_exeh.c

    r209 r242  
    1717
    1818#define INCL_KBD
     19#define INCL_WINPROGRAMLIST     // needed for PROGDETAILS, wppgm.h
    1920#include <os2.h>
    2021
     
    4849        if (!(arc = exehOpen(argv[1], &pExe)))
    4950        {
     51            APIRET  arc2;
     52            ULONG   progt;
     53
     54            printf("exeh: dumping base info of \"%s\"\n", argv[1]);
     55            printf("    cbDosExeHeader    %d\n", pExe->cbDosExeHeader);
     56            printf("    ulExeFormat       %d (%s)\n",
     57                    pExe->ulExeFormat,
     58                    (pExe->ulExeFormat == EXEFORMAT_OLDDOS) ? "EXEFORMAT_OLDDOS"
     59                    : (pExe->ulExeFormat == EXEFORMAT_NE) ? "EXEFORMAT_NE"
     60                    : (pExe->ulExeFormat == EXEFORMAT_PE) ? "EXEFORMAT_PE"
     61                    : (pExe->ulExeFormat == EXEFORMAT_LX) ? "EXEFORMAT_LX"
     62                    : (pExe->ulExeFormat == EXEFORMAT_TEXT_BATCH) ? "EXEFORMAT_TEXT_BATCH"
     63                    : (pExe->ulExeFormat == EXEFORMAT_TEXT_CMD) ? "EXEFORMAT_TEXT_CMD"
     64                    : (pExe->ulExeFormat == EXEFORMAT_COM) ? "EXEFORMAT_COM"
     65                    : "unknown"
     66                  );
     67            if (pExe->pLXHeader)
     68                printf("    LX flags:         0x%lX\n", pExe->pLXHeader->ulFlags);
     69            else if (pExe->pNEHeader)
     70                printf("    NE flags:         0x%lX\n", pExe->pNEHeader->usFlags);
     71            printf("    fLibrary          %d\n", pExe->fLibrary);
     72            printf("    f32Bits           %d\n", pExe->f32Bits);
     73            if (!(arc2 = exehQueryProgType(pExe, &progt)))
     74                printf("    progtype:         %d (%s)\n", progt, exehDescribeProgType(progt));
     75            else
     76                printf("    exehQueryProgType returned %d\n", arc2);
     77            printf("exeh: dumping bldlevel of \"%s\"\n", argv[1]);
     78
    5079            if (!(arc = exehQueryBldLevel(pExe)))
    5180            {
    5281                #define STRINGORNA(p) ((pExe->p) ? (pExe->p) : "n/a")
    5382
    54                 printf("exeh: dumping bldlevel of \"%s\"\n", argv[1]);
    5583                printf("    Description:      \"%s\"\n", STRINGORNA(pszDescription));
    5684                printf("    Vendor:           \"%s\"\n", STRINGORNA(pszVendor));
  • trunk/src/helpers/apps.c

    r229 r242  
    5252#include "helpers\dosh.h"
    5353#include "helpers\except.h"             // exception handling
     54#include "helpers\exeh.h"
    5455#include "helpers\prfh.h"
    5556#include "helpers\standards.h"          // some standard macros
     
    676677
    677678/*
    678  *@@ PROGTYPESTRING:
    679  *
    680  *@@added V0.9.16 (2002-01-13) [umoeller]
    681  */
    682 
    683 typedef struct _PROGTYPESTRING
    684 {
    685     PROGCATEGORY    progc;
    686     PCSZ            pcsz;
    687 } PROGTYPESTRING, *PPROGTYPESTRING;
    688 
    689 PROGTYPESTRING G_aProgTypes[] =
    690     {
    691         PROG_DEFAULT, "PROG_DEFAULT",
    692         PROG_FULLSCREEN, "PROG_FULLSCREEN",
    693         PROG_WINDOWABLEVIO, "PROG_WINDOWABLEVIO",
    694         PROG_PM, "PROG_PM",
    695         PROG_GROUP, "PROG_GROUP",
    696         PROG_VDM, "PROG_VDM",
    697             // same as PROG_REAL, "PROG_REAL",
    698         PROG_WINDOWEDVDM, "PROG_WINDOWEDVDM",
    699         PROG_DLL, "PROG_DLL",
    700         PROG_PDD, "PROG_PDD",
    701         PROG_VDD, "PROG_VDD",
    702         PROG_WINDOW_REAL, "PROG_WINDOW_REAL",
    703         PROG_30_STD, "PROG_30_STD",
    704             // same as PROG_WINDOW_PROT, "PROG_WINDOW_PROT",
    705         PROG_WINDOW_AUTO, "PROG_WINDOW_AUTO",
    706         PROG_30_STDSEAMLESSVDM, "PROG_30_STDSEAMLESSVDM",
    707             // same as PROG_SEAMLESSVDM, "PROG_SEAMLESSVDM",
    708         PROG_30_STDSEAMLESSCOMMON, "PROG_30_STDSEAMLESSCOMMON",
    709             // same as PROG_SEAMLESSCOMMON, "PROG_SEAMLESSCOMMON",
    710         PROG_31_STDSEAMLESSVDM, "PROG_31_STDSEAMLESSVDM",
    711         PROG_31_STDSEAMLESSCOMMON, "PROG_31_STDSEAMLESSCOMMON",
    712         PROG_31_ENHSEAMLESSVDM, "PROG_31_ENHSEAMLESSVDM",
    713         PROG_31_ENHSEAMLESSCOMMON, "PROG_31_ENHSEAMLESSCOMMON",
    714         PROG_31_ENH, "PROG_31_ENH",
    715         PROG_31_STD, "PROG_31_STD",
    716 
    717 // Warp 4 toolkit defines, whatever these were designed for...
    718 #ifndef PROG_DOS_GAME
    719     #define PROG_DOS_GAME            (PROGCATEGORY)21
    720 #endif
    721 #ifndef PROG_WIN_GAME
    722     #define PROG_WIN_GAME            (PROGCATEGORY)22
    723 #endif
    724 #ifndef PROG_DOS_MODE
    725     #define PROG_DOS_MODE            (PROGCATEGORY)23
    726 #endif
    727 
    728         PROG_DOS_GAME, "PROG_DOS_GAME",
    729         PROG_WIN_GAME, "PROG_WIN_GAME",
    730         PROG_DOS_MODE, "PROG_DOS_MODE",
    731 
    732         // added this V0.9.16 (2001-12-08) [umoeller]
    733         PROG_WIN32, "PROG_WIN32"
    734     };
    735 
    736 /*
    737  *@@ appDescribeAppType:
    738  *      returns a "PROG_*" string for the given
    739  *      program type. Useful for WPProgram setup
    740  *      strings and such.
    741  *
    742  *@@added V0.9.16 (2001-10-06)
    743  */
    744 
    745 PCSZ appDescribeAppType(PROGCATEGORY progc)        // in: from PROGDETAILS.progc
    746 {
    747     ULONG ul;
    748     for (ul = 0;
    749          ul < ARRAYITEMCOUNT(G_aProgTypes);
    750          ul++)
    751     {
    752         if (G_aProgTypes[ul].progc == progc)
    753             return G_aProgTypes[ul].pcsz;
    754     }
    755 
    756     return NULL;
    757 }
    758 
    759 /*
    760679 *@@ appIsWindowsApp:
    761680 *      checks the specified program category
  • trunk/src/helpers/cctl_toolbar.c

    r233 r242  
    354354}
    355355
    356 static const SYSCOLORSET scsToolbarButton =
     356static const SYSCOLORSET G_scsToolbarButton =
    357357    {
    358358        TRUE,       // inherit presparams
     359
    359360        SYSCLR_BUTTONMIDDLE,
    360361        SYSCLR_MENUTEXT
     
    444445                   &pData->bd.dwd,
    445446                   WinDefWindowProc,
    446                    &scsToolbarButton);
     447                   &G_scsToolbarButton);
    447448
    448449        if (    (pcszText)
     
    850851 ********************************************************************/
    851852
    852 static const SYSCOLORSET scsToolbar =
     853static const SYSCOLORSET G_scsToolbar =
    853854    {
    854855        TRUE,       // inherit presparams
     
    10201021                                     PP_BACKGROUNDCOLORINDEX,
    10211022                                     FALSE,
    1022                                      scsToolbar.lBackIndex);
     1023                                     G_scsToolbar.lBackIndex);
    10231024        winhStorePresParam(&ppp,
    10241025                           PP_BACKGROUNDCOLOR,
     
    10301031                                     PP_FOREGROUNDCOLORINDEX,
    10311032                                     FALSE,
    1032                                      scsToolbar.lForeIndex);
     1033                                     G_scsToolbar.lForeIndex);
    10331034        winhStorePresParam(&ppp,
    10341035                           PP_FOREGROUNDCOLOR,
     
    11111112               &pData->dwd,
    11121113               WinDefWindowProc,
    1113                &scsToolbar);
     1114               &G_scsToolbar);
    11141115
    11151116    pData->hwndControlsOwner = ptbcd->hwndControlsOwner;
  • trunk/src/helpers/cctl_xframe.c

    r233 r242  
    8282
    8383MRESULT ctlFormatExtFrame(HWND hwndFrame,
    84                           PXFRAMECONTROLS pxfc,
     84                          const XFRAMECONTROLS *pxfc,
    8585                          MPARAM mp1,
    8686                          MPARAM mp2)
     
    209209 */
    210210
    211 VOID ctlCalcExtFrameRect(MPARAM mp1,
    212                          MPARAM mp2,
    213                          LONG lStatusBarHeight)
     211MRESULT ctlCalcExtFrameRect(HWND hwndFrame,
     212                            const XFRAMECONTROLS *pxfc,
     213                            MPARAM mp1,
     214                            MPARAM mp2)
    214215{
    215216    PRECTL prclPassed = (PRECTL)mp1;
     217
     218    MRESULT mrc = pxfc->pfnwpOrig(hwndFrame, WM_CALCFRAMERECT, mp1, mp2);
    216219
    217220    if (mp2)
     
    220223        //  call default window procedure to subtract child frame
    221224        //  controls from the rectangle's height
    222         LONG lClientHeight;
    223 
    224         //  position the static text frame extension below the client
    225         lClientHeight = prclPassed->yTop - prclPassed->yBottom;
    226         if (lStatusBarHeight > lClientHeight)
    227             // extension is taller than client, so set client height to 0
    228             prclPassed->yTop = prclPassed->yBottom;
    229         else
    230         {
    231             //  set the origin of the client and shrink it based upon the
    232             //  static text control's height
    233             prclPassed->yBottom += lStatusBarHeight;
    234             prclPassed->yTop -= lStatusBarHeight;
    235         }
     225
     226        if (pxfc->hwndToolBar)
     227            prclPassed->yTop -= pxfc->lToolBarHeight;
     228
     229        if (pxfc->hwndStatusBar)
     230            prclPassed->yBottom += pxfc->lStatusBarHeight;
    236231    }
    237232    else
     
    242237        //  set the origin of the frame and increase it based upon the
    243238        //  static text control's height
    244         prclPassed->yBottom -= lStatusBarHeight;
    245         prclPassed->yTop += lStatusBarHeight;
     239
     240        if (pxfc->hwndToolBar)
     241            prclPassed->yTop += pxfc->lToolBarHeight;
     242
     243        if (pxfc->hwndStatusBar)
     244            prclPassed->yBottom -= pxfc->lStatusBarHeight;
    246245    }
     246
     247    return mrc;
    247248}
    248249
     
    289290
    290291        case WM_CALCFRAMERECT:
    291             mrc = pData->xfc.pfnwpOrig(hwndFrame, msg, mp1, mp2);
    292 
    293292            // we have a status bar: calculate its rectangle
    294             ctlCalcExtFrameRect(mp1,
    295                                 mp2,
    296                                 STATUS_BAR_HEIGHT);
     293            mrc = ctlCalcExtFrameRect(hwndFrame,
     294                                      &pData->xfc,
     295                                      mp1,
     296                                      mp2);
    297297        break;
     298
     299        /*
     300        case WM_WINDOWPOSCHANGED:
     301            WinSendMsg(hwndFrame, WM_UPDATEFRAME, 0, 0);
     302        break; */
    298303
    299304        case WM_SYSCOMMAND:
  • trunk/src/helpers/cnrh.c

    r232 r242  
    168168                      BOOL fDrawLines)           // in: if TRUE, we'll draw lines around the columns
    169169{
    170     PFIELDINFO pInfo;
     170    PFIELDINFO pfi;
    171171    if (    (ppFieldInfo2)
    172          && (pInfo = *ppFieldInfo2)
     172         && (pfi = *ppFieldInfo2)
    173173       )
    174174    {
     
    177177            flData |= CFA_HORZSEPARATOR | CFA_SEPARATOR;
    178178
    179         pInfo->cb = sizeof(FIELDINFO);
    180         pInfo->flData = flData;
    181         pInfo->flTitle = CFA_FITITLEREADONLY | ulOrientation;
    182         pInfo->offStruct = ulFieldOffset;
    183         pInfo->pTitleData = pszColumnTitle;   // strdup removed, V0.9.1 (99-12-18) [umoeller]
    184         pInfo->pUserData   = NULL;
    185         pInfo->cxWidth = 0;
    186         *ppFieldInfo2 = pInfo->pNextFieldInfo;
     179        pfi->cb = sizeof(FIELDINFO);
     180        pfi->flData = flData;
     181        pfi->flTitle = CFA_FITITLEREADONLY | ulOrientation;
     182        pfi->offStruct = ulFieldOffset;
     183        pfi->pTitleData = pszColumnTitle;   // strdup removed, V0.9.1 (99-12-18) [umoeller]
     184        pfi->pUserData   = NULL;
     185        pfi->cxWidth = 0;
     186        *ppFieldInfo2 = pfi->pNextFieldInfo;
    187187    }
    188188}
     
    342342
    343343        // insert field infos
    344         if (cnrhInsertFieldInfos(hwndCnr,
    345                                  pFieldInfoFirst,
    346                                  ulFieldCount) == 0)
     344        if (!cnrhInsertFieldInfos(hwndCnr,
     345                                  pFieldInfoFirst,
     346                                  ulFieldCount))
    347347            pFieldInfoReturn = NULL;
    348348    }
  • trunk/src/helpers/comctl.c

    r238 r242  
    248248        case WM_ENABLE:
    249249            WinInvalidateRect(pdwd->hwnd, NULL, TRUE);
     250        break;
     251
     252        case WM_WINDOWPOSCHANGED:
     253            if (((PSWP)mp1)->fl & SWP_SIZE)
     254            {
     255                pdwd->szlWin.cx = ((PSWP)mp1)->cx;
     256                pdwd->szlWin.cy = ((PSWP)mp1)->cy;
     257            }
    250258        break;
    251259
  • trunk/src/helpers/exeh.c

    r240 r242  
    4545#define INCL_DOSDEVIOCTL
    4646#define INCL_DOSERRORS
     47
     48#define INCL_WINPROGRAMLIST
    4749#include <os2.h>
    4850
     
    835837{
    836838    APIRET      arc = NO_ERROR;
     839    PXFILE      pFile;
     840    ULONG       ulNRNTOfs = 0;
    837841
    838842    if (!pExec)
    839         arc = ERROR_INVALID_PARAMETER;
     843        return ERROR_INVALID_PARAMETER;
     844
     845    pFile = pExec->pFile;
     846    if (pExec->ulExeFormat == EXEFORMAT_LX)
     847    {
     848        // OK, LX format:
     849        // check if we have a non-resident name table
     850        if (pExec->pLXHeader == NULL)
     851            arc = ERROR_INVALID_DATA;
     852        else if (pExec->pLXHeader->ulNonResdNameTblOfs == 0)
     853            arc = ERROR_INVALID_DATA;
     854        else
     855            ulNRNTOfs = pExec->pLXHeader->ulNonResdNameTblOfs;
     856    }
     857    else if (pExec->ulExeFormat == EXEFORMAT_NE)
     858    {
     859        // OK, NE format:
     860        // check if we have a non-resident name table
     861        if (pExec->pNEHeader == NULL)
     862            arc = ERROR_INVALID_DATA;
     863        else if (pExec->pNEHeader->ulNonResdTblOfs == 0)
     864            arc = ERROR_INVALID_DATA;
     865        else
     866            ulNRNTOfs = pExec->pNEHeader->ulNonResdTblOfs;
     867    }
    840868    else
     869        // neither LX nor NE: stop
     870        arc = ERROR_INVALID_EXE_SIGNATURE;
     871
     872    if (    (!arc)
     873         && (ulNRNTOfs)
     874       )
    841875    {
    842         PXFILE      pFile = pExec->pFile;
    843 
    844         ULONG       ulNRNTOfs = 0;
    845 
    846         if (pExec->ulExeFormat == EXEFORMAT_LX)
     876        ULONG       cb = 2000;
     877
     878        PSZ         pszNameTable;
     879
     880        if (!(pszNameTable = (PSZ)malloc(2001)))
     881            arc = ERROR_NOT_ENOUGH_MEMORY;
     882        else
    847883        {
    848             // OK, LX format:
    849             // check if we have a non-resident name table
    850             if (pExec->pLXHeader == NULL)
    851                 arc = ERROR_INVALID_DATA;
    852             else if (pExec->pLXHeader->ulNonResdNameTblOfs == 0)
    853                 arc = ERROR_INVALID_DATA;
    854             else
    855                 ulNRNTOfs = pExec->pLXHeader->ulNonResdNameTblOfs;
    856         }
    857         else if (pExec->ulExeFormat == EXEFORMAT_NE)
    858         {
    859             // OK, NE format:
    860             // check if we have a non-resident name table
    861             if (pExec->pNEHeader == NULL)
    862                 arc = ERROR_INVALID_DATA;
    863             else if (pExec->pNEHeader->ulNonResdTblOfs == 0)
    864                 arc = ERROR_INVALID_DATA;
    865             else
    866                 ulNRNTOfs = pExec->pNEHeader->ulNonResdTblOfs;
    867         }
    868         else
    869             // neither LX nor NE: stop
    870             arc = ERROR_INVALID_EXE_SIGNATURE;
    871 
    872         if (    (!arc)
    873              && (ulNRNTOfs)
    874            )
    875         {
    876             ULONG       cb = 2000;
    877 
    878             PSZ         pszNameTable;
    879 
    880             if (!(pszNameTable = (PSZ)malloc(2001)))
    881                 arc = ERROR_NOT_ENOUGH_MEMORY;
    882             else
     884            // V0.9.16 (2002-01-05) [umoeller]: rewrote the following
     885
     886            // read from offset of non-resident name table
     887            if (!(arc = doshReadAt(pFile,           // file is still open
     888                                   ulNRNTOfs,       // ofs determined above
     889                                   &cb,             // 2000
     890                                   pszNameTable,
     891                                   0)))
    883892            {
    884                 // V0.9.16 (2002-01-05) [umoeller]: rewrote the following
    885 
    886                 // read from offset of non-resident name table
    887                 if (!(arc = doshReadAt(pFile,           // file is still open
    888                                        ulNRNTOfs,       // ofs determined above
    889                                        &cb,             // 2000
    890                                        pszNameTable,
    891                                        0)))
    892                 {
    893                     // the string is in Pascal format, so the
    894                     // first byte has the length
    895                     BYTE bLen;
    896                     if (!(bLen = *pszNameTable))
    897                         // length byte is null:
    898                         arc = ERROR_INVALID_DATA;
     893                // the string is in Pascal format, so the
     894                // first byte has the length
     895                BYTE bLen;
     896                if (!(bLen = *pszNameTable))
     897                    // length byte is null:
     898                    arc = ERROR_INVALID_DATA;
     899                else
     900                {
     901                    // now copy the string
     902                    if (!(pExec->pszDescription = (PSZ)malloc(bLen + 1)))
     903                        arc = ERROR_NOT_ENOUGH_MEMORY;
    899904                    else
    900905                    {
    901                         // now copy the string
    902                         if (!(pExec->pszDescription = (PSZ)malloc(bLen + 1)))
    903                             arc = ERROR_NOT_ENOUGH_MEMORY;
    904                         else
    905                         {
    906                             memcpy(pExec->pszDescription,
    907                                    pszNameTable + 1,    // skip length byte
    908                                    bLen);               // length byte
    909                             // terminate string
    910                             pExec->pszDescription[bLen] = 0;
    911 
    912                             ParseBldLevel(pExec);
    913                         }
     906                        memcpy(pExec->pszDescription,
     907                               pszNameTable + 1,    // skip length byte
     908                               bLen);               // length byte
     909                        // terminate string
     910                        pExec->pszDescription[bLen] = 0;
     911
     912                        ParseBldLevel(pExec);
    914913                    }
    915914                }
    916 
    917                 free(pszNameTable);
    918915            }
     916
     917            free(pszNameTable);
    919918        }
    920     } // end if (!pExec)
     919    }
    921920
    922921    return arc;
     922}
     923
     924/*
     925 *@@ exehQueryProgType:
     926 *      attempts to sets *pulProgType to a PROGTYPE constant.
     927 *
     928 *      Returns:
     929 *
     930 *      --  NO_ERROR
     931 *
     932 *      --  ERROR_INVALID_PARAMETER;
     933 *
     934 *@@added V1.0.1 (2003-01-17) [umoeller]
     935 *@@changed V1.0.1 (2003-01-17) [umoeller]: now correctly returning PROG_PDD/VDD for NE and LX @@fixes 343
     936 */
     937
     938APIRET exehQueryProgType(const EXECUTABLE *pExec,
     939                         PROGCATEGORY *pulProgType)
     940{
     941    APIRET      arc = NO_ERROR;
     942
     943    if (!pExec)
     944        return ERROR_INVALID_PARAMETER;
     945
     946    // now we have the PEXECUTABLE:
     947    // check what we found
     948    switch (pExec->ulOS)
     949    {
     950        case EXEOS_DOS3:
     951        case EXEOS_DOS4:
     952            *pulProgType = PROG_WINDOWEDVDM;
     953        break;
     954
     955        case EXEOS_OS2:
     956            switch (pExec->ulExeFormat)
     957            {
     958                case EXEFORMAT_LX:
     959                    switch (pExec->pLXHeader->ulFlags & E32MODMASK)
     960                    {
     961                        case E32MODPDEV:
     962                            *pulProgType = PROG_PDD;
     963                        break;
     964
     965                        case E32MODVDEV:
     966                            *pulProgType = PROG_VDD;
     967                        break;
     968
     969                        case E32MODDLL:
     970                        case E32MODPROTDLL:
     971                            *pulProgType = PROG_DLL;
     972                        break;
     973
     974                        default:
     975                            // all bits clear: --> real executable
     976                            switch (pExec->pLXHeader->ulFlags & E32APPMASK)
     977                            {
     978                                case E32PMAPI:
     979                                    // _Pmpf(("  LX OS2 PM"));
     980                                    *pulProgType = PROG_PM;
     981                                break;
     982
     983                                case E32PMW:
     984                                    // _Pmpf(("  LX OS2 VIO"));
     985                                    *pulProgType = PROG_WINDOWABLEVIO;
     986                                break;
     987
     988                                case E32NOPMW:
     989                                    // _Pmpf(("  LX OS2 FULLSCREEN"));
     990                                    *pulProgType = PROG_FULLSCREEN;
     991                                break;
     992
     993                                default:
     994                                    // _Pmpf(("  LX OS2 FULLSCREEN"));
     995                                    *pulProgType = PROG_FULLSCREEN;
     996                                break;
     997                            }
     998                        break;      // executable
     999                    }
     1000                break;
     1001
     1002                case EXEFORMAT_NE:
     1003                    if (pExec->fLibrary)
     1004                    {
     1005                        // there is no flag in the NE header for whether
     1006                        // this is a device driver, so rely on extension
     1007                        // V1.0.1 (2003-01-17) [umoeller]
     1008                        PSZ p;
     1009                        if (    (p = doshGetExtension(pExec->pFile->pszFilename))
     1010                             && (    (!stricmp(p, "ADD"))
     1011                                  || (!stricmp(p, "DMD"))
     1012                                  || (!stricmp(p, "FLT"))
     1013                                  || (!stricmp(p, "IFS"))
     1014                                  || (!stricmp(p, "SNP"))
     1015                                  || (!stricmp(p, "SYS"))
     1016                                )
     1017                           )
     1018                            *pulProgType = PROG_PDD;
     1019                                    // there can be no 16-bit VDDs, so this must be a PDD
     1020                        else
     1021                            *pulProgType = PROG_DLL;
     1022                    }
     1023                    else switch (pExec->pNEHeader->usFlags & NEAPPTYP)
     1024                    {
     1025                        case NEWINCOMPAT:
     1026                            // _Pmpf(("  NE OS2 VIO"));
     1027                            *pulProgType = PROG_WINDOWABLEVIO;
     1028                        break;
     1029
     1030                        case NEWINAPI:
     1031                            // _Pmpf(("  NE OS2 PM"));
     1032                            *pulProgType = PROG_PM;
     1033                        break;
     1034
     1035                        case NENOTWINCOMPAT:
     1036                        default:
     1037                            // _Pmpf(("  NE OS2 FULLSCREEN"));
     1038                            *pulProgType = PROG_FULLSCREEN;
     1039                        break;
     1040                    }
     1041                break;
     1042
     1043                case EXEFORMAT_COM:
     1044                    *pulProgType = PROG_WINDOWABLEVIO;
     1045                break;
     1046
     1047                default:
     1048                    arc = ERROR_INVALID_EXE_SIGNATURE;
     1049            }
     1050        break;
     1051
     1052        case EXEOS_WIN16:
     1053        case EXEOS_WIN386:
     1054            // _Pmpf(("  WIN16"));
     1055            *pulProgType = PROG_31_ENHSEAMLESSCOMMON;
     1056        break;
     1057
     1058        case EXEOS_WIN32_GUI:
     1059        case EXEOS_WIN32_CLI:
     1060            // _Pmpf(("  WIN32"));
     1061            *pulProgType = PROG_WIN32;
     1062        break;
     1063
     1064        default:
     1065            arc = ERROR_INVALID_EXE_SIGNATURE;
     1066    }
     1067
     1068    return arc;
     1069}
     1070
     1071/*
     1072 *@@ PROGTYPESTRING:
     1073 *
     1074 *@@added V0.9.16 (2002-01-13) [umoeller]
     1075 */
     1076
     1077typedef struct _PROGTYPESTRING
     1078{
     1079    PROGCATEGORY    progc;
     1080    PCSZ            pcsz;
     1081} PROGTYPESTRING, *PPROGTYPESTRING;
     1082
     1083PROGTYPESTRING G_aProgTypes[] =
     1084    {
     1085        PROG_DEFAULT, "PROG_DEFAULT",
     1086        PROG_FULLSCREEN, "PROG_FULLSCREEN",
     1087        PROG_WINDOWABLEVIO, "PROG_WINDOWABLEVIO",
     1088        PROG_PM, "PROG_PM",
     1089        PROG_GROUP, "PROG_GROUP",
     1090        PROG_VDM, "PROG_VDM",
     1091            // same as PROG_REAL, "PROG_REAL",
     1092        PROG_WINDOWEDVDM, "PROG_WINDOWEDVDM",
     1093        PROG_DLL, "PROG_DLL",
     1094        PROG_PDD, "PROG_PDD",
     1095        PROG_VDD, "PROG_VDD",
     1096        PROG_WINDOW_REAL, "PROG_WINDOW_REAL",
     1097        PROG_30_STD, "PROG_30_STD",
     1098            // same as PROG_WINDOW_PROT, "PROG_WINDOW_PROT",
     1099        PROG_WINDOW_AUTO, "PROG_WINDOW_AUTO",
     1100        PROG_30_STDSEAMLESSVDM, "PROG_30_STDSEAMLESSVDM",
     1101            // same as PROG_SEAMLESSVDM, "PROG_SEAMLESSVDM",
     1102        PROG_30_STDSEAMLESSCOMMON, "PROG_30_STDSEAMLESSCOMMON",
     1103            // same as PROG_SEAMLESSCOMMON, "PROG_SEAMLESSCOMMON",
     1104        PROG_31_STDSEAMLESSVDM, "PROG_31_STDSEAMLESSVDM",
     1105        PROG_31_STDSEAMLESSCOMMON, "PROG_31_STDSEAMLESSCOMMON",
     1106        PROG_31_ENHSEAMLESSVDM, "PROG_31_ENHSEAMLESSVDM",
     1107        PROG_31_ENHSEAMLESSCOMMON, "PROG_31_ENHSEAMLESSCOMMON",
     1108        PROG_31_ENH, "PROG_31_ENH",
     1109        PROG_31_STD, "PROG_31_STD",
     1110
     1111// Warp 4 toolkit defines, whatever these were designed for...
     1112#ifndef PROG_DOS_GAME
     1113    #define PROG_DOS_GAME            (PROGCATEGORY)21
     1114#endif
     1115#ifndef PROG_WIN_GAME
     1116    #define PROG_WIN_GAME            (PROGCATEGORY)22
     1117#endif
     1118#ifndef PROG_DOS_MODE
     1119    #define PROG_DOS_MODE            (PROGCATEGORY)23
     1120#endif
     1121
     1122        PROG_DOS_GAME, "PROG_DOS_GAME",
     1123        PROG_WIN_GAME, "PROG_WIN_GAME",
     1124        PROG_DOS_MODE, "PROG_DOS_MODE",
     1125
     1126        // added this V0.9.16 (2001-12-08) [umoeller]
     1127        PROG_WIN32, "PROG_WIN32"
     1128    };
     1129
     1130/*
     1131 *@@ exehDescribeProgType:
     1132 *      returns a "PROG_*" string for the given
     1133 *      program type. Useful for WPProgram setup
     1134 *      strings and such.
     1135 *
     1136 *@@added V0.9.16 (2001-10-06)
     1137 *@@changed V1.0.1 (2003-01-17) [umoeller]: moved this here from apps.c
     1138 */
     1139
     1140PCSZ exehDescribeProgType(PROGCATEGORY progc)        // in: from PROGDETAILS.progc
     1141{
     1142    ULONG ul;
     1143    for (ul = 0;
     1144         ul < ARRAYITEMCOUNT(G_aProgTypes);
     1145         ul++)
     1146    {
     1147        if (G_aProgTypes[ul].progc == progc)
     1148            return G_aProgTypes[ul].pcsz;
     1149    }
     1150
     1151    return NULL;
    9231152}
    9241153
  • 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;
  • trunk/src/helpers/helpers_pre.in

    r232 r242  
    8686$(OUTPUTDIR)\cctl_chart.obj\
    8787$(OUTPUTDIR)\cctl_checkcnr.obj\
     88$(OUTPUTDIR)\cctl_cnr.obj\
     89$(OUTPUTDIR)\cctl_cnr_dtls.obj\
    8890$(OUTPUTDIR)\cctl_combo.obj\
    8991$(OUTPUTDIR)\cctl_progbar.obj\
  • trunk/src/helpers/linklist.c

    r238 r242  
    675675
    676676/*
     677 *@@ InsertFront:
     678 *
     679 *@@added V1.0.1 (2003-01-17) [umoeller]
     680 */
     681
     682VOID InsertFront(PLINKLIST pList,
     683                 PLISTNODE pNewNode)
     684{
     685    if (pList->pFirst)
     686        pList->pFirst->pPrevious = pNewNode;
     687
     688    pNewNode->pNext = pList->pFirst;
     689    pNewNode->pPrevious = NULL;
     690
     691    pList->pFirst = pNewNode;
     692
     693    if (!pList->pLast)
     694        // the list was empty:
     695        pList->pLast = pNewNode;        // V0.9.14 (2001-07-14) [umoeller]
     696
     697    (pList->ulCount)++;
     698}
     699
     700/*
     701 *@@ InsertAfterNode:
     702 *
     703 *@@added V1.0.1 (2003-01-17) [umoeller]
     704 */
     705
     706VOID InsertAfterNode(PLINKLIST pList,
     707                     PLISTNODE pNewNode,
     708                     PLISTNODE pNodeInsertAfter)
     709{
     710    // 1) set pointers for new node
     711    pNewNode->pPrevious = pNodeInsertAfter;
     712    pNewNode->pNext = pNodeInsertAfter->pNext;
     713
     714    // 2) adjust next item
     715    // so that it points to the new node
     716    if (pNodeInsertAfter->pNext)
     717        pNodeInsertAfter->pNext->pPrevious = pNewNode;
     718
     719    // 3) adjust previous item
     720    // so that it points to the new node
     721    pNodeInsertAfter->pNext = pNewNode;
     722
     723    // 4) adjust last item, if necessary
     724    if (pList->pLast == pNodeInsertAfter)
     725        pList->pLast = pNewNode;
     726
     727    (pList->ulCount)++;
     728}
     729
     730/*
    677731 *@@ lstInsertItemBefore:
    678732 *      this inserts a new node to the list. As opposed to
     
    699753
    700754PLISTNODE lstInsertItemBefore(PLINKLIST pList,
    701                               void* pNewItemData,     // data to store in list node
    702                               unsigned long ulIndex)
     755                              void* pNewItemData,       // in: data to store in list node
     756                              unsigned long ulIndex)    // in: index before which to insert
    703757{
    704758    PLISTNODE pNewNode = NULL;
     
    715769        {
    716770            // insert at beginning:
    717             if (pList->pFirst)
    718                 pList->pFirst->pPrevious = pNewNode;
    719 
    720             pNewNode->pNext = pList->pFirst;
    721             pNewNode->pPrevious = NULL;
    722 
    723             pList->pFirst = pNewNode;
    724 
    725             if (!pList->pLast)
    726                 // the list was empty:
    727                 pList->pLast = pNewNode;        // V0.9.14 (2001-07-14) [umoeller]
    728 
    729             (pList->ulCount)++;
     771            InsertFront(pList,
     772                        pNewNode);
    730773        }
    731774        else
     
    735778
    736779            if (pNodeInsertAfter = lstNodeFromIndex(pList,
    737                                                     (ulIndex - 1)))
     780                                                    ulIndex - 1))
    738781            {
    739                 // 1) set pointers for new node
    740                 pNewNode->pPrevious = pNodeInsertAfter;
    741                 pNewNode->pNext = pNodeInsertAfter->pNext;
    742 
    743                 // 2) adjust next item
    744                 // so that it points to the new node
    745                 if (pNodeInsertAfter->pNext)
    746                     pNodeInsertAfter->pNext->pPrevious = pNewNode;
    747 
    748                 // 3) adjust previous item
    749                 // so that it points to the new node
    750                 pNodeInsertAfter->pNext = pNewNode;
    751 
    752                 // 4) adjust last item, if necessary
    753                 if (pList->pLast == pNodeInsertAfter)
    754                     pList->pLast = pNewNode;
    755 
    756                 (pList->ulCount)++;
     782                InsertAfterNode(pList,
     783                                pNewNode,
     784                                pNodeInsertAfter);
    757785            }
    758786            else
     
    763791            }
    764792        }
     793    }
     794
     795    return pNewNode;
     796}
     797
     798/*
     799 *@@ lstInsertItemAfterNode:
     800 *      this inserts a new node to the list. As opposed to
     801 *      lstAppendItem, the new node can be appended anywhere
     802 *      in the list, that is, it will be appended AFTER
     803 *      the given existing list node.
     804 *
     805 *      If pNodeAfter is NULL, the new item will be made the
     806 *      first item.
     807 *
     808 *      As opposed to lstInsertItemBefore, this does not
     809 *      need to traverse the list, so it is very quick.
     810 *
     811 *      This returns the LISTNODE of the new list item,
     812 *      or NULL upon errors.
     813 *
     814 *@@added V1.0.1 (2003-01-17) [umoeller]
     815 */
     816
     817PLISTNODE lstInsertItemAfterNode(PLINKLIST pList,
     818                                 void* pNewItemData,            // in: data to store in list node
     819                                 PLISTNODE pNodeInsertAfter)    // in: node to insert after or NULL to make new node the first
     820{
     821    PLISTNODE pNewNode = NULL;
     822
     823    if (    (pList)
     824         && (pList->ulMagic == LINKLISTMAGIC)
     825         && (pNewNode = (PLISTNODE)malloc(sizeof(LISTNODE)))
     826       )
     827    {
     828        memset(pNewNode, 0, sizeof(LISTNODE));
     829        pNewNode->pItemData = pNewItemData;
     830
     831        if (!pNodeInsertAfter)
     832            // insert at beginning:
     833            InsertFront(pList,
     834                        pNewNode);
     835        else
     836            InsertAfterNode(pList,
     837                            pNewNode,
     838                            pNodeInsertAfter);
    765839    }
    766840
  • trunk/src/helpers/makefile

    r232 r242  
    234234    $(TESTCASE_DIR)\datetime.obj \
    235235    $(TESTCASE_DIR)\tree.obj \
    236     $(TESTCASE_DIR)\gpih.obj
     236    $(TESTCASE_DIR)\gpih.obj \
     237    $(TESTCASE_DIR)\prfh.obj \
     238    $(TESTCASE_DIR)\nls.obj \
     239    $(TESTCASE_DIR)\nlscache.obj
    237240
    238241$(TESTCASE_DIR)\dialog.obj: ..\..\include\helpers\dialog.h
     
    264267FDLG_TEST_OBJS = \
    265268    $(TESTCASE_DIR)\comctl.obj \
     269    $(TESTCASE_DIR)\cctl_cnr.obj \
     270    $(TESTCASE_DIR)\cctl_cnr_dtls.obj \
    266271    $(TESTCASE_DIR)\cctl_toolbar.obj \
    267272    $(TESTCASE_DIR)\cctl_tooltip.obj \
    268273    $(TESTCASE_DIR)\cctl_xframe.obj \
     274    $(TESTCASE_DIR)\cnrh.obj \
    269275    $(TESTCASE_DIR)\dosh.obj \
    270276    $(TESTCASE_DIR)\gpih.obj \
     
    273279    $(TESTCASE_DIR)\stringh.obj \
    274280    $(TESTCASE_DIR)\xstring.obj \
     281    $(TESTCASE_DIR)\prfh.obj \
     282    $(TESTCASE_DIR)\tree.obj \
     283    $(TESTCASE_DIR)\nls.obj \
     284    $(TESTCASE_DIR)\nlscache.obj \
    275285    $(TESTCASE_DIR)\_call_filedlg.obj
    276286
  • trunk/src/helpers/nls.c

    r222 r242  
    349349
    350350/*
     351 *@@ nlsGetAMPM:
     352 *
     353 *@@added V1.0.1 (2003-01-17) [umoeller]
     354 */
     355
     356VOID nlsGetAMPM(PCOUNTRYAMPM pampm)
     357{
     358    PrfQueryProfileString(HINI_USER,
     359                          "PM_National",
     360                          "s2359",        // key
     361                          "PM",           // default
     362                          pampm->sz2359,
     363                          sizeof(pampm->sz2359));
     364
     365    PrfQueryProfileString(HINI_USER,
     366                          "PM_National",
     367                          "s1159",        // key
     368                          "AM",           // default
     369                          pampm->sz1159,
     370                          sizeof(pampm->sz1159));
     371}
     372
     373/*
    351374 *@@ nlsQueryCountrySettings:
    352375 *      this returns the most frequently used country settings
     
    369392 */
    370393
    371 VOID nlsQueryCountrySettings(PCOUNTRYSETTINGS pcs)
    372 {
    373     if (pcs)
    374     {
     394VOID nlsQueryCountrySettings(PCOUNTRYSETTINGS2 pcs2)
     395{
     396    if (pcs2)
     397    {
     398        PCOUNTRYSETTINGS pcs = &pcs2->cs;
    375399        pcs->ulDateFormat = PrfQueryProfileInt(HINI_USER,
    376400                                               (PSZ)PMINIAPP_NATIONAL,
     
    397421                                               "sThousand",
    398422                                               ',');
     423
     424        nlsGetAMPM(&pcs2->ampm);
    399425    }
    400426}
     
    424450                      CHAR cThousands)     // in: separator char (e.g. '.')
    425451{
    426     USHORT ust, uss, usc;
    427     CHAR   szTemp[40];
    428     usc = sprintf(szTemp, "%lu", ul);  // V0.9.20 (2002-07-03) [umoeller]
    429 
    430     ust = 0;
    431     // usc = strlen(szTemp);
    432     for (uss = 0; uss < usc; uss++)
     452    CHAR    szTemp[30];
     453    USHORT  ust = 0,
     454            uss,
     455            usLen = sprintf(szTemp, "%lu", ul);  // V0.9.20 (2002-07-03) [umoeller]
     456
     457    for (uss = 0;
     458         uss < usLen;
     459         ++uss)
    433460    {
    434461        if (uss)
    435             if (((usc - uss) % 3) == 0)
     462            if (0 == ((usLen - uss) % 3))
    436463            {
    437464                pszTarget[ust] = cThousands;
    438465                ust++;
    439466            }
    440         pszTarget[ust] = szTemp[uss];
    441         ust++;
    442     }
     467
     468        pszTarget[ust++] = szTemp[uss];
     469    }
     470
    443471    pszTarget[ust] = '\0';
    444472
     
    473501                       CHAR cThousands)
    474502{
    475     USHORT ust, uss, usc;
     503    USHORT ust, uss, usLen;
    476504    CHAR   szTemp[40];
    477     usc = sprintf(szTemp, "%.0f", floor(dbl)); // V0.9.20 (2002-07-03) [umoeller]
     505    usLen = sprintf(szTemp, "%.0f", floor(dbl)); // V0.9.20 (2002-07-03) [umoeller]
    478506
    479507    ust = 0;
    480     // usc = strlen(szTemp);
    481     for (uss = 0; uss < usc; uss++)
     508    for (uss = 0; uss < usLen; uss++)
    482509    {
    483510        if (uss)
    484             if (((usc - uss) % 3) == 0)
     511            if (((usLen - uss) % 3) == 0)
    485512            {
    486513                pszTarget[ust] = cThousands;
     
    547574 *
    548575 *@@changed V0.9.0 (99-11-07) [umoeller]: now calling nlsDateTime
    549  */
    550 
    551 VOID nlsFileDate(PSZ pszBuf,           // out: string returned
    552                  FDATE *pfDate,        // in: date information
    553                  ULONG ulDateFormat,   // in: date format (0-3)
    554                  CHAR cDateSep)        // in: date separator (e.g. '.')
    555 {
    556     DATETIME dt;
    557     dt.day = pfDate->day;
    558     dt.month = pfDate->month;
    559     dt.year = pfDate->year + 1980;
    560 
    561     nlsDateTime(pszBuf,
    562                 NULL,          // no time
    563                 &dt,
    564                 ulDateFormat,
    565                 cDateSep,
    566                 0, 0);         // no time
     576 *@@changed V1.0.1 (2003-01-17) [umoeller]: prototype changed for optimization, this was not exported
     577 */
     578
     579VOID nlsFileDate(PSZ pszBuf,            // out: string returned
     580                 const FDATE *pfDate,   // in: date information
     581                 const COUNTRYSETTINGS2 *pcs)
     582{
     583    nlsDate(pcs,
     584            pszBuf,
     585            pfDate->year + 1980,
     586            pfDate->month,
     587            pfDate->day);
    567588}
    568589
     
    590611 *@@changed V0.8.5 (99-03-15) [umoeller]: fixed 12-hour crash
    591612 *@@changed V0.9.0 (99-11-07) [umoeller]: now calling nlsDateTime
     613 *@@changed V1.0.1 (2003-01-17) [umoeller]: prototype changed for optimization, this was not exported
    592614 */
    593615
    594616VOID nlsFileTime(PSZ pszBuf,           // out: string returned
    595                  FTIME *pfTime,        // in: time information
    596                  ULONG ulTimeFormat,   // in: 24-hour time format (0 or 1)
    597                  CHAR cTimeSep)        // in: time separator (e.g. ':')
    598 {
    599     DATETIME dt;
    600     dt.hours = pfTime->hours;
    601     dt.minutes = pfTime->minutes;
    602     dt.seconds = pfTime->twosecs * 2;
    603 
    604     nlsDateTime(NULL,          // no date
    605                  pszBuf,
    606                  &dt,
    607                  0, 0,          // no date
    608                  ulTimeFormat,
    609                  cTimeSep);
     617                 const FTIME *pfTime,        // in: time information
     618                 const COUNTRYSETTINGS2 *pcs)
     619{
     620    nlsTime(pcs,
     621            pszBuf,
     622            pfTime->hours,
     623            pfTime->minutes,
     624            pfTime->twosecs * 2);
     625}
     626
     627/*
     628 *@@ nlsDate:
     629 *
     630 *@@added V1.0.1 (2003-01-17) [umoeller]
     631 */
     632
     633VOID nlsDate(const COUNTRYSETTINGS2 *pcs2,
     634             PSZ pszDate,                   // out: date string returned
     635             USHORT year,
     636             BYTE month,
     637             BYTE day)
     638{
     639    switch (pcs2->cs.ulDateFormat)
     640    {
     641        case 0:  // mm.dd.yyyy  (English)
     642            sprintf(pszDate, "%02d%c%02d%c%04d",
     643                    month,
     644                        pcs2->cs.cDateSep,
     645                    day,
     646                        pcs2->cs.cDateSep,
     647                    year);
     648        break;
     649
     650        case 1:  // dd.mm.yyyy  (e.g. German)
     651            sprintf(pszDate, "%02d%c%02d%c%04d",
     652                    day,
     653                        pcs2->cs.cDateSep,
     654                    month,
     655                        pcs2->cs.cDateSep,
     656                    year);
     657        break;
     658
     659        case 2: // yyyy.mm.dd  (Japanese)
     660            sprintf(pszDate, "%04d%c%02d%c%02d",
     661                    year,
     662                        pcs2->cs.cDateSep,
     663                    month,
     664                        pcs2->cs.cDateSep,
     665                    day);
     666        break;
     667
     668        default: // yyyy.dd.mm
     669            sprintf(pszDate, "%04d%c%02d%c%02d",
     670                    year,
     671                        pcs2->cs.cDateSep,
     672                    day,
     673                        pcs2->cs.cDateSep,
     674                    month);
     675        break;
     676    }
     677}
     678
     679/*
     680 *@@ nlsTime:
     681 *
     682 *@@added V1.0.1 (2003-01-17) [umoeller]
     683 */
     684
     685VOID nlsTime(const COUNTRYSETTINGS2 *pcs2,
     686             PSZ pszTime,                   // out: time string returned
     687             BYTE hours,
     688             BYTE minutes,
     689             BYTE seconds)
     690{
     691    if (!pcs2->cs.ulTimeFormat)
     692    {
     693        // for 12-hour clock, we need additional INI data
     694        if (hours >= 12)  // V0.9.16 (2001-12-05) [pr] if (hours > 12)
     695        {
     696            // yeah cool Paul, now we get 00:20 PM if it's 20 past noon
     697            // V0.9.18 (2002-02-13) [umoeller]
     698            ULONG ulHours;
     699            if (!(ulHours = hours % 12))
     700                ulHours = 12;
     701
     702            // >= 12h: PM.
     703            sprintf(pszTime, "%02d%c%02d%c%02d %s",
     704                    // leave 12 == 12 (not 0)
     705                    ulHours,
     706                        pcs2->cs.cTimeSep,
     707                    minutes,
     708                        pcs2->cs.cTimeSep,
     709                    seconds,
     710                    pcs2->ampm.sz2359);
     711        }
     712        else
     713        {
     714            // < 12h: AM
     715            sprintf(pszTime, "%02d%c%02d%c%02d %s",
     716                    hours,
     717                        pcs2->cs.cTimeSep,
     718                    minutes,
     719                        pcs2->cs.cTimeSep,
     720                    seconds,
     721                    pcs2->ampm.sz1159);
     722        }
     723    }
     724    else
     725        // 24-hour clock
     726        sprintf(pszTime, "%02d%c%02d%c%02d",
     727                hours,
     728                    pcs2->cs.cTimeSep,
     729                minutes,
     730                    pcs2->cs.cTimeSep,
     731                seconds);
    610732}
    611733
     
    616738 *      for more detailed parameter descriptions.
    617739 *
     740 *      Use of this function is deprecated. Use the
     741 *      speedier nlsDateTime2 instead.
     742 *
    618743 *@@added V0.9.0 (99-11-07) [umoeller]
    619744 *@@changed V0.9.16 (2001-12-05) [pr]: fixed AM/PM hour bug
    620745 *@@changed V0.9.18 (2002-02-13) [umoeller]: fixed AM/PM hour bug fix
     746 *@@changed V1.0.1 (2003-01-17) [umoeller]: extracted nlsDate, nlsTime
    621747 */
    622748
    623749VOID nlsDateTime(PSZ pszDate,          // out: date string returned (can be NULL)
    624750                 PSZ pszTime,          // out: time string returned (can be NULL)
    625                  DATETIME *pDateTime,  // in: date/time information
     751                 const DATETIME *pDateTime,  // in: date/time information
    626752                 ULONG ulDateFormat,   // in: date format (0-3); see nlsFileDate
    627753                 CHAR cDateSep,        // in: date separator (e.g. '.')
     
    629755                 CHAR cTimeSep)        // in: time separator (e.g. ':')
    630756{
     757    COUNTRYSETTINGS2 cs2;
    631758    if (pszDate)
    632759    {
    633         switch (ulDateFormat)
    634         {
    635             case 0:  // mm.dd.yyyy  (English)
    636                 sprintf(pszDate, "%02d%c%02d%c%04d",
    637                         pDateTime->month,
    638                             cDateSep,
    639                         pDateTime->day,
    640                             cDateSep,
    641                         pDateTime->year);
    642             break;
    643 
    644             case 1:  // dd.mm.yyyy  (e.g. German)
    645                 sprintf(pszDate, "%02d%c%02d%c%04d",
    646                         pDateTime->day,
    647                             cDateSep,
    648                         pDateTime->month,
    649                             cDateSep,
    650                         pDateTime->year);
    651             break;
    652 
    653             case 2: // yyyy.mm.dd  (Japanese)
    654                 sprintf(pszDate, "%04d%c%02d%c%02d",
    655                         pDateTime->year,
    656                             cDateSep,
    657                         pDateTime->month,
    658                             cDateSep,
    659                         pDateTime->day);
    660             break;
    661 
    662             default: // yyyy.dd.mm
    663                 sprintf(pszDate, "%04d%c%02d%c%02d",
    664                         pDateTime->year,
    665                             cDateSep,
    666                         pDateTime->day,
    667                             cDateSep,
    668                         pDateTime->month);
    669             break;
    670         }
     760        cs2.cs.ulDateFormat = ulDateFormat;
     761        cs2.cs.cDateSep = cDateSep;
     762        nlsDate(&cs2,
     763                pszDate,                   // out: date string returned
     764                pDateTime->year,
     765                pDateTime->month,
     766                pDateTime->day);
    671767    }
    672768
    673769    if (pszTime)
    674770    {
    675         if (ulTimeFormat == 0)
    676         {
    677             // for 12-hour clock, we need additional INI data
    678             CHAR szAMPM[10] = "err";
    679 
    680             if (pDateTime->hours >= 12)  // V0.9.16 (2001-12-05) [pr] if (pDateTime->hours > 12)
    681             {
    682                 // yeah cool Paul, now we get 00:20 PM if it's 20 past noon
    683                 // V0.9.18 (2002-02-13) [umoeller]
    684                 ULONG ulHours;
    685                 if (!(ulHours = pDateTime->hours % 12))
    686                     ulHours = 12;
    687 
    688                 // >= 12h: PM.
    689                 PrfQueryProfileString(HINI_USER,
    690                                       "PM_National",
    691                                       "s2359",        // key
    692                                       "PM",           // default
    693                                       szAMPM, sizeof(szAMPM)-1);
    694                 sprintf(pszTime, "%02d%c%02d%c%02d %s",
    695                         // leave 12 == 12 (not 0)
    696                         ulHours,
    697                             cTimeSep,
    698                         pDateTime->minutes,
    699                             cTimeSep,
    700                         pDateTime->seconds,
    701                         szAMPM);
    702             }
    703             else
    704             {
    705                 // < 12h: AM
    706                 PrfQueryProfileString(HINI_USER,
    707                                       "PM_National",
    708                                       "s1159",        // key
    709                                       "AM",           // default
    710                                       szAMPM, sizeof(szAMPM)-1);
    711                 sprintf(pszTime, "%02d%c%02d%c%02d %s",
    712                         pDateTime->hours,
    713                             cTimeSep,
    714                         pDateTime->minutes,
    715                             cTimeSep,
    716                         pDateTime->seconds,
    717                         szAMPM);
    718             }
    719         }
    720         else
    721             // 24-hour clock
    722             sprintf(pszTime, "%02d%c%02d%c%02d",
    723                     pDateTime->hours,
    724                         cTimeSep,
    725                     pDateTime->minutes,
    726                         cTimeSep,
    727                     pDateTime->seconds);
     771        cs2.cs.ulTimeFormat = ulTimeFormat;
     772        cs2.cs.cTimeSep = cTimeSep;
     773        nlsGetAMPM(&cs2.ampm);
     774        nlsTime(&cs2,
     775                pszTime,
     776                pDateTime->hours,
     777                pDateTime->minutes,
     778                pDateTime->seconds);
    728779    }
    729780}
     
    752803}
    753804
     805/*
     806 *@@ nlsDateTime2:
     807 *      speedier version of nlsDateTime that caches
     808 *      all information and needs _no_ Prf* call
     809 *      any more.
     810 *
     811 *@@added V1.0.1 (2003-01-17) [umoeller]
     812 */
     813
     814VOID nlsDateTime2(PSZ pszDate,
     815                  PSZ pszTime,
     816                  const DATETIME *pDateTime,
     817                  const COUNTRYSETTINGS2 *pcs2)
     818{
     819    if (pszDate)
     820        nlsDate(pcs2,
     821                pszDate,
     822                pDateTime->year,
     823                pDateTime->month,
     824                pDateTime->day);
     825
     826    if (pszTime)
     827        nlsTime(pcs2,
     828                pszTime,
     829                pDateTime->hours,
     830                pDateTime->minutes,
     831                pDateTime->seconds);
     832}
     833
    754834CHAR G_szUpperMap[257];
    755835BOOL G_fUpperMapInited = FALSE;
  • trunk/src/helpers/stringh.c

    r240 r242  
    456456                CHAR c)
    457457{
    458     PSZ         p = (PSZ)pszSearch;
    459     ULONG       ulCount = 0;
     458    PCSZ    p = pszSearch;
     459    ULONG   ulCount = 0;
    460460    while (TRUE)
    461461    {
    462         p = strchr(p, c);
    463         if (p)
    464         {
    465             ulCount++;
    466             p++;
    467         }
    468         else
    469             break;
    470     }
    471     return ulCount;
     462        if (!(p = strchr(p, c)))
     463            return ulCount;
     464
     465        ulCount++;
     466        p++;
     467    }
    472468}
    473469
  • trunk/src/helpers/textview.c

    r229 r242  
    18901890
    18911891} TEXTVIEWWINDATA, *PTEXTVIEWWINDATA;
    1892 
    1893 #define ID_VSCROLL      100
    1894 #define ID_HSCROLL      101
    18951892
    18961893/*
     
    23272324                // can be NULL
    23282325    PCREATESTRUCT       pcs = (PCREATESTRUCT)mp2;
    2329     SBCDATA             sbcd;
    23302326
    23312327    MRESULT             mrc = (MRESULT)TRUE;     // error
     
    23832379        ptxvd->rclViewReal.yTop = pcs->cy;
    23842380
    2385         sbcd.cb = sizeof(SBCDATA);
    2386         sbcd.sHilite = 0;
    2387         sbcd.posFirst = 0;
    2388         sbcd.posLast = 100;
    2389         sbcd.posThumb = 30;
    2390         sbcd.cVisible = 50;
    2391         sbcd.cTotal = 50;
    2392 
    2393         ptxvd->hwndVScroll = WinCreateWindow(hwndTextView,
    2394                                              WC_SCROLLBAR,
    2395                                              "",
    2396                                              SBS_VERT | SBS_THUMBSIZE | WS_VISIBLE,
    2397                                              10, 10,
    2398                                              20, 100,
    2399                                              hwndTextView,     // owner
    2400                                              HWND_TOP,
    2401                                              ID_VSCROLL,
    2402                                              &sbcd,
    2403                                              0);
     2381        winhCreateScrollBars(hwndTextView,
     2382                             &ptxvd->hwndVScroll,
     2383                             &ptxvd->hwndHScroll);
     2384
    24042385        fShow = ((ptxvd->flStyle & XS_VSCROLL) != 0);
    24052386        WinShowWindow(ptxvd->hwndVScroll, fShow);
    24062387        ptxvd->fVScrollVisible = fShow;
    24072388
    2408         ptxvd->hwndHScroll = WinCreateWindow(hwndTextView,
    2409                                              WC_SCROLLBAR,
    2410                                              "",
    2411                                              SBS_THUMBSIZE | WS_VISIBLE,
    2412                                              10, 10,
    2413                                              20, 100,
    2414                                              hwndTextView,     // owner
    2415                                              HWND_TOP,
    2416                                              ID_HSCROLL,
    2417                                              &sbcd,
    2418                                              0);
    24192389        fShow = ((ptxvd->flStyle & XS_HSCROLL) != 0);
    24202390        WinShowWindow(ptxvd->hwndHScroll, fShow);
  • trunk/src/helpers/winh.c

    r239 r242  
    18961896
    18971897/*
     1898 *@@ winhCreateScrollBars:
     1899 *      creates two scroll bars with an arbitrary
     1900 *      position for later use with winhUpdateScrollBar.
     1901 *
     1902 *@@added V1.0.1 (2003-01-17) [umoeller]
     1903 */
     1904
     1905BOOL winhCreateScrollBars(HWND hwndParent,
     1906                          HWND *phwndV,     // out: vertical scroll bar
     1907                          HWND *phwndH)     // out: horizontal scroll bar
     1908{
     1909    SBCDATA     sbcd;
     1910    sbcd.cb = sizeof(SBCDATA);
     1911    sbcd.sHilite = 0;
     1912    sbcd.posFirst = 0;
     1913    sbcd.posLast = 100;
     1914    sbcd.posThumb = 30;
     1915    sbcd.cVisible = 50;
     1916    sbcd.cTotal = 50;
     1917
     1918    return (    (*phwndV = WinCreateWindow(hwndParent,
     1919                                           WC_SCROLLBAR,
     1920                                           "",
     1921                                           SBS_VERT | SBS_THUMBSIZE | WS_VISIBLE,
     1922                                           10, 10,
     1923                                           20, 100,
     1924                                           hwndParent,     // owner
     1925                                           HWND_TOP,
     1926                                           ID_VSCROLL,
     1927                                           &sbcd,
     1928                                           0))
     1929             && (*phwndH = WinCreateWindow(hwndParent,
     1930                                           WC_SCROLLBAR,
     1931                                           "",
     1932                                           SBS_THUMBSIZE | WS_VISIBLE,
     1933                                           10, 10,
     1934                                           20, 100,
     1935                                           hwndParent,     // owner
     1936                                           HWND_TOP,
     1937                                           ID_HSCROLL,
     1938                                           &sbcd,
     1939                                           0))
     1940           );
     1941}
     1942
     1943/*
    18981944 *@@ winhUpdateScrollBar:
    18991945 *      updates the given scroll bar according to the given
     
    19181964 *         The width or height of this must be passed in ulWinPels.
    19191965 *
    1920  *      -- "viewport": the entire data to be displayed, of which the
    1921  *         "window" can only display a subrectangle, if the viewport
     1966 *      -- "workarea": the entire data to be displayed, of which the
     1967 *         "window" can only display a subrectangle, if the workarea
    19221968 *         is larger than the window.
    19231969 *
    1924  *         The width or height of this must be passed in ulViewportPels.
     1970 *         The width or height of this must be passed in ulWorkareaPels.
    19251971 *         This can be smaller than ulWinPels (if the window is larger
    19261972 *         than the data) or the same or larger than ulWinPels
     
    19281974 *
    19291975 *      -- "window offset": the offset of the current window within
    1930  *         the viewport.
     1976 *         the workarea.
    19311977 *
    19321978 *         For horizontal scroll bars, this is the X coordinate,
     
    19341980 *
    19351981 *         For vertical scroll bars, this is counted from the _top_
    1936  *         of the viewport (0 means topmost, as opposed to OS/2
     1982 *         of the workarea (0 means topmost, as opposed to OS/2
    19371983 *         window coordinates!). This is because for vertical scroll
    19381984 *         bars controls, higher values move the thumb _down_. Yes
     
    19411987 *         The window offset is therefore always positive.
    19421988 *
    1943  *      The scroll bar gets disabled if the entire viewport is visible,
    1944  *      that is, if ulViewportPels <= ulWinPels. In that case
     1989 *      The scroll bar gets disabled if the entire workarea is visible,
     1990 *      that is, if ulWorkareaPels <= ulWinPels. In that case
    19451991 *      FALSE is returned. If (fAutoHide == TRUE), the scroll
    19461992 *      bar is not only disabled, but also hidden from the display.
    19471993 *      In that case, you will need to reformat your output because
    1948  *      your viewport becomes larger without the scroll bar.
     1994 *      your workarea becomes larger without the scroll bar.
    19491995 *
    19501996 *      This function will set the range of the scroll bar to 0 up
    1951  *      to a value depending on the viewport size. For vertical scroll
     1997 *      to a value depending on the workarea size. For vertical scroll
    19521998 *      bars, 0 means topmost (which is kinda sick with the OS/2
    19531999 *      coordinate system), for horizontal scroll bars, 0 means leftmost.
     
    19552001 *      The maximum value of the scroll bar will be
    19562002 *
    1957  +          (ulViewportPels - ulWinPels) / usScrollUnitPels
     2003 +          (ulWorkareaPels - ulWinPels) / usScrollUnitPels
    19582004 *
    19592005 *      The thumb size of the scroll bar will also be adjusted
    1960  *      based on the viewport and window size, as it should be.
     2006 *      based on the workarea and window size, as it should be.
    19612007 *
    19622008 *@@added V0.9.1 (2000-02-14) [umoeller]
     
    19692015                                                // visible window part (in pixels),
    19702016                                                // excluding the scroll bar!
    1971                          ULONG ulViewportPels,  // in: dimension of total data part, of
     2017                         ULONG ulWorkareaPels,  // in: dimension of total data part, of
    19722018                                                // which ulWinPels is a sub-dimension
    19732019                                                // (in pixels);
     
    19822028    // _Pmpf(("Entering winhUpdateScrollBar"));
    19832029
    1984     // for large viewports, adjust scroll bar units
     2030    // for large workareas, adjust scroll bar units
    19852031    USHORT  usScrollUnitPels = 1;
    1986     if (ulViewportPels > 10000)
     2032    if (ulWorkareaPels > 10000)
    19872033        usScrollUnitPels = 100;
    19882034
    1989     if (ulViewportPels > ulWinPels)
     2035    if (ulWorkareaPels > ulWinPels)
    19902036    {
    19912037        // scrollbar needed:
    19922038        USHORT  usThumbDivisorUnits = usScrollUnitPels;
    19932039        USHORT  lMaxAllowedUnitOfs;
    1994         // _Pmpf(("winhUpdateScrollBar: ulViewportPels > ulWinPels, enabling scroller"));
     2040        // _Pmpf(("winhUpdateScrollBar: ulWorkareaPels > ulWinPels, enabling scroller"));
    19952041        // divisor for thumb size (below)
    1996         if (ulViewportPels > 10000)
    1997             // for very large viewports, we need to
     2042        if (ulWorkareaPels > 10000)
     2043            // for very large workareas, we need to
    19982044            // raise the divisor, because we only
    19992045            // have a USHORT
    20002046            usThumbDivisorUnits = usScrollUnitPels * 100;
    20012047
    2002         // viewport is larger than window:
     2048        // workarea is larger than window:
    20032049        WinEnableWindow(hwndScrollBar, TRUE);
    20042050        if (fAutoHide)
     
    20062052
    20072053        // calculate limit
    2008         lMaxAllowedUnitOfs = ((ulViewportPels - ulWinPels + usScrollUnitPels)
     2054        lMaxAllowedUnitOfs = ((ulWorkareaPels - ulWinPels + usScrollUnitPels)
    20092055                               // scroll unit is 10
    20102056                               / usScrollUnitPels);
     
    20212067
    20222068        // set thumb size based on ulWinPels and
    2023         // ulViewportPels
     2069        // ulWorkareaPels
    20242070        WinSendMsg(hwndScrollBar,
    20252071                   SBM_SETTHUMBSIZE,
    20262072                   MPFROM2SHORT(    ulWinPels / usThumbDivisorUnits,       // visible
    2027                                     ulViewportPels / usThumbDivisorUnits), // total
     2073                                    ulWorkareaPels / usThumbDivisorUnits), // total
    20282074                   0);
    20292075        brc = TRUE;
     
    20312077    else
    20322078    {
    2033         // _Pmpf(("winhUpdateScrollBar: ulViewportPels <= ulWinPels"));
    2034         // entire viewport is visible:
     2079        // _Pmpf(("winhUpdateScrollBar: ulWorkareaPels <= ulWinPels"));
     2080        // entire workarea is visible:
    20352081        WinEnableWindow(hwndScrollBar, FALSE);
    20362082        if (fAutoHide)
     
    20662112 *      of the scroll bar is:
    20672113 *
    2068  +          ulViewportPels - (prcl2Scroll->yTop - prcl2Scroll->yBottom)
     2114 +          ulWorkareaPels - (prcl2Scroll->yTop - prcl2Scroll->yBottom)
    20692115 *
    20702116 *      This function also automatically changes the scroll bar
    2071  *      units, should you have a viewport size which doesn't fit
     2117 *      units, should you have a workarea size which doesn't fit
    20722118 *      into the SHORT's that the scroll bar uses internally. As
    20732119 *      a result, this function handles a the complete range of
    2074  *      a ULONG for the viewport.
     2120 *      a ULONG for the workarea.
    20752121 *
    20762122 *      Replace "bottom" and "top" with "right" and "left" for
     
    20852131BOOL winhHandleScrollMsg(HWND hwnd2Scroll,          // in: client window to scroll
    20862132                         HWND hwndScrollBar,        // in: vertical or horizontal scroll bar window
    2087                          PULONG pulCurPelsOfs,      // in/out: current viewport offset;
     2133                         PULONG pulCurPelsOfs,      // in/out: current workarea offset;
    20882134                                                    // this is updated with the proper scroll units
    20892135                         PRECTL prcl2Scroll,        // in: hwnd2Scroll rectangle to scroll
     
    20912137                                                    // this is passed to WinScrollWindow,
    20922138                                                    // which considers this inclusive!
    2093                          LONG ulViewportPels,       // in: total viewport dimension,
     2139                         LONG ulWorkareaPels,       // in: total workarea dimension,
    20942140                                                    // into which *pulCurPelsOfs is an offset
    20952141                         USHORT usLineStepPels,     // in: pixels to scroll line-wise
     
    21062152    ULONG   ulWinPels;
    21072153
    2108     // for large viewports, adjust scroll bar units
     2154    // for large workareas, adjust scroll bar units
    21092155    USHORT  usScrollUnitPels = 1;
    2110     if (ulViewportPels > 10000)
     2156    if (ulWorkareaPels > 10000)
    21112157        usScrollUnitPels = 100;
    21122158
     
    21172163        ulWinPels = (prcl2Scroll->xRight - prcl2Scroll->xLeft);
    21182164
    2119     lMaxAllowedUnitOfs = ((LONG)ulViewportPels - ulWinPels) / usScrollUnitPels;
     2165    lMaxAllowedUnitOfs = ((LONG)ulWorkareaPels - ulWinPels) / usScrollUnitPels;
    21202166
    21212167    // _Pmpf(("Entering winhHandleScrollMsg"));
     
    22222268
    22232269/*
     2270 *@@ winhHandleScrollMsg2:
     2271 *
     2272 *      Returns the amount of pixels to be passed to
     2273 *      WinScrollWindow.
     2274 *
     2275 *@@added V1.0.1 (2003-01-17) [umoeller]
     2276 */
     2277
     2278LONG winhHandleScrollMsg2(HWND hwndScrollBar,        // in: vertical or horizontal scroll bar window
     2279                          PLONG plCurPelsOfs,        // in/out: current workarea offset;
     2280                                                     // this is updated with the proper scroll units
     2281                          LONG lWindowPels,          // in: window cx or cy (in window coordinates);
     2282                          LONG lWorkareaPels,        // in: total workarea dimension,
     2283                                                     // into which *plCurPelsOfs is an offset
     2284                          USHORT usLineStepPels,     // in: pixels to scroll line-wise
     2285                                                     // (scroll bar buttons pressed)
     2286                          ULONG msg,                 // in: either WM_VSCROLL or WM_HSCROLL
     2287                          MPARAM mp2)                // in: complete mp2 of WM_VSCROLL/WM_HSCROLL;
     2288                                                     // this has two SHORT's (usPos and usCmd),
     2289                                                     // see PMREF for details
     2290{
     2291    LONG    lOldPelsOfs = *plCurPelsOfs;
     2292    USHORT  usPosUnits = SHORT1FROMMP(mp2), // in scroll units
     2293            usCmd = SHORT2FROMMP(mp2);
     2294    LONG    lMaxAllowedUnitOfs;
     2295
     2296    // for large workareas, adjust scroll bar units
     2297    USHORT  usScrollUnitPels = 1;
     2298    if (lWorkareaPels > 10000)
     2299        usScrollUnitPels = 100;
     2300
     2301    lMaxAllowedUnitOfs = (lWorkareaPels - lWindowPels) / usScrollUnitPels;
     2302
     2303    // _Pmpf(("Entering winhHandleScrollMsg"));
     2304
     2305    switch (usCmd)
     2306    {
     2307        case SB_LINEUP:
     2308            if (*plCurPelsOfs > usLineStepPels)
     2309                *plCurPelsOfs -= usLineStepPels;  //  * usScrollUnitPels);
     2310            else
     2311                *plCurPelsOfs = 0;
     2312        break;
     2313
     2314        case SB_LINEDOWN:
     2315            *plCurPelsOfs += usLineStepPels;  //  * usScrollUnitPels);
     2316        break;
     2317
     2318        case SB_PAGEUP:
     2319            if (*plCurPelsOfs > lWindowPels)
     2320                *plCurPelsOfs -= lWindowPels; // convert to units
     2321            else
     2322                *plCurPelsOfs = 0;
     2323        break;
     2324
     2325        case SB_PAGEDOWN:
     2326            *plCurPelsOfs += lWindowPels; // convert to units
     2327        break;
     2328
     2329        case SB_SLIDERTRACK:
     2330            *plCurPelsOfs = (usPosUnits * usScrollUnitPels);
     2331            // _Pmpf(("    SB_SLIDERTRACK: usUnits = %d", usPosUnits));
     2332        break;
     2333
     2334        case SB_SLIDERPOSITION:
     2335            *plCurPelsOfs = (usPosUnits * usScrollUnitPels);
     2336        break;
     2337    }
     2338
     2339    if (*plCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels))
     2340        *plCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels);
     2341
     2342    if (    (*plCurPelsOfs != lOldPelsOfs)
     2343         || (*plCurPelsOfs == 0)
     2344         || (*plCurPelsOfs == (lMaxAllowedUnitOfs * usScrollUnitPels))
     2345       )
     2346    {
     2347        // changed:
     2348        WinSendMsg(hwndScrollBar,
     2349                   SBM_SETPOS,
     2350                   (MPARAM)(*plCurPelsOfs / usScrollUnitPels), //  / usScrollUnit),
     2351                   0);
     2352
     2353        if (msg == WM_VSCROLL)
     2354            return (*plCurPelsOfs - lOldPelsOfs);
     2355
     2356        return -(*plCurPelsOfs - lOldPelsOfs);
     2357    }
     2358
     2359    return 0;
     2360}
     2361
     2362/*
     2363 *@@ winhScrollWindow:
     2364 *
     2365 *@@added V1.0.1 (2003-01-17) [umoeller]
     2366 */
     2367
     2368BOOL winhScrollWindow(HWND hwnd2Scroll,
     2369                      PRECTL prclClip,          // clipping rectangle or NULL
     2370                      PPOINTL pptlScroll)
     2371{
     2372    return !!WinScrollWindow(hwnd2Scroll,
     2373                             pptlScroll->x,
     2374                             pptlScroll->y,
     2375                             prclClip,
     2376                             prclClip,
     2377                             NULLHANDLE,     // no region
     2378                             NULL,           // no rect
     2379                             SW_INVALIDATERGN);
     2380}
     2381
     2382/*
    22242383 *@@ winhProcessScrollChars:
    22252384 *      helper for processing WM_CHAR messages for
     
    22642423                            MPARAM mp1,         // in: WM_CHAR mp1
    22652424                            MPARAM mp2,         // in: WM_CHAR mp2
    2266                             ULONG ulVertMax,    // in: maximum viewport cy
    2267                             ULONG ulHorzMax)    // in: maximum viewport cx
     2425                            ULONG ulVertMax,    // in: maximum workarea cy
     2426                            ULONG ulHorzMax)    // in: maximum workarea cx
    22682427{
    22692428    BOOL    fProcessed = FALSE;
     
    33053464            fl |= QPF_ID2COLORINDEX;            // convert indexed color 2 to RGB V0.9.20 (2002-08-04) [umoeller]
    33063465
    3307         if ((ul = WinQueryPresParam(hwnd,
    3308                                     ulppRGB,
    3309                                     ulppIndex,
    3310                                     &attrFound,
    3311                                     sizeof(lColorFound),
    3312                                     &lColorFound,
    3313                                     fl)))
     3466        if (ul = WinQueryPresParam(hwnd,
     3467                                   ulppRGB,
     3468                                   ulppIndex,
     3469                                   &attrFound,
     3470                                   sizeof(lColorFound),
     3471                                   &lColorFound,
     3472                                   fl))
    33143473            return lColorFound;
    33153474    }
     
    42704429                           NULL,
    42714430                           NULL);
     4431}
     4432
     4433/*
     4434 *@@ winhSetParentAndOwner:
     4435 *      switches owner _and_ parent of the given window.
     4436 *
     4437 *@@added V1.0.1 (2003-01-17) [umoeller]
     4438 */
     4439
     4440BOOL winhSetParentAndOwner(HWND hwnd,           // in: window whose parent and owner to change
     4441                           HWND hwndNewParent,  // in: new parent and owner
     4442                           BOOL fRedraw)
     4443{
     4444    return (    WinSetParent(hwnd, hwndNewParent, fRedraw)
     4445             && WinSetOwner(hwnd, hwndNewParent)
     4446           );
    42724447}
    42734448
Note: See TracChangeset for help on using the changeset viewer.