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