Changeset 1666 for trunk/src


Ignore:
Timestamp:
Nov 9, 1999, 6:06:14 PM (26 years ago)
Author:
cbratschi
Message:

don't draw line end

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/gdi32.cpp

    r1606 r1666  
    1 /* $Id: gdi32.cpp,v 1.13 1999-11-05 09:17:27 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.14 1999-11-09 17:06:14 cbratschi Exp $ */
    22
    33/*
     
    1414#include <stdarg.h>
    1515#include <string.h>
     16#include <math.h>
    1617#include "misc.h"
    1718#include "callback.h"
     
    1920#include "dibsect.h"
    2021
     22#define ROUND_FLOAT(x) ((INT)((x < 0) ? x-0.5:x+0.5))
     23#define sqr(x) (pow(x,2))
    2124
    2225typedef struct _POLYTEXTA
     
    805808//******************************************************************************
    806809//******************************************************************************
    807 BOOL WIN32API LineTo( HDC arg1, int arg2, int  arg3)
    808 {
    809     dprintf(("GDI32: OS2LineTo"));
    810     return O32_LineTo(arg1, arg2, arg3);
     810POINT OS2ToWin32LineEnd(POINT startPt,INT nXEnd,INT nYEnd)
     811{
     812  POINT pt;
     813
     814  if (startPt.x != nXEnd || startPt.y != nYEnd)
     815  {
     816    if (nXEnd == startPt.x)
     817    {
     818      pt.x = nXEnd;
     819      pt.y = (nYEnd > startPt.y) ? nYEnd-1:nYEnd+1;
     820    } else if (nYEnd == startPt.y)
     821    {
     822      pt.x = (nXEnd > startPt.x) ? nXEnd-1:nXEnd+1;
     823      pt.y = nYEnd;
     824    } else
     825    {
     826      DOUBLE len = sqrt(sqr(nXEnd-startPt.x)+sqr(nYEnd-startPt.y));
     827      DOUBLE lenDif = (len-1)/len;
     828      INT w = nXEnd-startPt.x,h = nYEnd-startPt.y;
     829
     830      pt.x = startPt.x+ROUND_FLOAT(w*lenDif);
     831      pt.y = startPt.y+ROUND_FLOAT(h*lenDif);
     832    }
     833  } else
     834  {
     835    pt.x = nXEnd;
     836    pt.y = nYEnd;
     837  }
     838
     839  return pt;
     840}
     841
     842VOID DrawSingleLinePoint(HDC hdc,POINT pt)
     843{
     844  LOGPEN penInfo;
     845
     846  if (!GetObjectA(GetCurrentObject(hdc,OBJ_PEN),sizeof(penInfo),(LPVOID)&penInfo)) return;
     847  if (penInfo.lopnWidth.x <= 1 && penInfo.lopnWidth.y <= 1) SetPixel(hdc,pt.x,pt.y,penInfo.lopnColor); else
     848  {
     849    INT x = pt.x-penInfo.lopnWidth.x/2;
     850    INT y = pt.y-penInfo.lopnWidth.y/2;
     851    Ellipse(hdc,x,y,x+penInfo.lopnWidth.x,y+penInfo.lopnWidth.y);
     852  }
     853}
     854
     855BOOL WIN32API LineTo( HDC hdc, int nXEnd, int  nYEnd)
     856{
     857  POINT oldPt,pt;
     858
     859  dprintf(("GDI32: OS2LineTo"));
     860
     861  //CB: Open32 draws a pixel too much!
     862  GetCurrentPositionEx(hdc,&oldPt);
     863  pt = OS2ToWin32LineEnd(oldPt,nXEnd,nYEnd);
     864
     865  BOOL rc;
     866
     867  if (oldPt.x == pt.x && oldPt.y == pt.y)
     868  {
     869    DrawSingleLinePoint(hdc,pt);
     870
     871    rc = TRUE;
     872  } else rc = O32_LineTo(hdc,pt.x,pt.y);
     873  MoveToEx(hdc,nXEnd,nYEnd,NULL);
     874
     875  return rc;
    811876}
    812877//******************************************************************************
     
    14921557//******************************************************************************
    14931558//******************************************************************************
    1494 BOOL WIN32API LineDDA( int arg1, int arg2, int arg3, int arg4, LINEDDAPROC lpLineFunc, LPARAM lpData)
     1559BOOL WIN32API LineDDA( int nXStart, int nYStart, int nXEnd, int nYEnd, LINEDDAPROC lpLineFunc, LPARAM lpData)
    14951560{
    14961561 BOOL                 rc;
    14971562 LineDDAProcCallback *callback = new LineDDAProcCallback(lpLineFunc, lpData);
     1563 POINT startPt,endPt;
    14981564
    14991565  dprintf(("GDI32: OS2LineDDA\n"));
    1500   rc = O32_LineDDA(arg1, arg2, arg3, arg4, callback->GetOS2Callback(), (LPARAM)callback);
     1566
     1567  //CB: don't know if Open32 reports the last pixel, but all other line functions do
     1568  startPt.x = nXStart;
     1569  startPt.y = nYStart;
     1570  endPt = OS2ToWin32LineEnd(startPt,nXEnd,nYEnd);
     1571
     1572  rc = O32_LineDDA(startPt.x,startPt.y,endPt.x,endPt.y,callback->GetOS2Callback(),(LPARAM)callback);
    15011573  if(callback)
    15021574        delete callback;
     
    16231695//******************************************************************************
    16241696//******************************************************************************
    1625 BOOL WIN32API PolyPolyline( HDC arg1, const POINT * arg2, const DWORD * arg3, DWORD  arg4)
     1697BOOL WIN32API PolyPolyline( HDC hdc, const POINT * lppt, const DWORD * lpdwPolyPoints, DWORD cCount)
    16261698{
    16271699    dprintf(("GDI32: OS2PolyPolyline"));
    1628     return O32_PolyPolyline(arg1, arg2, arg3, arg4);
     1700
     1701    return O32_PolyPolyline(hdc,lppt,lpdwPolyPoints,cCount);
    16291702}
    16301703//******************************************************************************
     
    16371710//******************************************************************************
    16381711//******************************************************************************
    1639 BOOL WIN32API Polyline( HDC arg1, const POINT * arg2, int  arg3)
     1712BOOL WIN32API Polyline( HDC hdc, const POINT *lppt, int cPoints)
    16401713{
    16411714    dprintf(("GDI32: OS2Polyline"));
    1642     return O32_Polyline(arg1, arg2, arg3);
    1643 }
    1644 //******************************************************************************
    1645 //******************************************************************************
    1646 BOOL WIN32API PolylineTo( HDC arg1, const POINT * arg2, DWORD  arg3)
     1715
     1716    if (cPoints == 0) return TRUE;
     1717    if (cPoints < 0)
     1718    {
     1719      SetLastError(ERROR_INVALID_PARAMETER);
     1720
     1721      return FALSE;
     1722    }
     1723
     1724    if (cPoints == 1)
     1725    {
     1726      DrawSingleLinePoint(hdc,*lppt); //CB: check metafile recording
     1727
     1728      return TRUE;
     1729    }
     1730
     1731    //CB: Open32 draw a pixel too much!
     1732    POINT *points = (POINT*)lppt;
     1733    POINT lastPt = lppt[cPoints-1];
     1734    BOOL rc;
     1735
     1736    points[cPoints-1] = OS2ToWin32LineEnd(lppt[cPoints-2],lastPt.x,lastPt.y);
     1737    rc = O32_Polyline(hdc,lppt,cPoints);
     1738    points[cPoints-1] = lastPt;
     1739
     1740    return rc;
     1741}
     1742//******************************************************************************
     1743//******************************************************************************
     1744BOOL WIN32API PolylineTo( HDC hdc, const POINT * lppt, DWORD cCount)
    16471745{
    16481746    dprintf(("GDI32: OS2PolylineTo"));
    1649     return O32_PolylineTo(arg1, arg2, arg3);
     1747
     1748    if (cCount == 0) return TRUE;
     1749
     1750    if (cCount == 1)
     1751    {
     1752      DrawSingleLinePoint(hdc,*lppt);
     1753
     1754      return TRUE; //CB: check metafile recording
     1755    }
     1756
     1757    //CB: Open32 draw a pixel too much!
     1758    POINT *points = (POINT*)lppt;
     1759    POINT lastPt = lppt[cCount-1];
     1760    BOOL rc;
     1761
     1762    points[cCount-1] = OS2ToWin32LineEnd(lppt[cCount-2],lastPt.x,lastPt.y);
     1763    rc = O32_PolylineTo(hdc,lppt,cCount);
     1764    points[cCount-1] = lastPt;
     1765    MoveToEx(hdc,lastPt.x,lastPt.y,NULL);
     1766
     1767    return rc;
    16501768}
    16511769//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.