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

GetTextExtentPoint reimplemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.