source: branches/v2.9/classes/mm-progs/_pmtst/volume.c

Last change on this file was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 73.7 KB
Line 
1/*
2 * pmmp3dec.c (C) Chris Wohlgemuth 2002
3 *
4 * This helper decodes an MP3
5 */
6/*
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21#define INCL_DOS
22#define INCL_GPI
23#define INCL_DOSFILEMGR
24#define INCL_DOSERRORS
25#define INCL_WIN
26#define INCL_OS2MM
27#define INCL_MMIOOS2
28#define INCL_MCIOS2
29#define INCL_SECONDARYWINDOW
30#define INCL_GRAPHICBUTTON
31#define INCL_GPIBITMAPS
32#define INCL_REXXSAA
33#define INCL_WINTRACKRECT
34#define INCL_PM
35
36
37#include <os2.h>
38#include <sw.h>
39#include <sys\types.h>
40#include <sys\stat.h>
41#include <stdio.h>
42#include <string.h>
43#include <stdlib.h>
44#include <stdarg.h>
45//#include <rexxsaa.h> /* needed for RexxStart() */
46#include "os2me.h"
47//#include "progbars.h"
48#include "common.h"
49#include "volumeres.h"
50
51#define ACTION_SETVOLUME 1L
52#define ACTION_QUERYVOLUME 2L
53
54#define INI_NAME_APP "volume"
55#define INI_WINDOWPOS_KEY "windowpos"
56#define INI_TBVISIBLE_KEY "tbVivible"
57#define INI_NAME_COLOR "color"
58#define INI_BTNBGCLR_KEY "btnbg"
59#define INI_BTNFGCLR_KEY "btnfg"
60
61#if 0
62#define INI_BGCLR_KEY "bg"
63#define INI_FGCLR_KEY "fg"
64#define INI_ACTIVETBBGCLR_KEY "activetbbg"
65#define INI_INACTIVETBBGCLR_KEY "inactivetbbg"
66#define INI_ACTIVETBFGCLR_KEY "activetbfg"
67#define INI_INACTIVETBFGCLR_KEY "inactivetbfg"
68#endif
69char logName[]="volume.log";
70
71BOOL bHaveWindowPos=FALSE;
72
73BOOL bMute=FALSE;
74HMODULE RESSOURCEHANDLE=0;
75BOOL bTBVisible;
76ULONG ulTBCy;
77
78HWND hwndThread;
79
80char* params[5];
81char chrIniFile[CCHMAXPATH];
82
83ULONG SysQueryOSRelease();
84void pmUsage();
85BOOL writeWindowPosToIni(char * iniFile, char* chrApp, char *chrKey, HWND hwnd);
86BOOL restoreWindowPosFromIni(char * iniFile, char* chrApp, char *chrKey, HWND hwnd);
87BOOL writeIntToIni(char * iniFile, char* chrApp, char *chrKey, int theInt);
88int queryIntFromIni(char * iniFile, char* chrApp, char *chrKey, int defaultInt);
89BOOL writeDataToIni(char * iniFile, char* chrApp, char *chrKey, void* theData, ULONG ulSize);
90BOOL queryDataFromIni(char * iniFile, char* chrApp, char *chrKey, void * theData, ULONG* ulMaxSize);
91BOOL saveWindowClrsToIni(char * chrIniFile, char* chrApp , HWND hwnd);
92BOOL restoreWindowClrsFromIni(char * chrIniFile, char* chrApp , HWND hwnd);
93
94
95PFNWP oldButtonProc2; //place for original button-procedure
96PFNWP oldProc;
97HWND hwndBubbleWindow;// The handle of the help window
98HWND hwndShadow;// The handle of the help window
99#define WM_NEWBUBBLE WM_USER+100 //Use ATOM later
100#define xVal 12 //x-distance of Bubble
101#define yVal 8 //y-distance of Bubble
102char chrTBFlyFontName[CCHMAXPATH]="9.WarpSans";/* Font for toolbar fly over help */
103RGB rgbTBFlyForeground={0};
104RGB rgbTBFlyBackground={180,255,255};
105BOOL bTBFlyOverEnabled=TRUE;
106int iTBFlyOverDelay=250;
107
108void SysWriteToTrapLog(const char* chrFormat, ...);
109
110#define EXCEPTION_LOGFILE_NAME "d:\\arbeitsoberflaeche\\tst.log"
111
112
113HAB globalHab;
114HBITMAP hBitmap;
115BITMAPINFOHEADER2 bmpInfoHeader2;
116
117#define mmioFOURCC( ch0, ch1, ch2, ch3 ) \
118 ( (ULONG)(BYTE)(ch0) | ( (ULONG)(BYTE)(ch1) << 8 ) | \
119 ( (ULONG)(BYTE)(ch2) << 16 ) | ( (ULONG)(BYTE)(ch3) << 24 ) )
120
121HBITMAP loadBitmap ( PSZ pszFileName , PBITMAPINFOHEADER2 pBMPInfoHeader2)
122{
123 HBITMAP hbm;
124 MMIOINFO mmioinfo;
125 MMFORMATINFO mmFormatInfo;
126 HMMIO hmmio;
127 ULONG ulImageHeaderLength;
128 MMIMAGEHEADER mmImgHdr;
129 ULONG ulBytesRead;
130 ULONG dwNumRowBytes;
131 PBYTE pRowBuffer;
132 ULONG dwRowCount;
133 SIZEL ImageSize;
134 ULONG dwHeight, dwWidth;
135 SHORT wBitCount;
136 FOURCC fccStorageSystem;
137 ULONG dwPadBytes;
138 ULONG dwRowBits;
139 ULONG ulReturnCode;
140 ULONG dwReturnCode;
141 HBITMAP hbReturnCode;
142 LONG lReturnCode;
143 FOURCC fccIOProc;
144 HDC hdc;
145 HPS hps;
146
147
148 ulReturnCode = mmioIdentifyFile ( pszFileName,
149 0L,
150 &mmFormatInfo,
151 &fccStorageSystem,
152 0L,
153 0L);
154 /*
155 * If this file was NOT identified, then this function won't
156 * work, so return an error by indicating an empty bitmap.
157 */
158 if ( ulReturnCode == MMIO_ERROR )
159 {
160 // showMsgBox(IDSTR_CWIMAGETITLE, IDSTR_NOIMGIOPROCERROR, queryModuleHandle());
161 return (0L);
162 }
163 /*
164 * If mmioIdentifyFile did not find a custom-written IO proc which
165 * can understand the image file, then it will return the DOS IO Proc
166 * info because the image file IS a DOS file.
167 */
168 if( mmFormatInfo.fccIOProc == FOURCC_DOS )
169 {
170 // showMsgBox(IDSTR_CWIMAGETITLE, IDSTR_NOIMGIOPROCERROR, queryModuleHandle());
171 return ( 0L );
172 }
173 /*
174 * Ensure this is an IMAGE IOproc, and that it can read
175 * translated data
176 */
177 if ( (mmFormatInfo.ulMediaType != MMIO_MEDIATYPE_IMAGE) ||
178 ((mmFormatInfo.ulFlags & MMIO_CANREADTRANSLATED) == 0) )
179 {
180 // showMsgBox(IDSTR_CWIMAGETITLE, IDSTR_NOIMGIOPROCERROR, queryModuleHandle());
181 return (0L);
182 }
183 else
184 {
185 fccIOProc = mmFormatInfo.fccIOProc;
186 }
187
188 /* Clear out and initialize mminfo structure */
189 memset ( &mmioinfo, 0L, sizeof ( MMIOINFO ) );
190 mmioinfo.fccIOProc = fccIOProc;
191 mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER | MMIO_TRANSLATEDATA;
192 hmmio = mmioOpen ( (PSZ) pszFileName,
193 &mmioinfo,
194 MMIO_READ | MMIO_DENYWRITE | MMIO_NOIDENTIFY );
195 if ( ! hmmio )
196 {
197 // If file could not be opened, return with error
198 // showMsgBox(IDSTR_CWIMAGETITLE, IDSTR_OPENFILEERROR, queryModuleHandle());
199 return (0L);
200 }
201
202
203 dwReturnCode = mmioQueryHeaderLength ( hmmio,
204 (PLONG)&ulImageHeaderLength,
205 0L,
206 0L);
207 if ( ulImageHeaderLength != sizeof ( MMIMAGEHEADER ) )
208 {
209 /* We have a problem.....possibly incompatible versions */
210 ulReturnCode = mmioClose (hmmio, 0L);
211 // showMsgBox(IDSTR_CWIMAGETITLE, IDSTR_NOIMGIOPROCERROR);
212 return (0L);
213 }
214
215 ulReturnCode = mmioGetHeader ( hmmio,
216 &mmImgHdr,
217 (LONG) sizeof ( MMIMAGEHEADER ),
218 (PLONG)&ulBytesRead,
219 0L,
220 0L);
221
222 if ( ulReturnCode != MMIO_SUCCESS )
223 {
224 /* Header unavailable */
225 ulReturnCode = mmioClose (hmmio, 0L);
226 // showMsgBox(IDSTR_CWIMAGETITLE, IDSTR_NOIMGIOPROCERROR);
227 return (0L);
228 }
229
230 memcpy(pBMPInfoHeader2, &mmImgHdr.mmXDIBHeader.BMPInfoHeader2,
231 sizeof(BITMAPINFOHEADER2)+256*sizeof(RGB2) );
232
233 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
234
235 /*
236 * Determine the number of bytes required, per row.
237 * PLANES MUST ALWAYS BE = 1
238 */
239 dwHeight = mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cy;
240 dwWidth = mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cx;
241 wBitCount = mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cBitCount;
242 dwRowBits = dwWidth * mmImgHdr.mmXDIBHeader.BMPInfoHeader2.cBitCount;
243 dwNumRowBytes = dwRowBits >> 3;
244
245#if 0
246 /*
247 * Determine the number of bytes required, per row.
248 * PLANES MUST ALWAYS BE = 1
249 */
250 dwHeight = pBMPInfoHeader2->cy;
251 dwWidth = pBMPInfoHeader2->cx;
252 wBitCount = pBMPInfoHeader2->cBitCount;
253 dwRowBits = dwWidth * pBMPInfoHeader2->cBitCount;
254 dwNumRowBytes = dwRowBits >> 3;
255#endif
256 /*
257 * Account for odd bits used in 1bpp or 4bpp images that are
258 * NOT on byte boundaries.
259 */
260 if ( dwRowBits % 8 )
261 {
262 dwNumRowBytes++;
263 }
264 /*
265 * Ensure the row length in bytes accounts for byte padding.
266 * All bitmap data rows must are aligned on LONG/4-BYTE boundaries.
267 * The data FROM an IOProc should always appear in this form.
268 */
269 dwPadBytes = ( dwNumRowBytes % 4 );
270 if ( dwPadBytes )
271 {
272 dwNumRowBytes += 4 - dwPadBytes;
273 }
274
275 /* Allocate space for ONE row of pels */
276 if ( DosAllocMem( (PPVOID)&pRowBuffer,
277 (ULONG)dwNumRowBytes,
278 fALLOC))
279 {
280 ulReturnCode = mmioClose (hmmio, 0L);
281 // showMsgBox(IDSTR_CWIMAGETITLE, IDSTR_NOMEMERROR, queryModuleHandle());
282 return(0L);
283 }
284
285 /* Create a device context */
286 hdc=DevOpenDC(globalHab, OD_MEMORY,"*",0L, NULL, NULLHANDLE);
287 if(hdc==NULLHANDLE)
288 {
289 DosFreeMem(pRowBuffer);
290 mmioClose (hmmio, 0L);
291 return(0L);
292 }
293
294
295 // ***************************************************
296 // Create a memory presentation space that includes
297 // the memory device context obtained above.
298 // ***************************************************
299
300 ImageSize.cx = dwWidth;
301 ImageSize.cy = dwHeight;
302
303 hps = GpiCreatePS ( globalHab,
304 hdc,
305 &ImageSize,
306 PU_PELS | GPIT_NORMAL | GPIA_ASSOC );
307 // PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC );
308 if ( !hps )
309 {
310#ifdef DEBUG
311 WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
312 "No HPS...",
313 "Open Image File",
314 (HMODULE) NULL,
315 (ULONG) MB_OK | MB_MOVEABLE |
316 MB_ERROR );
317#endif
318 DevCloseDC(hdc);
319 DosFreeMem(pRowBuffer);
320 mmioClose (hmmio, 0L);
321 return(0L);
322 }
323
324 // GpiSelectPalette(hps, NULLHANDLE);
325 // ***************************************************
326 // Create an uninitialized bitmap. This is where we
327 // will put all of the bits once we read them in.
328 // ***************************************************
329 hbm = GpiCreateBitmap ( hps,
330 &mmImgHdr.mmXDIBHeader.BMPInfoHeader2,
331 0L,
332 NULL,
333 NULL);
334
335#if 0
336 hbm = GpiCreateBitmap ( hps,
337 pBMPInfoHeader2,
338 0L,
339 NULL,
340 NULL);
341#endif
342
343 if ( !hbm )
344 {
345#ifdef DEBUG
346 WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
347 "No HBITMAP...",
348 "Open Image File",
349 (HMODULE) NULL,
350 (ULONG) MB_OK | MB_MOVEABLE |
351 MB_ERROR );
352#endif
353 GpiDestroyPS(hps);
354 DevCloseDC(hdc);
355 DosFreeMem(pRowBuffer);
356 ulReturnCode = mmioClose (hmmio, 0L);
357 return(0L);
358 }
359
360 // ***************************************************
361 // Select the bitmap into the memory device context.
362 // ***************************************************
363 hbReturnCode = GpiSetBitmap ( hps,
364 hbm );
365
366 //***************************************************************
367 // LOAD THE BITMAP DATA FROM THE FILE
368 // One line at a time, starting from the BOTTOM
369 //*************************************************************** */
370
371 for ( dwRowCount = 0; dwRowCount < dwHeight; dwRowCount++ )
372 {
373 ulBytesRead = (ULONG) mmioRead ( hmmio,
374 pRowBuffer,
375 dwNumRowBytes );
376 if ( !ulBytesRead )
377 {
378 break;
379 }
380 /*
381 * Allow context switching while previewing.. Couldn't get
382 * it to work. Perhaps will get to it when time is available...
383 */
384 lReturnCode = GpiSetBitmapBits ( hps,
385 (LONG) dwRowCount,
386 (LONG) 1,
387 (PBYTE) pRowBuffer,
388 (PBITMAPINFO2) &mmImgHdr.mmXDIBHeader.BMPInfoHeader2);
389 }
390
391 /* Clean up */
392 hbReturnCode = GpiSetBitmap ( hps,
393 NULLHANDLE );
394 ulReturnCode = mmioClose (hmmio, 0L);
395 DosFreeMem(pRowBuffer);
396 GpiDestroyPS(hps);
397 DevCloseDC(hdc);
398
399 return(hbm);
400}
401
402
403BOOL MyTrackRoutine(HWND hwnd, PRECTL rcl_, ULONG ulFlag)
404 {
405 TRACKINFO track;
406 HAB hab;
407 RECTL rcl2;
408 RECTL rcl;
409
410 track.cxBorder = 4;
411 track.cyBorder = 4; /* 4 pel wide lines used for rectangle */
412 track.cxGrid = 1;
413 track.cyGrid = 1; /* smooth tracking with mouse */
414 track.cxKeyboard = 8;
415 track.cyKeyboard = 8; /* faster tracking using cursor keys */
416
417 hab=WinQueryAnchorBlock(hwnd);
418
419 WinQueryWindowRect(hwnd, &rcl);
420 WinQueryWindowRect(WinQueryWindow(hwnd, QW_PARENT), &rcl2);
421
422 WinMapWindowPoints(hwnd, WinQueryWindow(hwnd, QW_PARENT), &rcl, 2);
423 rcl.yTop=rcl2.yTop;
424 rcl.yBottom=rcl2.yBottom;
425 WinCopyRect(hab, &track.rclTrack, &rcl); /* starting point */
426
427 WinQueryWindowRect(WinQueryWindow(hwnd, QW_PARENT), &track.rclBoundary);
428
429 // WinSetRect(hab, &track.rclBoundary, 0, 0, 640, 480); /* bounding rectangle */
430
431 track.ptlMinTrackSize.x = 2;
432 track.ptlMinTrackSize.y = 2; /* set smallest allowed size of rectangle */
433
434 track.ptlMaxTrackSize.x = track.rclBoundary.xRight;
435 track.ptlMaxTrackSize.y = track.rclBoundary.yTop; /* set largest allowed size of rectangle */
436
437 track.fs = TF_MOVE;
438 track.fs|=TF_ALLINBOUNDARY;
439 if (WinTrackRect(WinQueryWindow(hwnd, QW_PARENT), NULLHANDLE, &track) )
440 {
441 SWP swp;
442 /* if successful copy final position back */
443 //WinCopyRect(hab, &rcl, &track.rclTrack);
444 WinQueryWindowPos(hwnd, &swp);
445 WinSetWindowPos(hwnd, NULLHANDLE,/* swp.cx+*/track.rclTrack.xLeft+swp.cx/2/*-rcl.xRight*/, swp.y ,0,0,SWP_MOVE);
446
447 return(TRUE);
448 }
449 }
450
451
452
453
454POINTS ptsStart={0};
455POINTS ptsTemp={0};
456BOOL bTrack=FALSE;
457BOOL bHaveSelection=FALSE;
458
459ULONG chkPointerInSelection( HWND hwnd, POINTS ptsStart, POINTS ptsTemp, SHORT xPtr, SHORT yPtr)
460{
461 RECTL rcl;
462 RECTL rclTemp;
463 HAB hab;
464 POINTL ptl;
465
466 ptl.x=xPtr;
467 ptl.y=yPtr;
468
469 if(ptsTemp.x>ptsStart.x)
470 {
471 rcl.xLeft=ptsStart.x;
472 rcl.xRight=ptsTemp.x;
473 }
474 else
475 {
476 rcl.xLeft=ptsTemp.x;
477 rcl.xRight=ptsStart.x;
478 }
479 if(ptsTemp.y>ptsStart.y)
480 {
481 rcl.yBottom=ptsStart.y;
482 rcl.yTop=ptsTemp.y;
483 }
484 else
485 {
486 rcl.yBottom=ptsTemp.y;
487 rcl.yTop=ptsStart.y;
488 }
489
490 hab=WinQueryAnchorBlock(hwnd);
491
492 rclTemp=rcl;
493 WinInflateRect(hab, &rclTemp, 2, 2);
494 if(!WinPtInRect(hab, &rclTemp, &ptl))
495 return 0; /* Mouse out of selection */
496
497 rclTemp=rcl;
498 WinInflateRect(hab, &rclTemp, -2, -2);
499 if(WinPtInRect(hab, &rclTemp, &ptl))
500 return 1; /* Mouse somewhere in the center of the selection */
501
502 /* We are over the border */
503 if(yPtr>rclTemp.yBottom && yPtr<rclTemp.yTop)
504 {
505 /* One of the vertical borders */
506 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE));
507 if(xPtr>rclTemp.xLeft)
508 return 2;
509 else
510 return 3;
511 }
512 else if((xPtr>rclTemp.xLeft && xPtr<rclTemp.xRight))
513 {
514 /* One of the horizontal borders */
515 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZENS, FALSE));
516 if(yPtr>rclTemp.yBottom)
517 return 4;
518 else
519 return 5;
520 }
521
522 return 0;
523}
524
525BOOL drawSelection(HWND hwnd, POINTS ptsStart, POINTS ptsTemp)
526{
527 RECTL rcl;
528 HPS hps;
529
530 hps=WinGetPS(hwnd);
531 if(!hps)
532 return FALSE;
533
534 if(ptsTemp.x>ptsStart.x)
535 {
536 rcl.xLeft=ptsStart.x;
537 rcl.xRight=ptsTemp.x;
538 }
539 else
540 {
541 rcl.xLeft=ptsTemp.x;
542 rcl.xRight=ptsStart.x;
543 }
544 if(ptsTemp.y>ptsStart.y)
545 {
546 rcl.yBottom=ptsStart.y;
547 rcl.yTop=ptsTemp.y;
548 }
549 else
550 {
551 rcl.yBottom=ptsTemp.y;
552 rcl.yTop=ptsStart.y;
553 }
554 WinDrawBorder(hps, &rcl, 1, 1, 0,0, DB_PATINVERT);
555 WinReleasePS(hps);
556
557 return TRUE;
558}
559
560BOOL drawSelection2(HPS hps, POINTS ptsStart, POINTS ptsTemp)
561{
562 RECTL rcl;
563
564 if(ptsTemp.x>ptsStart.x)
565 {
566 rcl.xLeft=ptsStart.x;
567 rcl.xRight=ptsTemp.x;
568 }
569 else
570 {
571 rcl.xLeft=ptsTemp.x;
572 rcl.xRight=ptsStart.x;
573 }
574 if(ptsTemp.y>ptsStart.y)
575 {
576 rcl.yBottom=ptsStart.y;
577 rcl.yTop=ptsTemp.y;
578 }
579 else
580 {
581 rcl.yBottom=ptsTemp.y;
582 rcl.yTop=ptsStart.y;
583 }
584 WinDrawBorder(hps, &rcl, 1, 1, 0,0, DB_PATINVERT);
585
586 return TRUE;
587}
588
589BOOL rectlFrom2Points(RECTL *rcl, POINTS ptsStart, POINTS ptsTemp)
590{
591
592 if(ptsTemp.x>ptsStart.x)
593 {
594 rcl->xLeft=ptsStart.x;
595 rcl->xRight=ptsTemp.x;
596 }
597 else
598 {
599 rcl->xLeft=ptsTemp.x;
600 rcl->xRight=ptsStart.x;
601 }
602 if(ptsTemp.y>ptsStart.y)
603 {
604 rcl->yBottom=ptsStart.y;
605 rcl->yTop=ptsTemp.y;
606 }
607 else
608 {
609 rcl->yBottom=ptsTemp.y;
610 rcl->yTop=ptsStart.y;
611 }
612
613 return TRUE;
614}
615
616MRESULT EXPENTRY staticProc(HWND hwnd, ULONG msg,MPARAM mp1,MPARAM mp2 )
617{
618 switch (msg)
619 {
620 case WM_PAINT:
621 {
622 HPS hps;
623 RECTL rectl, rcl;
624 ULONG ulWidth, ulHeight, ulWidthWindow, ulHeightWindow, ulFact;
625
626 WinQueryUpdateRect(hwnd, &rcl);
627
628 hps=WinBeginPaint(hwnd, NULLHANDLE, NULLHANDLE/*&rectl*/);
629 ulHeight = bmpInfoHeader2.cy;
630 ulWidth = bmpInfoHeader2.cx;
631
632 WinFillRect(hps, &rcl, CLR_WHITE);
633
634 WinQueryWindowRect(hwnd, &rectl);
635
636 ulWidthWindow=rectl.xRight;
637 ulHeightWindow=rectl.yTop;
638
639 ulFact=ulWidth/ulWidthWindow>ulHeight/ulHeightWindow ? ulWidth*1000/ulWidthWindow : ulHeight*1000/ulHeightWindow;
640 ulWidth=ulWidth*1000/ulFact;
641 ulHeight=ulHeight*1000/ulFact;
642 rectl.xRight=ulWidth;
643 rectl.yTop=ulHeight;
644 WinDrawBitmap(hps, hBitmap, NULLHANDLE, (PPOINTL) &rectl, 0, 0, DBM_STRETCH);
645 drawSelection2(hps, ptsStart, ptsTemp);
646 WinEndPaint(hps);
647 return MRFALSE;
648 }
649 case WM_MOUSEMOVE:
650 {
651 WinSetPointer(HWND_DESKTOP, WinQuerySysPointer(HWND_DESKTOP, SPTR_SIZEWE, FALSE));
652 return MRFALSE;
653 }
654 case WM_BUTTON1UP:
655 bTrack=FALSE;
656 break;
657 case WM_BUTTON1MOTIONSTART:
658 case WM_BUTTON2MOTIONSTART:
659 {
660 MyTrackRoutine(hwnd, NULLHANDLE, TF_MOVE);
661 break;
662 }
663 default:
664 break;
665 }
666 return WinDefWindowProc(hwnd,msg,mp1,mp2);
667
668 }
669
670
671static void contextMenu(HWND hwnd)
672{
673 POINTL ptl;
674 HWND hwndPopup;
675 HWND hwndTitleBar;
676 BOOL bVisible;
677
678 if((hwndTitleBar=WinWindowFromID(hwnd, FID_TITLEBAR))==NULLHANDLE)
679 return;
680
681 hwndPopup = WinLoadMenu(hwnd, NULLHANDLE, IDM_POPUP);
682 if (hwndPopup == NULLHANDLE)
683 return;
684
685 bVisible=WinIsWindowVisible(hwndTitleBar);
686
687 if(!bVisible)
688 WinSendMsg(hwndPopup,MM_SETITEMATTR,MPFROM2SHORT(IDM_ITEMTITLEBAR,FALSE),
689 MPFROM2SHORT(MIA_CHECKED,MIA_CHECKED));
690
691 WinQueryPointerPos(HWND_DESKTOP, &ptl) ;
692 WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1);
693 WinPopupMenu(hwnd, hwnd, hwndPopup,
694 ptl.x, ptl.y, IDM_ITEMEXIT, PU_HCONSTRAIN | PU_VCONSTRAIN |
695 PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 | PU_NONE );
696}
697
698
699ULONG _launchPMProg(PSZ pszTitle, PSZ wrapperExe, PSZ parameters, char *thisPtr, ULONG ulView)
700{
701 HWND hwndNotify;
702 PROGDETAILS pDetails;
703 HAPP happ;
704
705 SysWriteToTrapLog("Wrapper: %s, Parameters: %s\n", wrapperExe, parameters);
706
707 memset(&pDetails, 0, sizeof(pDetails));
708
709 pDetails.Length = sizeof(PROGDETAILS);
710 pDetails.progt.progc = PROG_DEFAULT;
711 pDetails.progt.fbVisible = SHE_VISIBLE;
712 pDetails.pszTitle = pszTitle;
713 pDetails.pszParameters = parameters;
714 pDetails.pszStartupDir = NULL;
715 pDetails.pszExecutable = wrapperExe;
716
717 //pDetails->pszParameters = NULLHANDLE;
718 //pDetails->pszExecutable = "ab.exe";
719 //pDetails->pszParameters = "mmm3u";
720 //pDetails->pszStartupDir = "D:\\Arbeitsoberflaeche";
721 // pDetails->pszTitle = "Der Titel 2...";
722
723 // pDetails->pszEnvironment = "WORKPLACE\0\0";
724 pDetails.pszEnvironment = NULLHANDLE;
725 pDetails.swpInitial.fl = SWP_ACTIVATE|SWP_ZORDER; /* window positioning */
726 pDetails.swpInitial.cy = 0; /* width of window */
727 pDetails.swpInitial.cx = 0; /* height of window */
728 pDetails.swpInitial.y = 0; /* lower edge of window */
729 pDetails.swpInitial.x = 0; /* left edge of window */
730 pDetails.swpInitial.hwndInsertBehind = HWND_TOP;
731 pDetails.swpInitial.hwnd = 0;
732 // pDetails->swpInitial.hwnd = hwndNotify;
733 pDetails.swpInitial.ulReserved1 = 0;
734 pDetails.swpInitial.ulReserved2 = 0;
735
736 happ = WinStartApp( NULLHANDLE, &pDetails,NULL, NULL, SAF_INSTALLEDCMDLINE);
737 SysWriteToTrapLog("Done. happ: %d %x\n", happ, happ);
738 return happ;
739 return 1;
740}
741
742#define MAX_DIGITS 9 /* maximum digits in numeric arg */
743#define MAX 256 /* temporary buffer length */
744#define IBUF_LEN 4096 /* Input buffer length */
745#define AllocFlag PAG_COMMIT | PAG_WRITE /* for DosAllocMem */
746
747/*********************************************************************/
748/* Numeric Return calls */
749/*********************************************************************/
750
751#define INVALID_ROUTINE 40 /* Raise Rexx error */
752#define VALID_ROUTINE 0 /* Successful completion */
753
754/*********************************************************************/
755/* Alpha Numeric Return Strings */
756/*********************************************************************/
757
758#define ERROR_RETSTR "ERROR:"
759
760#if 0
761typedef struct RxStemData {
762 SHVBLOCK shvb; /* Request block for RxVar */
763 CHAR ibuf[IBUF_LEN]; /* Input buffer */
764 CHAR varname[MAX]; /* Buffer for the variable */
765 /* name */
766 CHAR stemname[MAX]; /* Buffer for the variable */
767 /* name */
768 ULONG stemlen; /* Length of stem. */
769 ULONG vlen; /* Length of variable value */
770 ULONG j; /* Temp counter */
771 ULONG tlong; /* Temp counter */
772 ULONG count; /* Number of elements */
773 /* processed */
774} RXSTEMDATA;
775
776
777
778ULONG printVar(RXSTRING args)
779{
780 char text[1000];
781 ULONG ulLen;
782 RXSTEMDATA ldp;
783
784#if 0
785 ulLen=theVar.strlength;
786 if(sizeof(text)-1<theVar.strlength)
787 ulLen=sizeof(text);
788
789 strncpy(text, theVar.strptr, ulLen);
790
791 if(text[strlen(text)-1]!=".")
792 strcat(text, ".");
793#endif
794
795 /* Initialize data area */
796 ldp.count = 0;
797 strcpy(ldp.varname, args.strptr);
798 ldp.stemlen = args.strlength;
799 strupr(ldp.varname); /* uppercase the name */
800
801 if (ldp.varname[ldp.stemlen-1] != '.')
802 ldp.varname[ldp.stemlen++] = '.';
803
804 sprintf(ldp.varname+ldp.stemlen, "%d", 0);
805
806
807 ldp.shvb.shvnext = NULL;
808 ldp.shvb.shvname.strptr = ldp.varname;
809 ldp.shvb.shvname.strlength = strlen(ldp.varname);
810 ldp.shvb.shvnamelen = ldp.shvb.shvname.strlength;
811
812 ldp.shvb.shvvalue.strptr = NULL;//ldp.ibuf;
813 ldp.shvb.shvvalue.strlength = 0;//sizeof(ldp.ibuf);
814 ldp.shvb.shvvaluelen = 0;//sizeof(ldp.ibuf);
815
816 ldp.shvb.shvcode = RXSHV_SYFET;
817 ldp.shvb.shvret = 0;
818 if (RexxVariablePool(&ldp.shvb) == RXSHV_BADN)
819 return INVALID_ROUTINE; /* error on non-zero */
820
821#if 0
822 strncpy(text, ldp.shvb.shvname.strptr, ldp.shvb.shvname.strlength);
823
824 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Varname", 1234, MB_MOVEABLE);
825#endif
826
827 strncpy(text, ldp.shvb.shvvalue.strptr, ldp.shvb.shvvalue.strlength);
828
829 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Value", 1234, MB_MOVEABLE);
830
831return 0;
832 //
833
834}
835#endif
836
837typedef struct RxStemData {
838 SHVBLOCK shvb; /* Request block for RxVar */
839 CHAR varname[MAX]; /* Buffer for the variable */
840 /* name */
841 // CHAR stemname[MAX]; /* Buffer for the variable */
842 /* name */
843 ULONG stemlen; /* Length of stem. */
844 } RXSTEMDATA;
845
846
847
848ULONG printVar(RXSTRING args)
849{
850 char text[1000];
851 RXSTEMDATA ldp={0};
852 /* Initialize data area */
853 strcpy(ldp.varname, args.strptr);
854 ldp.stemlen = args.strlength;
855 strupr(ldp.varname); /* uppercase the name */
856
857 if (ldp.varname[ldp.stemlen-1] != '.')
858 ldp.varname[ldp.stemlen++] = '.';
859
860 sprintf(ldp.varname+ldp.stemlen, "%d", 0);
861
862
863 ldp.shvb.shvnext = NULL;
864 ldp.shvb.shvname.strptr = ldp.varname;
865 ldp.shvb.shvname.strlength = strlen(ldp.varname);
866 ldp.shvb.shvnamelen = ldp.shvb.shvname.strlength;
867
868 ldp.shvb.shvvalue.strptr = NULL;//ldp.ibuf;
869 ldp.shvb.shvvalue.strlength = 0;//sizeof(ldp.ibuf);
870 ldp.shvb.shvvaluelen = 0;//sizeof(ldp.ibuf);
871
872 ldp.shvb.shvcode = RXSHV_SYFET;
873 ldp.shvb.shvret = 0;
874 if (RexxVariablePool(&ldp.shvb) == RXSHV_BADN)
875 return INVALID_ROUTINE; /* error on non-zero */
876
877 strncpy(text, ldp.shvb.shvvalue.strptr, ldp.shvb.shvvalue.strlength);
878
879 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Value", 1234, MB_MOVEABLE);
880 DosFreeMem(ldp.shvb.shvvalue.strptr);
881 return 0;
882}
883
884
885
886/* This function is undocumented */
887#pragma import(WinBuildPtrHandle,,"PMMERGE", 5117)
888
889HPOINTER WinBuildPtrHandle(void* pIconData);
890
891BOOL fileGetBinFileSize(char *chrFileName, ULONG* ulFileSize)
892{
893 FILE *file;
894 struct stat buf;
895
896 if((file=fopen(chrFileName, "rb"))==NULLHANDLE)
897 return FALSE;
898
899 if(fstat(fileno(file), &buf)!=0) {
900 fclose(file);
901 return FALSE;
902 }
903
904 fclose(file);
905 *ulFileSize=buf.st_size;
906
907 return TRUE;
908}
909
910HPOINTER createPointerFromFile(char *chrIconFile)
911{
912 ULONG ulFileSize;
913 void * pData;
914 FILE *file;
915 HPOINTER hPtr=NULLHANDLE;
916
917 if(!fileGetBinFileSize(chrIconFile, &ulFileSize))
918 return NULLHANDLE;
919
920 if((pData=malloc(ulFileSize))==NULLHANDLE)
921 return NULLHANDLE;
922
923 if((file=fopen(chrIconFile, "rb"))==NULLHANDLE)
924 {
925 free(pData);
926 return NULLHANDLE;
927 }
928
929 if(ulFileSize!=fread(pData, sizeof(BYTE), ulFileSize, file))
930 {
931 free(pData);
932 return NULLHANDLE;
933 }
934
935 hPtr=WinBuildPtrHandle(pData);
936
937 free(pData);
938 fclose(file);
939
940 return hPtr;
941}
942
943PFNWP oldStatic;
944
945PFNWP g_oldStatic;
946ULONG g_ulStaticDataOffset;
947ULONG ulQWP_WNDDATA;
948
949
950//char html[]="<1>šberschrift<2><3> 1.Link.<5><0>77878<3>2.Link<0>!111111111! !22! !333333! !44444!<5>!5555555555555555! ";
951//<3>Ein Link.<0>Normaler Text <3>Link <1>šberschrift";
952//char html[]="<0>!111111111111111111";
953//char html[]="<1>Selected object<2><9 1><0>Text...<3 1>Open... (Link)<4>LoooooongTextAboutFolderAndFileandthrowitinthebitbucketafterwards.<6><3 2>Delete...is another veeeeeryLoooooooongTextNotFittingIntoOneLine";
954char html[]="<1 0>Selected object<2><9 1><0>Text...<0>Text...<6><3 2>Delete...is another veeeeeryLoooooooongTextNotFittingIntoOneLine1234567890123456789012345678901234567890\
955<4><10><6><3 3>Move...<4><6><3 4>Open settings...<4>\
956<7><1>Details<2><0>Size: 123456 Bytes<6><0>Noch mehr Details<6><3 5>Und ein Link...<4>";
957char html2[1000]="Parsed: ";
958
959//struct htmlPart;
960
961typedef struct _htmlPart
962{
963 char* chrText; /* Text pointer */
964 int iLength; /* Length in chars */
965 int iType; /* Type e.g. link or text */
966 RECTL rcl; /* Bounding rect in window coords */
967 POINTL ptl; /* Start position for drawing */
968 ULONG ulParam; /* Number of link in the text */
969 struct _htmlPart* hpNext; /* Next text part */
970 struct _htmlPart* hpPrev; /* This links to a previous part
971 holding a part of the current link/text. It's
972 used to climb th elist to find the beginning of
973 a link so it may be painted comnpletely */
974}htmlPart;
975
976typedef struct _taginfo
977{
978 ULONG ulMark;
979 ULONG ulParam;
980}TAGINFO;
981
982/* Styles for paragraphs, headings etc. */
983typedef struct _style
984{
985 LONG cx; /* Delta to move the paragraph to the right */
986 LONG foreClr; /* Not yet used */
987}STYLE;
988
989/* Styles for sections */
990#define MAX_SECTION_STYLE 2
991STYLE sectionStyles[MAX_SECTION_STYLE]={0,0,10, 0};
992
993/* Known tags */
994#define MARK_TEXT 0
995#define MARK_H1 1 /* Heading 1 */
996#define MARK_H1_END 2
997
998#define MARK_LINK 3 /* A link */
999#define MARK_LINK_END 4
1000
1001#define MARK_BREAK 5 /* Break in the line */
1002#define MARK_PARAGRAPH 6
1003#define MARK_RULER 7 /* horizontal ruler */
1004#define MARK_IMAGE 8
1005
1006#define MARK_SECTION 9 /* New section with different properties */
1007#define MARK_SECTION_END 10
1008
1009
1010#define QWL_HTMLWNDDATA QWL_USER /* FIXME: Only for testing */
1011
1012typedef struct _formatinfo
1013{
1014 ULONG xPos;
1015 LONG cyChar;
1016 LONG foreClr;
1017 LONG backClr;
1018 int iFontSize;
1019 struct _formatinfo * fiNext;
1020}FORMATINFO;
1021
1022/* Additional windowdata */
1023typedef struct _htmlwnddata
1024{
1025 LONG lVertBarWidth;
1026 ULONG ulCyText; /* Necessary y size to draw the text */
1027 ULONG ulCxText; /* Not yet used */
1028 LONG lYViewPort; /* Delta for drawing contents when window is scrolled */
1029 htmlPart* hPartList; /* List of the html parts containing the text */
1030 HMTX hmtxList; /* Semaphore to protect html list when text changes */
1031 char * chrText; /* Pointer to unformatted text */
1032 FORMATINFO* hFormatInfo;
1033 HPOINTER hPtr;
1034}HTMLWNDDATA;
1035
1036
1037void parseHtml(void)
1038{
1039
1040}
1041
1042HWND hwndMsg;
1043
1044void printMsg(char *chrText)
1045{
1046 WinSendMsg(hwndMsg, LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(chrText));
1047}
1048void printLong(LONG l, char * text)
1049{
1050 char msg[500];
1051 sprintf(msg, "%s: %d",text, l);
1052 WinSendMsg(hwndMsg, LM_INSERTITEM, MPFROMSHORT(LIT_END), MPFROMP(msg));
1053}
1054
1055char* parseMark(int iLength, char *chrPos, TAGINFO *tagInfo)
1056{
1057 char *chrStart=chrPos;
1058
1059 *chrStart++; /* move to mark */
1060
1061 while(*chrPos!=0)
1062 {
1063 switch(*chrPos)
1064 {
1065 case '>':
1066 /* found end of mark */
1067 {
1068 int iType;
1069
1070 iType=atoi(chrStart++);/* Which mark e.g. link, text... */
1071 chrPos++;
1072 switch(iType)
1073 {
1074 case MARK_SECTION:
1075 case MARK_SECTION_END:
1076 case MARK_LINK:
1077 case MARK_H1:
1078 tagInfo->ulMark=iType;
1079 /* Get param number. Format of link is: <3 x> with x a number */
1080 tagInfo->ulParam=atoi(chrStart);
1081 break;
1082 case MARK_LINK_END:
1083 case MARK_H1_END:
1084 case MARK_BREAK:
1085 case MARK_PARAGRAPH:
1086 case MARK_RULER:
1087 tagInfo->ulMark=iType;
1088 tagInfo->ulParam=0;
1089 break;
1090 default:
1091 tagInfo->ulMark=MARK_TEXT;
1092 break;
1093 }
1094 return chrPos;
1095 }
1096 default:
1097 break;
1098 }
1099 chrPos++;
1100 }
1101 tagInfo->ulMark=MARK_TEXT;
1102 tagInfo->ulParam=0;
1103 return chrPos;
1104}
1105
1106char *findNextMark(char *chrPos)
1107{
1108 while(*chrPos!=0)
1109 {
1110 switch(*chrPos)
1111 {
1112 case '<':
1113 return chrPos;
1114 default:
1115 break;
1116 }
1117 chrPos++;
1118 }
1119 return chrPos;
1120}
1121
1122void addToHtmlPartList(HWND hwnd, htmlPart* hTemp)
1123{
1124 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1125
1126 if(!wndData->hPartList)
1127 {
1128 wndData->hPartList=hTemp;
1129 return;
1130 }
1131 hTemp->hpNext=wndData->hPartList;
1132 wndData->hPartList=hTemp;
1133}
1134
1135htmlPart* getHeadHtmlPart(htmlPart* hTemp)
1136{
1137 while(hTemp->hpPrev)
1138 hTemp=hTemp->hpPrev;
1139
1140 return hTemp;
1141}
1142
1143void freeHtmlPartList(HWND hwnd)
1144{
1145 htmlPart *htmlTemp;
1146 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1147
1148 htmlTemp=wndData->hPartList;
1149 while(htmlTemp)
1150 {
1151 htmlPart* hTemp=htmlTemp->hpNext;
1152 free(htmlTemp);
1153 htmlTemp=hTemp;
1154 }
1155 wndData->hPartList=NULLHANDLE;
1156}
1157
1158BOOL pushFormatInfo(HWND hwnd, FORMATINFO formatInfo)
1159{
1160 FORMATINFO* fiTemp;
1161 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1162 FORMATINFO* hFormatInfo;
1163
1164 if(!wndData)
1165 return FALSE; /* There's a problem*/
1166
1167 hFormatInfo=wndData->hFormatInfo;
1168
1169 if((fiTemp=malloc(sizeof(FORMATINFO)))==NULLHANDLE)
1170 return FALSE;
1171
1172 // memset(fiTemp, 0, sizeof(FORMATINFO));
1173
1174 *fiTemp=formatInfo;
1175
1176 // printLong(fiTemp->xPos, "push it");
1177 if(!hFormatInfo)
1178 {
1179 wndData->hFormatInfo=fiTemp;
1180 return TRUE;
1181 }
1182
1183 fiTemp->fiNext=hFormatInfo;
1184 wndData->hFormatInfo=fiTemp;
1185
1186 //htmlWndData.hFormatInfo=hFormatInfo; /* Testing only */
1187 return TRUE;
1188}
1189
1190BOOL popFormatInfo(HWND hwnd, FORMATINFO* formatInfo)
1191{
1192 FORMATINFO* fiTemp;
1193 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1194 FORMATINFO* hFormatInfo;
1195
1196 if(!wndData)
1197 return FALSE; /* There's a problem*/
1198
1199 hFormatInfo=wndData->hFormatInfo;
1200
1201 if(!hFormatInfo)
1202 return FALSE;
1203
1204 fiTemp=hFormatInfo->fiNext;
1205 *formatInfo=*hFormatInfo;
1206 formatInfo->fiNext=NULLHANDLE;
1207
1208 free(hFormatInfo);
1209
1210 wndData->hFormatInfo=fiTemp;
1211 return TRUE;
1212}
1213
1214BOOL getFormatInfo(HWND hwnd, FORMATINFO* formatInfo)
1215{
1216 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1217 FORMATINFO* hFormatInfo;
1218
1219 if(!wndData)
1220 return FALSE; /* There's a problem*/
1221
1222 hFormatInfo=wndData->hFormatInfo;
1223
1224 if(!hFormatInfo)
1225 return FALSE;
1226
1227 *formatInfo=*hFormatInfo;
1228
1229 return TRUE;
1230}
1231
1232void freeFormatInfoList(HWND hwnd)
1233{
1234 FORMATINFO* fiTemp;
1235 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1236 FORMATINFO* hFormatInfo;
1237
1238 if(!wndData)
1239 return; /* There's a problem*/
1240
1241 hFormatInfo=wndData->hFormatInfo;
1242
1243 fiTemp=hFormatInfo;
1244
1245 while(fiTemp)
1246 {
1247 FORMATINFO* hFi=fiTemp->fiNext;
1248 free(fiTemp);
1249 fiTemp=hFi;
1250 }
1251
1252 wndData->hFormatInfo=NULLHANDLE;
1253}
1254
1255
1256htmlPart * checkForLink(HWND hwnd, PPOINTL ptl)
1257{
1258 htmlPart *hTemp;
1259 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1260
1261 hTemp=wndData->hPartList;
1262 // printLong(ptl->y, "y");
1263 // printLong(hTemp->rcl.yTop, "rcl x");
1264 while(hTemp)
1265 {
1266 RECTL rcl=hTemp->rcl;
1267 rcl.yTop+=wndData->lYViewPort;
1268 rcl.yBottom+=wndData->lYViewPort;
1269 if(WinPtInRect(WinQueryAnchorBlock(HWND_DESKTOP), &rcl, ptl)) {
1270 if(hTemp->iType==MARK_LINK)
1271 return hTemp;
1272 }
1273 hTemp=hTemp->hpNext;
1274 }
1275 return NULLHANDLE;
1276}
1277
1278BOOL clickLink(HWND hwnd, PPOINTL ptl)
1279{
1280 htmlPart *hTemp;
1281 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1282
1283 hTemp=wndData->hPartList;
1284
1285 while(hTemp)
1286 {
1287 RECTL rcl=hTemp->rcl;
1288 rcl.yTop+=wndData->lYViewPort;
1289 rcl.yBottom+=wndData->lYViewPort;
1290
1291 if(WinPtInRect(WinQueryAnchorBlock(HWND_DESKTOP), &rcl, ptl)) {
1292 if(hTemp->iType==MARK_LINK) {
1293 return hTemp->ulParam;
1294 }
1295 }
1296 hTemp=hTemp->hpNext;
1297 }
1298 return 0;
1299}
1300
1301/* returns the string length in points for the given hps */
1302LONG gpiStringLength(HPS hps, LONG lLength, char * chrText)
1303{
1304 POINTL aptl[TXTBOX_COUNT];
1305
1306 GpiQueryTextBox(hps, lLength, chrText, TXTBOX_COUNT, aptl);
1307
1308 return aptl[TXTBOX_BOTTOMRIGHT].x-aptl[TXTBOX_BOTTOMLEFT].x;
1309}
1310
1311
1312/* returns the string length in chars. Accepts ' ' and '<' as
1313 string part separators */
1314LONG newStringLength(HPS hps, LONG lMax, char * chrText)
1315{
1316 char * chrPtr;
1317 LONG rc;
1318
1319 if((chrPtr=strchr(chrText, ' '))!=NULLHANDLE) {
1320 rc=chrPtr-chrText+1; /* Move behind the space */
1321 if(rc<=lMax)
1322 return rc;
1323 }
1324
1325 if((chrPtr=strchr(chrText, '<'))!=NULLHANDLE)
1326 return chrPtr-chrText; /* Move behind the space */
1327
1328 return strlen(chrText);
1329}
1330
1331/* Find a string which fits into the remaining window space */
1332LONG getFittingStringLength(HPS hps, LONG lMax, char* chrText, LONG lFreeSpace)
1333{
1334 LONG lPtl;
1335 int a=0;
1336
1337 /*
1338 FIXME:
1339 Very sloooooow
1340 */
1341 while((lPtl=gpiStringLength(hps, a+1, chrText))<=lFreeSpace)
1342 a++;
1343 return a;
1344}
1345
1346void setHeadingFormat(HPS hps, LONG * clrFore)
1347{
1348 FATTRS fat;
1349 memset(&fat, 0, sizeof(fat));
1350 fat.fsSelection=FATTR_SEL_BOLD;
1351 fat.usRecordLength=sizeof(fat);
1352 fat.lMaxBaselineExt=12L;
1353 fat.lAveCharWidth=12L;
1354 fat.fsFontUse=FATTR_FONTUSE_NOMIX;
1355
1356 strcpy(fat.szFacename, "WarpSans");
1357 GpiCreateLogFont(hps, NULL, 1L, &fat);
1358 GpiSetCharSet(hps, 1L);
1359 *clrFore=CLR_BLACK;
1360}
1361
1362
1363void setLinkFormat(HPS hps, LONG * clrFore)
1364{
1365#if 0
1366 FATTRS fat;
1367
1368 memset(&fat, 0, sizeof(fat));
1369 fat.fsSelection=FATTR_SEL_UNDERSCORE;
1370 fat.usRecordLength=sizeof(fat);
1371 fat.lMaxBaselineExt=10L;
1372 fat.lAveCharWidth=10L;
1373 fat.fsFontUse=FATTR_FONTUSE_NOMIX;
1374 strcpy(fat.szFacename, "WarpSans");
1375
1376 GpiCreateLogFont(hps, NULL, 1L, &fat);
1377
1378 GpiSetCharSet(hps, 1L);
1379#endif
1380 *clrFore=CLR_BLUE;
1381}
1382
1383/* format and draw text */
1384LONG drawText2(HPS hps, HWND hwnd, LONG lLength, char * chrText, RECTL* rcl, TAGINFO *tagInfo, LONG lCharsDone, ULONG ulFlags)
1385{
1386 POINTL aptl[TXTBOX_COUNT];
1387 POINTL ptl;
1388 LONG clrFore;
1389 LONG lTotalLength=lLength;
1390 htmlPart* hTemp=NULLHANDLE;
1391 LONG lPtl;
1392 LONG lMark=tagInfo->ulMark;
1393 FORMATINFO fi={0};
1394 htmlPart *hPrev=NULLHANDLE;
1395
1396 getFormatInfo( hwnd, &fi);
1397
1398#if 0
1399 if(lLength)
1400 GpiQueryTextBox(hps, lLength, chrText, TXTBOX_COUNT, aptl);
1401 else
1402#endif
1403
1404 GpiQueryTextBox(hps, 1, "*", TXTBOX_COUNT, aptl);
1405
1406
1407 GpiQueryCurrentPosition(hps, &ptl);
1408
1409 if(!lCharsDone)
1410 {
1411 //printMsg("First run...");
1412 /* First invocation */
1413 fi.cyChar=aptl[TXTBOX_TOPLEFT].y-aptl[TXTBOX_BOTTOMLEFT].y;
1414 fi.xPos=0;
1415
1416 ptl.x=fi.xPos;
1417 rcl->yTop-=fi.cyChar;
1418 ptl.y=rcl->yTop;
1419 GpiMove(hps, &ptl);
1420 /* Save current formatting info */
1421 pushFormatInfo(hwnd, fi);
1422 }
1423
1424
1425 switch(lMark)
1426 {
1427 case MARK_H1:
1428 {
1429 setHeadingFormat(hps, &clrFore);
1430
1431 GpiQueryTextBox(hps, 1, "*", TXTBOX_COUNT, aptl);
1432 fi.cyChar=aptl[TXTBOX_TOPLEFT].y-aptl[TXTBOX_BOTTOMLEFT].y;
1433 ptl.x=rcl->xLeft;
1434 rcl->yTop-=(fi.cyChar*1.5);
1435 ptl.y=rcl->yTop;
1436 GpiMove(hps, &ptl);
1437
1438 break;
1439 }
1440 case MARK_H1_END:
1441 GpiQueryTextBox(hps, 1, "*", TXTBOX_COUNT, aptl);
1442 fi.cyChar=aptl[TXTBOX_TOPLEFT].y-aptl[TXTBOX_BOTTOMLEFT].y;
1443
1444 // ptl.x=rcl->xLeft;
1445 ptl.x=fi.xPos;
1446 rcl->yTop-=(fi.cyChar*1.5);
1447 ptl.y=rcl->yTop;
1448 GpiMove(hps, &ptl);
1449
1450 GpiDeleteSetId(hps, LCID_ALL);
1451 return lLength;
1452 case MARK_SECTION:
1453 {
1454 int idx=0;
1455
1456 if(tagInfo->ulParam<=MAX_SECTION_STYLE)
1457 idx=tagInfo->ulParam;
1458 fi.xPos+=sectionStyles[idx].cx;
1459 ptl.x=fi.xPos;
1460 GpiMove(hps, &ptl);
1461
1462 pushFormatInfo(hwnd, fi);
1463
1464 if(!lLength)
1465 return lLength;
1466 break;
1467 }
1468 case MARK_SECTION_END:
1469
1470 popFormatInfo(hwnd, &fi);
1471
1472 if(!lLength)
1473 return lLength;
1474 break;
1475
1476 case MARK_LINK:
1477 {
1478 setLinkFormat(hps, &clrFore);
1479 break;
1480 }
1481
1482#if 0
1483 case MARK_LINK:
1484 {
1485 FATTRS fat;
1486
1487 memset(&fat, 0, sizeof(fat));
1488 fat.fsSelection=FATTR_SEL_BOLD;
1489 fat.usRecordLength=sizeof(fat);
1490 //fat.lMaxBaselineExt=9L;
1491 // fat.lAveCharWidth=9L;
1492 fat.fsFontUse=FATTR_FONTUSE_NOMIX;
1493 strcpy(fat.szFacename, "WarpSans");
1494
1495 GpiCreateLogFont(hps, NULL, 1L, &fat);
1496 GpiSetCharSet(hps, 1L);
1497
1498 clrFore=CLR_BLUE;
1499 break;
1500 }
1501#endif
1502
1503 case MARK_PARAGRAPH:
1504 // ptl.x=rcl->xLeft;
1505 ptl.x=fi.xPos;
1506 rcl->yTop-=fi.cyChar*1.5;
1507 ptl.y=rcl->yTop;
1508 GpiMove(hps, &ptl);
1509 return lLength;
1510 case MARK_BREAK:
1511 ptl.x=rcl->xLeft;
1512 rcl->yTop-=fi.cyChar;
1513 ptl.y=rcl->yTop;
1514 GpiMove(hps, &ptl);
1515 /* if lLength!=0 then no starting tag for following text. Only the <Break> tag given. */
1516 if(!lLength)
1517 return lLength;
1518 break;
1519 case MARK_RULER:
1520 {
1521 /* Draw ruler */
1522 ptl.x=rcl->xRight*0.1;
1523 rcl->yTop-=fi.cyChar*1.5;
1524 ptl.y=rcl->yTop;
1525
1526 //printLong(ptl.x, "ptl.x");
1527 //printLong(ptl.y, "ptl.y");
1528
1529 hTemp=malloc(sizeof(htmlPart));
1530 hTemp->iType=lMark;
1531
1532 WinSetRect(WinQueryAnchorBlock(HWND_DESKTOP), &hTemp->rcl,
1533 ptl.x, ptl.y,
1534 rcl->xRight*0.9, ptl.y+2 );
1535
1536 hTemp->ptl=ptl;
1537 hTemp->chrText=chrText;
1538 hTemp->iLength=rcl->xRight*0.8;
1539 hTemp->ulParam=tagInfo->ulParam;
1540 hTemp->hpPrev=hPrev;
1541 hPrev=hTemp;
1542 addToHtmlPartList(hwnd, hTemp);
1543
1544 GpiMove(hps, &ptl);
1545 ptl.x=rcl->xRight*0.9;
1546 GpiLine(hps, &ptl);
1547
1548
1549 ptl.x=fi.xPos;
1550 ptl.y=rcl->yTop;
1551 GpiMove(hps, &ptl);
1552 /* if lLength!=0 then no starting tag for following text. Only the <Break> tag given. */
1553 if(!lLength)
1554 return lLength;
1555 break;
1556 }
1557 default:
1558 GpiSetCharSet(hps, LCID_DEFAULT); /* Default font */
1559 GpiDeleteSetId(hps, LCID_ALL);
1560 clrFore=CLR_BLACK; /* Default color */
1561 break;
1562 }
1563
1564 // ptl.x=fi.xPos;
1565 // printLong(fi.xPos, "fi.xPos");
1566 /***********************/
1567 //GpiMove(hps, &ptl);
1568
1569 GpiSetColor(hps, clrFore);
1570 // GpiQueryCurrentPosition(hps, &ptl);
1571
1572 lPtl=gpiStringLength(hps, lLength, chrText );
1573 if( lPtl <= (rcl->xRight-ptl.x)) {
1574 /* String fits into line */
1575 //GpiSetColor(hps, CLR_BLACK);
1576 //printLong(ptl.x, "ptl.x");
1577 GpiCharString(hps, lLength, chrText);
1578 hTemp=malloc(sizeof(htmlPart));
1579 hTemp->iType=lMark;
1580 WinSetRect(WinQueryAnchorBlock(HWND_DESKTOP), &hTemp->rcl,
1581 ptl.x, ptl.y,
1582 ptl.x+ lPtl, ptl.y+fi.cyChar );
1583 hTemp->ptl=ptl;
1584 hTemp->chrText=chrText;
1585 hTemp->iLength=lLength;
1586 hTemp->ulParam=tagInfo->ulParam;
1587 hTemp->hpPrev=hPrev;
1588 hPrev=hTemp;
1589 addToHtmlPartList(hwnd, hTemp);
1590 return lLength;
1591 }
1592 else
1593 {
1594 LONG lDone=0;
1595 LONG lPtl;
1596 /* String is to long. Split in words and try to draw them */
1597
1598 //DosBeep(5000, 200);
1599 //DosSleep(100);
1600 /* Get next word */
1601 while((lLength=newStringLength( hps, lTotalLength-lDone, chrText)) && lDone+lLength<=lTotalLength)
1602 {
1603 lPtl=gpiStringLength(hps, lLength, chrText);
1604 GpiQueryCurrentPosition(hps, &ptl);
1605
1606 if(lPtl > (rcl->xRight-ptl.x))
1607 {
1608 /* Word doesn't fit. Check if it fits into a whole line */
1609 // if(lPtl <= (rcl->xRight-rcl->xLeft))
1610 if(lPtl <= (rcl->xRight-fi.xPos))
1611 {
1612 /* Yes, does fit. Move to next line and print it */
1613 // ptl.x=rcl->xLeft;
1614 ptl.x=fi.xPos;
1615 rcl->yTop-=fi.cyChar;
1616 ptl.y=rcl->yTop;
1617 GpiMove(hps, &ptl);
1618
1619 //GpiSetColor(hps, CLR_RED);
1620
1621 GpiCharString(hps, lLength, chrText);
1622 }
1623 else {
1624 /* No, too long for a whole line so start writing in current line and wrap */
1625 /* Get the amount of chars which do fit */
1626 lLength=getFittingStringLength(hps, lTotalLength-lDone, chrText, rcl->xRight-ptl.x);
1627 GpiSetColor(hps, CLR_BLUE);
1628 if(lLength)
1629 GpiCharString(hps, lLength, chrText);
1630 else
1631 {
1632 /* Not enough space for a single char, move to next line */
1633 ptl.x=fi.xPos;
1634 rcl->yTop-=fi.cyChar;
1635 ptl.y=rcl->yTop;
1636 GpiMove(hps, &ptl);
1637 }
1638 }
1639 }
1640 else {
1641 /* The current string fits into the remaining space */
1642 //GpiSetColor(hps, CLR_GREEN);
1643 GpiCharString(hps, lLength, chrText);
1644 }
1645 /* Crate the part info */
1646 hTemp=malloc(sizeof(htmlPart));
1647 hTemp->iType=lMark;
1648 WinSetRect(WinQueryAnchorBlock(HWND_DESKTOP), &hTemp->rcl,
1649 ptl.x, ptl.y,
1650 ptl.x+lPtl, ptl.y+fi.cyChar );
1651 hTemp->ptl=ptl;
1652 hTemp->chrText=chrText;
1653 hTemp->iLength=lLength;
1654 hTemp->ulParam=tagInfo->ulParam;
1655 hTemp->hpPrev=hPrev;
1656 hPrev=hTemp;
1657 addToHtmlPartList(hwnd, hTemp);
1658 lDone+=lLength;
1659 // printLong(lDone, "lDone");
1660 chrText+=lLength; /* Move write mark in string */
1661 // printMsg(chrText);
1662 /* Get next word */
1663 // lLength=newStringLength( hps, lTotalLength-lDone, chrText);
1664 // printLong(lLength, "lLength");
1665 }
1666 // printMsg("");
1667 return lDone;
1668 }
1669 return 0;
1670}
1671
1672/*
1673 FIXME: Use position info for optimized drawing instead of relying on
1674 system clipping in HPS.
1675 */
1676void drawItNow(HWND hwnd, HPS hps, RECTL *rcl)
1677{
1678 htmlPart *hTemp;
1679 LONG clrFore;
1680 POINTL ptl;
1681 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1682
1683 hTemp=wndData->hPartList;
1684 // printLong(ptl->y, "y");
1685 // printLong(hTemp->rcl.yTop, "rcl x");
1686 while(hTemp)
1687 {
1688 switch(hTemp->iType)
1689 {
1690 case MARK_H1:
1691 {
1692 setHeadingFormat(hps, &clrFore);
1693 break;
1694 }
1695 GpiDeleteSetId(hps, LCID_ALL);
1696 return;
1697 case MARK_LINK:
1698 {
1699 setLinkFormat(hps, &clrFore);
1700 break;
1701 }
1702 case MARK_RULER:
1703 {
1704 /* Draw ruler */
1705 GpiSetColor(hps, clrFore);
1706
1707 ptl=hTemp->ptl;
1708 ptl.y+=wndData->lYViewPort;
1709
1710 GpiMove(hps, &ptl);
1711 ptl.x+=hTemp->iLength;
1712 GpiLine(hps, &ptl);
1713
1714 hTemp=hTemp->hpNext;
1715 continue;
1716 }
1717 default:
1718 GpiSetCharSet(hps, LCID_DEFAULT);
1719 GpiDeleteSetId(hps, LCID_ALL);
1720 clrFore=CLR_BLACK;
1721 break;
1722 }
1723
1724 GpiSetColor(hps, clrFore);
1725
1726 ptl=hTemp->ptl;
1727 ptl.y+=wndData->lYViewPort;
1728 GpiMove(hps, &ptl);
1729 GpiCharString(hps, hTemp->iLength, hTemp->chrText);
1730
1731 hTemp=hTemp->hpNext;
1732 }
1733 return;
1734}
1735
1736void formatText(HWND hwnd, char *text, RECTL *rcl)
1737{
1738 LONG lLength;
1739 LONG lTotalLength=strlen(text);
1740 char *chrPos=text;
1741 char *chrEnd;
1742 LONG lDone=0;
1743 TAGINFO tagInfo;
1744 RECTL rclTemp;
1745 HPS hps;
1746 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1747
1748 if(!wndData)
1749 return ;
1750
1751 freeHtmlPartList(hwnd);
1752
1753 rclTemp=*rcl;
1754 // rclTemp.xRight-=10;//wndData->lVertBarWidth;
1755 hps=WinGetPS(hwnd);
1756 tagInfo.ulMark=MARK_TEXT;
1757
1758 while(lDone<=lTotalLength && *chrPos!=0)
1759 {
1760 /* Check if starting with a mark */
1761 if(*chrPos=='<')
1762 chrPos=parseMark(lLength, chrPos, &tagInfo); /* Start of real text in chrPos */
1763
1764 /* Get next mark */
1765 chrEnd=findNextMark(chrPos);
1766 lLength=chrEnd-chrPos; /* Length of text to be drawn */
1767
1768 lDone+=drawText2(hps, hwnd, lLength, chrPos, &rclTemp, &tagInfo, lDone, DT_WORDBREAK);
1769 chrPos=chrEnd;
1770 } /* while */
1771 // printLong( rcl->yTop, "cy window ");
1772 // printLong( rcl->yTop-rclTemp.yTop, "cy text ");
1773
1774 wndData->ulCyText=rcl->yTop-rclTemp.yTop;
1775 if(wndData->ulCyText>rcl->yTop) {
1776 /* Set scrollbar range and position */
1777 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETSCROLLBAR, MPFROMSHORT(1),
1778 MPFROM2SHORT( 1,wndData->ulCyText-rcl->yTop));
1779
1780 /* Set size of thumb */
1781 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETTHUMBSIZE,
1782 MPFROM2SHORT( rcl->yTop, wndData->ulCyText), 0L);
1783
1784 WinShowWindow(WinWindowFromID(hwnd, FID_VERTSCROLL), TRUE);
1785 }
1786 else
1787 WinShowWindow(WinWindowFromID(hwnd, FID_VERTSCROLL), FALSE);
1788 WinReleasePS(hps);
1789
1790 freeFormatInfoList(hwnd);
1791}
1792
1793MRESULT EXPENTRY htmlProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
1794{
1795 switch(msg)
1796 {
1797 case WM_MOUSEMOVE:
1798 {
1799 POINTL ptl;
1800 htmlPart *hTemp;
1801
1802 ptl.x=SHORT1FROMMP(mp1);
1803 ptl.y=SHORT2FROMMP(mp1);
1804 if((hTemp=checkForLink(hwnd, &ptl))!=NULLHANDLE) {
1805 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1806 /* Mouse is over a link */
1807 if(wndData->hPtr)
1808 WinSetPointer(HWND_DESKTOP, wndData->hPtr);
1809 // hTemp=getHeadHtmlPart(hTemp);
1810 // drawLinkSelected
1811 return MRTRUE;
1812 }
1813 break;
1814 }
1815 case WM_BUTTON1CLICK:
1816 {
1817 POINTL ptl;
1818 ULONG ulLink;
1819 ptl.x=SHORT1FROMMP(mp1);
1820 ptl.y=SHORT2FROMMP(mp1);
1821
1822 if((ulLink=clickLink(hwnd, &ptl))!=0) {
1823 printLong(ulLink, "Link nr.");
1824 return MRTRUE;
1825 }
1826
1827 return MRFALSE;
1828 }
1829 case WM_PAINT:
1830 {
1831 RECTL rcl;
1832 HPS hps;
1833
1834 hps=WinBeginPaint(hwnd, NULLHANDLE, &rcl);
1835
1836 WinQueryWindowRect(hwnd, &rcl);
1837 WinFillRect(hps, &rcl, CLR_WHITE);
1838
1839 drawItNow(hwnd, hps, &rcl);
1840
1841 WinEndPaint(hps);
1842 return MRFALSE;
1843 }
1844 /* Vertical slider */
1845 case WM_VSCROLL:
1846 {
1847 switch(SHORT1FROMMP(mp1))
1848 {
1849 case FID_VERTSCROLL:
1850 {
1851 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1852
1853 switch(SHORT2FROMMP(mp2))
1854 {
1855 case SB_LINEDOWN:
1856 {
1857 RECTL rcl;
1858 WinQueryWindowRect(hwnd, &rcl);
1859 wndData->lYViewPort+=10;//wndData->ulCyText;
1860 if(wndData->lYViewPort+rcl.yTop>wndData->ulCyText)
1861 wndData->lYViewPort=wndData->ulCyText-rcl.yTop;
1862 rcl.xRight-=wndData->lVertBarWidth;
1863 WinInvalidateRect(hwnd, &rcl, TRUE);
1864 /* Position slider */
1865 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETSCROLLBAR,
1866 MPFROMSHORT(1+wndData->lYViewPort),
1867 MPFROM2SHORT( 1,wndData->ulCyText-rcl.yTop));
1868 break;
1869 }
1870 case SB_LINEUP:
1871 {
1872 RECTL rcl;
1873 WinQueryWindowRect(hwnd, &rcl);
1874 wndData->lYViewPort-=10;//wndData->ulCyText;
1875 if(wndData->lYViewPort<0)
1876 wndData->lYViewPort=0;
1877 rcl.xRight-=wndData->lVertBarWidth;
1878 WinInvalidateRect(hwnd, &rcl, TRUE);
1879 /* Position slider */
1880 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETSCROLLBAR,
1881 MPFROMSHORT(1+wndData->lYViewPort),
1882 MPFROM2SHORT( 1,wndData->ulCyText-rcl.yTop));
1883 break;
1884 }
1885 case SB_PAGEDOWN:
1886 {
1887 RECTL rcl;
1888 WinQueryWindowRect(hwnd, &rcl);
1889 wndData->lYViewPort+=rcl.yTop;//wndData->ulCyText;
1890 if(wndData->lYViewPort+rcl.yTop>wndData->ulCyText)
1891 wndData->lYViewPort=wndData->ulCyText-rcl.yTop;
1892 rcl.xRight-=wndData->lVertBarWidth;
1893 WinInvalidateRect(hwnd, &rcl, TRUE);
1894 /* Position slider */
1895 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETSCROLLBAR,
1896 MPFROMSHORT(1+wndData->lYViewPort),
1897 MPFROM2SHORT( 1,wndData->ulCyText-rcl.yTop));
1898 break;
1899 }
1900 case SB_PAGEUP:
1901 {
1902 RECTL rcl;
1903 WinQueryWindowRect(hwnd, &rcl);
1904 wndData->lYViewPort-=rcl.yTop;//wndData->ulCyText;
1905 if(wndData->lYViewPort<0)
1906 wndData->lYViewPort=0;
1907 rcl.xRight-=wndData->lVertBarWidth;
1908 WinInvalidateRect(hwnd, &rcl, TRUE);
1909 /* Position slider */
1910 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETSCROLLBAR,
1911 MPFROMSHORT(1+wndData->lYViewPort),
1912 MPFROM2SHORT( 1,wndData->ulCyText-rcl.yTop));
1913 break;
1914 }
1915 /* User moved slider and released the button */
1916 case SB_SLIDERPOSITION:
1917 {
1918 RECTL rcl;
1919 WinQueryWindowRect(hwnd, &rcl);
1920 wndData->lYViewPort=SHORT1FROMMP(mp2);
1921 if(wndData->lYViewPort<0)
1922 wndData->lYViewPort=0;
1923 else if(wndData->lYViewPort+rcl.yTop>wndData->ulCyText)
1924 wndData->lYViewPort=wndData->ulCyText-rcl.yTop;
1925
1926 rcl.xRight-=wndData->lVertBarWidth;
1927 WinInvalidateRect(hwnd, &rcl, TRUE);
1928 /* Position slider */
1929 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETSCROLLBAR,
1930 MPFROMSHORT(1+wndData->lYViewPort),
1931 MPFROM2SHORT( 1,wndData->ulCyText-rcl.yTop));
1932 break;
1933 }
1934 case SB_SLIDERTRACK:
1935 {
1936 RECTL rcl;
1937 WinQueryWindowRect(hwnd, &rcl);
1938 wndData->lYViewPort=SHORT1FROMMP(mp2);
1939 if(wndData->lYViewPort<0)
1940 wndData->lYViewPort=0;
1941 else if(wndData->lYViewPort+rcl.yTop>wndData->ulCyText)
1942 wndData->lYViewPort=wndData->ulCyText-rcl.yTop;
1943
1944 rcl.xRight-=wndData->lVertBarWidth;
1945 WinInvalidateRect(hwnd, &rcl, TRUE);
1946 /* Position slider */
1947 WinSendMsg(WinWindowFromID(hwnd, FID_VERTSCROLL), SBM_SETSCROLLBAR,
1948 MPFROMSHORT(1+wndData->lYViewPort),
1949 MPFROM2SHORT( 1,wndData->ulCyText-rcl.yTop));
1950 break;
1951 }
1952 default:
1953 break;
1954 }
1955 break;
1956 }
1957 default:
1958 break;
1959 }
1960
1961 break;
1962 }
1963 case WM_SETWINDOWPARAMS:
1964 {
1965 PWNDPARAMS pwp=PVOIDFROMMP(mp1);
1966 RECTL rcl;
1967 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1968
1969 if(!pwp || !(pwp->fsStatus & WPM_TEXT))
1970 break;
1971
1972 WinQueryWindowRect(hwnd, &rcl);
1973
1974 if(wndData) {
1975 if(wndData->chrText)
1976 free(wndData->chrText);
1977
1978 wndData->chrText=malloc(pwp->cchText+1); /* Don't know if terminating 0 is included... */
1979 if(wndData->chrText)
1980 strncpy(wndData->chrText, pwp->pszText, pwp->cchText);
1981 rcl.xRight-= wndData->lVertBarWidth;
1982 formatText( hwnd, wndData->chrText, &rcl);
1983 }
1984 break;
1985 }
1986 case WM_WINDOWPOSCHANGED:
1987 {
1988 PSWP pswp=PVOIDFROMMP(mp1);
1989
1990 if(!pswp)
1991 break;
1992 if(pswp->fl & SWP_SIZE) {
1993 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
1994
1995 if(wndData) {
1996 RECTL rcl={0};
1997
1998 WinQueryWindowRect(hwnd, &rcl);
1999 rcl.xRight=pswp->cx-wndData->lVertBarWidth;
2000 rcl.yTop=pswp->cy;
2001 formatText(hwnd, html, &rcl);
2002 }
2003 }
2004 break;
2005 }
2006 case WM_CREATE:
2007 {
2008 FRAMECDATA frameCtrl={0};
2009 RECTL rcl;
2010 HTMLWNDDATA* wndData;
2011 MRESULT mr;
2012
2013 ULONG ulVBar=WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
2014 mr=g_oldStatic( hwnd, msg, mp1, mp2);
2015
2016
2017 /* Create scrollbar */
2018 frameCtrl.cb=sizeof(frameCtrl);
2019 frameCtrl.flCreateFlags=FCF_VERTSCROLL;
2020 WinCreateFrameControls(hwnd, &frameCtrl, "");
2021
2022 /* Position Framecontrol */
2023 WinQueryWindowRect( hwnd, &rcl);
2024 WinSetWindowPos(WinWindowFromID(hwnd, FID_VERTSCROLL),
2025 NULLHANDLE, rcl.xRight-ulVBar, 0, ulVBar, rcl.yTop, SWP_MOVE|SWP_SIZE);
2026
2027 wndData=malloc(sizeof(HTMLWNDDATA));
2028 if(wndData) {
2029 wndData->lVertBarWidth=ulVBar;
2030 WinSetWindowULong(hwnd, ulQWP_WNDDATA, (ULONG)wndData);
2031 // WinSetWindowULong(hwnd, QWL_USER, (ULONG)wndData);
2032 //printLong(ulQWP_WNDDATA,"wnddata");
2033 // DosBeep(500, 400);
2034 }
2035
2036 return mr;
2037 break;
2038 }
2039 case WM_DESTROY:
2040 {
2041 HTMLWNDDATA* wndData=(HTMLWNDDATA*)WinQueryWindowULong(hwnd, ulQWP_WNDDATA);
2042
2043 if(wndData)
2044 {
2045 freeHtmlPartList(hwnd);
2046 free(wndData);
2047 }
2048 break;
2049 }
2050 default:
2051 break;
2052 }
2053 // return WinDefWindowProc( hwnd, msg, mp1, mp2);
2054 return g_oldStatic( hwnd, msg, mp1, mp2);
2055}
2056
2057MRESULT EXPENTRY separatorProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2058{
2059 switch(msg)
2060 {
2061 case WM_PAINT:
2062 {
2063 MRESULT mr;
2064 HPS hps;
2065 RECTL rcl;
2066
2067 WinQueryWindowRect(hwnd, &rcl);
2068 if(rcl.yTop-rcl.yBottom<2)
2069 break;
2070
2071 mr=WinDefWindowProc(hwnd, msg, mp1, mp2);
2072 if((hps=WinGetPS(hwnd))!=NULLHANDLE) {
2073 POINTL ptl;
2074
2075 ptl.y=(rcl.yTop-rcl.yBottom)/2;
2076 ptl.x=0;
2077 GpiMove(hps, &ptl);
2078 ptl.x=rcl.xRight;
2079 GpiSetColor(hps, CLR_DARKGRAY);
2080 GpiLine(hps,&ptl);
2081 GpiSetColor(hps, CLR_WHITE);
2082 ptl.y-=1;
2083 GpiMove(hps, &ptl);
2084 ptl.x=0;
2085 GpiLine(hps,&ptl);
2086 WinReleasePS(hps);
2087 }
2088 return mr;
2089 break;
2090 }
2091 default:
2092 break;
2093 }
2094 return WinDefWindowProc(hwnd, msg, mp1, mp2);
2095}
2096
2097MRESULT EXPENTRY volumeDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
2098{
2099 // static bShowParsed=FALSE;
2100
2101 switch (msg)
2102 {
2103 case WM_BUTTON1DBLCLK:
2104#if 0
2105 if(bShowParsed) {
2106 WinSetWindowText(WinWindowFromID(hwnd, IDST_TEXT), html);
2107 bShowParsed=FALSE;
2108 }
2109 else {
2110 WinSetWindowText(WinWindowFromID(hwnd, IDST_TEXT), html2);
2111 bShowParsed=TRUE;
2112 }
2113#endif
2114 return MRTRUE;
2115 case WM_INITDLG:
2116 {
2117 RECTL rcl;
2118 HPS hps;
2119 SWP swp;
2120
2121 /* Set dialog font to WarpSans for Warp 4 and above */
2122 if(SysQueryOSRelease()>=40) {
2123 WinSetPresParam(hwnd,
2124 PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT),
2125 DEFAULT_DIALOG_FONT );
2126 }
2127
2128 // WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "", 1234, MB_MOVEABLE);
2129
2130 hwndMsg=WinWindowFromID(hwnd, IDLB_MSG);
2131 WinShowWindow( hwnd, TRUE );
2132
2133 // WinSubclassWindow(WinWindowFromID(hwnd, IDPB_DRAGBUTTON), staticProc);
2134 globalHab=WinQueryAnchorBlock(hwnd);
2135 // hBitmap=loadBitmap("H:\\cwmm\\classes\\mm-progs\\pmtst\\synthesis027.BMP", &bmpInfoHeader2);
2136
2137
2138 WinQueryWindowPos(WinWindowFromID(hwnd, IDST_TEXT), &swp);
2139
2140 WinDestroyWindow(WinWindowFromID(hwnd, IDST_TEXT));
2141 WinCreateWindow(hwnd, "WC_FORMATEDTEXT", "", WS_VISIBLE, swp.x, swp.y, swp.cx, swp.cy, hwnd, HWND_TOP,IDST_TEXT,
2142 NULLHANDLE, NULLHANDLE);
2143
2144
2145 WinSetWindowText(WinWindowFromID(hwnd, IDST_TEXT), html);
2146
2147
2148 return (MRESULT) FALSE;
2149 WinQueryWindowRect(WinWindowFromID(hwnd, IDST_TEXT), &rcl);
2150 hps=WinGetPS(WinWindowFromID(hwnd, IDST_TEXT));
2151 // formatText(hps, html, &rcl);
2152 WinReleasePS(hps);
2153
2154 return (MRESULT) FALSE;
2155 /*
2156 WinSetWindowULong(WinWindowFromID(hwnd, IDST_TEXT), QWL_STYLE,
2157 WinQueryWindowULong(WinWindowFromID(hwnd, IDST_TEXT), QWL_STYLE)&~WS_PARENTCLIP);
2158 /*
2159
2160 frameCtrl.cb=sizeof(frameCtrl);
2161 frameCtrl.flCreateFlags=FCF_VERTSCROLL;
2162 WinCreateFrameControls( WinWindowFromID(hwnd, IDST_TEXT), &frameCtrl, "");
2163
2164 /* Position Framecontrol */
2165 WinQueryWindowRect( WinWindowFromID(hwnd, IDST_TEXT), &rcl);
2166 WinSetWindowPos(WinWindowFromID(WinWindowFromID(hwnd, IDST_TEXT), FID_VERTSCROLL),
2167 NULLHANDLE, rcl.xRight-10, 0, 10, rcl.yTop, SWP_MOVE|SWP_SIZE|SWP_SHOW);
2168 oldStatic=WinSubclassWindow(WinWindowFromID(hwnd, IDST_TEXT), htmlProc);
2169 WinSetWindowText(WinWindowFromID(hwnd, IDST_TEXT), html);
2170 WinQueryWindowRect(WinWindowFromID(hwnd, IDST_TEXT), &rcl);
2171 hps=WinGetPS(WinWindowFromID(hwnd, IDST_TEXT));
2172 // formatText(hps, html, &rcl);
2173 WinReleasePS(hps);
2174 return (MRESULT) FALSE;
2175 }
2176 case WM_CONTEXTMENU:
2177 contextMenu(hwnd);
2178 return (MRESULT) FALSE;
2179 case WM_BUTTON2MOTIONSTART:
2180 case WM_BUTTON1MOTIONSTART:
2181 /* Drag the window without titlebar */
2182 WinSendMsg(hwnd, WM_TRACKFRAME,
2183 MPFROMSHORT(TF_MOVE /*| TF_SETPOINTERPOS */), NULL) ;
2184 return (MRESULT) 0 ;
2185 case WM_CONTROL:
2186 if (SHORT1FROMMP(mp1)==IDCS_VOLUME)
2187 {
2188 if ((SHORT2FROMMP(mp1)==CSN_CHANGED) || /* change volume? */
2189 (SHORT2FROMMP(mp1)==CSN_TRACKING)) /* tracking volume? */
2190 {
2191
2192 }
2193 }
2194 return( (MRESULT) 0);
2195 case WM_CLOSE:
2196 {
2197 WinPostMsg(hwnd, WM_QUIT, 0, 0);
2198 return (MRESULT )FALSE;
2199 }
2200 case WM_COMMAND:
2201 switch(SHORT1FROMMP(mp1))
2202 {
2203 case IDM_ITEMTITLEBAR:
2204 // DosBeep(5000, 500);
2205 break;
2206 case IDM_ITEMEXIT:
2207 WinPostMsg(hwnd, WM_CLOSE, 0, 0);/* Timer error so do a hard quit */
2208 break;
2209 default:
2210 break;
2211 }
2212 return (MRESULT) FALSE;
2213 default:
2214 break;
2215 }/* switch */
2216 //return (MRESULT) WinDefSecondaryWindowProc( hwnd, msg, mp1, mp2 ) ;
2217 return WinDefDlgProc( hwnd, msg, mp1, mp2);
2218}
2219
2220static void buildIniFileName(char* chrProgname)
2221{
2222 char * chrPtr;
2223 strcpy(chrIniFile, chrProgname);
2224
2225 if((chrPtr=strrchr(chrIniFile,'\\'))==NULLHANDLE)
2226 return;
2227
2228 *chrPtr=0;
2229 strcat(chrIniFile,"\\volume.ini");
2230 // WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrIniFile, "", 1234, MB_MOVEABLE);
2231}
2232
2233int main (int argc, char *argv[])
2234{
2235 HAB hab;
2236 HMQ hmq;
2237 QMSG qmsg;
2238
2239 CLASSINFO ci;
2240
2241 hab=WinInitialize(0);
2242 if(hab) {
2243 hmq=WinCreateMsgQueue(hab,0);
2244 if(hmq) {
2245 RESSOURCEHANDLE=0;
2246 buildIniFileName(argv[0]);
2247
2248 /* Register the new text control */
2249
2250 if(WinQueryClassInfo(WinQueryAnchorBlock(HWND_DESKTOP),
2251 WC_STATIC,
2252 &ci))
2253 {
2254 g_ulStaticDataOffset=ci.cbWindowData;
2255 g_oldStatic=ci.pfnWindowProc;
2256 ulQWP_WNDDATA=g_ulStaticDataOffset;
2257
2258
2259 if(WinRegisterClass(WinQueryAnchorBlock(HWND_DESKTOP),
2260 (PSZ)"WC_FORMATEDTEXT",
2261 htmlProc,
2262 (ci.flClassStyle) &~(CS_PUBLIC|CS_PARENTCLIP),
2263 ci.cbWindowData+sizeof(void*)))
2264 {
2265 /* */
2266 }
2267
2268 if(WinRegisterClass(WinQueryAnchorBlock(HWND_DESKTOP),
2269 (PSZ)"CW_SEPARATOR",
2270 separatorProc,
2271 (ci.flClassStyle) &~(CS_PUBLIC | CS_PARENTCLIP),
2272 0))
2273 {
2274 /* */
2275
2276 }
2277
2278 }
2279
2280
2281 if( WinDlgBox( HWND_DESKTOP, NULLHANDLE,
2282 volumeDialogProc, RESSOURCEHANDLE, IDDLG_VOLUME, 0) == DID_ERROR )
2283 {
2284 /*
2285 Text:
2286 Title: "Installation problem"
2287 */
2288 WinDestroyMsgQueue( hmq );
2289 WinTerminate( hab );
2290 DosBeep(100,600);
2291 return( 1 );
2292 }
2293 WinDestroyMsgQueue(hmq);
2294 }
2295 WinTerminate(hab);
2296 }
2297 return 0;
2298}
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308#if 0
2309
2310/* format and draw text */
2311LONG drawText2(HPS hps, LONG lLength, char * chrText, RECTL* rcl, TAGINFO *tagInfo, LONG lCharsDone, ULONG ulFlags)
2312{
2313 POINTL aptl[TXTBOX_COUNT];
2314 POINTL ptl;
2315 LONG cyChar;
2316 LONG clrFore;
2317 LONG lTotalLength=lLength;
2318 htmlPart* hTemp=NULLHANDLE;
2319 LONG lPtl;
2320 LONG lMark=tagInfo->ulMark;
2321 FORMATINFO fi;
2322
2323 if(lLength)
2324 GpiQueryTextBox(hps, lLength, chrText, TXTBOX_COUNT, aptl);
2325 else
2326 GpiQueryTextBox(hps, 1, "*", TXTBOX_COUNT, aptl);
2327
2328 cyChar=aptl[TXTBOX_TOPLEFT].y-aptl[TXTBOX_BOTTOMLEFT].y;
2329
2330
2331 GpiQueryCurrentPosition(hps, &ptl);
2332 if(!lCharsDone)
2333 {
2334 ptl.x=rcl->xLeft;
2335 rcl->yTop-=cyChar;
2336 ptl.y=rcl->yTop;
2337 GpiMove(hps, &ptl);
2338 }
2339
2340 switch(lMark)
2341 {
2342 case MARK_H1:
2343 {
2344 FATTRS fat;
2345 memset(&fat, 0, sizeof(fat));
2346 fat.fsSelection=FATTR_SEL_BOLD;
2347 fat.usRecordLength=sizeof(fat);
2348 fat.lMaxBaselineExt=12L;
2349 fat.lAveCharWidth=12L;
2350 fat.fsFontUse=FATTR_FONTUSE_NOMIX;
2351 strcpy(fat.szFacename, "WarpSans");
2352 GpiCreateLogFont(hps, NULL, 1L, &fat);
2353 GpiSetCharSet(hps, 1L);
2354 clrFore=CLR_BLACK;
2355
2356 GpiQueryTextBox(hps, 1, "*", TXTBOX_COUNT, aptl);
2357 cyChar=aptl[TXTBOX_TOPLEFT].y-aptl[TXTBOX_BOTTOMLEFT].y;
2358 ptl.x=rcl->xLeft;
2359 rcl->yTop-=(cyChar*1.5);
2360 ptl.y=rcl->yTop;
2361 GpiMove(hps, &ptl);
2362
2363 break;
2364 }
2365 case MARK_H1_END:
2366 GpiQueryTextBox(hps, 1, "*", TXTBOX_COUNT, aptl);
2367 cyChar=aptl[TXTBOX_TOPLEFT].y-aptl[TXTBOX_BOTTOMLEFT].y;
2368
2369 ptl.x=rcl->xLeft;
2370 rcl->yTop-=(cyChar*1.5);
2371 ptl.y=rcl->yTop;
2372 GpiMove(hps, &ptl);
2373
2374 GpiDeleteSetId(hps, LCID_ALL);
2375 return lLength;
2376 case MARK_LINK:
2377 {
2378 FATTRS fat;
2379
2380 memset(&fat, 0, sizeof(fat));
2381 fat.fsSelection=FATTR_SEL_UNDERSCORE;
2382 fat.usRecordLength=sizeof(fat);
2383 fat.lMaxBaselineExt=10L;
2384 fat.lAveCharWidth=10L;
2385 fat.fsFontUse=FATTR_FONTUSE_NOMIX;
2386 strcpy(fat.szFacename, "WarpSans");
2387
2388 GpiCreateLogFont(hps, NULL, 1L, &fat);
2389 GpiSetCharSet(hps, 1L);
2390
2391 clrFore=CLR_BLUE;
2392 break;
2393 }
2394 case MARK_PARAGRAPH:
2395 ptl.x=rcl->xLeft;
2396 rcl->yTop-=cyChar*1.5;
2397 ptl.y=rcl->yTop;
2398 GpiMove(hps, &ptl);
2399 return lLength;
2400 case MARK_BREAK:
2401 ptl.x=rcl->xLeft;
2402 rcl->yTop-=cyChar;
2403 ptl.y=rcl->yTop;
2404 GpiMove(hps, &ptl);
2405 /* if lLength!=0 then no starting tag for following text. Only the <Break> tag given. */
2406 if(!lLength)
2407 return lLength;
2408 break;
2409 case MARK_RULER:
2410 {
2411 /* Draw ruler */
2412 ptl.x=rcl->xRight*0.1;
2413 rcl->yTop-=cyChar*1.5;
2414 ptl.y=rcl->yTop;
2415 GpiMove(hps, &ptl);
2416 ptl.x=rcl->xRight*0.9;
2417 GpiLine(hps, &ptl);
2418 ptl.x=rcl->xLeft;
2419 // rcl->yTop-=cyChar;
2420 ptl.y=rcl->yTop;
2421 GpiMove(hps, &ptl);
2422 /* if lLength!=0 then no starting tag for following text. Only the <Break> tag given. */
2423 if(!lLength)
2424 return lLength;
2425 break;
2426 }
2427 default:
2428 GpiSetCharSet(hps, LCID_DEFAULT);
2429 GpiDeleteSetId(hps, LCID_ALL);
2430 clrFore=CLR_BLACK;
2431 break;
2432 }
2433
2434 GpiSetColor(hps, clrFore);
2435 GpiQueryCurrentPosition(hps, &ptl);
2436
2437 lPtl=gpiStringLength(hps, lLength, chrText );
2438 if( lPtl <= (rcl->xRight-ptl.x)) {
2439 // DosBeep(500, 200);
2440 /* String fits into line */
2441 // GpiSetColor(hps, CLR_BLACK);
2442 GpiCharString(hps, lLength, chrText);
2443 hTemp=malloc(sizeof(htmlPart));
2444 hTemp->iType=lMark;
2445 WinSetRect(WinQueryAnchorBlock(HWND_DESKTOP), &hTemp->rcl,
2446 ptl.x, ptl.y,
2447 ptl.x+ lPtl, ptl.y+cyChar );
2448 hTemp->ptl=ptl;
2449 hTemp->chrText=chrText;
2450 hTemp->iLength=lLength;
2451 hTemp->ulParam=tagInfo->ulParam;
2452 addToHtmlPartList(hTemp);
2453 return lLength;
2454 }
2455 else
2456 {
2457 LONG lDone=0;
2458 LONG lPtl;
2459 /* String is to long. Split in words and try to draw them */
2460 /* Get next word */
2461 lLength=newStringLength( hps, lTotalLength-lDone, chrText);
2462
2463 //DosBeep(5000, 200);
2464 //DosSleep(100);
2465 while(lLength && lDone+lLength<=lTotalLength)
2466 {
2467 lPtl=gpiStringLength(hps, lLength, chrText);
2468 GpiQueryCurrentPosition(hps, &ptl);
2469
2470 if(lPtl > (rcl->xRight-ptl.x))
2471 {
2472 /* Word doesn't fit. Check if it fits into a whole line */
2473 if(lPtl <= (rcl->xRight-rcl->xLeft))
2474 {
2475 /* Yes, does fit */
2476 ptl.x=rcl->xLeft;
2477 rcl->yTop-=cyChar;
2478 ptl.y=rcl->yTop;
2479 GpiMove(hps, &ptl);
2480
2481 // ptl.y=rcl->yTop-cyChar;
2482 // GpiMove(hps, &ptl);
2483 // GpiSetColor(hps, CLR_RED);
2484
2485 GpiCharString(hps, lLength, chrText);
2486
2487 }
2488 /* No, too long for a whole line so start writing in current line and wrap */
2489 /*
2490
2491 FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!
2492
2493 */
2494 }
2495 else {
2496 // DosBeep(5000, 500);
2497 // GpiSetColor(hps, CLR_GREEN);
2498 GpiCharString(hps, lLength, chrText);
2499 }
2500 hTemp=malloc(sizeof(htmlPart));
2501 hTemp->iType=lMark;
2502 WinSetRect(WinQueryAnchorBlock(HWND_DESKTOP), &hTemp->rcl,
2503 ptl.x, ptl.y,
2504 ptl.x+lPtl, ptl.y+cyChar );
2505 hTemp->ptl=ptl;
2506 hTemp->chrText=chrText;
2507 hTemp->iLength=lLength;
2508 hTemp->ulParam=tagInfo->ulParam;
2509 addToHtmlPartList(hTemp);
2510 lDone+=lLength;
2511 // printLong(lDone, "lDone");
2512 chrText+=lLength;
2513 // printMsg(chrText);
2514 /* Get next word */
2515 lLength=newStringLength( hps, lTotalLength-lDone, chrText);
2516 // printLong(lLength, "lLength");
2517 }
2518 // printMsg("");
2519 return lDone;
2520 }
2521 return 0;
2522}
2523
2524
2525#if 0
2526void drawText(HPS hps, char *text, RECTL *rcl)
2527{
2528 LONG lTotalDrawn;
2529 LONG cyChar=10;
2530 LONG lLength;
2531 LONG lDrawn;
2532 LONG lMark;
2533 LONG lTotalLength=strlen(text);
2534 char *chrPos=text;
2535 char *chrEnd;
2536 LONG lDone=0;
2537 POINTL ptl;
2538 char text2[1000];
2539
2540 lMark=MARK_TEXT;
2541
2542 while(lDone<=lTotalLength && *chrPos!=0)
2543 {
2544 /* Check if starting with a mark */
2545 if(*chrPos=='<')
2546 chrPos=parseMark(lLength, chrPos, &lMark); /* Start of real text in chrPos */
2547
2548 /* Get next mark */
2549 chrEnd=findNextMark(chrPos);
2550 // printMsg(chrEnd);
2551 lLength=chrEnd-chrPos; /* Length of text to be drawn */
2552 //printLong(lLength);
2553 strcpy(text2, chrPos);
2554 // text2[lLength-1]=0;
2555 // printMsg(text2);
2556
2557 lDone+=drawText2(hps, lLength, chrPos, rcl, lMark, lDone, DT_WORDBREAK);
2558 //chrPos+=lLength;
2559 chrPos=chrEnd;
2560 //DosSleep(500);
2561
2562 } /* while */
2563 printLong(iNum, "Anzahl: ");
2564}
2565#endif
2566
2567
2568#endif
Note: See TracBrowser for help on using the repository browser.