- Timestamp:
- Nov 9, 1999, 6:06:14 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/gdi32.cpp
r1606 r1666 1 /* $Id: gdi32.cpp,v 1.1 3 1999-11-05 09:17:27 sandervlExp $ */1 /* $Id: gdi32.cpp,v 1.14 1999-11-09 17:06:14 cbratschi Exp $ */ 2 2 3 3 /* … … 14 14 #include <stdarg.h> 15 15 #include <string.h> 16 #include <math.h> 16 17 #include "misc.h" 17 18 #include "callback.h" … … 19 20 #include "dibsect.h" 20 21 22 #define ROUND_FLOAT(x) ((INT)((x < 0) ? x-0.5:x+0.5)) 23 #define sqr(x) (pow(x,2)) 21 24 22 25 typedef struct _POLYTEXTA … … 805 808 //****************************************************************************** 806 809 //****************************************************************************** 807 BOOL WIN32API LineTo( HDC arg1, int arg2, int arg3) 808 { 809 dprintf(("GDI32: OS2LineTo")); 810 return O32_LineTo(arg1, arg2, arg3); 810 POINT 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 842 VOID 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 855 BOOL 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; 811 876 } 812 877 //****************************************************************************** … … 1492 1557 //****************************************************************************** 1493 1558 //****************************************************************************** 1494 BOOL WIN32API LineDDA( int arg1, int arg2, int arg3, int arg4, LINEDDAPROC lpLineFunc, LPARAM lpData)1559 BOOL WIN32API LineDDA( int nXStart, int nYStart, int nXEnd, int nYEnd, LINEDDAPROC lpLineFunc, LPARAM lpData) 1495 1560 { 1496 1561 BOOL rc; 1497 1562 LineDDAProcCallback *callback = new LineDDAProcCallback(lpLineFunc, lpData); 1563 POINT startPt,endPt; 1498 1564 1499 1565 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); 1501 1573 if(callback) 1502 1574 delete callback; … … 1623 1695 //****************************************************************************** 1624 1696 //****************************************************************************** 1625 BOOL WIN32API PolyPolyline( HDC arg1, const POINT * arg2, const DWORD * arg3, DWORD arg4)1697 BOOL WIN32API PolyPolyline( HDC hdc, const POINT * lppt, const DWORD * lpdwPolyPoints, DWORD cCount) 1626 1698 { 1627 1699 dprintf(("GDI32: OS2PolyPolyline")); 1628 return O32_PolyPolyline(arg1, arg2, arg3, arg4); 1700 1701 return O32_PolyPolyline(hdc,lppt,lpdwPolyPoints,cCount); 1629 1702 } 1630 1703 //****************************************************************************** … … 1637 1710 //****************************************************************************** 1638 1711 //****************************************************************************** 1639 BOOL WIN32API Polyline( HDC arg1, const POINT * arg2, int arg3)1712 BOOL WIN32API Polyline( HDC hdc, const POINT *lppt, int cPoints) 1640 1713 { 1641 1714 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 //****************************************************************************** 1744 BOOL WIN32API PolylineTo( HDC hdc, const POINT * lppt, DWORD cCount) 1647 1745 { 1648 1746 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; 1650 1768 } 1651 1769 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.