home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / pstoedit.zip / source.zip / pstoedit.2.50 / src / drvwmf.cpp < prev    next >
C/C++ Source or Header  |  1996-12-26  |  19KB  |  638 lines

  1. /*
  2.    drvWMF.c : This file is part of pstoedit
  3.      Backend for Windows Meta File (WMF)
  4.  
  5.    Copyright (C) 1996 Jens Weber, wr@lzh1.lzh.de
  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 of the License, or
  10.     (at your option) 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; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21. */
  22.  
  23. // drvwmf.cpp:
  24. // Fatal F:\BC5\INCLUDE\services/wsysinc.h 27: Error directive: if windows.h is included before
  25. //  services/wsysinc.h, STRICT must be defined
  26. // *** 1 errors in Compile ***
  27. #ifndef STRICT
  28. #define STRICT
  29. #endif
  30.  
  31. //JW fuer Zugriff auf Windows-API (WMF-Funktionen)
  32. #include <windows.h>
  33. #include <owl/gdiobjec.h>
  34. #include <winsys/geometry.h> // fuer tagPOINT (TPoint)
  35.  
  36. //JW
  37. #include <string.h>
  38. #include <alloc.h>
  39. #include <fstream.h>
  40. #include <math.h>
  41. #include <dir.h>
  42. #include <iostream.h>
  43. #include <string.h>
  44. #include <stdlib.h>
  45.  
  46. #include <process.h> // fuer exec-Fkt.
  47. #include <direct.h> // fuer getcwd-Fkt.
  48. #include <time.h> // fuer Zeitfunktionen
  49.  
  50. #include <owl/dc.h>
  51.  
  52.  
  53. #include "drvwmf.h"
  54.  
  55. #define GSFONTMAPENV "GS_LIB"
  56. #define GSFONTMAPFILE "FONTMAP"
  57.  
  58. #define FONT_ID 1
  59. #define DRAW_FILLED 1
  60. #define DRAW_UNFILLED 0
  61. #define DRAW_CLOSED 1
  62. #define DRAW_OPEN 0
  63. #define READ_pNumers 0
  64.  
  65. #define MAXPALENTRIES 256
  66.  
  67. struct WmfPrivate {
  68. // This struct contains all private data of drvwmf.
  69. // These were moved to here, in order to keep
  70. // drvwmf.h independent from OWL
  71.  
  72.     DRVWMFSETUP *pDrvWMFsetup;
  73.     TMetaFileDC *pMetaDC;
  74.     TDesktopDC *pDesktopDC;
  75.     TRect *pRect;
  76.  
  77.     LPLOGPALETTE MyLogPalette; // JW
  78.     TPalette *pThePalette; // JW
  79.  
  80.     TPen *pColoredPen; // JW Zeichenstift
  81.     LOGPEN PenData; // JW Datenstruktur des Zeichenstiftes
  82.  
  83.     TFont *pMyFont;
  84.     LOGFONT  TheFontRec; // Struktur zur Vorgabe der Fontattribute
  85.  
  86.     TBrush *pColoredBrush; // JW Pinsel zum Flaechenfuellen
  87.     LOGBRUSH BrushData; // JW Pinsel-Daten
  88.  
  89.     long FontsHeight, FontsWidth;
  90.  
  91.     long showFontList;
  92.     char lastSelectedFontName[maxFontNamesLength];
  93.     long cntPalEntries;
  94.  
  95.     long palStart;
  96.     long maxPalEntries;
  97.  
  98. };
  99.  
  100. // Short Cuts
  101. #define pDrvWMFsetup pd->pDrvWMFsetup
  102. #define pMetaDC pd->pMetaDC
  103. #define pRect pd->pRect
  104. #define pDesktopDC pd->pDesktopDC
  105. #define MyLogPalette pd->MyLogPalette
  106. #define pThePalette pd->pThePalette
  107. #define pColoredPen pd->pColoredPen
  108. #define PenData pd->PenData
  109. #define pMyFont pd->pMyFont
  110. #define TheFontRec pd->TheFontRec
  111. #define pColoredBrush pd->pColoredBrush
  112. #define BrushData pd->BrushData
  113. #define FontsHeight pd->FontsHeight
  114. #define FontsWidth pd->FontsWidth
  115. #define showFontList pd->showFontList
  116. #define lastSelectedFontName pd->lastSelectedFontName
  117. #define cntPalEntries pd->cntPalEntries
  118. #define palStart pd->palStart
  119. #define maxPalEntries pd->maxPalEntries
  120.  
  121.  
  122. const int NumColors = 48;
  123.  
  124. const TColor Colors[NumColors] = {
  125.   0x00FFFFFFl,0x00E0E0E0l,0x00C0C0FFl,0x00C0E0FFl,0x00E0FFFFl,0x00C0FFC0l,
  126.   0x00FFFFC0l,0x00FFC0C0l,0x00FFC0FFl,0x000000C0l,0x000040C0l,0x0000C0C0l,
  127.   0x0000C000l,0x00C0C000l,0x00C00000l,0x00C000C0l,
  128.   0x00C0C0C0l,0x00404040l,0x008080FFl,0x0080C0FFl,0x0080FFFFl,0x0080FF80l,
  129.   0x00FFFF80l,0x00FF8080l,0x00FF80FFl,0x00000080l,0x00004080l,0x00008080l,
  130.   0x00008000l,0x00808000l,0x00800000l,0x00800080l,
  131.   0x00808080l,0x00000000l,0x000000FFl,0x000080FFl,0x0000FFFFl,0x0000FF00l,
  132.   0x00FFFF00l,0x00FF0000l,0x00FF00FFl,0x00000040l,0x00404080l,0x00004040l,
  133.   0x00004000l,0x00404000l,0x00400000l,0x00400040l
  134. };
  135.  
  136. static void strRemove(char *toRemoveStr, char *pRemoves)
  137. {
  138.     int length = strlen(toRemoveStr);
  139.     for (int i=0; i<length;i++)
  140.        if (strchr(pRemoves,toRemoveStr[i]))
  141.        {
  142.         memmove((void*)&toRemoveStr[i],
  143.             (void*)&toRemoveStr[i+1],length-1-i);
  144.         toRemoveStr[--length] = '\0';
  145.        }
  146. }
  147.  
  148.  
  149. drvWMF::drvWMF(ostream & theoutStream,
  150.                 ostream & theerrStream,
  151.             float magnification,
  152.             char *driveroptions_p,
  153.             DRVWMFSETUP *pDrvWMFsetup_p):
  154.     drvbase(driveroptions_p,theoutStream,theerrStream,0,0,0)
  155.     // Flags: SubPathes
  156.     //        Curveto
  157.   //        Merging
  158. {
  159.     POINT PenWidth; // Datenstruktur fuer die Stiftbreite
  160.     int farben, xres, yres, fontzahl; // Device-Info's
  161.     int i;
  162.     const char description[]="generated by wmf backend of pstoedit";
  163. //now moved to private data    TRect *pRect;
  164.  
  165.     pd = new WmfPrivate();
  166.     pDrvWMFsetup = pDrvWMFsetup_p;
  167.  
  168.     pDesktopDC = new TDesktopDC();
  169.     farben =  pDesktopDC->GetDeviceCaps(NUMCOLORS);
  170.     xres =  pDesktopDC->GetDeviceCaps(HORZRES);
  171.     yres =  pDesktopDC->GetDeviceCaps(VERTRES);
  172.     fontzahl = pDesktopDC->GetDeviceCaps(NUMFONTS);
  173.     if (pDrvWMFsetup->info) {
  174.            errf << "Number of Colors: " << farben << endl;
  175.            errf << "X-Resolution: " << xres << endl;
  176.            errf << "Y-Resolution: " << yres << endl;
  177.            errf << "Number of Fonts: " << fontzahl << endl;
  178.     }
  179.  
  180.     pRect =  new TRect(0,0,xres,yres); // Screen-Size
  181.  
  182.     if (pDrvWMFsetup->enhanced)
  183.    // enhanced-Metafile (.emf) fuer W95 oder NT
  184.         pMetaDC = new TMetaFileDC((TDC&)(*(pDesktopDC)),
  185.                        pDrvWMFsetup->pOutFileName,
  186.                   pRect,
  187.                   description);  // Metafile erzeugen
  188.    // Standard-Metafile fuer Win3.1
  189.     else pMetaDC = new TMetaFileDC(pDrvWMFsetup->pOutFileName);
  190.  
  191.     if(!pMetaDC)
  192.            errf << "ERROR: could not open metafile: " <<
  193.             pDrvWMFsetup->pOutFileName << endl;
  194.     else {
  195.         if(pDrvWMFsetup->enhanced)    errf << "enhanced metafile opened: " <<
  196.             pDrvWMFsetup->pOutFileName << endl;
  197.         else errf << "standard metafile opened: " <<
  198.             pDrvWMFsetup->pOutFileName << endl;
  199.     }
  200.  
  201.     y_offset = 0;
  202.     x_offset = 0;
  203.     scale = magnification; // 4.0 for PU_HIENGLISH
  204.  
  205.    // in height und width werden die Extremwerte (Maxima) gespeichert
  206.     pDrvWMFsetup->height=0;
  207.     pDrvWMFsetup->width=0;
  208.    pDrvWMFsetup->maxstatus=0; // 0, bis erster Wert gefunden
  209.    // in origin_x und origin_y werden die Extremwerte (Minima) gespeichert
  210.     pDrvWMFsetup->origin_x=0;
  211.     pDrvWMFsetup->origin_y=0;
  212.    pDrvWMFsetup->minstatus=0; // 0, bis erster Wert gefunden
  213.  
  214.     if (pDrvWMFsetup->info) errf << "Open driver for: " << pDrvWMFsetup->pOutFileName << endl;
  215.  
  216.     errf << "allocating " << (sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * MAXPALENTRIES) << endl;
  217.     char * memspace = new char[sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * MAXPALENTRIES];
  218.     MyLogPalette = (LOGPALETTE *) memspace;
  219.       MyLogPalette->palVersion = 0x300;
  220.  
  221. //    MyLogPalette->palNumEntries=2;
  222.    MyLogPalette->palNumEntries = NumColors; // initial color table
  223.  
  224.    for (i = 2; i < NumColors; ++i) {
  225.         MyLogPalette->palPalEntry[i].peRed = Colors[i].Red();
  226.         MyLogPalette->palPalEntry[i].peGreen = Colors[i].Green();
  227.         MyLogPalette->palPalEntry[i].peBlue = Colors[i].Blue();
  228.         MyLogPalette->palPalEntry[i].peFlags = PC_RESERVED;
  229.    }
  230.  
  231.     MyLogPalette->palPalEntry[0].peRed = 0xff;
  232.     MyLogPalette->palPalEntry[0].peGreen = 0xff;
  233.     MyLogPalette->palPalEntry[0].peBlue = 0xff;
  234.     MyLogPalette->palPalEntry[1].peRed = 0x0;
  235.     MyLogPalette->palPalEntry[1].peGreen =  0x0;
  236.     MyLogPalette->palPalEntry[1].peBlue = 0x0;
  237.  
  238.     cntPalEntries = NumColors;
  239.  
  240. //   cntPalEntries = 2;
  241.  
  242.     maxPalEntries=MAXPALENTRIES;
  243.  
  244.     pThePalette = new TPalette(MyLogPalette);
  245.     if(pThePalette) {
  246.         pMetaDC->SelectObject(*pThePalette);
  247.         pMetaDC->RealizePalette();
  248.     }
  249.     else errf << "ERROR: Can't create palette!" << endl;
  250.  
  251.    // Festlegung der Farbe fuer Zeichenfunktionen
  252.     PenData.lopnStyle=PS_SOLID;
  253.     PenWidth.x=0; // y-Wert wird nicht verwendet
  254.     PenData.lopnWidth=PenWidth; // 0 heisst 1 Pixel breit
  255.     PenData.lopnColor=PALETTEINDEX(1);
  256.     pColoredPen = NULL;
  257.  
  258.    // Pinsel
  259.     BrushData.lbStyle=BS_SOLID;
  260.     BrushData.lbColor=PALETTEINDEX(1);
  261.     BrushData.lbHatch=NULL;
  262.     pColoredBrush = NULL; // wird spaeter aktiviert
  263.  
  264.     textInfo_.currentFontName.copy("Times New Roman");
  265.     strcpy(lastSelectedFontName,textInfo_.currentFontName.value());
  266.     pMyFont=NULL;
  267. }
  268.  
  269.  
  270.  
  271. drvWMF::~drvWMF()
  272.  
  273. {
  274.   // Ursprung und Groesse aendern
  275.  
  276.    TPoint Origin(pDrvWMFsetup->origin_x,pDrvWMFsetup->origin_y); // Fensterursprung
  277.    TPoint OldOrigin;
  278.     pMetaDC->SetWindowOrg(Origin, &OldOrigin); // Fensterursprung vorgeben
  279.  
  280.    TSize Extend(pDrvWMFsetup->width-pDrvWMFsetup->origin_x,
  281.        pDrvWMFsetup->height-pDrvWMFsetup->origin_y);
  282.    TSize OldExtend;
  283.    pMetaDC->SetWindowExt(Extend, &OldExtend);
  284.  
  285.     if (pDrvWMFsetup->info) {
  286.        errf << "Bounding Box " << endl;
  287.        errf << "Origin: " << pDrvWMFsetup->origin_x << " , " <<
  288.               pDrvWMFsetup->origin_y << endl;
  289.        errf << "Size: " << pDrvWMFsetup->width-pDrvWMFsetup->origin_x << " , "
  290.                << pDrvWMFsetup->height-pDrvWMFsetup->origin_y << endl;
  291.    }
  292.  
  293.     // Metafile speichern
  294.     delete pMetaDC;
  295.  
  296.    // JW neue Palette loeschen
  297. //   pMetaDC->RestorePalette();
  298.     if(MyLogPalette) delete[] (char *) MyLogPalette;
  299.  
  300.     // JW Stift loeschen, alten Stift nehmen
  301. //   pMetaDC->RestorePen();
  302.     if(pColoredPen) delete pColoredPen;
  303.  
  304.     // JW Pinsel loeschen, alten Pinsel nehmen
  305.  //  pMetaDC->RestoreBrush();
  306.     if(pColoredBrush) delete pColoredBrush;
  307.  
  308. //   pMetaDC->RestoreFont();
  309.     if(pMyFont) delete pMyFont;
  310.  
  311.     delete pThePalette;
  312.     delete pDesktopDC;
  313.     delete pRect;
  314.     delete pd;
  315. }
  316.  
  317.  
  318. long drvWMF::searchPalEntry(float r, float g, float b)
  319. {
  320.     BYTE rot, gruen, blau;
  321.    rot=(BYTE)(r*255);
  322.    gruen=(BYTE)(g*255);
  323.    blau=(BYTE)(b*255);
  324.  
  325.     for(int i=0; i<cntPalEntries; i++)
  326.       if ( (MyLogPalette->palPalEntry[i].peRed==rot) &&
  327.            (MyLogPalette->palPalEntry[i].peGreen==gruen) &&
  328.            (MyLogPalette->palPalEntry[i].peBlue==blau) ) return i;
  329.  
  330.     return -1;                              // Not found!
  331. }
  332.  
  333. void drvWMF::setColor(float r, float g, float b)
  334.  
  335. // die Farben fuer die Pen- und Brush-Strukturen werdeb gesetzt; sie werden erst
  336. // wirksam, wenn der Stift oder Pinsel erzeugt und Selektiert wurde
  337.  
  338. {
  339.    long index = searchPalEntry(r,g,b);
  340.    POINT PenWidth;
  341.  
  342.     if (index < 0) {        // Not found!
  343.  
  344.         if (cntPalEntries<maxPalEntries) {
  345.            MyLogPalette->palPalEntry[cntPalEntries].peRed = (BYTE)(r*255);
  346.             MyLogPalette->palPalEntry[cntPalEntries].peGreen = (BYTE)(g*255);
  347.             MyLogPalette->palPalEntry[cntPalEntries].peBlue = (BYTE)(b*255);
  348.  
  349.             if(pThePalette->SetPaletteEntries(0, cntPalEntries+1,&(MyLogPalette->palPalEntry[0]) )) {
  350.  
  351.                 MyLogPalette->palNumEntries = cntPalEntries+1;
  352.                 pMetaDC->RestorePalette();
  353.                 if(pThePalette) delete pThePalette;
  354.                 pThePalette=new TPalette(MyLogPalette);
  355.             if(!pThePalette) {
  356.                 errf << "ERROR: Can't create new palette!" << endl;
  357.                 return;
  358.             }
  359.                 pMetaDC->SelectObject(*pThePalette);
  360.                   pMetaDC->RealizePalette();
  361.  
  362.                 PenData.lopnColor=PALETTEINDEX(cntPalEntries);
  363.                 BrushData.lbColor=PALETTEINDEX(cntPalEntries);
  364.  
  365.                 if (pDrvWMFsetup->info) errf << "Set palette entry: " << cntPalEntries << endl;
  366.                 if (pDrvWMFsetup->info) errf << "r: " << (int)(r*255) <<
  367.                 " g: " << (int)(g*255) << " b: " << (int)(b*255) << endl;
  368.  
  369.                 cntPalEntries++;
  370.  
  371.             } else errf << "ERROR: Can't set palette entries!" << endl;
  372.  
  373.     } // end of maxPalEntries-condition
  374.         else errf << "WARNING: Max. number of colorentries ("<< maxPalEntries <<") exceeded!" << endl;
  375.         // am naechsten kommende Farbe nehmen
  376.        PenData.lopnColor=PALETTERGB((BYTE)(r*255),(BYTE)(g*255),(BYTE)(b*255));
  377.        BrushData.lbColor=PALETTERGB((BYTE)(r*255),(BYTE)(g*255),(BYTE)(b*255));
  378.  
  379.     } // end of not-found-cond.
  380.  
  381.   else {
  382.    if (pDrvWMFsetup->info) errf << "Color found! Index: " << index << endl;
  383.    if (pDrvWMFsetup->info) errf << "r: " << r << " g: " << g << " b: " << b << endl;
  384.  
  385.    PenData.lopnColor=PALETTEINDEX(index);
  386.    BrushData.lbColor=PALETTEINDEX(index); }
  387.  
  388.     PenWidth.x=(int)(((float)currentLineWidth())*scale);
  389.    PenData.lopnWidth=PenWidth;
  390.  
  391.    //  pMetaDC->RestorePen();
  392.    if(pColoredPen) delete pColoredPen;
  393.    pColoredPen=new TPen(&PenData);
  394.     if(!pColoredPen) errf << "ERROR: setColor: could not create pen !" << endl;
  395.    else pMetaDC->SelectObject(*pColoredPen);
  396.  
  397. //   pMetaDC->RestoreBrush();
  398.    if(pColoredBrush) delete pColoredBrush;
  399.    pColoredBrush=new TBrush(&BrushData);
  400.     if(!pColoredBrush) errf << "ERROR: setColor: could not create brush !" << endl;
  401.    else pMetaDC->SelectObject(*pColoredBrush);
  402.  
  403.  
  404. }
  405.  
  406.  
  407. int drvWMF::FetchFont(const char *pFamilyName, short int height, short int angle)
  408. {
  409.  
  410.   const char *pOrgFamilyName;
  411.   char     tmpSearchName[100];
  412.  
  413.   pOrgFamilyName = pFamilyName;
  414.  
  415.   TheFontRec.lfHeight = height;
  416.   TheFontRec.lfWidth = 0; // optimal anpassen
  417.   TheFontRec.lfEscapement = angle;
  418.   TheFontRec.lfOrientation = 0; // nicht kursiv
  419.   TheFontRec.lfWeight = 0; // FW_BOLD;
  420.   TheFontRec.lfItalic = 0;
  421.   TheFontRec.lfUnderline = 0;
  422.   TheFontRec.lfStrikeOut = 0;
  423.   TheFontRec.lfCharSet = ANSI_CHARSET;
  424.   TheFontRec.lfOutPrecision = OUT_DEFAULT_PRECIS;
  425.   TheFontRec.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  426.   TheFontRec.lfQuality = PROOF_QUALITY;
  427.   TheFontRec.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN;
  428.  
  429.   strcpy(tmpSearchName,pFamilyName);
  430. //  strRemove(tmpSearchName," -");
  431.  
  432.   strcpy(TheFontRec.lfFaceName,tmpSearchName);
  433.  
  434.   pMetaDC->RestoreFont();
  435.   if(pMyFont) delete pMyFont;
  436.   pMyFont=new TFont(&TheFontRec);
  437.   pMetaDC->SelectObject(*pMyFont);
  438.  
  439.   if (pDrvWMFsetup->info) {
  440.         errf << "Font requested: ";
  441.         errf << pOrgFamilyName << ", FONTMAP maps to: ";
  442.         errf << TheFontRec.lfFaceName << endl;
  443.         errf << "Font data: " << endl;
  444.         errf << "Height: " << TheFontRec.lfHeight << endl;
  445.         errf << "Width: " << TheFontRec.lfWidth << endl;
  446.         errf << "Angle: " << TheFontRec.lfEscapement << endl;
  447.         errf << "Orientation: " << TheFontRec.lfOrientation << endl;
  448.   }
  449.  
  450.   return 0;
  451.  
  452. }
  453.  
  454.  
  455. void drvWMF::print_coords(TPoint *aptlPoints)
  456.  
  457. // TPoint-Array fuellen
  458. {
  459.     const int numberOfPoints = numberOfElementsInPath();
  460.  
  461.     for (int n = 0; n < numberOfPoints; n++)  {
  462.         aptlPoints[n] = TPoint( transX(pathElement(n).getPoint(0).x_),
  463.                 transY(pathElement(n).getPoint(0).y_) );
  464.       if(pDrvWMFsetup->maxstatus) {
  465.           if(aptlPoints[n].X() < pDrvWMFsetup->origin_x)
  466.              pDrvWMFsetup->origin_x=aptlPoints[n].X();
  467.           if(aptlPoints[n].Y() < pDrvWMFsetup->origin_y)
  468.              pDrvWMFsetup->origin_y=aptlPoints[n].Y(); }
  469.       else {
  470.             pDrvWMFsetup->origin_x=aptlPoints[n].X();
  471.          pDrvWMFsetup->origin_y=aptlPoints[n].Y();
  472.          pDrvWMFsetup->maxstatus=1; }
  473.  
  474.       if(pDrvWMFsetup->minstatus) {
  475.           if(aptlPoints[n].X() > pDrvWMFsetup->width)
  476.               pDrvWMFsetup->width=aptlPoints[n].X();
  477.           if(aptlPoints[n].Y() > pDrvWMFsetup->height)
  478.              pDrvWMFsetup->height=aptlPoints[n].Y(); }
  479.       else {
  480.           pDrvWMFsetup->width=aptlPoints[n].X();
  481.          pDrvWMFsetup->height=aptlPoints[n].Y(); 
  482.          pDrvWMFsetup->minstatus=1;
  483.       }
  484.    }
  485. }
  486.  
  487.  
  488. void drvWMF::close_page()
  489. {
  490.     if (pDrvWMFsetup->info) errf << "End page: " << currentPageNumber << endl;
  491. }
  492.  
  493.  void drvWMF::open_page()
  494. {
  495.     if (pDrvWMFsetup->info) errf << "Start page: " << currentPageNumber << endl;
  496. }
  497.  
  498. void drvWMF::show_path() {
  499.     TPoint *aptlPoints = NULL;
  500.  
  501.     if (pDrvWMFsetup->info) errf << "Path-ShowType: " << currentShowType() << endl;
  502.     drawPoly(0, aptlPoints, (isPolygon() ? DRAW_CLOSED : DRAW_OPEN));
  503. };
  504.  
  505. void drvWMF::show_text(const TextInfo & textinfo)
  506. {
  507.  
  508.     short int height;
  509.     short int angle;
  510.     int x,y;
  511.  
  512.     if (pDrvWMFsetup->draw_noText) return;
  513.  
  514.   // JW PALETTERGB sucht einen Coloref-Wert aus der aktuellen Palette, der dem
  515.   //    gewuenschten Farbwert am naechsten kommt
  516.  
  517.     pMetaDC->SetTextColor(PALETTERGB(textinfo.currentR,textinfo.currentG,
  518.                                 textinfo.currentR));
  519.  
  520.     if (strcmp(lastSelectedFontName,textinfo.currentFontName.value())) {
  521.  
  522.         height = (short int)(textinfo.currentFontSize*scale);
  523.         angle = (short int)(textinfo.currentFontAngle);
  524.  
  525.        FetchFont(textinfo.currentFontName.value(), height, angle);
  526.         strcpy(lastSelectedFontName,textinfo.currentFontName.value());
  527.     }
  528.  
  529.     x = transX(textinfo.x);
  530.     y = transY(textinfo.y);
  531.  
  532.     pMetaDC->TextOut(x, y, textinfo.thetext, strlen(textinfo.thetext));
  533.  
  534. }
  535.  
  536. void drvWMF::drawPoly(int cntPoints, TPoint *aptlPoints, int closed)
  537. {
  538.    int ptsFollow;
  539.  
  540.     if (pDrvWMFsetup->draw_noGraphic) return;
  541.  
  542.     setColor(currentR(),currentG(),currentB());
  543.  
  544.     // preparing polygon array
  545.     if (!cntPoints) {        // transfer from pNumbers
  546.         if ( (aptlPoints=new TPoint[numberOfElementsInPath()] )==NULL) {
  547.                 errf << "ERROR: Cannot allocate memory for point-array" << endl;
  548.         return; }
  549.         print_coords( aptlPoints ); // Punkte eintragen
  550.       ptsFollow=numberOfElementsInPath();
  551.       // print-coords liefert die Anzahl der Punkte
  552.     }
  553.    else ptsFollow = cntPoints;
  554.  
  555.     int filled = (currentShowType()==fill) || (currentShowType()==eofill);
  556.  
  557.     if (filled && (!pDrvWMFsetup->draw_noFill) && (ptsFollow>=2) ) {
  558.    // draw filled polygon
  559.       if (pDrvWMFsetup->info)
  560.           errf << "Fillmode: " << ((currentShowType()==fill) ? WINDING : ALTERNATE) << endl;
  561.         if(!pMetaDC->SetPolyFillMode((currentShowType()==fill) ? WINDING : ALTERNATE))
  562.             errf << "ERROR: could not set fill mode" << endl;
  563.         if (!pMetaDC->Polygon(aptlPoints,ptsFollow)) {
  564.             errf << "ERROR: Polygon could not be drawn: " << endl;
  565.             errf << "Number of Points: " << ptsFollow << endl;
  566.             for(int i=0; i < ptsFollow; i++)
  567.              errf << aptlPoints[i].X() << "," << aptlPoints[i].Y() << endl;
  568.         }
  569.     } // ende fuellmodus
  570.  
  571.     else {
  572.    // draw not filled polygon (polyline)
  573.           if(!pMetaDC->Polyline(aptlPoints,ptsFollow)) {
  574.             errf << "ERROR: Polyline could not be drawn: " << endl;
  575.              errf << "Number of Points: " << ptsFollow << endl;
  576.             for(int i=0; i < ptsFollow; i++)
  577.                 errf << aptlPoints[i].X() << "," << aptlPoints[i].Y() << endl;
  578.         }
  579.  
  580.         if (closed) {
  581.               if(!pMetaDC->MoveTo(aptlPoints[ptsFollow-1].X(), aptlPoints[ptsFollow-1].Y()) )
  582.                 errf << "ERROR: MoveTo: " << aptlPoints[ptsFollow-1].X() << "," << aptlPoints[ptsFollow-1].Y() << endl;
  583.               if (!pMetaDC->LineTo(aptlPoints[0].X(), aptlPoints[0].Y()))      // and close it
  584.                 if (pDrvWMFsetup->info) errf << "ERROR: LineTo: " << aptlPoints[0].X() << "," << aptlPoints[0].Y() << endl;
  585.             else if (pDrvWMFsetup->info) errf << "Info: LineTo: " << aptlPoints[0].X() << "," << aptlPoints[0].Y() << endl;
  586.         }
  587.  
  588.     } // end of else
  589.  
  590.     if (pDrvWMFsetup->info) {
  591.       errf << "Info: Poly:" << endl;
  592.       errf << "Number of Points: " << ptsFollow << endl;
  593.       for(int i=0; i < ptsFollow; i++)
  594.           errf << aptlPoints[i].X() << "," << aptlPoints[i].Y() << endl;
  595.   }
  596.  
  597.      if (!cntPoints) delete[] aptlPoints;
  598.  
  599. }
  600.  
  601. void drvWMF::show_polyline()
  602. {
  603.     TPoint *aptlPoints = NULL;
  604.  
  605.     if (pDrvWMFsetup->info) errf << "show_Polyline: howToShow: " << currentShowType() << endl;
  606.  
  607.     drawPoly(0, aptlPoints, DRAW_OPEN);
  608. };
  609.  
  610. void drvWMF::show_rectangle(const float llx, const float lly, const float urx, const float ury)
  611. {
  612. #if 0
  613. // wogl old 
  614.     TPoint *Points = new TPoint[4];
  615.  
  616.    // Punkte-Array einrichten
  617.     Points[0]=TPoint(transX(llx),transY(lly));
  618.     Points[1]=TPoint(transX(urx),transY(lly));
  619.     Points[2]=TPoint(transX(urx),transY(ury));
  620.     Points[3]=TPoint(transX(llx),transY(ury));
  621.     if (pDrvWMFsetup->info) errf << "Rectangle-howToShow: " << currentShowType() << endl;
  622.  
  623.     drawPoly(4L, Points, DRAW_CLOSED);
  624. #endif
  625. // just do show_path for a first guess
  626.     show_path();
  627. }
  628.  
  629. void drvWMF::show_polygon()
  630. {
  631.     TPoint *aptlPoints = NULL;
  632.  
  633.     if (pDrvWMFsetup->info) errf << "show_Polygon: howToShow: " << currentShowType() << endl;
  634.  
  635.     drawPoly(0, aptlPoints, DRAW_CLOSED);
  636. }
  637.  
  638.