Ignore:
Timestamp:
Dec 9, 1999, 5:49:45 PM (26 years ago)
Author:
cbratschi
Message:

fixed TextOut, ExtTextOut bugs

File:
1 edited

Legend:

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

    r1961 r2049  
    1 /* $Id: text.cpp,v 1.2 1999-12-03 17:31:51 cbratschi Exp $ */
     1/* $Id: text.cpp,v 1.3 1999-12-09 16:49:45 cbratschi Exp $ */
    22
    33/*
     
    1616#include <misc.h>
    1717#include <string.h>
     18#include "oslibgpi.h"
    1819
    1920//******************************************************************************
     
    6162}
    6263//******************************************************************************
    63 //******************************************************************************
    64 static  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))
     64// CB: USER32 function, but here is the better place
     65//******************************************************************************
     66INT WIN32API InternalDrawTextExA(HDC hdc,LPCSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams)
     67{
     68  //CB: todo
     69
     70  return 0;
     71}
     72//******************************************************************************
     73//******************************************************************************
     74INT WIN32API InternalDrawTextExW(HDC hdc,LPWSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams)
     75{
     76  char *astring = UnicodeToAsciiStringN((LPWSTR)lpchText,cchText);
     77  INT  rc;
     78
     79  rc = InternalDrawTextExA(hdc,astring,cchText,lprc,dwDTFormat,lpDTParams);
     80  FreeAsciiString(astring);
     81
     82  return(rc);
     83}
     84//******************************************************************************
     85// CB: USER32 function, but here is the better place
     86//******************************************************************************
     87LONG WIN32API InternalTabbedTextOutA( HDC hdc, int x, int y, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int  nTabOrigin)
     88{
     89  //CB: todo
     90
     91  return 0;
     92}
     93//******************************************************************************
     94//******************************************************************************
     95LONG WIN32API InternalTabbedTextOutW( HDC hdc, int x, int y, LPCWSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int  nTabOrigin)
     96{
     97  char *astring = UnicodeToAsciiStringN((LPWSTR)lpString,nCount);
     98  LONG rc;
     99
     100  rc = InternalTabbedTextOutA(hdc,x,y,astring,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin);
     101  FreeAsciiString(astring);
     102
     103  return(rc);
     104}
     105//******************************************************************************
     106// CB: USER32 function, but here is the better place
     107//******************************************************************************
     108DWORD WIN32API InternalGetTabbedTextExtentA( HDC hDC, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions)
     109{
     110  //CB: todo
     111
     112  return 0;
     113}
     114//******************************************************************************
     115//******************************************************************************
     116DWORD WIN32API InternalGetTabbedTextExtentW( HDC hDC, LPCWSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions)
     117{
     118  char *astring = UnicodeToAsciiStringN((LPWSTR)lpString,nCount);
     119  DWORD rc;
     120
     121  rc = InternalGetTabbedTextExtentA(hDC,astring,nCount,nTabPositions,lpnTabStopPositions);
     122  FreeAsciiString(astring);
     123
     124  return(rc);
     125}
     126//******************************************************************************
     127// todo: metafile support
     128//******************************************************************************
     129BOOL InternalTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut)
     130{
     131  PVOID pHps = OSLibGpiQueryDCData(hdc);
     132  ULONG flOptions = 0;
     133  RECTLOS2 pmRect;
     134  POINTLOS2 ptl;
     135  LONG hits;
     136
     137  if (!pHps || cbCount < 0 || (lpszString == NULL && cbCount != 0))
    67138  {
    68139    SetLastError(ERROR_INVALID_HANDLE);
     
    70141  }
    71142
    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 //******************************************************************************
    81 static  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);
     143  if (cbCount > 512)
     144  {
     145    SetLastError(ERROR_INVALID_PARAMETER);
     146    return FALSE;
     147  }
     148  if (fuOptions & ~((UINT)(ETO_CLIPPED | ETO_OPAQUE)))
     149  {
     150    //ETO_GLYPH_INDEX, ETO_RTLLEADING, ETO_NUMERICSLOCAL, ETO_NUMERICSLATIN, ETO_IGNORELANGUAGE, ETO_PDY  are ignored
     151    return TRUE;
     152  }
     153
     154  //CB: add metafile info
     155
     156  if (lprc)
     157  {
     158    if (fuOptions)
     159    {
     160      MapWin32ToOS2Rect(*lprc,pmRect);
     161      if (excludeBottomRightPoint(pHps,(PPOINTLOS2)&pmRect) == 0)
     162      {
     163        return TRUE;
     164      }
     165
     166      if (fuOptions & ETO_CLIPPED) flOptions |= CHSOS_CLIP;
     167      if (fuOptions & ETO_OPAQUE)  flOptions |= CHSOS_OPAQUE;
     168    }
     169  } else
     170  {
     171    if (fuOptions)
     172    {
     173      SetLastError(ERROR_INVALID_HANDLE);
     174      return FALSE;
     175    }
     176  }
     177
     178  if (cbCount == 0)
     179  {
     180    if (fuOptions & ETO_OPAQUE)
     181    {
     182      lpszString = " ";
     183      cbCount = 1;
     184      flOptions |= CHSOS_CLIP;
     185    } else return TRUE;
     186  }
     187  if (lpDx)
     188    flOptions |= CHSOS_VECTOR;
     189
     190  if (getAlignUpdateCP(pHps) == FALSE)
     191  {
     192    ptl.x = X;
     193    ptl.y = Y;
     194
     195    flOptions |= CHSOS_LEAVEPOS;
     196  } else OSLibGpiQueryCurrentPosition(pHps,&ptl);
     197
     198  UINT align = GetTextAlign(hdc);
     199  LONG pmHAlign,pmVAlign;
     200
     201  //CB: TA_RIGHT not supported, only TA_CENTER and TA_LEFT
     202  if ((align & 0x6) == TA_RIGHT)
     203  {
     204    PPOINTLOS2 pts = (PPOINTLOS2)malloc((cbCount+1)*sizeof(POINTLOS2));
     205
     206    OSLibGpiQueryCharStringPosAt(pHps,&ptl,flOptions,cbCount,lpszString,lpDx,pts);
     207    ptl.x -= pts[cbCount].x-pts[0].x;
     208    free(pts);
     209  }
     210
     211  if (lprc && (align & 0x18) == TA_BASELINE)
     212  {
     213    //CB: if TA_BASELINE is set, GPI doesn't fill rect
     214    //    TA_BOTTOM fills rect
     215    OSLibGpiQueryTextAlignment(pHps,&pmHAlign,&pmVAlign);
     216    OSLibGpiSetTextAlignment(pHps,pmHAlign,(pmVAlign & ~TAOS_BASE) | TAOS_BOTTOM);
     217  }
     218
     219  ptl.y += getWorldYDeltaFor1Pixel(pHps);
     220
     221  hits = OSLibGpiCharStringPosAt(pHps,&ptl,&pmRect,flOptions,cbCount,lpszString,lpDx);
     222
     223  if (lprc && (align & 0x18) == TA_BASELINE)
     224    OSLibGpiSetTextAlignment(pHps,pmHAlign,pmVAlign);
     225
     226  if (hits == GPIOS_ERROR)
     227  {
     228    return FALSE;
     229  }
     230  if (getAlignUpdateCP(pHps))
     231  {
     232    OSLibGpiQueryCurrentPosition(pHps,&ptl);
     233    ptl.y -= getWorldYDeltaFor1Pixel(pHps);
     234    OSLibGpiSetCurrentPosition(pHps,&ptl);
     235  }
     236
     237  return TRUE;
     238}
     239//******************************************************************************
     240//******************************************************************************
     241BOOL InternalTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,INT cbCount,CONST INT *lpDx,BOOL IsExtTextOut)
     242{
     243  char *astring = UnicodeToAsciiStringN((LPWSTR)lpszString,cbCount);
    84244  BOOL  rc;
    85245
Note: See TracChangeset for help on using the changeset viewer.