Changeset 4602 for trunk/src


Ignore:
Timestamp:
Nov 16, 2000, 5:34:49 PM (25 years ago)
Author:
sandervl
Message:

GetTextExtentPoint reimplemented

Location:
trunk/src/gdi32
Files:
4 edited

Legend:

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

    r4598 r4602  
    1 /* $Id: gdi32.cpp,v 1.62 2000-11-15 16:10:41 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.63 2000-11-16 16:34:48 sandervl Exp $ */
    22
    33/*
     
    3232//******************************************************************************
    3333//******************************************************************************
    34 BOOL WIN32API GetTextExtentPointA(HDC hdc, LPCSTR lpsz, int cbString, LPSIZE lpSize)
    35 {
    36  BOOL rc;
    37 
    38   lpSize->cx = lpSize->cy = 0;
    39   rc = O32_GetTextExtentPoint(hdc, lpsz, cbString, lpSize);
    40   dprintf(("GDI32: GetTextExtentPointA of %s returned %d\n", lpsz, rc));
    41   return(rc);
    42 }
    4334//******************************************************************************
    4435//******************************************************************************
     
    754745//******************************************************************************
    755746//******************************************************************************
    756 BOOL WIN32API GetCharWidth32A( HDC arg1, UINT arg2, UINT arg3, PINT  arg4)
    757 {
    758     dprintf(("GDI32: GetCharWidth32A"));
    759     return O32_GetCharWidth(arg1, arg2, arg3, arg4);
     747BOOL WIN32API GetCharWidth32A( HDC hdc, UINT iFirstChar, UINT iLastChar, PINT pWidthArray)
     748{
     749 BOOL ret;
     750
     751    dprintf(("GDI32: GetCharWidth32A %x %x %x %x", hdc, iFirstChar, iLastChar, pWidthArray));
     752    ret = O32_GetCharWidth(hdc, iFirstChar, iLastChar, pWidthArray);
     753    dprintf(("GDI32: GetCharWidth32A returned %d", ret));
     754#ifdef DEBUG
     755    if(ret) {
     756      for(int i=iFirstChar;i<iLastChar;i++) {
     757          if((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z')) {
     758                dprintf2(("Char %c -> width %d", i, pWidthArray[i]));
     759          }
     760          else  dprintf2(("Char %x -> width %d", i, pWidthArray[i]));
     761      }
     762    }
     763#endif
     764    return ret;
    760765}
    761766//******************************************************************************
    762767//TODO: Cut off Unicode chars?
    763768//******************************************************************************
    764 BOOL WIN32API GetCharWidth32W(HDC arg1, UINT iFirstChar, UINT iLastChar, PINT  arg4)
     769BOOL WIN32API GetCharWidth32W(HDC hdc, UINT iFirstChar, UINT iLastChar, PINT pWidthArray)
    765770{
    766771    dprintf(("GDI32: GetCharWidth32W, not properly implemented"));
    767     return O32_GetCharWidth(arg1, iFirstChar, iLastChar, arg4);
     772    return O32_GetCharWidth(hdc, iFirstChar, iLastChar, pWidthArray);
    768773}
    769774//******************************************************************************
     
    891896//******************************************************************************
    892897//******************************************************************************
    893 BOOL WIN32API GetTextExtentPoint32A( HDC hdc, LPCSTR lpsz, int cbString, PSIZE  lpSize)
    894 {
    895  BOOL rc;
    896 
    897     lpSize->cx = lpSize->cy = 0;
    898     rc = O32_GetTextExtentPoint32(hdc, lpsz, cbString, lpSize);
    899     dprintf(("GDI32: GetTextExtentPoint32A %x %s %d returned %d (%d,%d)", hdc, lpsz, cbString, rc, lpSize->cx, lpSize->cy));
    900     return rc;
    901 }
    902 //******************************************************************************
    903 //******************************************************************************
    904 BOOL WIN32API GetTextExtentPoint32W(HDC arg1, LPCWSTR arg2, int arg3, PSIZE lpSize)
    905 {
    906  char *astring = UnicodeToAsciiString((LPWSTR)arg2);
    907  BOOL  rc;
    908 
    909     dprintf(("GDI32: GetTextExtentPoint32W %s\n", astring));
    910     lpSize->cx = lpSize->cy = 0;
    911     rc = O32_GetTextExtentPoint32(arg1, astring, arg3, lpSize);
    912     FreeAsciiString(astring);
    913     return(rc);
    914 }
    915 //******************************************************************************
    916 //******************************************************************************
    917 BOOL WIN32API GetTextExtentPointW(HDC    hdc,
    918                                   LPCWSTR lpString,
    919                                   int    cbString,
    920                                   PSIZE  lpSize)
    921 {
    922   char *astring = UnicodeToAsciiString((LPWSTR)lpString);
    923   BOOL  rc;
    924 
    925   lpSize->cx = lpSize->cy = 0;
    926   rc = O32_GetTextExtentPoint(hdc,
    927                          astring,
    928                          cbString,
    929                          lpSize);
    930   dprintf(("GDI32: GetTextExtentPointW %X %s (size %08xh) returned %d\n", hdc, astring, cbString, rc));
    931   dprintf(("GDI32: GetTextExtentPointW (%d,%d)\n", lpSize->cx, lpSize->cy));
    932 
    933   FreeAsciiString(astring);
    934   return(rc);
    935 }
    936898//******************************************************************************
    937899//******************************************************************************
  • trunk/src/gdi32/oslibgpi.cpp

    r4596 r4602  
    1 /* $Id: oslibgpi.cpp,v 1.8 2000-11-15 13:56:45 sandervl Exp $ */
     1/* $Id: oslibgpi.cpp,v 1.9 2000-11-16 16:34:49 sandervl Exp $ */
    22
    33/*
     
    242242}
    243243
    244 LONG OSLibGpiQueryTabbedTextExtent(PVOID pHps,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops)
    245 {
    246   return GpiQueryTabbedTextExtent(GetDCData(pHps)->hps,lCount,(PCH)pchString,lTabCount,(PULONG)puTabStops);
     244LONG OSLibGpiQueryTabbedTextExtent(pDCData pHps,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops)
     245{
     246  return GpiQueryTabbedTextExtent(pHps->hps,lCount,(PCH)pchString,lTabCount,(PULONG)puTabStops);
    247247}
    248248
     
    252252}
    253253
    254 BOOL OSLibGpiQueryTextBox(PVOID pHps,LONG lCount1,LPCSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints)
    255 {
    256   return GpiQueryTextBox(GetDCData(pHps)->hps,lCount1,(PCH)pchString,lCount2,(PPOINTL)aptlPoints);
     254BOOL OSLibGpiQueryTextBox(pDCData pHps,LONG lCount1,LPCSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints)
     255{
     256  return GpiQueryTextBox(pHps->hps,lCount1,(PCH)pchString,lCount2,(PPOINTL)aptlPoints);
    257257}
    258258
     
    265265  {
    266266    point->y = labs (box[TXTBOX_BOTTOMLEFT].y-box[TXTBOX_TOPLEFT].y);
    267     point->x = labs (box[TXTBOX_CONCAT].x-box[TXTBOX_BOTTOMLEFT].x);
     267    point->x = labs (box[TXTBOX_BOTTOMRIGHT].x-box[TXTBOX_BOTTOMLEFT].x);
    268268
    269269    if (box[TXTBOX_BOTTOMLEFT].x != box[TXTBOX_TOPLEFT].x)
     
    435435}
    436436#endif
     437
     438BOOL OSLibDevQueryCaps(pDCData pHps, LONG lStart, LONG lCount, LONG *alArray)
     439{
     440   return DevQueryCaps(pHps->hdc, lStart, lCount, alArray);
     441}
  • trunk/src/gdi32/oslibgpi.h

    r4596 r4602  
    1 /* $Id: oslibgpi.h,v 1.8 2000-11-15 13:56:45 sandervl Exp $ */
     1/* $Id: oslibgpi.h,v 1.9 2000-11-16 16:34:49 sandervl Exp $ */
    22
    33/*
     
    1212#define __OSLIBGPI_H__
    1313
     14#include <dcdata.h>
    1415
    1516#ifdef DEBUG
     
    133134BOOL OSLibGpiQueryTextAlignment(PVOID pHps,PLONG plHoriz,PLONG plVert);
    134135
    135 LONG OSLibGpiQueryTabbedTextExtent(PVOID pHps,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops);
     136LONG OSLibGpiQueryTabbedTextExtent(pDCData pHps,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops);
    136137LONG OSLibGpiTabbedCharStringAt(PVOID pHps,PPOINTLOS2 pPtStart,PRECTLOS2 prclRect,ULONG flOptions,INT lCount,LPCSTR pchString,INT lTabCount,PINT puTabStops,INT lTabOrigin);
    137138
     
    143144#define TXTBOXOS_COUNT                    5L
    144145
    145 BOOL OSLibGpiQueryTextBox(PVOID pHps,LONG lCount1,LPCSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints);
     146BOOL OSLibGpiQueryTextBox(pDCData pHps,LONG lCount1,LPCSTR pchString,LONG lCount2,PPOINTLOS2 aptlPoints);
    146147
    147148VOID calcDimensions(POINTLOS2 box[],PPOINTLOS2 point);
     
    208209BOOL  OSLibGpiSetCp(HDC hdc, ULONG codepage);
    209210
     211#define OSLIB_CAPS_HORIZONTAL_RESOLUTION      8L      /* pels per meter  */
     212#define OSLIB_CAPS_VERTICAL_RESOLUTION        9L      /* pels per meter  */
     213
     214BOOL  OSLibDevQueryCaps(pDCData hHps, LONG lStart, LONG lCount, LONG *alArray);
    210215
    211216   // from pmddi.h:
  • trunk/src/gdi32/text.cpp

    r4365 r4602  
    1 /* $Id: text.cpp,v 1.13 2000-10-02 13:11:47 phaller Exp $ */
     1/* $Id: text.cpp,v 1.14 2000-11-16 16:34:49 sandervl Exp $ */
    22
    33/*
     
    1818#include <float.h>
    1919#include "oslibgpi.h"
     20#include <dcdata.h>
    2021
    2122#define DBG_LOCALLOG    DBG_text
     
    112113  }
    113114
    114   PVOID pHps = OSLibGpiQueryDCData(hdc);
     115  pDCData pHps = (pDCData)OSLibGpiQueryDCData(hdc);
    115116
    116117  if (!pHps)
     
    167168    }
    168169  }
    169 
     170#ifdef INVERT
    170171  flCmd = DTOS_INVERT | DTOS_WORLDRECT | DTOS_TEXTATTRS | DTOS_AMPERSAND | DTOS_VERTICALEXTENT;
     172#else
     173  flCmd = DTOS_WORLDRECT | DTOS_TEXTATTRS | DTOS_AMPERSAND | DTOS_VERTICALEXTENT;
     174#endif
    171175
    172176  LONG lMixMode = OSLibGpiQueryBackMix(pHps);
     
    231235      rectPtr->bottom = lprc->bottom;
    232236    }
    233   }
     237
     238#ifndef INVERT
     239    if (pHps->yInvert > 0) {
     240      int temp        = pHps->yInvert - rectPtr->bottom;
     241      rectPtr->bottom = pHps->yInvert - rectPtr->top;
     242      rectPtr->top    = temp;
     243    }
     244#endif
     245  }
     246
     247#ifndef INVERT
     248////  dwDTFormat &= ~DT_INVERT;
     249////  dwDTFormat |=  DT_INVERTCHAR;
     250  int top = rectPtr->top;
     251#endif
    234252
    235253  if (dwDTFormat & DT_EXPANDTABS)
     
    398416  if (dwDTFormat & DT_CALCRECT)
    399417  {
     418#ifndef INVERT
     419    if (pHps->yInvert > 0) {
     420         top              = top - rectPtr->top;
     421         rectPtr->top    += top;
     422         rectPtr->bottom += top;
     423    } /* endif */
     424#endif
    400425    if (!(dwDTFormat & DT_RIGHT) && (rectPtr->left < xLeft))
    401426    {
     
    440465DWORD SYSTEM EXPORT InternalGetTabbedTextExtentA(HDC hDC,LPCSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions)
    441466{
    442   PVOID pHps = OSLibGpiQueryDCData(hDC);
     467  pDCData pHps = (pDCData)OSLibGpiQueryDCData(hDC);
    443468  BOOL result;
    444469  POINTLOS2 pts[TXTBOXOS_COUNT];
     
    496521LONG SYSTEM EXPORT InternalTabbedTextOutA(HDC hdc,INT x,INT y,LPCSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions,INT nTabOrigin)
    497522{
    498   PVOID pHps = OSLibGpiQueryDCData(hdc);
     523  pDCData pHps = (pDCData)OSLibGpiQueryDCData(hdc);
    499524  POINTLOS2 ptl;
    500525  DWORD dimensions;
     
    521546    return 0;
    522547  }
    523   if (getAlignUpdateCP(pHps) == TRUE)
     548  if (getAlignUpdateCP(pHps) == TRUE) {
    524549    OSLibGpiQueryCurrentPosition(pHps,&ptl);
     550  }
    525551  else
    526552  {
    527553    ptl.x = x;
    528554    ptl.y = y;
     555#ifndef INVERT
     556    if (pHps->yInvert > 0) {
     557       ptl.y = pHps->yInvert - ptl.y;
     558    }
     559#endif
    529560  }
    530561
     
    569600BOOL InternalTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut)
    570601{
    571   PVOID pHps = OSLibGpiQueryDCData(hdc);
     602  pDCData pHps = (pDCData)OSLibGpiQueryDCData(hdc);
    572603  ULONG flOptions = 0;
    573604  RECTLOS2 pmRect;
     
    607638        return TRUE;
    608639      }
     640#ifndef INVERT
     641      if (pHps->yInvert > 0) {
     642          int temp       = pHps->yInvert - pmRect.yTop;
     643          pmRect.yTop    = pHps->yInvert - pmRect.yBottom;
     644          pmRect.yBottom = temp;
     645      }   
     646#endif
    609647
    610648      if (fuOptions & ETO_CLIPPED) flOptions |= CHSOS_CLIP;
     
    642680    ptl.x = X;
    643681    ptl.y = Y;
     682
     683#ifndef INVERT
     684    if (pHps->yInvert > 0) {
     685       ptl.y = pHps->yInvert - Y;
     686    }
     687#endif
    644688
    645689    flOptions |= CHSOS_LEAVEPOS;
     
    670714  ptl.y += getWorldYDeltaFor1Pixel(pHps);
    671715
     716#ifndef INVERT
     717  int vertAdjust = 0;
     718  if ((pHps->taMode & 0x18) == TA_TOP)
     719  {
     720      vertAdjust = OSLibGpiQueryFontMaxHeight(pHps->hps);
     721  }
     722  ptl.y -= vertAdjust;
     723#endif
     724
    672725  hits = OSLibGpiCharStringPosAt(pHps,&ptl,&pmRect,flOptions,cbCount,lpszString,lpDx);
    673726
     
    684737    OSLibGpiQueryCurrentPosition(pHps,&ptl);
    685738    ptl.y -= getWorldYDeltaFor1Pixel(pHps);
     739#ifndef INVERT
     740    ptl.y += vertAdjust;
     741#endif
    686742    OSLibGpiSetCurrentPosition(pHps,&ptl);
    687743  }
     
    705761BOOL WIN32API ExtTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,UINT cbCount,CONST INT *lpDx)
    706762{
    707   dprintf(("GDI32: ExtTextOutA %x %s", hdc, lpszString));
    708 
    709   return InternalTextOutA(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
     763  dprintf(("GDI32: ExtTextOutA %x %s (%d,%d) %x %d %x", hdc, lpszString, X, Y, fuOptions, cbCount, lpDx));
     764  return InternalTextOutA(hdc, X, Y, fuOptions, lprc, lpszString, cbCount, lpDx, TRUE);
    710765}
    711766//******************************************************************************
     
    714769{
    715770  dprintf(("GDI32: ExtTextOutW\n"));
    716 
    717   return InternalTextOutW(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
     771  return InternalTextOutW(hdc, X, Y, fuOptions, lprc, lpszString, cbCount, lpDx, TRUE);
    718772}
    719773//******************************************************************************
     
    721775BOOL WIN32API TextOutA(HDC hdc,int nXStart,int nYStart,LPCSTR lpszString,int cbString)
    722776{
    723   dprintf(("GDI32: TextOutA %x %s", hdc, lpszString));
     777  dprintf(("GDI32: TextOutA %x (%d,%d) %s", hdc, nXStart, nYStart, lpszString));
    724778
    725779  return InternalTextOutA(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE);
     
    765819  return TRUE;
    766820}
     821//******************************************************************************
     822//******************************************************************************
     823BOOL WIN32API GetTextExtentPointA(HDC hdc, LPCTSTR lpsz, int cbString,
     824                                  LPSIZE lpsSize)
     825{
     826   BOOL       rc;
     827   POINTLOS2  pts[TXTBOXOS_COUNT];
     828   POINTLOS2  widthHeight = { 0, 0};
     829   pDCData    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     830
     831   dprintf(("GDI32: GetTextExtentPointA %s\n", lpsz));
     832   if(pHps == NULL)
     833   {
     834      SetLastError(ERROR_INVALID_HANDLE);
     835      return FALSE;
     836   }
     837
     838   if(lpsz == NULL || cbString < 0 || lpsSize == NULL)
     839   {
     840      SetLastError(ERROR_INVALID_PARAMETER);
     841      return FALSE;
     842   }
     843
     844   lpsSize->cx = 0;
     845   lpsSize->cy = 0;
     846
     847   // Verified with NT4, SP6
     848   if(cbString == 0)
     849   {
     850      SetLastError(ERROR_SUCCESS);
     851      return TRUE;
     852   }
     853   if(cbString > 512) {
     854      dprintf(("ERROR: Oh, oh, string too long!!"));
     855      DebugInt3();
     856   }
     857
     858   rc = OSLibGpiQueryTextBox(pHps, cbString, lpsz, TXTBOXOS_COUNT, pts);
     859   if(rc == FALSE)
     860   {
     861      SetLastError(ERROR_INVALID_PARAMETER);    //todo wrong error
     862      return FALSE;
     863   }
     864   calcDimensions(pts, &widthHeight);
     865   lpsSize->cx = widthHeight.x;
     866   lpsSize->cy = widthHeight.y;
     867
     868   if(pHps && pHps->isPrinter && pHps->hdc)
     869   {//scale for printer dcs
     870       LONG alArray[2];
     871
     872       if (OSLibDevQueryCaps(pHps, OSLIB_CAPS_HORIZONTAL_RESOLUTION, 2, &alArray[0]))
     873         lpsSize->cx = lpsSize->cx * alArray[0] / alArray[1];
     874   }
     875
     876   dprintf(("GDI32: GetTextExtentPointA %x %s %d returned %d (%d,%d)", hdc, lpsz, cbString, rc, lpsSize->cx, lpsSize->cy));
     877   SetLastError(ERROR_SUCCESS);
     878   return TRUE;
     879}
     880//******************************************************************************
     881//******************************************************************************
     882BOOL WIN32API GetTextExtentPointW(HDC    hdc,
     883                                  LPCWSTR lpString,
     884                                  int    cbString,
     885                                  PSIZE  lpSize)
     886{
     887  char *astring = UnicodeToAsciiString((LPWSTR)lpString);
     888  BOOL  rc;
     889
     890  dprintf(("GDI32: GetTextExtentPointW %s\n", astring));
     891  lpSize->cx = lpSize->cy = 0;
     892  rc = GetTextExtentPointA(hdc,
     893                           astring,
     894                           cbString,
     895                           lpSize);
     896  FreeAsciiString(astring);
     897  return(rc);
     898}
     899//******************************************************************************
     900//******************************************************************************
     901BOOL WIN32API GetTextExtentPoint32A( HDC hdc, LPCSTR lpsz, int cbString, PSIZE  lpSize)
     902{
     903 BOOL rc;
     904
     905    dprintf(("GDI32: GetTextExtentPoint32A %s\n", lpsz));
     906    lpSize->cx = lpSize->cy = 0;
     907    rc = GetTextExtentPointA(hdc, lpsz, cbString, lpSize);
     908    return rc;
     909}
     910//******************************************************************************
     911//******************************************************************************
     912BOOL WIN32API GetTextExtentPoint32W(HDC arg1, LPCWSTR arg2, int arg3, PSIZE lpSize)
     913{
     914 char *astring = UnicodeToAsciiString((LPWSTR)arg2);
     915 BOOL  rc;
     916
     917    dprintf(("GDI32: GetTextExtentPoint32W %s\n", astring));
     918    rc = GetTextExtentPointA(arg1, astring, arg3, lpSize);
     919    FreeAsciiString(astring);
     920    return(rc);
     921}
     922//******************************************************************************
     923//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.