source: trunk/src/gdi32/text.cpp@ 2016

Last change on this file since 2016 was 1961, checked in by cbratschi, 26 years ago

moved line API's to line.cpp, first work on InternalTextOut

File size: 4.5 KB
Line 
1/* $Id: text.cpp,v 1.2 1999-12-03 17:31:51 cbratschi Exp $ */
2
3/*
4 * GDI32 text apis
5 *
6 * Based on Wine code (991031) (objects\text.c)
7 *
8 * Copyright 1993, 1994 Alexandre Julliard
9 *
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 */
14#include <os2win.h>
15#include <stdlib.h>
16#include <misc.h>
17#include <string.h>
18
19//******************************************************************************
20//******************************************************************************
21UINT WINAPI GetTextCharsetInfo(
22 HDC hdc, /* [in] Handle to device context */
23 LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
24 DWORD flags) /* [in] Reserved - must be 0 */
25{
26 HGDIOBJ hFont;
27 UINT charSet = DEFAULT_CHARSET;
28 LOGFONTW lf;
29 CHARSETINFO csinfo;
30
31 dprintf(("GetTextCharsetInfo %x %x %x", hdc, fs, flags));
32
33 hFont = GetCurrentObject(hdc, OBJ_FONT);
34 if (hFont == 0)
35 return(DEFAULT_CHARSET);
36 if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
37 charSet = lf.lfCharSet;
38
39 if (fs != NULL) {
40 if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
41 return (DEFAULT_CHARSET);
42 memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
43 }
44 return charSet;
45}
46/***********************************************************************
47 * GetTextCharset32 [GDI32.226] Gets character set for font in DC
48 *
49 * NOTES
50 * Should it return a UINT32 instead of an INT32?
51 * => YES, as GetTextCharsetInfo returns UINT32
52 *
53 * RETURNS
54 * Success: Character set identifier
55 * Failure: DEFAULT_CHARSET
56 */
57UINT WINAPI GetTextCharset(HDC hdc) /* [in] Handle to device context */
58{
59 /* MSDN docs say this is equivalent */
60 return GetTextCharsetInfo(hdc, NULL, 0);
61}
62//******************************************************************************
63//******************************************************************************
64static 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))
67 {
68 SetLastError(ERROR_INVALID_HANDLE);
69 return FALSE;
70 }
71
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//******************************************************************************
81static 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);
84 BOOL rc;
85
86 rc = InternalTextOutA(hdc,X,Y,fuOptions,lprc,(LPCSTR)astring,cbCount,lpDx,IsExtTextOut);
87 FreeAsciiString(astring);
88
89 return(rc);
90}
91//******************************************************************************
92//******************************************************************************
93BOOL WIN32API ExtTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,UINT cbCount,CONST INT *lpDx)
94{
95 dprintf(("GDI32: ExtTextOutA\n"));
96
97 return InternalTextOutA(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
98}
99//******************************************************************************
100//******************************************************************************
101BOOL WIN32API ExtTextOutW(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCWSTR lpszString,UINT cbCount,CONST int *lpDx)
102{
103 dprintf(("GDI32: ExtTextOutW\n"));
104
105 return InternalTextOutW(hdc,X,Y,fuOptions,lprc,lpszString,cbCount,lpDx,TRUE);
106}
107//******************************************************************************
108//******************************************************************************
109BOOL WIN32API TextOutA(HDC hdc,int nXStart,int nYStart,LPCSTR lpszString,int cbString)
110{
111 dprintf(("GDI32: TextOutA"));
112
113 return InternalTextOutA(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE);
114}
115//******************************************************************************
116//******************************************************************************
117BOOL WIN32API TextOutW(HDC hdc,int nXStart,int nYStart,LPCWSTR lpszString,int cbString)
118{
119 dprintf(("GDI32: TextOutW"));
120
121 return InternalTextOutW(hdc,nXStart,nYStart,0,NULL,lpszString,cbString,NULL,FALSE);
122}
123//******************************************************************************
124//******************************************************************************
Note: See TracBrowser for help on using the repository browser.