| 1 | /* $Id: text.cpp,v 1.9 2000-02-23 17:05:17 cbratschi Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Font and Text Functions | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1999 Christoph Bratschi | 
|---|
| 7 | * | 
|---|
| 8 | * Copyright 1993, 1994 Alexandre Julliard | 
|---|
| 9 | * | 
|---|
| 10 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 11 | */ | 
|---|
| 12 |  | 
|---|
| 13 | #include "winuser.h" | 
|---|
| 14 | #include "user32.h" | 
|---|
| 15 | #include "syscolor.h" | 
|---|
| 16 |  | 
|---|
| 17 | #define DBG_LOCALLOG    DBG_text | 
|---|
| 18 | #include "dbglocal.h" | 
|---|
| 19 |  | 
|---|
| 20 | //WINE parts: wine-991031 | 
|---|
| 21 |  | 
|---|
| 22 | INT WIN32API DrawTextA(HDC hDC,LPCSTR lpString,INT nCount,PRECT lpRect,UINT nFormat) | 
|---|
| 23 | { | 
|---|
| 24 | int bla; | 
|---|
| 25 |  | 
|---|
| 26 | dprintf(("USER32: DrawTextA %x %s %d (%d,%d)(%d,%d) %x",hDC, lpString, nCount, lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, nFormat)); | 
|---|
| 27 |  | 
|---|
| 28 | if(nFormat == 0x828) { | 
|---|
| 29 | bla = 1; | 
|---|
| 30 | } | 
|---|
| 31 | return InternalDrawTextExA(hDC,lpString,nCount,lpRect,nFormat,NULL,FALSE); | 
|---|
| 32 | } | 
|---|
| 33 | //****************************************************************************** | 
|---|
| 34 | //****************************************************************************** | 
|---|
| 35 | INT WIN32API DrawTextW(HDC hDC,LPCWSTR lpString,INT nCount,PRECT lpRect,UINT nFormat) | 
|---|
| 36 | { | 
|---|
| 37 | dprintf(("USER32: DrawTextW %x",hDC)); | 
|---|
| 38 |  | 
|---|
| 39 | return InternalDrawTextExW(hDC,lpString,nCount,lpRect,nFormat,NULL,FALSE); | 
|---|
| 40 | } | 
|---|
| 41 | //****************************************************************************** | 
|---|
| 42 | //****************************************************************************** | 
|---|
| 43 | INT WIN32API DrawTextExA(HDC hdc,LPCSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams) | 
|---|
| 44 | { | 
|---|
| 45 | dprintf(("USER32: DrawTextExA %x %s %d (%d,%d)(%d,%d) %x",hdc, lpchText, cchText, lprc->left, lprc->top, lprc->right, lprc->bottom, dwDTFormat)); | 
|---|
| 46 |  | 
|---|
| 47 | return InternalDrawTextExA(hdc,lpchText,cchText,lprc,dwDTFormat,lpDTParams,TRUE); | 
|---|
| 48 | } | 
|---|
| 49 | //****************************************************************************** | 
|---|
| 50 | //****************************************************************************** | 
|---|
| 51 | int WIN32API DrawTextExW(HDC hdc,LPWSTR lpchText,INT cchText,LPRECT lprc,UINT dwDTFormat,LPDRAWTEXTPARAMS lpDTParams) | 
|---|
| 52 | { | 
|---|
| 53 | dprintf(("USER32: DrawTextExW %x",hdc)); | 
|---|
| 54 |  | 
|---|
| 55 | return InternalDrawTextExW(hdc,lpchText,cchText,lprc,dwDTFormat,lpDTParams,TRUE); | 
|---|
| 56 | } | 
|---|
| 57 | //****************************************************************************** | 
|---|
| 58 | //****************************************************************************** | 
|---|
| 59 | DWORD WIN32API GetTabbedTextExtentA( HDC hDC, LPCSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions) | 
|---|
| 60 | { | 
|---|
| 61 | dprintf(("USER32: GetTabbedTextExtentA %x",hDC)); | 
|---|
| 62 |  | 
|---|
| 63 | return InternalGetTabbedTextExtentA(hDC,lpString,nCount,nTabPositions,lpnTabStopPositions); | 
|---|
| 64 | } | 
|---|
| 65 | //****************************************************************************** | 
|---|
| 66 | //****************************************************************************** | 
|---|
| 67 | DWORD WIN32API GetTabbedTextExtentW(HDC hDC,LPCWSTR lpString,INT nCount,INT nTabPositions,LPINT lpnTabStopPositions) | 
|---|
| 68 | { | 
|---|
| 69 | dprintf(("USER32: GetTabbedTextExtentW %x",hDC)); | 
|---|
| 70 |  | 
|---|
| 71 | return InternalGetTabbedTextExtentW(hDC,lpString,nCount,nTabPositions,lpnTabStopPositions); | 
|---|
| 72 | } | 
|---|
| 73 | //****************************************************************************** | 
|---|
| 74 | //****************************************************************************** | 
|---|
| 75 | LONG WIN32API TabbedTextOutA(HDC hdc,INT x,INT y,LPCSTR lpString,INT nCount,INT nTabPositions, LPINT lpnTabStopPositions,INT nTabOrigin) | 
|---|
| 76 | { | 
|---|
| 77 | dprintf(("USER32: TabbedTextOutA %x",hdc)); | 
|---|
| 78 |  | 
|---|
| 79 | return InternalTabbedTextOutA(hdc,x,y,lpString,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin); | 
|---|
| 80 | } | 
|---|
| 81 | //****************************************************************************** | 
|---|
| 82 | //****************************************************************************** | 
|---|
| 83 | LONG WIN32API TabbedTextOutW( HDC hdc, int x, int y, LPCWSTR lpString, int nCount, int nTabPositions, LPINT lpnTabStopPositions, int  nTabOrigin) | 
|---|
| 84 | { | 
|---|
| 85 | dprintf(("USER32: TabbedTextOutW %x",hdc)); | 
|---|
| 86 |  | 
|---|
| 87 | return InternalTabbedTextOutW(hdc,x,y,lpString,nCount,nTabPositions,lpnTabStopPositions,nTabOrigin); | 
|---|
| 88 | } | 
|---|
| 89 | //****************************************************************************** | 
|---|
| 90 | // WINE/objects/text.c | 
|---|
| 91 | //****************************************************************************** | 
|---|
| 92 | static BOOL InternalGrayString(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,INT nCount,INT x,INT y,INT nWidth,INT nHeight,BOOL isUnicode) | 
|---|
| 93 | { | 
|---|
| 94 | HBITMAP hbm, hbmsave; | 
|---|
| 95 | HBRUSH hbsave; | 
|---|
| 96 | HFONT hfsave; | 
|---|
| 97 | HDC memdc = CreateCompatibleDC(hdc); | 
|---|
| 98 | BOOL retval = TRUE; | 
|---|
| 99 | RECT r; | 
|---|
| 100 | COLORREF fg, bg; | 
|---|
| 101 |  | 
|---|
| 102 | if (!hdc) return FALSE; | 
|---|
| 103 |  | 
|---|
| 104 | if (nCount == 0) | 
|---|
| 105 | nCount = isUnicode ? lstrlenW((LPCWSTR)lpData):lstrlenA((LPCSTR)lpData); | 
|---|
| 106 |  | 
|---|
| 107 | if((nWidth == 0 || nHeight == 0) && nCount != -1) | 
|---|
| 108 | { | 
|---|
| 109 | SIZE s; | 
|---|
| 110 |  | 
|---|
| 111 | if (isUnicode) | 
|---|
| 112 | GetTextExtentPoint32W(hdc,(LPCWSTR)lpData,nCount,&s); | 
|---|
| 113 | else | 
|---|
| 114 | GetTextExtentPoint32A(hdc,(LPCSTR)lpData,nCount,&s); | 
|---|
| 115 | if (nWidth == 0) nWidth = s.cx; | 
|---|
| 116 | if (nHeight == 0) nHeight = s.cy; | 
|---|
| 117 | } | 
|---|
| 118 |  | 
|---|
| 119 | r.left = r.top = 0; | 
|---|
| 120 | r.right = nWidth; | 
|---|
| 121 | r.bottom = nHeight; | 
|---|
| 122 |  | 
|---|
| 123 | hbm = CreateBitmap(nWidth,nHeight,1,1,NULL); | 
|---|
| 124 | hbmsave = (HBITMAP)SelectObject(memdc,hbm); | 
|---|
| 125 | FillRect(memdc,&r,(HBRUSH)GetStockObject(BLACK_BRUSH)); | 
|---|
| 126 | SetTextColor(memdc,RGB(255,255,255)); | 
|---|
| 127 | SetBkColor(memdc,RGB(0,0,0)); | 
|---|
| 128 | hfsave = (HFONT)SelectObject(memdc,GetCurrentObject(hdc,OBJ_FONT)); | 
|---|
| 129 |  | 
|---|
| 130 | if (lpOutputFunc) | 
|---|
| 131 | retval = lpOutputFunc(memdc,lpData,nCount); | 
|---|
| 132 | else | 
|---|
| 133 | if (isUnicode) | 
|---|
| 134 | TextOutW(memdc,0,0,(LPCWSTR)lpData,nCount); | 
|---|
| 135 | else | 
|---|
| 136 | TextOutA(memdc,0,0,(LPCSTR)lpData,nCount); | 
|---|
| 137 | SelectObject(memdc, hfsave); | 
|---|
| 138 |  | 
|---|
| 139 | /* | 
|---|
| 140 | * Windows doc says that the bitmap isn't grayed when len == -1 and | 
|---|
| 141 | * the callback function returns FALSE. However, testing this on | 
|---|
| 142 | * win95 showed otherwise... | 
|---|
| 143 | */ | 
|---|
| 144 | #ifdef GRAYSTRING_USING_DOCUMENTED_BEHAVIOUR | 
|---|
| 145 | if(retval || nCount != -1) | 
|---|
| 146 | #endif | 
|---|
| 147 | { | 
|---|
| 148 | hbsave = (HBRUSH)SelectObject(memdc,GetPattern55AABrush()); | 
|---|
| 149 | PatBlt(memdc,0,0,nWidth,nHeight,0x000A0329); | 
|---|
| 150 | SelectObject(memdc, hbsave); | 
|---|
| 151 | } | 
|---|
| 152 |  | 
|---|
| 153 | if (hBrush) hbsave = (HBRUSH)SelectObject(hdc,hBrush); | 
|---|
| 154 | fg = SetTextColor(hdc, RGB(0, 0, 0)); | 
|---|
| 155 | bg = SetBkColor(hdc, RGB(255, 255, 255)); | 
|---|
| 156 | BitBlt(hdc,x,y,nWidth,nHeight,memdc,0,0,0x00E20746); | 
|---|
| 157 | SetTextColor(hdc, fg); | 
|---|
| 158 | SetBkColor(hdc, bg); | 
|---|
| 159 | if (hBrush) SelectObject(hdc,hbsave); | 
|---|
| 160 |  | 
|---|
| 161 | SelectObject(memdc, hbmsave); | 
|---|
| 162 | DeleteObject(hbm); | 
|---|
| 163 | DeleteDC(memdc); | 
|---|
| 164 |  | 
|---|
| 165 | return retval; | 
|---|
| 166 | } | 
|---|
| 167 | //****************************************************************************** | 
|---|
| 168 | //****************************************************************************** | 
|---|
| 169 | BOOL WIN32API GrayStringA(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,int nCount,int X,int Y,int nWidth,int nHeight) | 
|---|
| 170 | { | 
|---|
| 171 | dprintf(("USER32: GrayStringA %x",hdc)); | 
|---|
| 172 |  | 
|---|
| 173 | return InternalGrayString(hdc,hBrush,lpOutputFunc,lpData,nCount,X,Y,nWidth,nHeight,FALSE); | 
|---|
| 174 | } | 
|---|
| 175 | //****************************************************************************** | 
|---|
| 176 | //****************************************************************************** | 
|---|
| 177 | BOOL WIN32API GrayStringW(HDC hdc,HBRUSH hBrush,GRAYSTRINGPROC lpOutputFunc,LPARAM lpData,int nCount,int X,int Y,int nWidth,int nHeight) | 
|---|
| 178 | { | 
|---|
| 179 | dprintf(("USER32: GrayStringW %x",hdc)); | 
|---|
| 180 |  | 
|---|
| 181 | return InternalGrayString(hdc,hBrush,lpOutputFunc,lpData,nCount,X,Y,nWidth,nHeight,TRUE); | 
|---|
| 182 | } | 
|---|
| 183 |  | 
|---|