Ignore:
Timestamp:
Jan 17, 2001, 6:34:55 PM (25 years ago)
Author:
umoeller
Message:

Misc. changes for V0.9.7.

File:
1 edited

Legend:

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

    r23 r25  
    109109                                            //      insert or MIT_END
    110110                         SHORT sItemId,     // in:  ID of new menu item
    111                          PSZ pszItemTitle,  // in:  title of new menu item
     111                         const char *pcszItemTitle,  // in:  title of new menu item
    112112                         SHORT afStyle,
    113113                            // in:  MIS_* style flags.
     
    168168                                  MM_INSERTITEM,
    169169                                  (MPARAM)&mi,
    170                                   (MPARAM)pszItemTitle));
     170                                  (MPARAM)pcszItemTitle));
    171171    return (src);
    172172}
     
    186186                       ULONG iPosition,     // in: index where to add submenu or MIT_END
    187187                       SHORT sMenuId,       // in: menu ID of new submenu
    188                        PSZ pszSubmenuTitle, // in: title of new submenu
     188                       const char *pcszSubmenuTitle, // in: title of new submenu
    189189                       USHORT afMenuStyle,  // in: MIS* style flags for submenu;
    190190                                            // MIS_SUBMENU will always be added
    191191                       SHORT sItemId,       // in: ID of first item to add to submenu;
    192192                                            // if 0, no first item is inserted
    193                        PSZ pszItemTitle,    // in: title of this item
     193                       const char *pcszItemTitle,    // in: title of this item
    194194                                            // (if sItemID != 0)
    195195                       USHORT afItemStyle,  // in: style flags for this item, e.g. MIS_TEXT
     
    216216        mi.hwndSubMenu = hwndNewMenu;
    217217        mi.hItem = 0;
    218         src = SHORT1FROMMR(WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, (MPARAM)pszSubmenuTitle));
     218        src = SHORT1FROMMR(WinSendMsg(hwndMenu, MM_INSERTITEM, (MPARAM)&mi, (MPARAM)pcszSubmenuTitle));
    219219        if (    (src != MIT_MEMERROR)
    220220            &&  (src != MIT_ERROR)
     
    237237                           MM_INSERTITEM,
    238238                           (MPARAM)&mi,
    239                            (MPARAM)pszItemTitle);
     239                           (MPARAM)pcszItemTitle);
    240240            }
    241241        }
     
    10591059 *      extension, and position, all in one shot.
    10601060 *
     1061 *      This function usually gets called when the window is
     1062 *      created and later when the window is resized.
     1063 *
    10611064 *      This simplifies the typical functionality of a scroll
    10621065 *      bar in a client window which is to be scrolled. I am
     
    10681071 *
    10691072 *      -- "window": the actual window with scroll bars which displays
    1070  *         a subrectangle of the available data.
     1073 *         a subrectangle of the available data. With a typical PM
     1074 *         application, this will be your client window.
     1075 *
    10711076 *         The width or height of this must be passed in ulWinPels.
    10721077 *
    10731078 *      -- "viewport": the entire data to be displayed, of which the
    10741079 *         "window" can only display a subrectangle, if the viewport
    1075  *         is larger than the window. The width or height of this must be
    1076  *         passed in ulViewportPels. This can be smaller than ulWinPels (if the
    1077  *         window is larger than the data), the same or larger than ulWinPels
     1080 *         is larger than the window.
     1081 *
     1082 *         The width or height of this must be passed in ulViewportPels.
     1083 *         This can be smaller than ulWinPels (if the window is larger
     1084 *         than the data) or the same or larger than ulWinPels
    10781085 *         (if the window is too small to show all the data).
    10791086 *
    10801087 *      -- "window offset": the offset of the current window within
    1081  *         the viewport. For horizontal scroll bars, this is
    1082  *         the X coordinate, counting from the left of the window
    1083  *         (0 means leftmost).
     1088 *         the viewport.
     1089 *
     1090 *         For horizontal scroll bars, this is the X coordinate,
     1091 *         counting from the left of the window (0 means leftmost).
     1092 *
    10841093 *         For vertical scroll bars, this is counted from the _top_
    10851094 *         of the viewport (0 means topmost, as opposed to OS/2
    1086  *         window coordinates!).
    1087  *         This is because for vertical scroll bars controls, higher
    1088  *         values move the thumb _down_.
    1089  *
    1090  *      The scroll bar is disabled if the entire viewport is visible,
     1095 *         window coordinates!). This is because for vertical scroll
     1096 *         bars controls, higher values move the thumb _down_. Yes
     1097 *         indeed, this conflicts with PM's coordinate system.
     1098 *
     1099 *         The window offset is therefore always positive.
     1100 *
     1101 *      The scroll bar gets disabled if the entire viewport is visible,
    10911102 *      that is, if ulViewportPels <= ulWinPels. In that case
    10921103 *      FALSE is returned. If (fAutoHide == TRUE), the scroll
     
    10991110 *      bars, 0 means topmost (which is kinda sick with the OS/2
    11001111 *      coordinate system), for horizontal scroll bars, 0 means leftmost.
    1101  *      The maximum value of the scroll bar will be:
     1112 *
     1113 *      The maximum value of the scroll bar will be
     1114 *
    11021115 +          (ulViewportPels - ulWinPels) / usScrollUnitPels
    11031116 *
     
    12101223 *      on values starting from zero. The maximum value
    12111224 *      of the scroll bar is:
     1225 *
    12121226 +          ulViewportPels - (prcl2Scroll->yTop - prcl2Scroll->yBottom)
    12131227 *
     
    12241238 *@@changed V0.9.3 (2000-04-30) [umoeller]: changed prototype, fixed pels/unit confusion
    12251239 *@@changed V0.9.3 (2000-05-08) [umoeller]: now handling scroll units automatically
     1240 *@@changed V0.9.7 (2001-01-17) [umoeller]: changed PLONG to PULONG
    12261241 */
    12271242
    12281243BOOL winhHandleScrollMsg(HWND hwnd2Scroll,          // in: client window to scroll
    12291244                         HWND hwndScrollBar,        // in: vertical or horizontal scroll bar window
    1230                          PLONG plCurPelsOfs,        // in/out: current viewport offset;
     1245                         PULONG pulCurPelsOfs,      // in/out: current viewport offset;
    12311246                                                    // this is updated with the proper scroll units
    12321247                         PRECTL prcl2Scroll,        // in: hwnd2Scroll rectangle to scroll
     
    12431258                                                    // see PMREF for details
    12441259{
    1245     LONG    lOldPelsOfs = *plCurPelsOfs;
     1260    ULONG   ulOldPelsOfs = *pulCurPelsOfs;
    12461261    USHORT  usPosUnits = SHORT1FROMMP(mp2), // in scroll units
    12471262            usCmd = SHORT2FROMMP(mp2);
     
    12671282    {
    12681283        case SB_LINEUP:
    1269             // _Pmpf(("SB_LINEUP"));
    1270             *plCurPelsOfs -= usLineStepPels;  //  * usScrollUnitPels);
     1284            if (*pulCurPelsOfs > usLineStepPels)
     1285                *pulCurPelsOfs -= usLineStepPels;  //  * usScrollUnitPels);
     1286            else
     1287                *pulCurPelsOfs = 0;
    12711288        break;
    12721289
    12731290        case SB_LINEDOWN:
    1274             // _Pmpf(("SB_LINEDOWN"));
    1275             *plCurPelsOfs += usLineStepPels;  //  * usScrollUnitPels);
     1291            *pulCurPelsOfs += usLineStepPels;  //  * usScrollUnitPels);
    12761292        break;
    12771293
    12781294        case SB_PAGEUP:
    1279             *plCurPelsOfs -= ulWinPels; // convert to units
     1295            if (*pulCurPelsOfs > ulWinPels)
     1296                *pulCurPelsOfs -= ulWinPels; // convert to units
     1297            else
     1298                *pulCurPelsOfs = 0;
    12801299        break;
    12811300
    12821301        case SB_PAGEDOWN:
    1283             *plCurPelsOfs += ulWinPels; // convert to units
     1302            *pulCurPelsOfs += ulWinPels; // convert to units
    12841303        break;
    12851304
    12861305        case SB_SLIDERTRACK:
    1287             *plCurPelsOfs = (usPosUnits * usScrollUnitPels);
     1306            *pulCurPelsOfs = (usPosUnits * usScrollUnitPels);
    12881307            // _Pmpf(("    SB_SLIDERTRACK: usUnits = %d", usPosUnits));
    12891308        break;
    12901309
    12911310        case SB_SLIDERPOSITION:
    1292             *plCurPelsOfs = (usPosUnits * usScrollUnitPels);
     1311            *pulCurPelsOfs = (usPosUnits * usScrollUnitPels);
    12931312        break;
    12941313    }
     
    13041323    } */
    13051324
    1306     if (*plCurPelsOfs < 0)
    1307         *plCurPelsOfs = 0;
    1308     if (*plCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels))
     1325    /* if (*plCurPelsOfs < 0)
     1326        *plCurPelsOfs = 0; */       // checked above
     1327    if (*pulCurPelsOfs > (lMaxAllowedUnitOfs * usScrollUnitPels))
    13091328    {
    13101329        // _Pmpf(("        !!! limiting 2: %d to %d", *plCurUnitOfs, lMaxAllowedUnitOfs));
    1311         *plCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels);
    1312     }
    1313     if (    (*plCurPelsOfs != lOldPelsOfs)
    1314          || (*plCurPelsOfs == 0)
    1315          || (*plCurPelsOfs == (lMaxAllowedUnitOfs * usScrollUnitPels))
     1330        *pulCurPelsOfs = (lMaxAllowedUnitOfs * usScrollUnitPels);
     1331    }
     1332    if (    (*pulCurPelsOfs != ulOldPelsOfs)
     1333         || (*pulCurPelsOfs == 0)
     1334         || (*pulCurPelsOfs == (lMaxAllowedUnitOfs * usScrollUnitPels))
    13161335       )
    13171336    {
     
    13221341        WinSendMsg(hwndScrollBar,
    13231342                   SBM_SETPOS,
    1324                    (MPARAM)(*plCurPelsOfs / usScrollUnitPels), //  / usScrollUnit),
     1343                   (MPARAM)(*pulCurPelsOfs / usScrollUnitPels), //  / usScrollUnit),
    13251344                   0);
    13261345        // scroll window rectangle:
     
    13331352            WinScrollWindow(hwnd2Scroll,
    13341353                            0,
    1335                             (*plCurPelsOfs - lOldPelsOfs)  // scroll units changed
     1354                            (*pulCurPelsOfs - ulOldPelsOfs)  // scroll units changed
    13361355                            ,    // * usScrollUnitPels,     // convert to pels
    13371356                            &rcl2Scroll,  // rcl to scroll
     
    13421361        else
    13431362            WinScrollWindow(hwnd2Scroll,
    1344                             -(*plCurPelsOfs - lOldPelsOfs) // scroll units changed
     1363                            -(LONG)(*pulCurPelsOfs - ulOldPelsOfs) // scroll units changed
    13451364                            ,    // * usScrollUnitPels,
    13461365                            0,
     
    15551574BOOL winhSaveWindowPos(HWND hwnd,   // in: window to save
    15561575                       HINI hIni,   // in: INI file (or HINI_USER/SYSTEM)
    1557                        PSZ pszApp,  // in: INI application name
    1558                        PSZ pszKey)  // in: INI key name
     1576                       const char *pcszApp,  // in: INI application name
     1577                       const char *pcszKey)  // in: INI key name
    15591578{
    15601579    BOOL brc = FALSE;
     
    15721591        }
    15731592
    1574         brc = PrfWriteProfileData(hIni, pszApp, pszKey, &swp, sizeof(swp));
     1593        brc = PrfWriteProfileData(hIni, (PSZ)pcszApp, (PSZ)pcszKey, &swp, sizeof(swp));
    15751594    }
    15761595    return (brc);
     
    16141633BOOL winhRestoreWindowPos(HWND hwnd,   // in: window to restore
    16151634                          HINI hIni,   // in: INI file (or HINI_USER/SYSTEM)
    1616                           PSZ pszApp,  // in: INI application name
    1617                           PSZ pszKey,  // in: INI key name
     1635                          const char *pcszApp,  // in: INI application name
     1636                          const char *pcszKey,  // in: INI key name
    16181637                          ULONG fl)    // in: "fl" parameter for WinSetWindowPos
    16191638{
     
    16231642    ULONG   fl2 = (fl & ~SWP_ZORDER);
    16241643
    1625     if (PrfQueryProfileData(hIni, pszApp, pszKey, &swp, &cbswp))
     1644    if (PrfQueryProfileData(hIni, (PSZ)pcszApp, (PSZ)pcszKey, &swp, &cbswp))
    16261645    {
    16271646        ULONG ulScreenCX = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
     
    23412360 */
    23422361
    2343 HWND winhCreateHelp(HWND    hwndFrame,      // in: app's frame window handle; can be NULLHANDLE
    2344                     PSZ     pszFileName,    // in: help file name or NULL
     2362HWND winhCreateHelp(HWND hwndFrame,      // in: app's frame window handle; can be NULLHANDLE
     2363                    const char *pcszFileName,    // in: help file name or NULL
    23452364                    HMODULE hmod,           // in: module with help table or NULLHANDLE (current)
    23462365                    PHELPTABLE pHelpTable,  // in: help table or resource ID
    2347                     PSZ     pszWindowTitle) // in: help window title or NULL
     2366                    const char *pcszWindowTitle) // in: help window title or NULL
    23482367{
    23492368    PPIB     ppib;
     
    23542373    HWND     hwndHelp;
    23552374
    2356     if (     (pszFileName == NULL)
     2375    if (     (pcszFileName == NULL)
    23572376          // || (*pszFileName)
    23582377       )
     
    23682387            strcat(szName, ".hlp");
    23692388
    2370         pszFileName = szName;
     2389        pcszFileName = szName;
    23712390    }
    23722391
     
    23792398    hi.idAccelTable             = 0;
    23802399    hi.idActionBar              = 0;
    2381     hi.pszHelpWindowTitle       = pszWindowTitle;
     2400    hi.pszHelpWindowTitle       = (PSZ)pcszWindowTitle;
    23822401    hi.fShowPanelId             = CMIC_HIDE_PANEL_ID;
    2383     hi.pszHelpLibraryName       = pszFileName;
     2402    hi.pszHelpLibraryName       = (PSZ)pcszFileName;
    23842403
    23852404    hwndHelp = WinCreateHelpInstance(WinQueryAnchorBlock(hwndFrame),
     
    27832802 */
    27842803
    2785 BOOL winhAnotherInstance(PSZ pszSemName,    // in: semaphore ID
     2804BOOL winhAnotherInstance(const char *pcszSemName,    // in: semaphore ID
    27862805                         BOOL fSwitch)      // in: if TRUE, switch to first instance if running
    27872806{
    27882807    HMTX hmtx;
    27892808
    2790     if (DosCreateMutexSem(pszSemName,
     2809    if (DosCreateMutexSem((PSZ)pcszSemName,
    27912810                          &hmtx,
    27922811                          DC_SEM_SHARED,
     
    28042823    {
    28052824        // yes: query mutex creator
    2806         if (DosOpenMutexSem(pszSemName,
     2825        if (DosOpenMutexSem((PSZ)pcszSemName,
    28072826                            &hmtx)
    28082827                    == NO_ERROR)
     
    29662985                                    // -- WINH_FOD_INISAVEDIR: store FOD path to INI on OK
    29672986                 HINI hini,         // in: INI file to load/store last path from (can be HINI_USER)
    2968                  PSZ pszApplication, // in: INI application to load/store last path from
    2969                  PSZ pszKey)        // in: INI key to load/store last path from
     2987                 const char *pcszApplication, // in: INI application to load/store last path from
     2988                 const char *pcszKey)        // in: INI key to load/store last path from
    29702989{
    29712990    FILEDLG fd;
     
    29863005        // overwrite with initial directory for FOD from OS2.INI
    29873006        if (PrfQueryProfileString(hini,
    2988                                   pszApplication,
    2989                                   pszKey,
     3007                                  (PSZ)pcszApplication,
     3008                                  (PSZ)pcszKey,
    29903009                                  "",      // default string
    29913010                                  fd.szFullFile,
     
    30203039                {
    30213040                    PrfWriteProfileString(hini,
    3022                                           pszApplication,
    3023                                           pszKey, // "XWPSound:LastDir"
     3041                                          (PSZ)pcszApplication,
     3042                                          (PSZ)pcszKey,
    30243043                                          pszDir);
    30253044                    free(pszDir);
     
    31013120
    31023121BOOL winhReplaceWindowText(HWND hwnd,           // in: window whose text is to be modified
    3103                            PSZ pszSearch,       // in: search string (e.g. "%1")
    3104                            PSZ pszReplaceWith)  // in: replacement string for pszSearch
     3122                           const char *pcszSearch,       // in: search string (e.g. "%1")
     3123                           const char *pcszReplaceWith)  // in: replacement string for pszSearch
    31053124{
    31063125    BOOL    brc = FALSE;
     
    31093128    {
    31103129        ULONG ulOfs = 0;
    3111         if (strhFindReplace(&pszText, &ulOfs, pszSearch, pszReplaceWith) > 0)
     3130        if (strhFindReplace(&pszText, &ulOfs, pcszSearch, pcszReplaceWith) > 0)
    31123131        {
    31133132            WinSetWindowText(hwnd, pszText);
     
    31973216                         ULONG flFrameCreateFlags,  // in: FCF_* flags
    31983217                         ULONG ulFrameStyle,        // in: WS_* flags (e.g. WS_VISIBLE, WS_ANIMATE)
    3199                          PSZ pszFrameTitle,
     3218                         const char *pcszFrameTitle,
    32003219                         ULONG ulResourcesID,       // in: according to FCF_* flags
    3201                          PSZ pszClassClient,
     3220                         const char *pcszClassClient,
    32023221                         ULONG flStyleClient,
    32033222                         ULONG ulID,                // in: frame window ID
     
    32173236    hwndFrame = WinCreateWindow(hwndFrameParent,
    32183237                                WC_FRAME,
    3219                                 pszFrameTitle,
     3238                                (PSZ)pcszFrameTitle,
    32203239                                ulFrameStyle,
    32213240                                0,0,0,0,         // size and position = 0
     
    32293248    {
    32303249        *phwndClient = WinCreateWindow(hwndFrame,      // parent
    3231                                        pszClassClient, // class
     3250                                       (PSZ)pcszClassClient, // class
    32323251                                       NULL,           // no title
    32333252                                       flStyleClient,  // style
     
    32733292    }
    32743293    return (hwndFrame);
     3294}
     3295
     3296/*
     3297 *@@ winhCreateObjectWindow:
     3298 *      creates an object window of the specified
     3299 *      window class, which you should have registered
     3300 *      before calling this. pvCreateParam will be
     3301 *      given to the window on WM_CREATE.
     3302 *
     3303 *      Returns the HWND of the object window or
     3304 *      NULLHANDLE on errors.
     3305 *
     3306 *@@added V0.9.3 (2000-04-17) [umoeller]
     3307 *@@changed V0.9.7 (2001-01-17) [umoeller]: made this a function from a macro
     3308 */
     3309
     3310HWND winhCreateObjectWindow(const char *pcszWindowClass,    // in: PM window class name
     3311                            PVOID pvCreateParam)            // in: create param
     3312{
     3313    return (WinCreateWindow(HWND_OBJECT,
     3314                            (PSZ)pcszWindowClass,
     3315                            (PSZ)"",
     3316                            0,
     3317                            0,0,0,0,
     3318                            0,
     3319                            HWND_BOTTOM,
     3320                            0,
     3321                            pvCreateParam,
     3322                            NULL));
    32753323}
    32763324
     
    35703618 *
    35713619 *      After this function returns, *prcl is modified like this:
     3620 *
    35723621 *      -- yTop and yBottom contain the upper and lower boundaries
    35733622 *         which were needed to draw the text. This depends on
     
    35973646                            PRECTL prcl, // in/out: rectangle to use for drawing
    35983647                                         // (modified)
    3599                             PSZ pszText, // in: text to draw (zero-terminated)
     3648                            const char *pcszText, // in: text to draw (zero-terminated)
    36003649                            ULONG flCmd) // in: flags like in WinDrawText; I have
    36013650                                         // only tested DT_TOP and DT_LEFT though.
     
    36053654                                         // have prcl calculated without drawing.
    36063655{
    3607     PSZ     p = pszText;
     3656    PSZ     p = (PSZ)pcszText;
    36083657    LONG    lDrawn = 1,
    36093658            lTotalDrawn = 0,
    36103659            lLineCount = 0,
    36113660            lOrigYTop = prcl->yTop;
    3612     ULONG   ulTextLen = strlen(pszText),
     3661    ULONG   ulTextLen = strlen(pcszText),
    36133662            ulCharHeight,
    36143663            flCmd2,
Note: See TracChangeset for help on using the changeset viewer.