Changeset 201 for trunk


Ignore:
Timestamp:
Aug 11, 2002, 7:07:59 PM (23 years ago)
Author:
umoeller
Message:

Major work on textview control and dialogs.

Location:
trunk
Files:
13 edited

Legend:

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

    r153 r201  
    116116                                    PULONG pulExitCode);
    117117
    118         HAPP XWPENTRY appQuickStartApp(const char *pcszFile,
    119                                        ULONG ulProgType,
    120                                        const char *pcszArgs,
    121                                        PULONG pulExitCode);
     118        HAPP appQuickStartApp(const char *pcszFile,
     119                              ULONG ulProgType,
     120                              const char *pcszArgs,
     121                              const char *pcszWorkingDir,
     122                              PULONG pulExitCode);
     123
     124        BOOL appOpenURL(PCSZ pcszURL);
    122125
    123126    #endif
  • trunk/include/helpers/dialog.h

    r198 r201  
    430430            id, CTL_COMMON_FONT, 0, {cx, cy}, COMMON_SPACING, pctldata }
    431431
     432    // the following require #include helpers\textview.h
     433
     434    #define CONTROLDEF_XTEXTVIEW(text, id, cx, pctldata) { WC_XTEXTVIEW, text, \
     435            WS_VISIBLE | XS_STATIC | XS_WORDWRAP, \
     436            id, CTL_COMMON_FONT, 0, {cx, SZL_AUTOSIZE}, COMMON_SPACING, pctldata }
     437
     438    #define CONTROLDEF_XTEXTVIEW_HTML(text, id, cx, pctldata) { WC_XTEXTVIEW, text, \
     439            WS_VISIBLE | XS_STATIC | XS_WORDWRAP | XS_HTML, \
     440            id, CTL_COMMON_FONT, 0, {cx, SZL_AUTOSIZE}, COMMON_SPACING, pctldata }
     441
    432442    /* ******************************************************************
    433443     *
  • trunk/include/helpers/textv_html.h

    r113 r201  
    3737     ********************************************************************/
    3838
    39     /*
    40      *@@ XHTMLLINK:
    41      *      describes a link.
    42      *
    43      *@@added V0.9.3 (2000-05-19) [umoeller]
    44      */
    45 
    46     typedef struct _XHTMLLINK
    47     {
    48         USHORT      usLinkIndex;        // >= 1; this is stored in the XTextView control
    49         PSZ         pszTargetFile;      // target file (HREF="...") without anchors;
    50                                         // this is NULL if the target is an anchor only
    51                                         // (HREF="#anchor")
    52         PSZ         pszTargetAnchor;    // anchor in target file; this is NULL if the
    53                                         // target has no anchor
    54     } XHTMLLINK, *PXHTMLLINK;
    55 
    56     #ifdef LINKLIST_HEADER_INCLUDED
    57         /*
    58          *@@ XHTMLDATA:
    59          *      for storing output from txvConvertFromHTML.
    60          *
    61          *@@added V0.9.3 (2000-05-19) [umoeller]
    62          */
    63 
    64         typedef struct _XHTMLDATA
    65         {
    66             PSZ         pszTitle;           // contents of TITLE tag (must be freed)
    67             LINKLIST    llLinks;            // list of XHTMLLINK structures; empty if none
    68                                             // (auto-free mode; use lstClear)
    69         } XHTMLDATA, *PXHTMLDATA;
    70     #endif
    71 
    72     BOOL txvConvertFromHTML(char **ppszText,
    73                             PVOID pxhtml,
     39    BOOL txvConvertFromHTML(PSZ *ppszText,
     40                            PSZ *ppszTitle,
    7441                            PULONG pulProgress,
    7542                            PBOOL pfCancel);
    76 
    7743#endif
    7844
  • trunk/include/helpers/textview.h

    r113 r201  
    7575
    7676    // links
    77     #define TXVESC_LINK             TXVESC_STRING "\x06"
    78                 // here follow four characters with the
    79                 // link index in hex (0001-FFFF);
    80                 // "####" means end of link
    81                 // --> total size: 6
    82 
    83     #define TXVESC_ANCHORNAME       TXVESC_STRING "\x07"
     77    #define TXVESC_LINK_BEGIN       TXVESC_STRING "\x06"
     78                // here follows the link reference, which
     79                // is variable in length and must be terminated
     80                // with another 0xFF escape code (NOT null byte);
     81                // --> total size: 2 plus link name length
     82                //      plus 1 for 0xFF terminator
     83
     84    #define TXVESC_LINK_END         TXVESC_STRING "\x07"
     85                // end of the link
     86                // --> total size: 2
     87
     88    #define TXVESC_ANCHORNAME       TXVESC_STRING "\x08"
    8489                // here follows the anchor name, which is
    8590                // variable in length and must be terminated
     
    223228        LONG        lPointSize;     // point size to use for this rectangle;
    224229                                    // this is set to 0 for bitmap fonts
    225         ULONG       flOptions;      // flOptions parameter for GpiCharStringPosAt;
     230        ULONG       flChar;         // flOptions parameter for GpiCharStringPosAt;
    226231                                    // this will only have the CHS_UNDERSCORE or
    227232                                    // CHS_STRIKEOUT flags set
    228233
    229         USHORT      usAnchor;       // != 0 if this word belongs to an anchor
     234        PSZ         pszLinkTarget;  // if != NULL, pointer to a string in XFORMATDATA.llLinks;
     235                                    // the word is then part of a link
     236                                    // V0.9.20 (2002-08-10) [umoeller]
     237
    230238    } TXVWORD, *PTXVWORD;
    231239
     
    364372                                // to the words stored in this list.
    365373
    366             ULONG       ulViewportCX,   // width of viewport (total text space)
    367                         ulViewportCY;   // height of viewport (total text space)
     374            SIZEL       szlWorkspace;   // width and height of viewport (total text space)
     375
     376            LINKLIST    llLinks;
     377                                // list of malloc'd PSZ's (auto-free) with all
     378                                // the links encountered while parsing the text.
     379                                // These are needed for passing the correct link
     380                                // target names when the user clicks on one.
     381                                // V0.9.20 (2002-08-10) [umoeller]
    368382
    369383        } XFORMATDATA, *PXFORMATDATA;
     
    400414    #define TXM_SETCDATA                    (WM_USER + 1026)
    401415    #define TXM_JUMPTOANCHORNAME            (WM_USER + 1027)
     416    #define TXM_QUERYTEXTEXTENT             (WM_USER + 1028)
    402417
    403418    #define WC_XTEXTVIEW     "XTextViewClass"
     
    417432     *      -- USHORT SHORT1FROMMP(mp1): id of the control.
    418433     *      -- USHORT SHORT2FROMMP(mp1): nofify code (TXVN_LINK).
    419      *      -- USHORT mp2: index of anchor (1 >= index > 0xFFFF).
     434     *      -- const char *mp2: link target.
    420435     *
    421436     *@@added V0.9.3 (2000-05-18) [umoeller]
     
    425440
    426441    /*
    427      * XTextView style flags:
    428      *
    429      */
    430 
    431     #define XTXF_VSCROLL        0x0100
    432     #define XTXF_HSCROLL        0x0200
    433     #define XTXF_AUTOVHIDE      0x0400
    434     #define XTXF_AUTOHHIDE      0x0800
     442     * XTextView window style flags:
     443     *      all renamed, all turned into window style flags
     444     */
     445
     446    #define XS_VSCROLL          0x0001      // show vertical scroll bar
     447    #define XS_HSCROLL          0x0002      // show horizontal scroll bar
     448    #define XS_AUTOVHIDE        0x0004      // with XTXF_VSCROLL: automatically hide scrollbar
     449    #define XS_AUTOHHIDE        0x0008      // with XTXF_HSCROLL: automatically hide scrollbar
     450
     451    // handy macro V0.9.20 (2002-08-10) [umoeller]
     452    #define XS_FULLSCROLL       (XS_VSCROLL | XS_HSCROLL | XS_AUTOVHIDE | XS_AUTOHHIDE)
     453
     454    #define XS_WORDWRAP         0x0010
     455                // enable word-wrapping in the default paragraph
     456                // format from the start
     457
     458    #define XS_STATIC           0x0020
     459                // behave like static control: no focus, be skipped
     460                // over with tabbing in dialogs
     461                // V0.9.20 (2002-08-10) [umoeller]
     462
     463    #define XS_FORMAT_MASK      0x0700
     464    #define XS_PREFORMATTED     0x0000      // plain text with \n only plus \xFF escape codes
     465                                            // (no conversion performed)
     466    #define XS_PLAINTEXT        0x0100      // plain text with \r and \xFF chars that need conversion
     467    #define XS_HTML             0x0200      // HTML
    435468
    436469    /*
     
    446479    {
    447480        USHORT      cbData;
    448         ULONG       flStyle;
    449                 // XTXF_* flags:
    450                 // --  XTXF_VSCROLL: show vertical scroll bar.
    451                 // --  XTXF_HSCROLL: show horizontal scroll bar.
    452                 // --  XTXF_AUTOVHIDE: with XTXF_VSCROLL: automatically hide scrollbar.
    453                 // --  XTXF_AUTOHHIDE: with XTXF_HSCROLL: automatically hide scrollbar.
    454481        ULONG       ulXBorder,
    455482                // space to leave on the left and right of text view;
     
    472499                                USHORT usID,
    473500                                ULONG flWinStyle,
    474                                 ULONG flStyle,
    475501                                USHORT usBorder);
    476502
  • trunk/src/helpers/apps.c

    r196 r201  
    3939
    4040#define INCL_WINPROGRAMLIST     // needed for PROGDETAILS, wppgm.h
     41#define INCL_WINSHELLDATA
    4142#define INCL_WINERRORS
    4243#define INCL_SHLERRORS
     
    11461147 *@@added V0.9.18 (2002-03-27) [umoeller]
    11471148 *@@changed V0.9.19 (2002-03-28) [umoeller]: now allocating contiguous buffer
     1149 *@@changed V0.9.20 (2002-07-03) [umoeller]: fixed Win-OS/2 full screen breakage
     1150 *@@changed V0.9.20 (2002-07-03) [umoeller]: fixed broken bat and cmd files when PROG_DEFAULT was set
    11481151 */
    11491152
     
    11631166
    11641167    if (!pcProgDetails && !ppDetails)
    1165         return (ERROR_INVALID_PARAMETER);
     1168        return ERROR_INVALID_PARAMETER;
    11661169
    11671170    /*
     
    13861389        {
    13871390            if (    (ulIsWinApp)
    1388                  && (    (Details.pszEnvironment == NULL)
    1389                       || (!strlen(Details.pszEnvironment))
     1391                 && (    (!(Details.pszEnvironment))
     1392                      || (!(*Details.pszEnvironment))
    13901393                    )
    13911394               )
     
    17291732
    17301733    if (!pcProgDetails)
    1731         return (ERROR_INVALID_PARAMETER);
     1734        return ERROR_INVALID_PARAMETER;
    17321735
    17331736    if (pszFailingName)
     
    19331936
    19341937    if (!phapp)
    1935         return (ERROR_INVALID_PARAMETER);
     1938        return ERROR_INVALID_PARAMETER;
    19361939
    19371940    if (!(arc = appBuildProgDetails(&pDetails,
     
    20152018/*
    20162019 *@@ appQuickStartApp:
    2017  *      shortcut for simply starting an app and
    2018  *      waiting until it's finished.
     2020 *      shortcut for simply starting an app.
    20192021 *
    20202022 *      On errors, NULLHANDLE is returned.
    20212023 *
    2022  *      If pulReturnCode != NULL, it receives the
    2023  *      return code of the app.
     2024 *      Only if pulExitCode != NULL, we wait for
     2025 *      the app to complete and return the
     2026 *      exit code.
    20242027 *
    20252028 *@@added V0.9.16 (2001-10-19) [umoeller]
     2029 *@@changed V0.9.20 (2002-08-10) [umoeller]: fixed missing destroy window, made wait optional
     2030 *@@changed V0.9.20 (2002-08-10) [umoeller]: added pcszWorkingDir
    20262031 */
    20272032
    20282033HAPP appQuickStartApp(const char *pcszFile,
    2029                       ULONG ulProgType,         // e.g. PROG_PM
    2030                       const char *pcszArgs,
    2031                       PULONG pulExitCode)
     2034                      ULONG ulProgType,             // e.g. PROG_PM
     2035                      const char *pcszArgs,         // in: arguments (can be NULL)
     2036                      const char *pcszWorkingDir,   // in: working dir (can be NULL)
     2037                      PULONG pulExitCode)           // out: exit code; if ptr is NULL, we don't wait
    20322038{
    20332039    PROGDETAILS    pd = {0};
     
    20432049    pd.pszExecutable = (PSZ)pcszFile;
    20442050    pd.pszParameters = (PSZ)pcszArgs;
    2045     if (p = strrchr(pcszFile, '\\'))
     2051
     2052    if (    (!(pd.pszStartupDir = (PSZ)pcszWorkingDir))
     2053         && (p = strrchr(pcszFile, '\\'))
     2054       )
    20462055    {
    20472056        strhncpy0(szDir,
     
    20602069       )
    20612070    {
    2062         if (appWaitForApp(hwndObject,
     2071        if (pulExitCode)
     2072            appWaitForApp(hwndObject,
    20632073                          happ,
    2064                           pulExitCode))
    2065             happReturn = happ;
     2074                          pulExitCode);
     2075
     2076        happReturn = happ;
     2077
     2078        WinDestroyWindow(hwndObject);       // was missing V0.9.20 (2002-08-10) [umoeller]
    20662079    }
    20672080
    20682081    return happReturn;
    20692082}
     2083
     2084/*
     2085 *@@ appOpenURL:
     2086 *      opens the system default browser with the given
     2087 *      URL.
     2088 *
     2089 *@@added V0.9.20 (2002-08-10) [umoeller]
     2090 */
     2091
     2092BOOL appOpenURL(PCSZ pcszURL)
     2093{
     2094    BOOL        brc = FALSE;
     2095
     2096    CHAR        szBrowser[CCHMAXPATH],
     2097                szStartupDir[CCHMAXPATH];
     2098    XSTRING     strParameters;
     2099
     2100    xstrInit(&strParameters, 0);
     2101
     2102    if (PrfQueryProfileString(HINI_USER,
     2103                              "WPURLDEFAULTSETTINGS",
     2104                              "DefaultBrowserExe",
     2105                              "NETSCAPE.EXE",
     2106                              szBrowser,
     2107                              sizeof(szBrowser)))
     2108    {
     2109        PSZ pszDefParams;
     2110
     2111        if (pszDefParams = prfhQueryProfileData(HINI_USER,
     2112                                                "WPURLDEFAULTSETTINGS",
     2113                                                "DefaultParameters",
     2114                                                NULL))
     2115        {
     2116            xstrcpy(&strParameters, pszDefParams, 0);
     2117            xstrcatc(&strParameters, ' ');
     2118            free(pszDefParams);
     2119        }
     2120
     2121        xstrcat(&strParameters, pcszURL, 0);
     2122
     2123        PrfQueryProfileString(HINI_USER,
     2124                              "WPURLDEFAULTSETTINGS",
     2125                              "DefaultWorkingDir",
     2126                              "",
     2127                              szStartupDir,
     2128                              sizeof(szStartupDir));
     2129
     2130
     2131        brc = !!appQuickStartApp(szBrowser,
     2132                                 PROG_DEFAULT,
     2133                                 strParameters.psz,
     2134                                 szStartupDir,
     2135                                 NULL);            // don't wait
     2136    }
     2137
     2138    xstrClear(&strParameters);
     2139
     2140    return brc;
     2141}
  • trunk/src/helpers/dialog.c

    r199 r201  
    8080#include "helpers\standards.h"
    8181#include "helpers\stringh.h"
     82#include "helpers\textview.h"
    8283#include "helpers\winh.h"
    8384#include "helpers\xstring.h"
     
    118119
    119120    POINTL      ptlTotalOfs;
     121
     122    LINKLIST    llTempControls;         // linked list of HWNDs that were
     123                                        // created temporarily to determine
     124                                        // control sizes for SZL_AUTOSIZE
     125                                        // V0.9.20 (2002-08-10) [umoeller]
    120126
    121127    PLINKLIST   pllControls;            // linked list of HWNDs in the order
     
    365371        {
    366372            RECTL rcl = {0, 0, 0, 0};
    367             /*
    368             if (pControlDef->szlControlProposed.cx > 0)
    369                 rcl.xRight = pControlDef->szlControlProposed.cx;   // V0.9.12 (2001-05-31) [umoeller]
    370             else
    371                 rcl.xRight = winhQueryScreenCX() * 2 / 3;
    372             */
    373373            rcl.xRight = ulWidth;
    374374            if (pControlDef->szlDlgUnits.cy > 0)
     
    488488
    489489        default:
    490             // any other control (just to be safe):
    491             SetDlgFont(pControlDef, pDlgData);
    492             pszlAuto->cx = 50;
    493             pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
    494                            + pDlgData->fmLast.lExternalLeading
    495                            + 7;         // some space
     490            if (!strcmp(pControlDef->pcszClass, WC_XTEXTVIEW))
     491            {
     492                HWND hwnd = NULLHANDLE;
     493                PCSZ pcszTitle;
     494
     495                PLISTNODE pTempNode;
     496                HWND hwndFound = NULLHANDLE;
     497                FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode)
     498                {
     499                    HWND hwndThis = (HWND)pTempNode->pItemData;
     500                    if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID)
     501                    {
     502                        hwnd = hwndThis;
     503
     504                        // resize it to what we really need
     505                        WinSetWindowPos(hwndThis,
     506                                        HWND_BOTTOM,
     507                                        0,
     508                                        0,
     509                                        ulWidth,
     510                                        2000,
     511                                        SWP_SIZE);
     512                        break;
     513                    }
     514                }
     515
     516                if (!hwnd)
     517                {
     518                    if (hwnd = WinCreateWindow(pDlgData->hwndDlg,   // parent
     519                                               (PSZ)pControlDef->pcszClass,
     520                                               NULL,
     521                                               pControlDef->flStyle,
     522                                               0,
     523                                               0,
     524                                               ulWidth,
     525                                               2000,         // cy, for now
     526                                               pDlgData->hwndDlg,   // owner
     527                                               HWND_BOTTOM,
     528                                               pControlDef->usID,
     529                                               pControlDef->pvCtlData,
     530                                               NULL))
     531                    {
     532                        PCSZ pcszFont = pControlDef->pcszFont;
     533                                        // can be NULL, or CTL_COMMON_FONT
     534                        if (pcszFont == CTL_COMMON_FONT)
     535                            pcszFont = pDlgData->pcszControlsFont;
     536
     537                        if (pcszFont)
     538                            winhSetWindowFont(hwnd,
     539                                              pcszFont);
     540
     541                        WinSetWindowText(hwnd,
     542                                         (pcszTitle = pControlDef->pcszText)
     543                                             ? (PSZ)pcszTitle
     544                                             : "");
     545
     546                        // store the window we have created in the temp
     547                        // windows list so it can be reused in
     548                        // ColumnCreateControls
     549                        lstAppendItem(&pDlgData->llTempControls,
     550                                      (PVOID)hwnd);
     551                    }
     552                    else
     553                        arc = DLGERR_CANNOT_CREATE_CONTROL;
     554                }
     555
     556                if (hwnd)
     557                {
     558                    SIZEL szlTemp;
     559                    WinSendMsg(hwnd,
     560                               TXM_QUERYTEXTEXTENT,
     561                               (MPARAM)&szlTemp,
     562                               0);
     563
     564                    pszlAuto->cy = szlTemp.cy;
     565                }
     566            }
     567            else
     568            {
     569                // any other control (just to be safe):
     570                SetDlgFont(pControlDef, pDlgData);
     571                pszlAuto->cx = 50;
     572                pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
     573                               + pDlgData->fmLast.lExternalLeading
     574                               + 7;         // some space
     575            }
    496576    }
    497577
     
    9581038    {
    9591039        // create something:
    960         PCSZ pcszFont = pControlDef->pcszFont;
    961                         // can be NULL, or CTL_COMMON_FONT
    962         if (pcszFont == CTL_COMMON_FONT)
    963             pcszFont = pDlgData->pcszControlsFont;
    964 
    965         if (pColumnDef->hwndControl
    966             = WinCreateWindow(pDlgData->hwndDlg,   // parent
    967                               (PSZ)pcszClass,   // hacked
    968                               (pcszTitle)   // hacked
    969                                     ? (PSZ)pcszTitle
    970                                     : "",
    971                               flStyle,      // hacked
    972                               x,
    973                               y,
    974                               cx,
    975                               cy,
    976                               pDlgData->hwndDlg,   // owner
    977                               HWND_BOTTOM,
    978                               pControlDef->usID,
    979                               pControlDef->pvCtlData,
    980                               NULL))
    981         {
     1040
     1041        // check if we have the window on the temp list from
     1042        // CalcAutoSize V0.9.20 (2002-08-10) [umoeller]
     1043        PLISTNODE pTempNode;
     1044        HWND hwndFound = NULLHANDLE;
     1045        FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode)
     1046        {
     1047            HWND hwndThis = (HWND)pTempNode->pItemData;
     1048            if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID)
     1049            {
     1050                hwndFound
     1051                    = pColumnDef->hwndControl
     1052                    = hwndThis;
     1053
     1054                // resize it to what we really need
     1055                WinSetWindowPos(hwndThis,
     1056                                HWND_BOTTOM,
     1057                                x,
     1058                                y,
     1059                                cx,
     1060                                cy,
     1061                                SWP_SIZE | SWP_MOVE | SWP_ZORDER);
     1062
     1063                lstRemoveNode(&pDlgData->llTempControls, pTempNode);
     1064                break;
     1065            }
     1066        }
     1067
     1068        if (    (!hwndFound)
     1069             && (!(pColumnDef->hwndControl = WinCreateWindow(pDlgData->hwndDlg,   // parent
     1070                                                             (PSZ)pcszClass,   // hacked
     1071                                                             (pcszTitle)   // hacked
     1072                                                                   ? (PSZ)pcszTitle
     1073                                                                   : "",
     1074                                                             flStyle,      // hacked
     1075                                                             x,
     1076                                                             y,
     1077                                                             cx,
     1078                                                             cy,
     1079                                                             pDlgData->hwndDlg,   // owner
     1080                                                             HWND_BOTTOM,
     1081                                                             pControlDef->usID,
     1082                                                             pControlDef->pvCtlData,
     1083                                                             NULL)))
     1084           )
     1085            arc = DLGERR_CANNOT_CREATE_CONTROL;
     1086
     1087        if (!arc)
     1088        {
     1089            PCSZ pcszFont = pControlDef->pcszFont;
     1090                            // can be NULL, or CTL_COMMON_FONT
     1091            if (pcszFont == CTL_COMMON_FONT)
     1092                pcszFont = pDlgData->pcszControlsFont;
     1093
     1094            if (lHandleSet)
     1095            {
     1096                // subclass the damn static
     1097                if ((flOld & 0x0F) == SS_ICON)
     1098                    // this was a static:
     1099                    ctlPrepareStaticIcon(pColumnDef->hwndControl,
     1100                                         1);
     1101                else
     1102                    // this was a bitmap:
     1103                    ctlPrepareStretchedBitmap(pColumnDef->hwndControl,
     1104                                              TRUE);
     1105
     1106                WinSendMsg(pColumnDef->hwndControl,
     1107                           SM_SETHANDLE,
     1108                           (MPARAM)lHandleSet,
     1109                           0);
     1110            }
     1111            else if (pcszFont)
     1112                // we must set the font explicitly here...
     1113                // doesn't always work with WinCreateWindow
     1114                // presparams parameter, for some reason
     1115                // V0.9.12 (2001-05-31) [umoeller]
     1116                winhSetWindowFont(pColumnDef->hwndControl,
     1117                                  pcszFont);
     1118
    9821119#ifdef DEBUG_DIALOG_WINDOWS
    9831120            {
     
    10201157            }
    10211158#endif
    1022 
    1023             if (lHandleSet)
    1024             {
    1025                 // subclass the damn static
    1026                 if ((flOld & 0x0F) == SS_ICON)
    1027                     // this was a static:
    1028                     ctlPrepareStaticIcon(pColumnDef->hwndControl,
    1029                                          1);
    1030                 else
    1031                     // this was a bitmap:
    1032                     ctlPrepareStretchedBitmap(pColumnDef->hwndControl,
    1033                                               TRUE);
    1034 
    1035                 WinSendMsg(pColumnDef->hwndControl,
    1036                            SM_SETHANDLE,
    1037                            (MPARAM)lHandleSet,
    1038                            0);
    1039             }
    1040             else
    1041                 if (pcszFont)
    1042                     // we must set the font explicitly here...
    1043                     // doesn't always work with WinCreateWindow
    1044                     // presparams parameter, for some reason
    1045                     // V0.9.12 (2001-05-31) [umoeller]
    1046                     winhSetWindowFont(pColumnDef->hwndControl,
    1047                                       pcszFont);
    1048 
    10491159            // append window that was created
    10501160            // V0.9.18 (2002-03-03) [umoeller]
     
    12601370                        PROWDEF     pRowThis = (PROWDEF)pRowNode->pItemData;
    12611371                        PCOLUMNDEF  pCorrespondingColumn;
    1262                         if (    (pCorrespondingColumn = lstItemFromIndex(&pRowThis->llColumns, ulMyIndex))
     1372                        if (    (pCorrespondingColumn = (PCOLUMNDEF)lstItemFromIndex(&pRowThis->llColumns,
     1373                                                                                     ulMyIndex))
    12631374                             && (pCorrespondingColumn->cpColumn.cx > pColumnDef->cpColumn.cx)
    12641375                           )
     
    13571468            }
    13581469        }
     1470        // we should stop on errors V0.9.20 (2002-08-10) [umoeller]
     1471        else
     1472            break;
    13591473    }
    13601474
     
    15261640            }
    15271641        }
     1642        // we should stop on errors V0.9.20 (2002-08-10) [umoeller]
     1643        else
     1644            break;
    15281645    }
    15291646
     
    16511768    ZERO(pDlgData);
    16521769    lstInit(&pDlgData->llTables, FALSE);
     1770
     1771    lstInit(&pDlgData->llTempControls, FALSE);     // V0.9.20 (2002-08-10) [umoeller]
    16531772
    16541773    if (pllControls)
     
    19042023 *@@added V0.9.15 (2001-08-26) [umoeller]
    19052024 *@@changed V0.9.15 (2001-08-26) [umoeller]: BS_DEFAULT for other than first button was ignored, fixed
     2025 *@@changed V0.9.20 (2002-08-10) [umoeller]: return code checking was missing, fixed
    19062026 */
    19072027
     
    19162036     */
    19172037
    1918     ProcessAll(pDlgData,
    1919                PROCESS_4_CALC_POSITIONS);
    1920 
    1921     /*
    1922      *  6) create control windows, finally
    1923      *
    1924      */
    1925 
    1926     pDlgData->ptlTotalOfs.x = DLG_OUTER_SPACING_X * FACTOR_X;
    1927     pDlgData->ptlTotalOfs.y = DLG_OUTER_SPACING_Y * FACTOR_Y;
    1928 
    1929     ProcessAll(pDlgData,
    1930                PROCESS_5_CREATE_CONTROLS);
    1931 
    1932     if (pDlgData->hwndDefPushbutton)
    1933     {
    1934         // we had a default pushbutton:
    1935         // go set it V0.9.14 (2001-08-21) [umoeller]
    1936         WinSetWindowULong(pDlgData->hwndDlg,
    1937                           QWL_DEFBUTTON,
    1938                           pDlgData->hwndDefPushbutton);
    1939         *phwndFocusItem = pDlgData->hwndDefPushbutton;
    1940                 // V0.9.15 (2001-08-26) [umoeller]
    1941     }
    1942     else
    1943         *phwndFocusItem = (pDlgData->hwndFirstFocus)
    1944                             ? pDlgData->hwndFirstFocus
    1945                             : pDlgData->hwndDlg;
     2038    // this was missing a return code, fixed V0.9.20 (2002-08-10) [umoeller]
     2039    if (!(arc = ProcessAll(pDlgData,
     2040                           PROCESS_4_CALC_POSITIONS)))
     2041    {
     2042        /*
     2043         *  6) create control windows, finally
     2044         *
     2045         */
     2046
     2047        pDlgData->ptlTotalOfs.x = DLG_OUTER_SPACING_X * FACTOR_X;
     2048        pDlgData->ptlTotalOfs.y = DLG_OUTER_SPACING_Y * FACTOR_Y;
     2049
     2050        // this was missing a return code, fixed V0.9.20 (2002-08-10) [umoeller]
     2051        if (!(arc = ProcessAll(pDlgData,
     2052                               PROCESS_5_CREATE_CONTROLS)))
     2053        {
     2054            if (pDlgData->hwndDefPushbutton)
     2055            {
     2056                // we had a default pushbutton:
     2057                // go set it V0.9.14 (2001-08-21) [umoeller]
     2058                WinSetWindowULong(pDlgData->hwndDlg,
     2059                                  QWL_DEFBUTTON,
     2060                                  pDlgData->hwndDefPushbutton);
     2061                *phwndFocusItem = pDlgData->hwndDefPushbutton;
     2062                        // V0.9.15 (2001-08-26) [umoeller]
     2063            }
     2064            else
     2065                *phwndFocusItem = (pDlgData->hwndFirstFocus)
     2066                                    ? pDlgData->hwndFirstFocus
     2067                                    : pDlgData->hwndDlg;
     2068        }
     2069    }
    19462070
    19472071    return arc;
     
    19732097                    // this may recurse for nested tables
    19742098        }
     2099
     2100        lstClear(&pDlgData->llTempControls);     // V0.9.20 (2002-08-10) [umoeller]
    19752101
    19762102        lstClear(&pDlgData->llTables);
     
    24612587
    24622588APIRET dlghFormatDlg(HWND hwndDlg,              // in: dialog frame to work on
    2463                      PCDLGHITEM paDlgItems,      // in: definition array
     2589                     PCDLGHITEM paDlgItems,     // in: definition array
    24642590                     ULONG cDlgItems,           // in: array item count (NOT array size)
    2465                      PCSZ pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT
     2591                     PCSZ pcszControlsFont,     // in: font for ctls with CTL_COMMON_FONT
    24662592                     ULONG flFlags,             // in: DFFL_* flags
    24672593                     PSIZEL pszlClient,         // out: size of all controls (ptr can be NULL)
    2468                      PVOID *ppllControls)   // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL)
     2594                     PVOID *ppllControls)       // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL)
    24692595{
    24702596    APIRET      arc = NO_ERROR;
  • trunk/src/helpers/dosh.c

    r192 r201  
    268268        // Warp 3 is reported as 20.30
    269269        // Warp 4 is reported as 20.40
    270         // Aurora is reported as 20.45
     270        // Aurora is reported as 20.45 (regardless of convenience packs)
    271271
    272272        if     (    (aulBuf[0] > 20)        // major > 20; not the case with Warp 3, 4, 5
  • trunk/src/helpers/gpih.c

    r200 r201  
    534534 *
    535535 *@@added V0.9.3 (2000-05-06) [umoeller]
     536 *@@changed V0.9.20 (2002-08-10) [umoeller]: fixed underline for bitmap fonts, which never worked
    536537 */
    537538
     
    559560            lHits = GpiCharStringPos(hps,
    560561                                     prclRect,
    561                                      flOptions,
     562                                     0, // flOptions,
    562563                                     lCountThis,
    563564                                     pchThis,
     
    567568            lCountLeft -= 512;
    568569        } while (lCountLeft > 0);
     570    }
     571
     572    // I can't get underscore to work with bitmap fonts,
     573    // so I'm doing it manually always now
     574    // V0.9.20 (2002-08-10) [umoeller]
     575    if (flOptions & CHS_UNDERSCORE)
     576    {
     577        POINTL ptl2, ptlSave;
     578        GpiQueryCurrentPosition(hps, &ptlSave);
     579        ptl2.x = pptlStart->x;
     580        ptl2.y = pptlStart->y - 2;
     581        GpiMove(hps, &ptl2);
     582        ptl2.x = ptlSave.x;
     583        GpiLine(hps, &ptl2);
     584        GpiMove(hps, &ptlSave);
    569585    }
    570586
  • trunk/src/helpers/makefile

    r159 r201  
    183183    $(TESTCASE_DIR)\except.obj \
    184184    $(TESTCASE_DIR)\debug.obj \
     185    $(TESTCASE_DIR)\textview.obj \
     186    $(TESTCASE_DIR)\textv_html.obj \
     187    $(TESTCASE_DIR)\tmsgfile.obj \
     188    $(TESTCASE_DIR)\datetime.obj \
     189    $(TESTCASE_DIR)\tree.obj \
    185190    $(TESTCASE_DIR)\gpih.obj
    186191
  • trunk/src/helpers/textv_html.c

    r167 r201  
    114114    CHAR    cSaved;
    115115
    116     PXHTMLDATA pxhtml;      // ptr to XHTMLDATA passed to txvConvertFromHTML
     116    PSZ     *ppszTitle;     // out: title (ptr can be NULL)
     117                            // V0.9.20 (2002-08-10) [umoeller]
    117118
    118119    // formatting flags while going through the text
     
    133134
    134135    // anchors count
    135     USHORT  usAnchorIndex;  // start with 1
     136    // USHORT  usAnchorIndex;  // start with 1      removed V0.9.20 (2002-08-10) [umoeller]
    136137
    137138    // list maintenance
     
    421422    *pSource = pct->cSaved;
    422423
    423     pSource = strchr(pct->pSource, '>');
    424     if (pSource)
     424    if (pSource = strchr(pct->pSource, '>'))
    425425    {
    426         PSZ pNextOpen = strchr(pSource, '<');
    427         if (pNextOpen)
     426        PSZ pNextOpen;
     427        if (pNextOpen = strchr(pSource, '<'))
    428428        {
    429429            // extract title
    430             pct->pxhtml->pszTitle = strhSubstr(pSource + 1, pNextOpen);
     430            if (pct->ppszTitle)
     431                *(pct->ppszTitle) = strhSubstr(pSource + 1, pNextOpen);
     432                        // adjusted V0.9.20 (2002-08-10) [umoeller]
    431433
    432434            if (strnicmp(pNextOpen + 1, "/TITLE", 6) == 0)
     
    434436                // closing /TITLE tag found:
    435437                // search on after that
    436                 pct->pNewSource = strchr(pNextOpen, '>');
    437                 if (pct->pNewSource)
     438                if (pct->pNewSource = strchr(pNextOpen, '>'))
    438439                    pct->pNewSource++;
    439440            }
     
    806807{
    807808    CHAR    szAnchor[10];
     809    PSZ     pHREF = NULL;
    808810
    809811    pct->fInLink = FALSE;
    810812
    811     if ((pct->pszAttributes) && (pct->pxhtml))     // points into main source buffer
     813    if (pct->pszAttributes)
    812814    {
    813815        // we have attributes:
    814         PSZ pszClosingTag = strchr(pct->pszAttributes, '>');
    815         if (pszClosingTag)
     816        PSZ pszClosingTag;
     817        if (pszClosingTag = strchr(pct->pszAttributes, '>'))
    816818        {
    817819            ULONG ulOfs = 0;
     
    822824             */
    823825
    824             PSZ pHREF = strhGetTextAttr(pct->pszAttributes, "HREF", &ulOfs),
    825                 pNAME = 0;
     826            PSZ pNAME = 0;
    826827
    827828            // replace '>' with null char to mark end of search
    828829            *pszClosingTag = 0;
    829830
    830             if (pHREF)
    831             {
     831            if (pHREF = strhGetTextAttr(pct->pszAttributes, "HREF", &ulOfs))
    832832                // OK, we got a link target:
    833                 // create a link item and append it to the output list
    834                 PXHTMLLINK pNewLink = (PXHTMLLINK)malloc(sizeof(XHTMLLINK));
    835                 memset(pNewLink, 0, sizeof(XHTMLLINK));
    836 
    837833                pct->fInLink = TRUE;
    838 
    839                 // this starts with anchor 1
    840                 pNewLink->usLinkIndex = ++pct->usAnchorIndex;
    841                 pNewLink->pszTargetFile = pHREF;
    842834                            // do not free
    843                 lstAppendItem(&pct->pxhtml->llLinks, pNewLink);
    844             }
    845835
    846836            /*
     
    849839             */
    850840
    851             pNAME = strhGetTextAttr(pct->pszAttributes, "NAME", &ulOfs);
    852             if (pNAME)
     841            if (pNAME = strhGetTextAttr(pct->pszAttributes, "NAME", &ulOfs))
    853842            {
    854843                AppendString(pct,
     
    860849                free(pNAME);
    861850            }
     851
    862852            // restore '>'
    863853            *pszClosingTag = '>';
     
    865855    }
    866856
    867     if (pct->fInLink)
     857    if (pHREF)
    868858    {
    869         sprintf(szAnchor, "%04hX", pct->usAnchorIndex);
    870859        AppendString(pct,
    871                      TXVESC_LINK);
     860                     TXVESC_LINK_BEGIN);
    872861        AppendString(pct,
    873                      szAnchor);
     862                     pHREF);
     863        // must be terminated with 0xFF
     864        AppendChar(pct, 0xFF);
     865
     866        free(pHREF);
    874867    }
    875868}
     
    880873    {
    881874        AppendString(pct,
    882                      TXVESC_LINK "####");
     875                     TXVESC_LINK_END);
    883876        pct->fInLink = FALSE;
    884877    }
     
    20512044 *
    20522045 *@@added V0.9.3 (2000-05-06) [umoeller]
     2046 *@@changed V0.9.20 (2002-08-10) [umoeller]: changed prototype
    20532047 */
    20542048
    2055 BOOL txvConvertFromHTML(char **ppszText,
    2056                         PVOID pxhtml,           // out: various config data (PXHTMLDATA)
     2049BOOL txvConvertFromHTML(PSZ *ppszText,          // in/out: text (gets reallocated)
     2050                        PSZ *ppszTitle,         // out: if != NULL, receives malloc'd buffer with HTML title
    20572051                        PULONG pulProgress,     // out: progress (ptr can be NULL)
    20582052                        PBOOL pfCancel)         // in: cancel flag (ptr can be NULL)
     
    20622056    ULONG   cbSource = strlen(*ppszText);
    20632057
    2064     XHTMLDATA xhtmlTemp = {0};
    2065     BOOL fUsingTemp = FALSE;
    20662058    COPYTARGET  ct = {0};
    20672059
    20682060    lstInit(&ct.llLists,
    20692061            TRUE);      // free items
     2062
     2063    ct.ppszTitle = ppszTitle;       // V0.9.20 (2002-08-10) [umoeller]
     2064                // can be NULL
    20702065
    20712066    ct.pSource = *ppszText;
    20722067    // skip leading spaces
    20732068    ct.fSkipNextSpace = TRUE;
    2074     ct.pxhtml = (PXHTMLDATA)pxhtml;
    2075     if (ct.pxhtml == NULL)  // not specified:
    2076     {
    2077         ct.pxhtml = &xhtmlTemp;
    2078         fUsingTemp = TRUE;
    2079     }
    2080 
    2081     lstInit(&ct.pxhtml->llLinks, TRUE);       // auto-free
    20822069
    20832070    // step 2:
     
    22292216    lstClear(&ct.llLists);
    22302217
    2231     if (fUsingTemp)
    2232     {
    2233         if (xhtmlTemp.pszTitle)
    2234             free(xhtmlTemp.pszTitle);
    2235         lstClear(&xhtmlTemp.llLinks);
    2236                 // ### better really clear this... there are PSZ's inside
    2237     }
    2238 
    22392218    return brc;
    22402219}
  • trunk/src/helpers/textview.c

    r167 r201  
    243243
    244244#include "helpers\textview.h"
     245#include "helpers\textv_html.h"
    245246
    246247#pragma hdrstop
     
    418419 *
    419420 *@@added V0.9.3 (2000-05-07) [umoeller]
     421 *@@changed V0.9.20 (2002-08-10) [umoeller]: now stripping \xFF too
    420422 */
    421423
     
    423425                       ULONG ulTabSize)
    424426{
    425     PSZ pSource = *ppszText;
    426     ULONG cbNew = 1000;
    427     PSZ pszNew = (PSZ)malloc(cbNew);
    428     PSZ pTarget = pszNew;
     427    PSZ     pSource = *ppszText;
     428    ULONG   cbNew = 1000;
     429    PSZ     pszNew = (PSZ)malloc(cbNew);
     430    PSZ     pTarget = pszNew;
     431    ULONG   ul;
    429432
    430433    while (*pSource)
    431434    {
    432         if (*pSource == '\r')
    433             pSource++;
    434         else if (*pSource == '\t')
    435         {
    436             ULONG ul;
    437             for (ul = 0;
    438                  ul < ulTabSize;
    439                  ul++)
     435        switch (*pSource)
     436        {
     437            case '\r':
     438                pSource++;
     439            break;
     440
     441            case '\t':
     442                for (ul = 0;
     443                     ul < ulTabSize;
     444                     ul++)
     445                    AppendCharNoCheck(&pszNew,
     446                                      &cbNew,
     447                                      &pTarget,
     448                                      ' ');
     449
     450                // skip the tab
     451                pSource++;
     452            break;
     453
     454            case '\xFF':        // V0.9.20 (2002-08-10) [umoeller]
    440455                AppendCharNoCheck(&pszNew,
    441456                                  &cbNew,
    442457                                  &pTarget,
    443458                                  ' ');
    444 
    445             // skip the tab
    446             pSource++;
     459                pSource++;
     460            break;
     461
     462            default:
     463                AppendCharNoCheck(&pszNew,
     464                                  &cbNew,
     465                                  &pTarget,
     466                                  *pSource++);
    447467        }
    448         else
    449             AppendCharNoCheck(&pszNew,
    450                               &cbNew,
    451                               &pTarget,
    452                               *pSource++);
    453468    }
     469
    454470    AppendCharNoCheck(&pszNew,
    455471                      &cbNew,
     
    542558    //      of the next line or points to the \0 character
    543559
    544     return (prc);
     560    return prc;
    545561}
    546562
     
    551567#define TXVFRECTF_ENDOFTEXT              0x0010
    552568   */
     569
    553570/*
    554571 *@@ FORMATLINEBUF:
     
    577594
    578595    // current anchor
    579     USHORT          usCurrentAnchor;
    580                         // this is > 0 if we're currently in an anchor block
     596    PSZ             pszCurrentLink;
     597                        // this is != NULL if we're currently in a link block
     598                        // and points to an item in XFORMATDATA.llLinks
     599                        // (simply copied to the word structs that are created)
    581600
    582601    // data copied to TXVWORD
    583602    LONG            lcid;
    584603    LONG            lPointSize;
    585     ULONG           flOptions;  // any combination of CHS_UNDERSCORE and CHS_STRIKEOUT
     604    ULONG           flChar;     // any combination of CHS_UNDERSCORE and CHS_STRIKEOUT
    586605
    587606    // counters, ...
     
    611630 *
    612631 *@@added V0.9.3 (2000-05-14) [umoeller]
     632 *@@changed V0.9.20 (2002-08-10) [umoeller]: rewrote link implementation
    613633 */
    614634
     
    709729        pWord->lcid = pflbuf->pfmtf->lcid;
    710730        pWord->lPointSize = pflbuf->lPointSize;
    711         pWord->flOptions = pflbuf->flOptions;
    712 
    713         pWord->usAnchor = pflbuf->usCurrentAnchor; // 0 if none
     731        pWord->flChar = pflbuf->flChar;
     732
     733        pWord->pszLinkTarget = pflbuf->pszCurrentLink; // 0 if none
    714734    }
    715735
    716     return (pWord);
     736    return pWord;
    717737}
    718738
     
    756776    // an escape character was found; txvCreateRectangle
    757777    // then sets pCurrent to the escape character (\xFF)
    758     CHAR    cCode1 = *((*ppCurrent)+1);
    759     CHAR    cCode2 = *((*ppCurrent)+2);
     778    CHAR    cCode1 = *((*ppCurrent) + 1);
     779    CHAR    cCode2 = *((*ppCurrent) + 2);
    760780    ULONG   ulSkip = 3; // per default, skip \xFF plus two
    761781    CHAR    szDecimal[10];
     
    769789        case 1:     // change font:
    770790            // three decimals follow specifying the font
    771             memcpy(szDecimal, (*ppCurrent)+2, 3);
     791            memcpy(szDecimal, (*ppCurrent) + 2, 3);
    772792            szDecimal[3] = 0;
    773793            lDecimal = atoi(szDecimal);
     
    795815        case 4:     // U or /U
    796816            if (cCode2 == 1)
    797                 pflbuf->flOptions |= CHS_UNDERSCORE;
     817                pflbuf->flChar |= CHS_UNDERSCORE;
    798818            else
    799                 pflbuf->flOptions &= ~CHS_UNDERSCORE;
     819                pflbuf->flChar &= ~CHS_UNDERSCORE;
    800820        break;
    801821
    802822        case 5:     // STRIKE or /STRIKE
    803823            if (cCode2 == 1)
    804                 pflbuf->flOptions |= CHS_STRIKEOUT;
     824                pflbuf->flChar |= CHS_STRIKEOUT;
    805825            else
    806                 pflbuf->flOptions &= ~CHS_STRIKEOUT;
     826                pflbuf->flChar &= ~CHS_STRIKEOUT;
    807827        break;
    808828
    809         case 6:     // A or /A HREF= (link)
    810             // four characters with hex anchor index (>=1)
    811             // or "####"
    812             if (  *( (*ppCurrent)+2 )
    813                   == '#'
    814                )
    815                 pflbuf->usCurrentAnchor = 0;
    816             else
     829        case 6:     // A HREF= (link)
     830                    // changed implementation V0.9.20 (2002-08-10) [umoeller]
     831        {
     832            // this is variable in length and terminated with
     833            // another 0xFF char; what's in between is the
     834            // link target name and gets appended to
     835            // XFORMATDATA.llLinks
     836            PSZ pEnd;
     837            if (pEnd = strchr((*ppCurrent) + 2, 0xFF))
    817838            {
    818                 PSZ pEnd;
    819                 memcpy(szDecimal, (*ppCurrent)+2, 4);
    820                 szDecimal[4] = 0;
    821                 lDecimal = strtol(szDecimal, &pEnd, 16);
    822                 pflbuf->usCurrentAnchor = lDecimal;
     839                pflbuf->pszCurrentLink = strhSubstr((*ppCurrent) + 2, pEnd);
     840                ulSkip = pEnd - *ppCurrent + 1;
     841
     842                lstAppendItem(&pxfd->llLinks,
     843                              pflbuf->pszCurrentLink);
    823844            }
    824 
    825             ulSkip = 6;
     845        }
    826846        break;
    827847
    828         case 7:     // A NAME= (anchor name)
     848        case 7:     // /A HREF (end of link)
     849            pflbuf->pszCurrentLink = NULL;
     850            ulSkip = 2;
     851        break;
     852
     853        case 8:     // A NAME= (anchor name)
    829854        {
    830855            // this is variable in length and terminated with
     
    834859            // searches the buffer
    835860            PSZ pEnd;
    836             if (pEnd = strchr((*ppCurrent)+2, 0xFF))
     861            if (pEnd = strchr((*ppCurrent) + 2, 0xFF))
    837862            {
    838863                ulSkip = pEnd - *ppCurrent + 1;
     
    849874            // three characters follow specifying the
    850875            // percentage
    851             memcpy(szDecimal, (*ppCurrent)+2, 3);
     876            memcpy(szDecimal, (*ppCurrent) + 2, 3);
    852877            szDecimal[3] = 0;
    853878            lDecimal = atoi(szDecimal);
     
    858883
    859884        case 0x20: // left margin changed:
    860             memcpy(szDecimal, (*ppCurrent)+2, 4);   // four decimals xxxx
     885            memcpy(szDecimal, (*ppCurrent) + 2, 4);   // four decimals xxxx
    861886            szDecimal[4] = 0;
    862887            lDecimal = atoi(szDecimal);
     
    871896
    872897        case 0x21: // first line margin changed:
    873             memcpy(szDecimal, (*ppCurrent)+2, 4);   // +xxx, -xxx
     898            memcpy(szDecimal, (*ppCurrent) + 2, 4);   // +xxx, -xxx
    874899            szDecimal[4] = 0;
    875900            lDecimal = atoi(szDecimal);
     
    899924        case 0x30:  // spacing before paragraph:
    900925            // four chars follow with either "####" or decimal spacing
    901             memcpy(szDecimal, (*ppCurrent)+2, 4);
     926            memcpy(szDecimal, (*ppCurrent) + 2, 4);
    902927            szDecimal[4] = 0;
    903928            if (memcmp(szDecimal, "####", 4) == 0)
     
    915940        case 0x31:  // spacing before paragraph:
    916941            // four chars follow with either "####" or decimal spacing
    917             memcpy(szDecimal, (*ppCurrent)+2, 4);
     942            memcpy(szDecimal, (*ppCurrent) + 2, 4);
    918943            szDecimal[4] = 0;
    919944            if (memcmp(szDecimal, "####", 4) == 0)
     
    949974            pEscapeWord->cEscapeCode = *(*ppCurrent + 1);
    950975            pEscapeWord->fPaintEscapeWord = fPaintEscapeWord;
    951             pEscapeWord->usAnchor = pflbuf->usCurrentAnchor; // 0 if none
     976            pEscapeWord->pszLinkTarget = pflbuf->pszCurrentLink;
     977                    // V0.9.20 (2002-08-10) [umoeller]
     978                    // NULL if none
    952979            if (fPaintEscapeWord)
    953980            {
     
    955982                pEscapeWord->lcid = pflbuf->pfmtf->lcid;
    956983                pEscapeWord->lPointSize = pflbuf->lPointSize;
    957                 pEscapeWord->flOptions = pflbuf->flOptions;
     984                pEscapeWord->flChar = pflbuf->flChar;
    958985            }
    959986            lstAppendItem(&pxfd->llWords, pEscapeWord);
     
    965992        *ppCurrent += ulSkip;
    966993
    967     return (pEscapeWord);
     994    return pEscapeWord;
    968995}
    969996
     
    10551082 *         to paint rectangles.
    10561083 *
    1057  *      -- XFORMATDATA.ulViewportCX, ulViewportCY: total width
    1058  *         and height of the "viewport", i.e. the total space
     1084 *      -- XFORMATDATA.szlWorkspace: total width
     1085 *         and height of the "workspace", i.e. the total space
    10591086 *         needed to display the text (in pels). This might
    10601087 *         be smaller, the same, or larger than prclView,
     
    10621089 *
    10631090 *         When displaying text, you should display scroll bars
    1064  *         if the viewport is larger than the window (prclView).
    1065  *
    1066  *         When printing, if the viewport is larger than the
     1091 *         if the workspace is larger than the window (prclView).
     1092 *
     1093 *         When printing, if the workspace is larger than the
    10671094 *         printer page (prclView), you will need to call
    10681095 *         txvPaintText several times for each page.
     
    10871114        lstClear(&pxfd->llWords);
    10881115
    1089     pxfd->ulViewportCX = 0;
    1090     pxfd->ulViewportCY = 0;
     1116    pxfd->szlWorkspace.cx = 0;
     1117    pxfd->szlWorkspace.cy = 0;
    10911118
    10921119    if (pxfd->strViewText.cbAllocated)
     
    13661393
    13671394                                // update x extents
    1368                                 if (pRect->rcl.xRight > pxfd->ulViewportCX)
    1369                                     pxfd->ulViewportCX = pRect->rcl.xRight;
     1395                                if (pRect->rcl.xRight > pxfd->szlWorkspace.cx)
     1396                                    pxfd->szlWorkspace.cx = pRect->rcl.xRight;
    13701397
    13711398                                // and quit the inner loop
     
    13921419
    13931420                // lCurrentYTop now has the bottommost point we've used;
    1394                 // store this as viewport (this might be negative)
    1395                 pxfd->ulViewportCY = lOrigYTop - lCurrentYTop;
     1421                // store this as workspace (this might be negative)
     1422                pxfd->szlWorkspace.cy = lOrigYTop - lCurrentYTop;
    13961423            }
    13971424        }
     
    15861613            {
    15871614                PTXVWORD pWordThis = (PTXVWORD)pWordNode->pItemData;
    1588                 ULONG flOptions = pWordThis->flOptions;
    1589 
    1590                 if (pWordThis->usAnchor)
    1591                     flOptions |= CHS_UNDERSCORE;
     1615                ULONG flChar = pWordThis->flChar;
     1616
     1617                if (pWordThis->pszLinkTarget)       // V0.9.20 (2002-08-10) [umoeller]
     1618                    flChar |= CHS_UNDERSCORE;
    15921619
    15931620                // x start: this word's X coordinate
     
    16211648                                        &ptlStart,
    16221649                                        &rclLine,
    1623                                         flOptions,
     1650                                        flChar,
    16241651                                        pWordThis->cChars,
    16251652                                        (PSZ)pWordThis->pStart);
     
    17491776    }
    17501777
    1751     return (pWordNodeFound);
     1778    return pWordNodeFound;
    17521779}
    17531780
     
    18021829    }
    18031830
    1804     return (pNodeFound);
     1831    return pNodeFound;
    18051832}
    18061833
     
    18101837 *
    18111838 ********************************************************************/
     1839
     1840#define QWL_PRIVATE     4               // V0.9.20 (2002-08-10) [umoeller]
    18121841
    18131842/*
    18141843 *@@ TEXTVIEWWINDATA:
    18151844 *      view control-internal structure, stored in
    1816  *      QWL_USER at fnwpTextView.
     1845 *      QWL_PRIVATE at fnwpTextView.
    18171846 *      This is device-dependent on the text view
    18181847 *      window.
     
    18261855    HPS     hps;
    18271856
     1857    ULONG   flStyle;            // window style flags copied on WM_CREATE
     1858                                // V0.9.20 (2002-08-10) [umoeller]
     1859
    18281860    LONG    lBackColor,
    18291861            lForeColor;
     
    18401872
    18411873    RECTL   rclViewReal,        // window rect as returned by WinQueryWindowRect
    1842                                 // (top right point is inclusive!!)
     1874                                // (top right point is inclusive!)
    18431875            rclViewPaint,       // same as rclViewReal, but excluding scroll bars
    18441876            rclViewText;        // same as rclViewPaint, but excluding cdata borders
     
    18511883    // anchor clicking
    18521884    PLISTNODE   pWordNodeFirstInAnchor;  // points to first word which belongs to anchor
    1853     USHORT      usLastAnchorClicked;    // last anchor which was clicked (1-0xFFFF)
     1885    // USHORT      usLastAnchorClicked;    // last anchor which was clicked (1-0xFFFF)
     1886    PSZ         pszLastLinkClicked;     // last link that was clicked (points into llLinks)
     1887
    18541888} TEXTVIEWWINDATA, *PTEXTVIEWWINDATA;
    18551889
     
    19531987    // if either the vertical or horizontal scroll bar has
    19541988    // popped up or been hidden
    1955     if (ptxvd->cdata.flStyle & XTXF_VSCROLL)
     1989    if (ptxvd->flStyle & XS_VSCROLL)
    19561990    {
    19571991        // vertical scroll bar enabled:
     
    19682002    }
    19692003
    1970     if (ptxvd->cdata.flStyle & XTXF_HSCROLL)
     2004    if (ptxvd->flStyle & XS_HSCROLL)
    19712005    {
    19722006        ulOfs = 0;
     
    20112045    if (ptxvd->ulViewYOfs < 0)
    20122046        ptxvd->ulViewYOfs = 0;
    2013     if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.ulViewportCY - ulWinCY))
    2014         ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.ulViewportCY - ulWinCY;
     2047    if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY))
     2048        ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY;
    20152049
    20162050    // vertical scroll bar enabled at all?
    2017     if (ptxvd->cdata.flStyle & XTXF_VSCROLL)
     2051    if (ptxvd->flStyle & XS_VSCROLL)
    20182052    {
    20192053        BOOL fEnabled = winhUpdateScrollBar(ptxvd->hwndVScroll,
    20202054                                            ulWinCY,
    2021                                             ptxvd->xfd.ulViewportCY,
     2055                                            ptxvd->xfd.szlWorkspace.cy,
    20222056                                            ptxvd->ulViewYOfs,
    2023                                             (ptxvd->cdata.flStyle & XTXF_AUTOVHIDE));
     2057                                            (ptxvd->flStyle & XS_AUTOVHIDE));
    20242058        // is auto-hide on?
    2025         if (ptxvd->cdata.flStyle & XTXF_AUTOVHIDE)
     2059        if (ptxvd->flStyle & XS_AUTOVHIDE)
    20262060        {
    20272061            // yes, auto-hide on: did visibility change?
     
    20462080
    20472081    // horizontal scroll bar enabled at all?
    2048     if (ptxvd->cdata.flStyle & XTXF_HSCROLL)
     2082    if (ptxvd->flStyle & XS_HSCROLL)
    20492083    {
    20502084        BOOL fEnabled = winhUpdateScrollBar(ptxvd->hwndHScroll,
    20512085                                            ulWinCX,
    2052                                             ptxvd->xfd.ulViewportCX,
     2086                                            ptxvd->xfd.szlWorkspace.cx,
    20532087                                            ptxvd->ulViewXOfs,
    2054                                             (ptxvd->cdata.flStyle & XTXF_AUTOHHIDE));
     2088                                            (ptxvd->flStyle & XS_AUTOHHIDE));
    20552089        // is auto-hide on?
    2056         if (ptxvd->cdata.flStyle & XTXF_AUTOHHIDE)
     2090        if (ptxvd->flStyle & XS_AUTOHHIDE)
    20572091        {
    20582092            // yes, auto-hide on: did visibility change?
     
    20712105
    20722106    WinInvalidateRect(hwndTextView, NULL, FALSE);
     2107}
     2108
     2109/*
     2110 *@@ SetWindowText:
     2111 *      implementation for WM_SETWINDOWPARAMS and
     2112 *      also WM_CREATE to set the window text.
     2113 *
     2114 *@@added V0.9.20 (2002-08-10) [umoeller]
     2115 */
     2116
     2117VOID SetWindowText(HWND hwndTextView,
     2118                   PTEXTVIEWWINDATA ptxvd,
     2119                   PCSZ pcszText)
     2120{
     2121    if (pcszText && *pcszText)
     2122    {
     2123        PXSTRING pstr = &ptxvd->xfd.strViewText;
     2124        PSZ p;
     2125
     2126        switch (ptxvd->flStyle & XS_FORMAT_MASK)
     2127        {
     2128            case XS_PLAINTEXT:          // 0x0100
     2129                xstrcpy(pstr,
     2130                        pcszText,
     2131                        0);
     2132                xstrConvertLineFormat(pstr,
     2133                                      CRLF2LF);
     2134                p = pstr->psz;
     2135                while (p = strchr(p, '\xFF'))
     2136                    *p = ' ';
     2137            break;
     2138
     2139            case XS_HTML:               // 0x0200
     2140                if (p = strdup(pcszText))
     2141                {
     2142                    PSZ p2 = p;
     2143                    while (p2 = strchr(p2, '\xFF'))
     2144                        *p2 = ' ';
     2145                    txvConvertFromHTML(&p, NULL, NULL, NULL);
     2146                    xstrset(pstr, p);
     2147                    xstrConvertLineFormat(pstr,
     2148                                          CRLF2LF);
     2149                }
     2150            break;
     2151
     2152            default: // case XS_PREFORMATTED:       // 0x0000
     2153                // no conversion (default)
     2154                xstrcpy(pstr,
     2155                        pcszText,
     2156                        0);
     2157            break;
     2158        }
     2159
     2160        // if the last character of the window text is not "\n",
     2161        // add it explicitly here, or our lines processing
     2162        // is being funny
     2163        // V0.9.20 (2002-08-10) [umoeller]
     2164        if (pstr->psz[pstr->ulLength - 1] != '\n')
     2165            xstrcatc(pstr, '\n');
     2166
     2167        ptxvd->ulViewXOfs = 0;
     2168        ptxvd->ulViewYOfs = 0;
     2169        AdjustViewRects(hwndTextView,
     2170                        ptxvd);
     2171        FormatText2Screen(hwndTextView,
     2172                          ptxvd,
     2173                          FALSE,
     2174                          TRUE);        // full format
     2175    }
    20732176}
    20742177
     
    21362239{
    21372240    POINTL ptlStart;
    2138     ULONG flOptions = pWordThis->flOptions;
     2241    ULONG flChar = pWordThis->flChar;
    21392242    PTXVRECTANGLE pLineRcl = pWordThis->pRectangle;
    21402243
     
    21452248    rclLine.yTop = pLineRcl->rcl.yTop + ptxvd->ulViewYOfs;
    21462249
    2147     if (pWordThis->usAnchor)
    2148         flOptions |= CHS_UNDERSCORE;
     2250    if (pWordThis->pszLinkTarget)
     2251        flChar |= CHS_UNDERSCORE;
    21492252
    21502253    // x start: this word's X coordinate
     
    21642267
    21652268    if (!pWordThis->cEscapeCode)
     2269    {
    21662270        gpihCharStringPosAt(ptxvd->hps,
    21672271                            &ptlStart,
    21682272                            &rclLine,
    2169                             flOptions,
     2273                            flChar,
    21702274                            pWordThis->cChars,
    21712275                            (PSZ)pWordThis->pStart);
     2276    }
    21722277    else
    21732278        // escape to be painted:
     
    21882293{
    21892294    PLISTNODE pNode = ptxvd->pWordNodeFirstInAnchor;
    2190     USHORT usAnchor = 0;
     2295    PSZ     pszLinkTarget = NULL;
    21912296    while (pNode)
    21922297    {
    21932298        PTXVWORD pWordThis = (PTXVWORD)pNode->pItemData;
    2194         if (usAnchor == 0)
     2299        if (!pszLinkTarget)
    21952300            // first loop:
    2196             usAnchor = pWordThis->usAnchor;
     2301            pszLinkTarget = pWordThis->pszLinkTarget;
    21972302        else
    2198             if (pWordThis->usAnchor != usAnchor)
     2303            if (pWordThis->pszLinkTarget != pszLinkTarget)
    21992304                // first word with different anchor:
    22002305                break;
     
    22112316 *      window procedure for the text view control. This is
    22122317 *      registered with the WC_XTEXTVIEW class in txvRegisterTextView.
    2213  *      We have a TEXTVIEWWINDATA structure in QWL_USER where we
    2214  *      store all information we need.
    22152318 *
    22162319 *      The text view control is not a subclassed whatever control,
     
    22362339 *
    22372340 *      -- WM_CHAR: if we have the focus, the user can move the
    2238  *         visible part within the viewport using the usual
     2341 *         visible part within the workspace using the usual
    22392342 *         cursor and HOME/END keys.
    22402343 *
     
    22512354 *      should be speedier.
    22522355 *
     2356 *      The text view control uses a private window word for storing
     2357 *      its own data. The client is free to use QWL_USER of the
     2358 *      text view control.
     2359 *
    22532360 *@@changed V0.9.3 (2000-05-05) [umoeller]: removed TXM_NEWTEXT; now supporting WinSetWindowText
    22542361 *@@changed V0.9.3 (2000-05-07) [umoeller]: crashed if create param was NULL; fixed
     2362 *@@changed V0.9.20 (2002-08-10) [umoeller]: no longer using QWL_USER, which is free now
     2363 *@@changed V0.9.20 (2002-08-10) [umoeller]: setting text on window creation never worked, fixed
     2364 *@@changed V0.9.20 (2002-08-10) [umoeller]: added TXN_ANCHORCLICKED owner notify for anchors
     2365 *@@changed V0.9.20 (2002-08-10) [umoeller]: converted private style flags to XS_* window style flags
     2366 *@@changed V0.9.20 (2002-08-10) [umoeller]: added support for formatting HTML and plain text automatically
    22552367 */
    22562368
     
    22592371    MRESULT mrc = 0;
    22602372
    2261     PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_USER);
     2373    PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_PRIVATE);
    22622374
    22632375    switch (msg)
     
    22772389            mrc = (MPARAM)TRUE;     // error
    22782390
    2279             // allocate TEXTVIEWWINDATA for QWL_USER
     2391            // allocate TEXTVIEWWINDATA for QWL_PRIVATE
    22802392            if (ptxvd = (PTEXTVIEWWINDATA)malloc(sizeof(TEXTVIEWWINDATA)))
    22812393            {
    22822394                SIZEL   szlPage = {0, 0};
    22832395                BOOL    fShow = FALSE;
    2284                 // LONG    lcid = 0;
    22852396
    22862397                // query message queue
     
    22902401
    22912402                memset(ptxvd, 0, sizeof(TEXTVIEWWINDATA));
    2292                 WinSetWindowPtr(hwndTextView, QWL_USER, ptxvd);
     2403                WinSetWindowPtr(hwndTextView, QWL_PRIVATE, ptxvd);
    22932404
    22942405                ptxvd->hab = WinQueryAnchorBlock(hwndTextView);
     
    22992410                                         &szlPage, // use same page size as device
    23002411                                         PU_PELS | GPIT_MICRO | GPIA_ASSOC);
     2412
     2413                // copy window style flags V0.9.20 (2002-08-10) [umoeller]
     2414                ptxvd->flStyle = pcs->flStyle;
    23012415
    23022416                gpihSwitchToRGB(ptxvd->hps);
     
    23452459                                                     &sbcd,
    23462460                                                     0);
    2347                 fShow = ((ptxvd->cdata.flStyle & XTXF_VSCROLL) != 0);
     2461                fShow = ((ptxvd->flStyle & XS_VSCROLL) != 0);
    23482462                WinShowWindow(ptxvd->hwndVScroll, fShow);
    23492463                ptxvd->fVScrollVisible = fShow;
     
    23602474                                                     &sbcd,
    23612475                                                     0);
    2362                 fShow = ((ptxvd->cdata.flStyle & XTXF_HSCROLL) != 0);
     2476                fShow = ((ptxvd->flStyle & XS_HSCROLL) != 0);
    23632477                WinShowWindow(ptxvd->hwndHScroll, fShow);
    23642478                ptxvd->fHScrollVisible = fShow;
    23652479
     2480                if (ptxvd->flStyle & XS_WORDWRAP)
     2481                    // word-wrapping should be enabled from the start:
     2482                    // V0.9.20 (2002-08-10) [umoeller]
     2483                    ptxvd->xfd.fmtpStandard.fWordWrap = TRUE;
     2484
    23662485                // set "code" format
    23672486                SetFormatFont(ptxvd->hps,
    2368                                  &ptxvd->xfd.fmtcCode,
    2369                                  6,
    2370                                  "System VIO");
     2487                              &ptxvd->xfd.fmtcCode,
     2488                              6,
     2489                              "System VIO");
    23712490
    23722491                // get colors from presparams/syscolors
     
    23752494                AdjustViewRects(hwndTextView,
    23762495                                ptxvd);
     2496
     2497                if (ptxvd->flStyle & XS_HTML)
     2498                {
     2499                    // if we're operating in HTML mode, set a
     2500                    // different default paragraph format to
     2501                    // make things prettier
     2502                    // V0.9.20 (2002-08-10) [umoeller]
     2503                    ptxvd->xfd.fmtpStandard.lSpaceBefore = 5;
     2504                    ptxvd->xfd.fmtpStandard.lSpaceAfter = 5;
     2505                }
     2506
     2507                // setting the window text on window creation never
     2508                // worked V0.9.20 (2002-08-10) [umoeller]
     2509                if (pcs->pszText)
     2510                    SetWindowText(hwndTextView,
     2511                                  ptxvd,
     2512                                  pcs->pszText);
    23772513
    23782514                mrc = (MPARAM)FALSE;        // OK
     
    23922528        {
    23932529            WNDPARAMS *pwndParams;
    2394             if (pwndParams = (WNDPARAMS *)mp1)
     2530            if (    (pwndParams = (WNDPARAMS *)mp1)
     2531                 && (pwndParams->fsStatus & WPM_TEXT)
     2532               )
    23952533            {
    2396                 if (pwndParams->fsStatus & WPM_TEXT)
    2397                 {
    2398                     xstrcpy(&ptxvd->xfd.strViewText,
    2399                             pwndParams->pszText,
    2400                             0);
    2401                     ptxvd->ulViewXOfs = 0;
    2402                     ptxvd->ulViewYOfs = 0;
    2403                     /* ptxvd->fVScrollVisible = FALSE;
    2404                     ptxvd->fHScrollVisible = FALSE; */
    2405                     AdjustViewRects(hwndTextView,
    2406                                     ptxvd);
    2407                     FormatText2Screen(hwndTextView,
    2408                                       ptxvd,
    2409                                       FALSE,
    2410                                       TRUE);        // full format
    2411                 }
     2534                SetWindowText(hwndTextView,
     2535                              ptxvd,
     2536                              pwndParams->pszText);
     2537                mrc = (MRESULT)TRUE;     // was missing V0.9.20 (2002-08-10) [umoeller]
    24122538            }
    24132539        }
     
    24852611                // (in between scroll bars) if we have
    24862612                // both vertical and horizontal scroll bars
    2487                 if (    (ptxvd->cdata.flStyle & (XTXF_VSCROLL | XTXF_HSCROLL))
    2488                         == (XTXF_VSCROLL | XTXF_HSCROLL)
     2613                if (    (ptxvd->flStyle & (XS_VSCROLL | XS_HSCROLL))
     2614                        == (XS_VSCROLL | XS_HSCROLL)
    24892615                     && (ptxvd->fVScrollVisible)
    24902616                     && (ptxvd->fHScrollVisible)
     
    25232649                                     &rcl2Update);
    25242650
    2525                 if (WinQueryFocus(HWND_DESKTOP) == hwndTextView)
     2651                if (    (!(ptxvd->flStyle & XS_STATIC))
     2652                                // V0.9.20 (2002-08-10) [umoeller]
     2653                     && (WinQueryFocus(HWND_DESKTOP) == hwndTextView)
     2654                   )
    25262655                {
    25272656                    // we have the focus:
     
    25852714                                    &ptxvd->ulViewYOfs,
    25862715                                    &ptxvd->rclViewText,
    2587                                     ptxvd->xfd.ulViewportCY,
     2716                                    ptxvd->xfd.szlWorkspace.cy,
    25882717                                    ptxvd->cdata.ulVScrollLineUnit,
    25892718                                    msg,
     
    26042733                                    &ptxvd->ulViewXOfs,
    26052734                                    &ptxvd->rclViewText,
    2606                                     ptxvd->xfd.ulViewportCX,
     2735                                    ptxvd->xfd.szlWorkspace.cx,
    26072736                                    ptxvd->cdata.ulHScrollLineUnit,
    26082737                                    msg,
     
    26182747        case WM_SETFOCUS:
    26192748        {
    2620             HPS hps = WinGetPS(hwndTextView);
    2621             gpihSwitchToRGB(hps);
    2622             PaintViewFocus(hps,
    2623                            ptxvd,
    2624                            (mp2 != 0));
    2625             WinReleasePS(hps);
     2749            if (ptxvd->flStyle & XS_STATIC)
     2750            {
     2751                if (mp2)
     2752                {
     2753                    // we're receiving the focus, but shouldn't have it:
     2754                    // then behave like the static control does, that is,
     2755                    // give focus to the next window in the dialog
     2756                    HWND    hwnd = hwndTextView,
     2757                            hwndStart = hwnd;
     2758
     2759                    while (TRUE)
     2760                    {
     2761                        ULONG flStyle;
     2762
     2763                        if (!(hwnd = WinQueryWindow(hwnd, QW_NEXT)))
     2764                            hwnd = WinQueryWindow(WinQueryWindow(hwndStart, QW_PARENT), QW_TOP);
     2765
     2766                        // avoid endless looping
     2767                        if (hwnd == hwndStart)
     2768                        {
     2769                            if (    (hwnd = WinQueryWindow(hwnd, QW_OWNER))
     2770                                 && (hwnd == hwndStart)
     2771                               )
     2772                                hwnd = NULLHANDLE;
     2773
     2774                            break;
     2775                        }
     2776
     2777                        if (    (flStyle = WinQueryWindowULong(hwnd, QWL_STYLE))
     2778                             && (flStyle & (WS_DISABLED | WS_TABSTOP | WS_VISIBLE)
     2779                                    == (WS_TABSTOP | WS_VISIBLE))
     2780                           )
     2781                        {
     2782                            WinSetFocus(HWND_DESKTOP, hwnd);
     2783                            break;
     2784                        }
     2785                    };
     2786                }
     2787            }
     2788            else
     2789            {
     2790                HPS hps = WinGetPS(hwndTextView);
     2791                gpihSwitchToRGB(hps);
     2792                PaintViewFocus(hps,
     2793                               ptxvd,
     2794                               (mp2 != 0));
     2795                WinReleasePS(hps);
     2796            }
    26262797        }
    26272798        break;
     
    26632834            ptlPos.y = SHORT2FROMMP(mp1) - ptxvd->ulViewYOfs;
    26642835
    2665             if (hwndTextView != WinQueryFocus(HWND_DESKTOP))
     2836            if (    (!(ptxvd->flStyle & XS_STATIC))
     2837                            // V0.9.20 (2002-08-10) [umoeller]
     2838                 && (hwndTextView != WinQueryFocus(HWND_DESKTOP))
     2839               )
    26662840                WinSetFocus(HWND_DESKTOP, hwndTextView);
    26672841
    2668             ptxvd->usLastAnchorClicked = 0;
     2842            ptxvd->pszLastLinkClicked = NULL;
    26692843
    26702844            if (pWordNodeClicked = txvFindWordFromPoint(&ptxvd->xfd,
     
    26732847                PTXVWORD pWordClicked = (PTXVWORD)pWordNodeClicked->pItemData;
    26742848
    2675                 // store anchor (can be 0)
    2676                 ptxvd->usLastAnchorClicked = pWordClicked->usAnchor;
    2677 
    2678                 if (pWordClicked->usAnchor)
     2849                // store link target (can be NULL)
     2850                if (ptxvd->pszLastLinkClicked = pWordClicked->pszLinkTarget)
    26792851                {
    2680                     // word has an anchor:
     2852                    // word has a link target:
    26812853                    PLISTNODE   pNode = pWordNodeClicked;
    26822854
     
    26892861                    {
    26902862                        PTXVWORD pWordThis = (PTXVWORD)pNode->pItemData;
    2691                         if (pWordThis->usAnchor == pWordClicked->usAnchor)
     2863                        if (pWordThis->pszLinkTarget == pWordClicked->pszLinkTarget)
    26922864                        {
    26932865                            // still has same anchor:
     
    27272899            WinSetCapture(HWND_DESKTOP, NULLHANDLE);
    27282900
    2729             if (ptxvd->usLastAnchorClicked)
     2901            if (ptxvd->pszLastLinkClicked)
    27302902            {
    27312903                RepaintAnchor(ptxvd,
     
    27392911                                                                 QWS_ID),
    27402912                                            TXVN_LINK),
    2741                                (MPARAM)(ULONG)(ptxvd->usLastAnchorClicked));
     2913                               (MPARAM)(ULONG)(ptxvd->pszLastLinkClicked));
    27422914            }
    27432915
     
    28032975                        if (usFlags & KC_CTRL)
    28042976                        {
    2805                             sPos = ptxvd->xfd.ulViewportCY;
     2977                            sPos = ptxvd->xfd.szlWorkspace.cy;
    28062978                            usCmd = SB_SLIDERPOSITION;
    28072979                        }
     
    28262998                            // vertical:
    28272999                            ulMsg = WM_VSCROLL;
    2828                             sPos = ptxvd->xfd.ulViewportCY;
     3000                            sPos = ptxvd->xfd.szlWorkspace.cy;
    28293001                        }
    28303002                        else
    28313003                        {
    28323004                            ulMsg = WM_HSCROLL;
    2833                             sPos = ptxvd->xfd.ulViewportCX;
     3005                            sPos = ptxvd->xfd.szlWorkspace.cx;
    28343006                        }
    28353007
     
    28663038         *      index specified in mp1.
    28673039         *
     3040         *      This must be sent, not posted, to the control.
     3041         *
    28683042         *      Parameters:
     3043         *
    28693044         *      -- ULONG mp1: index of format to query.
    28703045         *              Must be 0 currently for the standard
    28713046         *              paragraph format.
     3047         *
    28723048         *      -- PXFMTPARAGRAPH mp2: pointer to buffer
    28733049         *              which is to receive the formatting
     
    29043080         *      and such).
    29053081         *
     3082         *      This must be sent, not posted, to the control.
     3083         *
    29063084         *      Parameters:
     3085         *
    29073086         *      -- ULONG mp1: index of format to set.
    29083087         *              Must be 0 currently for the standard
    29093088         *              paragraph format.
     3089         *
    29103090         *      -- PXFMTPARAGRAPH mp2: pointer to buffer
    29113091         *              from which to copy formatting data.
     
    29533133         *      the word-wrapping style of the default
    29543134         *      paragraph formatting.
     3135         *
     3136         *      This may be sent or posted.
     3137         *
    29553138         *      (BOOL)mp1 determines whether word wrapping
    29563139         *      should be turned on or off.
     
    29723155         *@@ TXM_QUERYCDATA:
    29733156         *      copies the current XTEXTVIEWCDATA
    2974          *      into the specified buffer. This must
    2975          *      be sent to the control.
     3157         *      into the specified buffer.
     3158         *
     3159         *      This must be sent, not posted, to the control.
    29763160         *
    29773161         *      Parameters:
    2978          *      -- PXTEXTVIEWCDATA mp1: target buffer.
    2979          *         Before calling this, you MUST specify
    2980          *         XTEXTVIEWCDATA.cbData.
     3162         *
     3163         *      --  PXTEXTVIEWCDATA mp1: target buffer.
     3164         *          Before calling this, you MUST specify
     3165         *          XTEXTVIEWCDATA.cbData.
     3166         *
     3167         *      Returns: the bytes that were copied as
     3168         *      a ULONG.
    29813169         */
    29823170
     
    29853173            {
    29863174                PXTEXTVIEWCDATA pTarget = (PXTEXTVIEWCDATA)mp1;
    2987                 memcpy(pTarget, &ptxvd->cdata, pTarget->cbData);
     3175                mrc = (MRESULT)min(pTarget->cbData, sizeof(XTEXTVIEWCDATA));
     3176                memcpy(pTarget,
     3177                       &ptxvd->cdata,
     3178                       (ULONG)mrc);
    29883179            }
    29893180        break;
     
    29933184         *      updates the current XTEXTVIEWCDATA
    29943185         *      with the data from the specified buffer.
    2995          *      This must be sent to the control.
     3186         *
     3187         *      This must be sent, not posted, to the control.
    29963188         *
    29973189         *      Parameters:
     
    30163208         *      of the control.
    30173209         *
    3018          *      This must be sent, not posted to the control
     3210         *      This must be sent, not posted, to the control.
    30193211         *
    30203212         *      Parameters:
     
    30463238                        if (ptxvd->ulViewYOfs < 0)
    30473239                            ptxvd->ulViewYOfs = 0;
    3048                         if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.ulViewportCY - ulWinCY))
    3049                             ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.ulViewportCY - ulWinCY;
     3240                        if (ptxvd->ulViewYOfs > ((LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY))
     3241                            ptxvd->ulViewYOfs = (LONG)ptxvd->xfd.szlWorkspace.cy - ulWinCY;
    30503242
    30513243                        // vertical scroll bar enabled at all?
    3052                         if (ptxvd->cdata.flStyle & XTXF_VSCROLL)
     3244                        if (ptxvd->flStyle & XS_VSCROLL)
    30533245                        {
    30543246                            /* BOOL fEnabled = */ winhUpdateScrollBar(ptxvd->hwndVScroll,
    30553247                                                                ulWinCY,
    3056                                                                 ptxvd->xfd.ulViewportCY,
     3248                                                                ptxvd->xfd.szlWorkspace.cy,
    30573249                                                                ptxvd->ulViewYOfs,
    3058                                                                 (ptxvd->cdata.flStyle & XTXF_AUTOVHIDE));
     3250                                                                (ptxvd->flStyle & XS_AUTOVHIDE));
    30593251                            WinInvalidateRect(hwndTextView, NULL, FALSE);
    30603252                        }
    30613253                    }
    30623254                }
     3255            }
     3256        break;
     3257
     3258        /*
     3259         *@@ TXM_QUERYTEXTEXTENT:
     3260         *      returns the extents of the currently set text,
     3261         *      that is, the width and height of the internal
     3262         *      work area, of which the current view rectangle
     3263         *      displays a subrectangle.
     3264         *
     3265         *      This must be sent, not posted, to the control.
     3266         *
     3267         *      Parameters:
     3268         *
     3269         *      --  PSIZEL mp1: pointer to a SIZEL buffer,
     3270         *          which receives the extent in the cx and
     3271         *          cy members. These will be set to null
     3272         *          values if the control currently has no
     3273         *          text.
     3274         *
     3275         *      Returns TRUE on success.
     3276         *
     3277         *@@added V0.9.20 (2002-08-10) [umoeller]
     3278         */
     3279
     3280        case TXM_QUERYTEXTEXTENT:
     3281            if (mp1)
     3282            {
     3283                memcpy((PSIZEL)mp1,
     3284                       &ptxvd->xfd.szlWorkspace,
     3285                       sizeof(SIZEL));
     3286                mrc = (MRESULT)TRUE;
    30633287            }
    30643288        break;
     
    30933317BOOL txvRegisterTextView(HAB hab)
    30943318{
    3095     return (WinRegisterClass(hab,
    3096                              WC_XTEXTVIEW,
    3097                              fnwpTextView,
    3098                              0,
    3099                              sizeof(PVOID)));     // QWL_USER
     3319    return WinRegisterClass(hab,
     3320                            WC_XTEXTVIEW,
     3321                            fnwpTextView,
     3322                            0,
     3323                            2 * sizeof(PVOID));     // QWL_USER and QWL_PRIVATE
    31003324}
    31013325
     
    31113335                            USHORT usID,
    31123336                            ULONG flWinStyle,
    3113                             ULONG flStyle,
    31143337                            USHORT usBorder)
    31153338{
     
    31503373        memset(&xtxCData, 0, sizeof(xtxCData));
    31513374        xtxCData.cbData = sizeof(xtxCData);
    3152         xtxCData.flStyle = flStyle;
    31533375        xtxCData.ulXBorder = usBorder;
    31543376        xtxCData.ulYBorder = usBorder;
     
    31833405                            &lForeClr);
    31843406    }
    3185     return (hwndTextView);
     3407    return hwndTextView;
    31863408}
    31873409
     
    32403462    }
    32413463
    3242     return (pprq3);
     3464    return pprq3;
    32433465}
    32443466
     
    33013523                     palRes);   // buffer
    33023524
    3303     return (hdc);
     3525    return hdc;
    33043526}
    33053527
     
    33343556    }
    33353557
    3336     return (pahci);
     3558    return pahci;
    33373559}
    33383560
     
    33623584    sizel.cx = 0;
    33633585    sizel.cy = 0;
    3364     return (GpiCreatePS(hab,
    3365                         hdc,
    3366                         &sizel,
    3367                         ulUnits | GPIA_ASSOC | GPIT_NORMAL));
     3586    return GpiCreatePS(hab,
     3587                       hdc,
     3588                       &sizel,
     3589                       ulUnits | GPIA_ASSOC | GPIT_NORMAL);
    33683590}
    33693591
     
    35293751    prthEndDoc(hdc, hps);
    35303752
    3531     return (TRUE);
     3753    return TRUE;
    35323754}
    35333755
     
    35493771    int     irc = 0;
    35503772
    3551     PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_USER);
     3773    PTEXTVIEWWINDATA ptxvd = (PTEXTVIEWWINDATA)WinQueryWindowPtr(hwndTextView, QWL_PRIVATE);
    35523774
    35533775    if (!ptxvd)
     
    36463868    }
    36473869
    3648     return (irc);
     3870    return irc;
    36493871}
    36503872
  • trunk/src/helpers/winh.c

    r200 r201  
    545545                                       0,
    546546                                       0);
    547         _PmpfF(("lOldDefault is %d", lOldDefault));
    548547    }
    549548    else
Note: See TracChangeset for help on using the changeset viewer.