| 1 |  | 
|---|
| 2 | /* | 
|---|
| 3 | *@@sourcefile textview.h: | 
|---|
| 4 | *      header file for textview.c. See remarks there. | 
|---|
| 5 | * | 
|---|
| 6 | *      Note: Version numbering in this file relates to XWorkplace version | 
|---|
| 7 | *            numbering. | 
|---|
| 8 | */ | 
|---|
| 9 |  | 
|---|
| 10 | /*      Copyright (C) 2000 Ulrich Mller. | 
|---|
| 11 | *      This file is part of the "XWorkplace helpers" source package. | 
|---|
| 12 | *      This is free software; you can redistribute it and/or modify | 
|---|
| 13 | *      it under the terms of the GNU General Public License as published | 
|---|
| 14 | *      by the Free Software Foundation, in version 2 as it comes in the | 
|---|
| 15 | *      "COPYING" file of the XWorkplace main distribution. | 
|---|
| 16 | *      This program is distributed in the hope that it will be useful, | 
|---|
| 17 | *      but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 18 | *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 19 | *      GNU General Public License for more details. | 
|---|
| 20 | * | 
|---|
| 21 | *@@include #define INCL_SPL        // for printing functions | 
|---|
| 22 | *@@include #include <os2.h> | 
|---|
| 23 | *@@include #include "helpers\linklist.h"   // for device-independent functions | 
|---|
| 24 | *@@include #include "helpers\xstring.h"    // for device-independent functions | 
|---|
| 25 | *@@include #include "helpers\textview.h" | 
|---|
| 26 | */ | 
|---|
| 27 |  | 
|---|
| 28 | #if __cplusplus | 
|---|
| 29 | extern "C" { | 
|---|
| 30 | #endif | 
|---|
| 31 |  | 
|---|
| 32 | #ifndef TEXTVIEW_HEADER_INCLUDED | 
|---|
| 33 | #define TEXTVIEW_HEADER_INCLUDED | 
|---|
| 34 |  | 
|---|
| 35 | /* ****************************************************************** | 
|---|
| 36 | * | 
|---|
| 37 | *   Escape sequences | 
|---|
| 38 | * | 
|---|
| 39 | ********************************************************************/ | 
|---|
| 40 |  | 
|---|
| 41 | /* | 
|---|
| 42 | *@@ TXVESC_CHAR: | 
|---|
| 43 | *      general escape character which introduces | 
|---|
| 44 | *      all escape sequences. | 
|---|
| 45 | */ | 
|---|
| 46 |  | 
|---|
| 47 | #define TXVESC_CHAR             '\xFF' | 
|---|
| 48 | #define TXVESC_STRING           "\xFF" | 
|---|
| 49 |  | 
|---|
| 50 | // fixed formatting tags: PRE, B, I U, STRIKE | 
|---|
| 51 | // (no parameters) | 
|---|
| 52 | /* #define TXVESC_PRE_BEGIN        TXVESC_STRING "\x01\x01" | 
|---|
| 53 | #define TXVESC_PRE_END          TXVESC_STRING "\x01\x02" */ | 
|---|
| 54 |  | 
|---|
| 55 | #define TXVESC_SET_FONT         TXVESC_STRING "\x01" | 
|---|
| 56 | // here follow three characters with the | 
|---|
| 57 | // font index: | 
|---|
| 58 | // e.g. "000" == default font | 
|---|
| 59 | //      "001" == monospaced font | 
|---|
| 60 | // Fonts 0 and 1 always exist in the XTextView control. | 
|---|
| 61 | // Other fonts are presently not supported. | 
|---|
| 62 | // --> total size: 5 | 
|---|
| 63 |  | 
|---|
| 64 | #define TXVESC_BOLD_BEGIN       TXVESC_STRING "\x02\x01" | 
|---|
| 65 | #define TXVESC_BOLD_END         TXVESC_STRING "\x02\x02" | 
|---|
| 66 |  | 
|---|
| 67 | #define TXVESC_ITALICS_BEGIN    TXVESC_STRING "\x03\x01" | 
|---|
| 68 | #define TXVESC_ITALICS_END      TXVESC_STRING "\x03\x02" | 
|---|
| 69 |  | 
|---|
| 70 | #define TXVESC_UNDERLINE_BEGIN  TXVESC_STRING "\x04\x01" | 
|---|
| 71 | #define TXVESC_UNDERLINE_END    TXVESC_STRING "\x04\x02" | 
|---|
| 72 |  | 
|---|
| 73 | #define TXVESC_STRIKE_BEGIN     TXVESC_STRING "\x05\x01" | 
|---|
| 74 | #define TXVESC_STRIKE_END       TXVESC_STRING "\x05\x02" | 
|---|
| 75 |  | 
|---|
| 76 | // links | 
|---|
| 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" | 
|---|
| 89 | // here follows the anchor name, which is | 
|---|
| 90 | // variable in length and must be terminated | 
|---|
| 91 | // with another 0xFF escape code (NOT null byte); | 
|---|
| 92 | // --> total size: 2 plus anchor name length | 
|---|
| 93 | //      plus 1 for 0xFF terminator | 
|---|
| 94 |  | 
|---|
| 95 | // character formatting with parameters: | 
|---|
| 96 | #define TXVESC_POINTSIZE_REL    TXVESC_STRING "\x10" | 
|---|
| 97 | // here follow three characters with a percentage | 
|---|
| 98 | // of the default point size | 
|---|
| 99 | // e.g. "050" == half the size | 
|---|
| 100 | //      "200" == double the size | 
|---|
| 101 | // --> total size: 5 | 
|---|
| 102 |  | 
|---|
| 103 | /* | 
|---|
| 104 | * paragraph formatting | 
|---|
| 105 | *      -- left and right margins: | 
|---|
| 106 | */ | 
|---|
| 107 |  | 
|---|
| 108 | #define TXVESC_LEFTMARGIN               TXVESC_STRING "\x20" | 
|---|
| 109 | // here follow four characters to specify the | 
|---|
| 110 | // new first line left margin (XFMTPARAGRAPH.lLeftMargin), | 
|---|
| 111 | // which is based on the average char width of | 
|---|
| 112 | // the current font: | 
|---|
| 113 | // e.g. "0020" == set margin to 20 average char widths | 
|---|
| 114 | // --> total size: 6 | 
|---|
| 115 |  | 
|---|
| 116 | #define TXVESC_FIRSTLINEMARGIN_LEFT     TXVESC_STRING "\x21-" | 
|---|
| 117 | #define TXVESC_FIRSTLINEMARGIN_RIGHT    TXVESC_STRING "\x21+" | 
|---|
| 118 | // here follow three characters to specify the | 
|---|
| 119 | // new absolute left margin (XFMTPARAGRAPH.lFirstLineMargin) | 
|---|
| 120 | // which is based on the average char width of | 
|---|
| 121 | // the current font: | 
|---|
| 122 | // e.g. "+020" == set first line margin to 20 average char widths | 
|---|
| 123 | // e.g. "-020" == set first line margin to 20 average char widths | 
|---|
| 124 | // --> total size: 6 | 
|---|
| 125 |  | 
|---|
| 126 | #define TXVESC_TAB                      TXVESC_STRING "\x22" | 
|---|
| 127 | // the tab can be used to move from the first line margin | 
|---|
| 128 | // to the left margin, if the first line margin is negative; | 
|---|
| 129 | // used with list items (UL LI and such) | 
|---|
| 130 | // --> total size: 2 | 
|---|
| 131 |  | 
|---|
| 132 | #define TXVESC_MARKER                   TXVESC_STRING "\x23" | 
|---|
| 133 | // draw marker at the current position: the next byte | 
|---|
| 134 | // determines the type of marker: | 
|---|
| 135 | // -- 1: disc (filled circle) | 
|---|
| 136 | // -- 2: square (filled box) | 
|---|
| 137 | // -- 3: circle (hollow circle) | 
|---|
| 138 | // --> total size: 3 | 
|---|
| 139 |  | 
|---|
| 140 | /* | 
|---|
| 141 | * paragraph formatting | 
|---|
| 142 | *      -- paragraph spacing: | 
|---|
| 143 | */ | 
|---|
| 144 |  | 
|---|
| 145 | #define TXVESC_SPACEBEFORE              TXVESC_STRING "\x30" | 
|---|
| 146 | #define TXVESC_SPACEAFTER               TXVESC_STRING "\x31" | 
|---|
| 147 | // here follow four characters to specify the | 
|---|
| 148 | // new spacing before or after a paragraph: | 
|---|
| 149 | // e.g. "0020" == twenty | 
|---|
| 150 | // !! special case: "####" means reset to default | 
|---|
| 151 | // --> total size: 6 | 
|---|
| 152 |  | 
|---|
| 153 | #define TXVESC_WORDWRAP                 TXVESC_STRING "\x32" | 
|---|
| 154 | // here follows a single character being "0" or "1" | 
|---|
| 155 | // --> total size: 3 | 
|---|
| 156 |  | 
|---|
| 157 | /* ****************************************************************** | 
|---|
| 158 | * | 
|---|
| 159 | *   Device-independent functions | 
|---|
| 160 | * | 
|---|
| 161 | ********************************************************************/ | 
|---|
| 162 |  | 
|---|
| 163 | #define TXVWORDF_GLUEWITHNEXT       1       // escape | 
|---|
| 164 | #define TXVWORDF_LINEBREAK          2       // \n | 
|---|
| 165 | #define TXVWORDF_LINEFEED           4       // \r | 
|---|
| 166 |  | 
|---|
| 167 | typedef struct _TXVRECTANGLE *PTXVRECTANGLE; | 
|---|
| 168 |  | 
|---|
| 169 | /* | 
|---|
| 170 | *@@ TXVWORD: | 
|---|
| 171 | *      this defines a "word" to be drawn. A word is | 
|---|
| 172 | *      normally a sequence of characters between | 
|---|
| 173 | *      space, \n, or \r characters, unless escape | 
|---|
| 174 | *      sequences come up. See txvFormatText. | 
|---|
| 175 | * | 
|---|
| 176 | *@@added V0.9.3 (2000-05-14) [umoeller] | 
|---|
| 177 | */ | 
|---|
| 178 |  | 
|---|
| 179 | typedef struct _TXVWORD | 
|---|
| 180 | { | 
|---|
| 181 | const char  *pStart;        // ptr into TEXTVIEWWINDATA.pszViewText | 
|---|
| 182 | ULONG       cChars;         // characters in line to draw, starting | 
|---|
| 183 | // at pStartOfLine; | 
|---|
| 184 | // this might be less than the next \n | 
|---|
| 185 | // char if word-wrapping has been enabled | 
|---|
| 186 | // or an escape character was found | 
|---|
| 187 |  | 
|---|
| 188 | CHAR        cEscapeCode; | 
|---|
| 189 | // if 0, this word represents a substring to be painted | 
|---|
| 190 | // ("normal word"). | 
|---|
| 191 | // If != 0; this "word" holds an escape sequence in *pStart | 
|---|
| 192 | // which must be considered for paragraph formatting, but | 
|---|
| 193 | // NOT be painted, except if fPaintEscapeWord is TRUE also. | 
|---|
| 194 | // cEscapeCode then holds a copy of the escape character | 
|---|
| 195 | // (which is pStart + 1). | 
|---|
| 196 | BOOL        fPaintEscapeWord; | 
|---|
| 197 | // if this is TRUE, this escape is some special graphics | 
|---|
| 198 | // to be painted also (e.g. list markers). txvPaint then | 
|---|
| 199 | // evaluates the escape code (in pStart) to see what needs | 
|---|
| 200 | // to be done. | 
|---|
| 201 |  | 
|---|
| 202 | // all the following are only set if (fIsEscapeSequence == FALSE): | 
|---|
| 203 |  | 
|---|
| 204 | ULONG       ulFlags; | 
|---|
| 205 | // one of the following: | 
|---|
| 206 | // -- TXVWORDF_GLUEWITHNEXT: this "word" was cut because | 
|---|
| 207 | //          an escape sequence was found; this word must | 
|---|
| 208 | //          therefore be in the same line with the next word | 
|---|
| 209 | // -- TXVWORDF_LINEBREAK: this word ends with a \n char; | 
|---|
| 210 | //          start new paragraph after this | 
|---|
| 211 | // -- TXVWORDF_LINEFEED: this words ends with a \r char; | 
|---|
| 212 | //          start new line after this | 
|---|
| 213 |  | 
|---|
| 214 | ULONG       ulCXWithSpaces, // width of word (in pels), including trailing spaces | 
|---|
| 215 | ulCXWord,       // width of word (in pels), without trailing spaces | 
|---|
| 216 | ulCY;           // height of word (in pels) | 
|---|
| 217 |  | 
|---|
| 218 | LONG        lX;             // X position to paint this word at; | 
|---|
| 219 | // this is (re)set during word-to-rectangle correlation! | 
|---|
| 220 | PTXVRECTANGLE pRectangle;   // reverse pointer to the TXVRECTANGLE structure to | 
|---|
| 221 | // which this word belongs; useful for repainting; | 
|---|
| 222 | // this is (re)set during word-to-rectangle correlation! | 
|---|
| 223 | ULONG       ulBaseLineOfs;  // base line offset; add this to rcl.yBottom | 
|---|
| 224 | // to get the the start point to be used for | 
|---|
| 225 | // GpiCharStringPosAt | 
|---|
| 226 |  | 
|---|
| 227 | LONG        lcid;           // logical font ID to use for this rectangle | 
|---|
| 228 | LONG        lPointSize;     // point size to use for this rectangle; | 
|---|
| 229 | // this is set to 0 for bitmap fonts | 
|---|
| 230 | ULONG       flChar;         // flOptions parameter for GpiCharStringPosAt; | 
|---|
| 231 | // this will only have the CHS_UNDERSCORE or | 
|---|
| 232 | // CHS_STRIKEOUT flags set | 
|---|
| 233 |  | 
|---|
| 234 | PCSZ        pcszLinkTarget; // 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 |  | 
|---|
| 238 | } TXVWORD, *PTXVWORD; | 
|---|
| 239 |  | 
|---|
| 240 | #ifdef LINKLIST_HEADER_INCLUDED | 
|---|
| 241 | /* | 
|---|
| 242 | *@@ TXVRECTANGLE: | 
|---|
| 243 | *      this defines one line to be drawn. | 
|---|
| 244 | *      This is device-independent. | 
|---|
| 245 | *      See txvFormatText. | 
|---|
| 246 | */ | 
|---|
| 247 |  | 
|---|
| 248 | typedef struct _TXVRECTANGLE | 
|---|
| 249 | { | 
|---|
| 250 | RECTL       rcl;            // rectangle of this line, into which | 
|---|
| 251 | // the words in llWords should be painted; | 
|---|
| 252 | // the bottom of this rectangle specifies the | 
|---|
| 253 | // bottommost point used (neccessary for | 
|---|
| 254 | // characters with underlengths, such as | 
|---|
| 255 | // "g" or "y"); ulMaxBaseLineOfs must be | 
|---|
| 256 | // added to the starting point | 
|---|
| 257 | // when using GpiCharStringPosAt | 
|---|
| 258 | ULONG       ulMaxBaseLineOfs; // highest ulBaseLineOfs of all words | 
|---|
| 259 | // belonging to this rectangle. | 
|---|
| 260 | LINKLIST    llWords;        // list of TXVWORD's which belong to this | 
|---|
| 261 | // rectangle. Note that these are duplicate | 
|---|
| 262 | // pointers to be able to correlate rectangles | 
|---|
| 263 | // to words; there is a second list of TXVWORD's | 
|---|
| 264 | // in XFORMATDATA which holds really all the | 
|---|
| 265 | // words which were created (for cleanup). | 
|---|
| 266 | // So one allocated TXVWORD structure can | 
|---|
| 267 | // have two pointers pointing to it. | 
|---|
| 268 | } TXVRECTANGLE; | 
|---|
| 269 | #endif | 
|---|
| 270 |  | 
|---|
| 271 | /* | 
|---|
| 272 | *@@ XFMTFONT: | 
|---|
| 273 | *      specifies a font to be used in | 
|---|
| 274 | *      XFMTCHARACTER. | 
|---|
| 275 | * | 
|---|
| 276 | *@@added V0.9.3 (2000-05-06) [umoeller] | 
|---|
| 277 | */ | 
|---|
| 278 |  | 
|---|
| 279 | typedef struct _XFMTFONT | 
|---|
| 280 | { | 
|---|
| 281 | LONG        lcid; | 
|---|
| 282 | // default font to use for this paragraph | 
|---|
| 283 | FONTMETRICS FontMetrics; | 
|---|
| 284 | LONG        alCX[256]; // width of each ASCII character for this | 
|---|
| 285 | // string; computed by txvSetFormatFont | 
|---|
| 286 | } XFMTFONT, *PXFMTFONT; | 
|---|
| 287 |  | 
|---|
| 288 | /* | 
|---|
| 289 | *@@ XFMTCHARACTER: | 
|---|
| 290 | *      character formatting parameters. | 
|---|
| 291 | *      This is used by the formatting engine | 
|---|
| 292 | *      (txvFormat) | 
|---|
| 293 | *      to describe character formatting. | 
|---|
| 294 | *      Character formatting can only be | 
|---|
| 295 | *      changed between words (TXVWORD). | 
|---|
| 296 | * | 
|---|
| 297 | *@@added V0.9.3 (2000-05-06) [umoeller] | 
|---|
| 298 | */ | 
|---|
| 299 |  | 
|---|
| 300 | typedef struct _XFMTCHARACTER | 
|---|
| 301 | { | 
|---|
| 302 | LONG        lPointSize; | 
|---|
| 303 | // default font size to use for this paragraph | 
|---|
| 304 | XFMTFONT    fntRegular, | 
|---|
| 305 | fntBold, | 
|---|
| 306 | fntItalics, | 
|---|
| 307 | fntBoldItalics; | 
|---|
| 308 | } XFMTCHARACTER, *PXFMTCHARACTER; | 
|---|
| 309 |  | 
|---|
| 310 | /* | 
|---|
| 311 | *@@ XFMTPARAGRAPH: | 
|---|
| 312 | *      paragraph formatting parameters. | 
|---|
| 313 | *      This is used by the formatting engine | 
|---|
| 314 | *      (txvFormat) | 
|---|
| 315 | *      for every paragraph which is started. | 
|---|
| 316 | * | 
|---|
| 317 | *@@added V0.9.3 (2000-05-06) [umoeller] | 
|---|
| 318 | */ | 
|---|
| 319 |  | 
|---|
| 320 | typedef struct _XFMTPARAGRAPH | 
|---|
| 321 | { | 
|---|
| 322 | BOOL        fWordWrap; | 
|---|
| 323 | LONG        lLeftMargin, | 
|---|
| 324 | // left indentation for all lines | 
|---|
| 325 | // (in pixels) | 
|---|
| 326 | lRightMargin, | 
|---|
| 327 | // right indentation for all lines | 
|---|
| 328 | // (in pixels) | 
|---|
| 329 | lFirstLineMargin; | 
|---|
| 330 | // additional indentation for first line only; | 
|---|
| 331 | // this is added to lLeftMargin (can be negative) | 
|---|
| 332 | // (in pixels) | 
|---|
| 333 | LONG        lSpaceBefore, | 
|---|
| 334 | // space before each paragraph | 
|---|
| 335 | // (in pixels) | 
|---|
| 336 | lSpaceAfter; | 
|---|
| 337 | // space after each paragraph | 
|---|
| 338 | // (in pixels) | 
|---|
| 339 | } XFMTPARAGRAPH, *PXFMTPARAGRAPH; | 
|---|
| 340 |  | 
|---|
| 341 | #ifdef LINKLIST_HEADER_INCLUDED | 
|---|
| 342 | #ifdef XSTRING_HEADER_INCLUDED | 
|---|
| 343 |  | 
|---|
| 344 | /* | 
|---|
| 345 | *@@ XFORMATDATA: | 
|---|
| 346 | *      text formatting data. Passed to | 
|---|
| 347 | *      txvPaintText, stored in TEXTVIEWWINDATA. | 
|---|
| 348 | *      This is device-independent. | 
|---|
| 349 | */ | 
|---|
| 350 |  | 
|---|
| 351 | typedef struct _XFORMATDATA | 
|---|
| 352 | { | 
|---|
| 353 | // input to txvFormatText | 
|---|
| 354 | XSTRING     strViewText;    // original view text | 
|---|
| 355 | // from WinSetWindowText | 
|---|
| 356 |  | 
|---|
| 357 | XFMTPARAGRAPH | 
|---|
| 358 | fmtpStandard;   // standard paragraph format | 
|---|
| 359 |  | 
|---|
| 360 | XFMTCHARACTER | 
|---|
| 361 | fmtcStandard,   // format for standard text | 
|---|
| 362 | fmtcCode;       // format for code text (monospaced; PRE, CODE etc.) | 
|---|
| 363 |  | 
|---|
| 364 | // output from txvFormatText | 
|---|
| 365 | LINKLIST    llRectangles; | 
|---|
| 366 | // list of TXVRECTANGLE, from top to bottom; | 
|---|
| 367 | // text pointers point into pszViewText | 
|---|
| 368 | LINKLIST    llWords; | 
|---|
| 369 | // list of TXVWORD's, in order of creation; | 
|---|
| 370 | // this is just for proper cleanup. The items | 
|---|
| 371 | // in the TXVRECTANGLE.llWords list also point | 
|---|
| 372 | // to the words stored in this list. | 
|---|
| 373 |  | 
|---|
| 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] | 
|---|
| 382 |  | 
|---|
| 383 | } XFORMATDATA, *PXFORMATDATA; | 
|---|
| 384 |  | 
|---|
| 385 | VOID txvInitFormat(PXFORMATDATA pxfd); | 
|---|
| 386 |  | 
|---|
| 387 | VOID txvFormatText(HPS hps, | 
|---|
| 388 | PXFORMATDATA pxfd, | 
|---|
| 389 | PRECTL prclView, | 
|---|
| 390 | BOOL fFullRecalc); | 
|---|
| 391 | #endif | 
|---|
| 392 | #endif | 
|---|
| 393 |  | 
|---|
| 394 | VOID txvStripLinefeeds(char **ppszText, | 
|---|
| 395 | ULONG ulTabSize); | 
|---|
| 396 |  | 
|---|
| 397 | /* ****************************************************************** | 
|---|
| 398 | * | 
|---|
| 399 | *   Window-dependent functions | 
|---|
| 400 | * | 
|---|
| 401 | ********************************************************************/ | 
|---|
| 402 |  | 
|---|
| 403 | /* | 
|---|
| 404 | * XTextView messages: | 
|---|
| 405 | * | 
|---|
| 406 | */ | 
|---|
| 407 |  | 
|---|
| 408 | #define TXM_QUERYCHARFORMAT             (WM_USER + 1022) | 
|---|
| 409 | #define TXM_SETCHARFORMAT               (WM_USER + 1023) | 
|---|
| 410 | #define TXM_QUERYPARFORMAT              (WM_USER + 1022) | 
|---|
| 411 | #define TXM_SETPARFORMAT                (WM_USER + 1023) | 
|---|
| 412 | #define TXM_SETWORDWRAP                 (WM_USER + 1024) | 
|---|
| 413 | #define TXM_QUERYCDATA                  (WM_USER + 1025) | 
|---|
| 414 | #define TXM_SETCDATA                    (WM_USER + 1026) | 
|---|
| 415 | #define TXM_JUMPTOANCHORNAME            (WM_USER + 1027) | 
|---|
| 416 | #define TXM_QUERYTEXTEXTENT             (WM_USER + 1028) | 
|---|
| 417 |  | 
|---|
| 418 | #define WC_XTEXTVIEW     "XTextViewClass" | 
|---|
| 419 |  | 
|---|
| 420 | /* | 
|---|
| 421 | * XTextView nofication codes: | 
|---|
| 422 | * | 
|---|
| 423 | */ | 
|---|
| 424 |  | 
|---|
| 425 | /* | 
|---|
| 426 | *@@ TXVN_LINK: | 
|---|
| 427 | *      WM_CONTROL notification code posted (!) | 
|---|
| 428 | *      to the XTextView control's owner. | 
|---|
| 429 | * | 
|---|
| 430 | *      Parameters: | 
|---|
| 431 | * | 
|---|
| 432 | *      --  USHORT SHORT1FROMMP(mp1): id of the control. | 
|---|
| 433 | * | 
|---|
| 434 | *      --  USHORT SHORT2FROMMP(mp1): nofify code (TXVN_LINK). | 
|---|
| 435 | * | 
|---|
| 436 | *      --  const char *mp2: target of the link that the | 
|---|
| 437 | *          user clicked on. | 
|---|
| 438 | * | 
|---|
| 439 | *@@added V0.9.3 (2000-05-18) [umoeller] | 
|---|
| 440 | */ | 
|---|
| 441 |  | 
|---|
| 442 | #define TXVN_LINK                       1 | 
|---|
| 443 |  | 
|---|
| 444 | /* | 
|---|
| 445 | * XTextView window style flags: | 
|---|
| 446 | *      all renamed, all turned into window style flags | 
|---|
| 447 | */ | 
|---|
| 448 |  | 
|---|
| 449 | #define XS_VSCROLL          0x0001      // show vertical scroll bar | 
|---|
| 450 | #define XS_HSCROLL          0x0002      // show horizontal scroll bar | 
|---|
| 451 | #define XS_AUTOVHIDE        0x0004      // with XTXF_VSCROLL: automatically hide scrollbar | 
|---|
| 452 | #define XS_AUTOHHIDE        0x0008      // with XTXF_HSCROLL: automatically hide scrollbar | 
|---|
| 453 |  | 
|---|
| 454 | // handy macro V0.9.20 (2002-08-10) [umoeller] | 
|---|
| 455 | #define XS_FULLSCROLL       (XS_VSCROLL | XS_HSCROLL | XS_AUTOVHIDE | XS_AUTOHHIDE) | 
|---|
| 456 |  | 
|---|
| 457 | #define XS_WORDWRAP         0x0010 | 
|---|
| 458 | // enable word-wrapping in the default paragraph | 
|---|
| 459 | // format from the start | 
|---|
| 460 |  | 
|---|
| 461 | #define XS_STATIC           0x0020 | 
|---|
| 462 | // behave like static control: no focus, be skipped | 
|---|
| 463 | // over with tabbing in dialogs | 
|---|
| 464 | // V0.9.20 (2002-08-10) [umoeller] | 
|---|
| 465 |  | 
|---|
| 466 | #define XS_FORMAT_MASK      0x0700 | 
|---|
| 467 | #define XS_PREFORMATTED     0x0000      // plain text with \n only plus \xFF escape codes | 
|---|
| 468 | // (no conversion performed) | 
|---|
| 469 | #define XS_PLAINTEXT        0x0100      // plain text with \r and \xFF chars that need conversion | 
|---|
| 470 | #define XS_HTML             0x0200      // HTML | 
|---|
| 471 |  | 
|---|
| 472 | /* | 
|---|
| 473 | *@@ XTEXTVIEWCDATA: | 
|---|
| 474 | *      control data structure for text view | 
|---|
| 475 | *      control. This can be passed to | 
|---|
| 476 | *      WinCreateWindow with the pCtlData | 
|---|
| 477 | *      parameter. You then MUST set the | 
|---|
| 478 | *      "cbData" field to sizeof(XTEXTVIEWCDATA). | 
|---|
| 479 | */ | 
|---|
| 480 |  | 
|---|
| 481 | typedef struct _XTEXTVIEWCDATA | 
|---|
| 482 | { | 
|---|
| 483 | USHORT      cbData; | 
|---|
| 484 | ULONG       ulXBorder, | 
|---|
| 485 | // space to leave on the left and right of text view; | 
|---|
| 486 | // defaults to 0 | 
|---|
| 487 | ulYBorder; | 
|---|
| 488 | // space to leave on the top and bottom of text view; | 
|---|
| 489 | // defaults to 0 | 
|---|
| 490 | ULONG       ulVScrollLineUnit, | 
|---|
| 491 | // pixels to scroll if scroll bar "up" or "down" button | 
|---|
| 492 | // is pressed; defaults to 15 | 
|---|
| 493 | ulHScrollLineUnit; | 
|---|
| 494 | // pixels to scroll if scroll bar "left" or "right" button | 
|---|
| 495 | // is pressed; defaults to 15 | 
|---|
| 496 | } XTEXTVIEWCDATA, *PXTEXTVIEWCDATA; | 
|---|
| 497 |  | 
|---|
| 498 |  | 
|---|
| 499 | BOOL txvRegisterTextView(HAB hab); | 
|---|
| 500 |  | 
|---|
| 501 | HWND txvReplaceWithTextView(HWND hwndParentAndOwner, | 
|---|
| 502 | USHORT usID, | 
|---|
| 503 | ULONG flWinStyle, | 
|---|
| 504 | USHORT usBorder); | 
|---|
| 505 |  | 
|---|
| 506 | /* ****************************************************************** | 
|---|
| 507 | * | 
|---|
| 508 | *   Printer-dependent functions | 
|---|
| 509 | * | 
|---|
| 510 | ********************************************************************/ | 
|---|
| 511 |  | 
|---|
| 512 | typedef BOOL APIENTRY FNPRINTCALLBACK(ULONG ulPage, | 
|---|
| 513 | ULONG ulUser); | 
|---|
| 514 |  | 
|---|
| 515 | #ifdef INCL_SPL | 
|---|
| 516 | BOOL txvPrint(HAB hab, | 
|---|
| 517 | HDC hdc, | 
|---|
| 518 | HPS hps, | 
|---|
| 519 | PSZ pszViewText, | 
|---|
| 520 | ULONG ulSize, | 
|---|
| 521 | PSZ pszFaceName, | 
|---|
| 522 | HCINFO  *phci, | 
|---|
| 523 | PSZ pszDocTitle, | 
|---|
| 524 | FNPRINTCALLBACK *pfnCallback); | 
|---|
| 525 | #endif | 
|---|
| 526 |  | 
|---|
| 527 | int txvPrintWindow(HWND hwndTextView, | 
|---|
| 528 | PSZ pszDocTitle, | 
|---|
| 529 | FNPRINTCALLBACK *pfnCallback); | 
|---|
| 530 |  | 
|---|
| 531 | #endif | 
|---|
| 532 |  | 
|---|
| 533 | #if __cplusplus | 
|---|
| 534 | } | 
|---|
| 535 | #endif | 
|---|
| 536 |  | 
|---|