Changeset 12546


Ignore:
Timestamp:
Dec 3, 1999, 6:31:51 PM (25 years ago)
Author:
cbratschi
Message:

moved line API's to line.cpp, first work on InternalTextOut

Location:
tags/trunk/src/gdi32
Files:
1 added
3 edited

Legend:

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

    r12539 r12546  
    1 /* $Id: gdi32.cpp,v 1.21 1999-12-03 11:55:45 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.22 1999-12-03 17:31:49 cbratschi Exp $ */
    22
    33/*
     
    1414#include <stdarg.h>
    1515#include <string.h>
    16 #include <math.h>
    1716#include "misc.h"
    1817#include "callback.h"
    1918#include "unicode.h"
    2019#include "dibsect.h"
    21 
    22 #define ROUND_FLOAT(x) ((INT)((x < 0) ? x-0.5:x+0.5))
    23 #define sqr(x) (pow(x,2))
    2420
    2521typedef struct _POLYTEXTA
     
    150146  dprintf(("GDI32: SetTextColor from %X to %X\n", clr, crColor));
    151147  return(clr);
    152 }
    153 //******************************************************************************
    154 //******************************************************************************
    155 BOOL WIN32API TextOutA(HDC hdc, int nXStart, int nYStart,
    156                              LPCSTR lpszString, int cbString)
    157 {
    158  BOOL rc;
    159 
    160   rc = O32_TextOut(hdc, nXStart, nYStart, lpszString, cbString);
    161   dprintf(("GDI32: TextOut %s returned %d\n", lpszString, rc));
    162   return(rc);
    163148}
    164149//******************************************************************************
     
    284269//TEMPORARY HACK TO PREVENT CRASH IN OPEN32 (WSeB GA)
    285270    if(arg2->biHeight < 0) {
    286         ((BITMAPINFOHEADER *)arg2)->biHeight = -arg2->biHeight;
     271        ((BITMAPINFOHEADER *)arg2)->biHeight = -arg2->biHeight;
    287272    }
    288273    return O32_CreateDIBitmap(arg1, arg2, arg3, arg4, arg5, arg6);
     
    447432    dprintf(("GDI32: SetBkMode\n"));
    448433    return O32_SetBkMode(arg1, arg2);
    449 }
    450 //******************************************************************************
    451 //******************************************************************************
    452 BOOL WIN32API ExtTextOutA(HDC hdc, int X, int Y, UINT fuOptions, CONST RECT *lprc,
    453                           LPCSTR lpszString, UINT cbCount, CONST INT *lpDx)
    454 {
    455   if(lpszString && strlen(lpszString) > cbCount)
    456         ((LPSTR)lpszString)[cbCount] = 0;
    457   dprintf(("GDI32: ExtTextOutA %s\n", lpszString));
    458   return(O32_ExtTextOut(hdc, X, Y, fuOptions, lprc, lpszString, cbCount, lpDx));
    459434}
    460435//******************************************************************************
     
    963938//******************************************************************************
    964939//******************************************************************************
    965 POINT ToWin32LineEnd(POINT startPt,INT nXEnd,INT nYEnd)
    966 {
    967   POINT pt;
    968 
    969   if (startPt.x != nXEnd || startPt.y != nYEnd)
    970   {
    971     if (nXEnd == startPt.x)
    972     {
    973       pt.x = nXEnd;
    974       pt.y = (nYEnd > startPt.y) ? nYEnd-1:nYEnd+1;
    975     } else if (nYEnd == startPt.y)
    976     {
    977       pt.x = (nXEnd > startPt.x) ? nXEnd-1:nXEnd+1;
    978       pt.y = nYEnd;
    979     } else
    980     {
    981       DOUBLE len = sqrt(sqr(nXEnd-startPt.x)+sqr(nYEnd-startPt.y));
    982       DOUBLE lenDif = (len-1)/len;
    983       INT w = nXEnd-startPt.x,h = nYEnd-startPt.y;
    984 
    985       pt.x = startPt.x+ROUND_FLOAT(w*lenDif);
    986       pt.y = startPt.y+ROUND_FLOAT(h*lenDif);
    987     }
    988   } else
    989   {
    990     pt.x = nXEnd;
    991     pt.y = nYEnd;
    992   }
    993 
    994   return pt;
    995 }
    996 
    997 VOID DrawSingleLinePoint(HDC hdc,POINT pt)
    998 {
    999   LOGPEN penInfo;
    1000 
    1001   if (!GetObjectA(GetCurrentObject(hdc,OBJ_PEN),sizeof(penInfo),(LPVOID)&penInfo)) return;
    1002   if (penInfo.lopnWidth.x <= 1 && penInfo.lopnWidth.y <= 1) SetPixel(hdc,pt.x,pt.y,penInfo.lopnColor); else
    1003   {
    1004     INT x = pt.x-penInfo.lopnWidth.x/2;
    1005     INT y = pt.y-penInfo.lopnWidth.y/2;
    1006     Ellipse(hdc,x,y,x+penInfo.lopnWidth.x,y+penInfo.lopnWidth.y);
    1007   }
    1008 }
    1009 
    1010 BOOL WIN32API LineTo( HDC hdc, int nXEnd, int  nYEnd)
    1011 {
    1012   POINT oldPt,pt;
    1013 
    1014   dprintf(("GDI32: LineTo"));
    1015 
    1016   //CB: Open32 draws a pixel too much!
    1017   GetCurrentPositionEx(hdc,&oldPt);
    1018   pt = ToWin32LineEnd(oldPt,nXEnd,nYEnd);
    1019 
    1020   BOOL rc;
    1021 
    1022   if (oldPt.x == pt.x && oldPt.y == pt.y)
    1023   {
    1024     DrawSingleLinePoint(hdc,pt);
    1025 
    1026     rc = TRUE;
    1027   } else rc = O32_LineTo(hdc,pt.x,pt.y);
    1028   MoveToEx(hdc,nXEnd,nYEnd,NULL);
    1029 
    1030   return rc;
    1031 }
    1032 //******************************************************************************
    1033 //******************************************************************************
    1034940BOOL WIN32API MoveToEx( HDC arg1, int arg2, int arg3, PPOINT  arg4)
    1035941{
     
    11281034    dprintf(("GDI32: ExtSelectClipRgn"));
    11291035    return O32_ExtSelectClipRgn(arg1, arg2, arg3);
    1130 }
    1131 //******************************************************************************
    1132 //******************************************************************************
    1133 BOOL WIN32API ExtTextOutW(HDC hdc, int X, int Y, UINT fuOptions,
    1134                           const RECT *lprc, LPCWSTR lpString, UINT cbCount,
    1135                           const int *lpDx)
    1136 {
    1137  char *astring = UnicodeToAsciiString((LPWSTR)lpString);
    1138  BOOL  rc;
    1139 
    1140     if(lprc)
    1141             dprintf(("GDI32: ExtTextOutW (%d,%d) %X, (%d,%d)(%d,%d)\n", X, Y, fuOptions, lprc->left, lprc->top, lprc->right, lprc->bottom));
    1142     else    dprintf(("GDI32: ExtTextOutW (%d,%d) %X\n", X, Y, fuOptions));
    1143     rc = O32_ExtTextOut(hdc, X, Y, fuOptions, lprc, astring, cbCount, lpDx);
    1144     dprintf(("GDI32: ExtTextOutW %s (%X) length %d rc %d\n", astring, lpString, cbCount, rc));
    1145     FreeAsciiString(astring);
    1146     return(rc);
    11471036}
    11481037//******************************************************************************
     
    17131602//******************************************************************************
    17141603//******************************************************************************
    1715 BOOL WIN32API LineDDA( int nXStart, int nYStart, int nXEnd, int nYEnd, LINEDDAPROC lpLineFunc, LPARAM lpData)
    1716 {
    1717  BOOL                 rc;
    1718  LineDDAProcCallback *callback = new LineDDAProcCallback(lpLineFunc, lpData);
    1719  POINT startPt,endPt;
    1720 
    1721   dprintf(("GDI32: LineDDA\n"));
    1722 
    1723   //CB: don't know if Open32 reports the last pixel, but all other line functions do
    1724   startPt.x = nXStart;
    1725   startPt.y = nYStart;
    1726   endPt = ToWin32LineEnd(startPt,nXEnd,nYEnd);
    1727 
    1728   rc = O32_LineDDA(startPt.x,startPt.y,endPt.x,endPt.y,callback->GetOS2Callback(),(LPARAM)callback);
    1729   if(callback)
    1730         delete callback;
    1731   return(rc);
    1732 }
    1733 //******************************************************************************
    1734 //******************************************************************************
    17351604BOOL WIN32API MaskBlt( HDC arg1, int arg2, int arg3, int arg4, int arg5, HDC   arg6, int arg7, int arg8, HBITMAP arg9, int arg10, int arg11, DWORD  arg12)
    17361605{
     
    18631732    dprintf(("GDI32: Polygon"));
    18641733    return O32_Polygon(arg1, arg2, arg3);
    1865 }
    1866 //******************************************************************************
    1867 //******************************************************************************
    1868 BOOL WIN32API Polyline( HDC hdc, const POINT *lppt, int cPoints)
    1869 {
    1870     dprintf(("GDI32: Polyline"));
    1871 
    1872     if (cPoints == 0) return TRUE;
    1873     if (cPoints < 0)
    1874     {
    1875       SetLastError(ERROR_INVALID_PARAMETER);
    1876 
    1877       return FALSE;
    1878     }
    1879 
    1880     if (cPoints == 1)
    1881     {
    1882       DrawSingleLinePoint(hdc,*lppt); //CB: check metafile recording
    1883 
    1884       return TRUE;
    1885     }
    1886 
    1887     //CB: Open32 draw a pixel too much!
    1888     POINT *points = (POINT*)lppt;
    1889     POINT lastPt = lppt[cPoints-1];
    1890     BOOL rc;
    1891 
    1892     points[cPoints-1] = ToWin32LineEnd(lppt[cPoints-2],lastPt.x,lastPt.y);
    1893     rc = O32_Polyline(hdc,lppt,cPoints);
    1894     points[cPoints-1] = lastPt;
    1895 
    1896     return rc;
    1897 }
    1898 //******************************************************************************
    1899 //******************************************************************************
    1900 BOOL WIN32API PolylineTo( HDC hdc, const POINT * lppt, DWORD cCount)
    1901 {
    1902     dprintf(("GDI32: PolylineTo"));
    1903 
    1904     if (cCount == 0) return TRUE;
    1905 
    1906     if (cCount == 1)
    1907     {
    1908       DrawSingleLinePoint(hdc,*lppt);
    1909 
    1910       return TRUE; //CB: check metafile recording
    1911     }
    1912 
    1913     //CB: Open32 draw a pixel too much!
    1914     POINT *points = (POINT*)lppt;
    1915     POINT lastPt = lppt[cCount-1];
    1916     BOOL rc;
    1917 
    1918     points[cCount-1] = ToWin32LineEnd(lppt[cCount-2],lastPt.x,lastPt.y);
    1919     rc = O32_PolylineTo(hdc,lppt,cCount);
    1920     points[cCount-1] = lastPt;
    1921     MoveToEx(hdc,lastPt.x,lastPt.y,NULL);
    1922 
    1923     return rc;
    19241734}
    19251735//******************************************************************************
     
    22452055    dprintf(("GDI32: StartPage"));
    22462056    return O32_StartPage(arg1);
    2247 }
    2248 //******************************************************************************
    2249 //******************************************************************************
    2250 BOOL WIN32API TextOutW( HDC arg1, int arg2, int arg3, LPCWSTR arg4, int  arg5)
    2251 {
    2252  char *astring = UnicodeToAsciiString((LPWSTR)arg4);
    2253  BOOL  rc;
    2254 
    2255     dprintf(("GDI32: TextOutW"));
    2256     // NOTE: This will not work as is (needs UNICODE support)
    2257     rc = O32_TextOut(arg1, arg2, arg3, astring, arg5);
    2258     FreeAsciiString(astring);
    2259     return rc;
    22602057}
    22612058//******************************************************************************
  • TabularUnified tags/trunk/src/gdi32/makefile

    r12517 r12546  
    1 # $Id: makefile,v 1.12 1999-12-01 23:30:09 sandervl Exp $
     1# $Id: makefile,v 1.13 1999-12-03 17:31:51 cbratschi Exp $
    22
    33#
    44# PD-Win32 API
    55#
    6 #       gdi32.dll makefile
     6#       gdi32.dll makefile
    77#
    88
     
    2222TARGET = gdi32
    2323
    24 OBJS =  gdi32.obj opengl.obj callback.obj dibsect.obj initterm.obj oslibgdi.obj font.obj text.obj palette.obj
     24OBJS =  gdi32.obj opengl.obj callback.obj dibsect.obj initterm.obj oslibgdi.obj font.obj text.obj palette.obj line.obj
    2525
    2626
     
    2929
    3030$(TARGET).dll: $(OBJS) $(TARGET).def
    31         $(LD) $(LDFLAGS) -Fm -Fe$@ $(OBJS) $(TARGET).def \
     31        $(LD) $(LDFLAGS) -Fm -Fe$@ $(OBJS) $(TARGET).def \
    3232              $(PDWIN32_LIB)/pmwinx.lib $(PDWIN32_LIB)/kernel32.lib $(PDWIN32_LIB)/user32.lib \
    3333              $(PDWIN32_LIB)/odincrt.lib OS2386.LIB $(RTLLIB_O)
    34         $(CP) $@ $(PDWIN32_BIN)
     34        $(CP) $@ $(PDWIN32_BIN)
    3535
    3636
    3737$(TARGET).lib: $(TARGET)exp.def
    38         $(IMPLIB) $(IMPLIBFLAGS) $@ $(TARGET)exp.def
    39         $(CP) $@ $(PDWIN32_LIB)
     38        $(IMPLIB) $(IMPLIBFLAGS) $@ $(TARGET)exp.def
     39        $(CP) $@ $(PDWIN32_LIB)
    4040
    4141$(TARGET)exp.def: $(TARGET).def
     
    7171oslibgdi.obj: oslibgdi.cpp oslibgdi.h
    7272
     73line.obj: line.cpp \
     74    $(PDWIN32_INCLUDE)\misc.h \
     75
    7376initterm.obj: initterm.cpp
    7477
    7578
    7679clean:
    77         $(RM) *.obj *.lib *.dll *.map *.pch
    78         $(RM) $(PDWIN32_BIN)\$(TARGET).dll
    79         $(RM) $(PDWIN32_LIB)\$(TARGET).lib
     80        $(RM) *.obj *.lib *.dll *.map *.pch
     81        $(RM) $(PDWIN32_BIN)\$(TARGET).dll
     82        $(RM) $(PDWIN32_LIB)\$(TARGET).lib
    8083    $(RM) $(TARGET)exp.def
    8184
  • TabularUnified tags/trunk/src/gdi32/text.cpp

    r12517 r12546  
    1 /* $Id: text.cpp,v 1.1 1999-12-01 23:30:30 sandervl Exp $ */
     1/* $Id: text.cpp,v 1.2 1999-12-03 17:31:51 cbratschi Exp $ */
    22
    33/*
     
    6262//******************************************************************************
    6363//******************************************************************************
     64static  BOOL InternalTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut)
     65{
     66  if (cbCount < 0 || (lpszString == NULL && cbCount != 0))
     67  {
     68    SetLastError(ERROR_INVALID_HANDLE);
     69    return FALSE;
     70  }
     71
     72  //CB: todo
     73
     74  if (IsExtTextOut)
     75    return O32_ExtTextOut(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx);
     76  else
     77    return O32_TextOut(hdc,X,Y,lpszString,cbCount);
     78}
     79//******************************************************************************
     80//******************************************************************************
     81static  BOOL InternalTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut)
     82{
     83  char *astring = UnicodeToAsciiString((LPWSTR)lpszString);
     84  BOOL  rc;
     85
     86  rc = InternalTextOutA(hdc,X,Y,fuOptions,lprc,(LPCSTR)astring,cbCount,lpDx,IsExtTextOut);
     87  FreeAsciiString(astring);
     88
     89  return(rc);
     90}
     91//******************************************************************************
     92//******************************************************************************
     93BOOL WIN32API ExtTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,UINT cbCount,CONST INT *lpDx)
     94{
     95  dprintf(("GDI32: ExtTextOutA\n"));
     96
     97  return InternalTextOutA(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
     98}
     99//******************************************************************************
     100//******************************************************************************
     101BOOL WIN32API ExtTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,UINT cbCount,CONST int *lpDx)
     102{
     103  dprintf(("GDI32: ExtTextOutW\n"));
     104
     105  return InternalTextOutW(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
     106}
     107//******************************************************************************
     108//******************************************************************************
     109BOOL WIN32API TextOutA(HDC hdc,int nXStart,int nYStart,LPCSTR lpszString,int cbString)
     110{
     111  dprintf(("GDI32: TextOutA"));
     112
     113  return InternalTextOutA(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE);
     114}
     115//******************************************************************************
     116//******************************************************************************
     117BOOL WIN32API TextOutW(HDC hdc,int nXStart,int nYStart,LPCWSTR lpszString,int cbString)
     118{
     119  dprintf(("GDI32: TextOutW"));
     120
     121  return InternalTextOutW(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE);
     122}
     123//******************************************************************************
     124//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.