Skip to content
Snippets Groups Projects
Commit fd59f34e authored by Bill Medland's avatar Bill Medland Committed by Alexandre Julliard
Browse files

First stage of DrawText upgrade.

- Rearrange code into three distinct areas; DrawText, GrayString,
  TabbedText.
- Remove unused macros.
- Modify treatment of Tab arguments to fit with observed behaviour.
  e.g. DrawTextEx with DT_TABSTOP but null dtp will not take the
  setting from the flags.  Also only uses bits 15 to 8, not the
  higher bits.
parent 26a5261a
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,10 @@
*
* Copyright 1993, 1994 Alexandre Julliard
*
* Contains
* 1. DrawText functions
* 2. GrayString functions
* 3. TabbedText functions
*/
#include <string.h>
......@@ -19,6 +23,11 @@
DEFAULT_DEBUG_CHANNEL(text);
/*********************************************************************
*
* DrawText functions
*/
#define TAB 9
#define LF 10
#define CR 13
......@@ -35,30 +44,11 @@ static const WCHAR ELLIPSISW[] = {'.','.','.', 0};
static const WCHAR FORWARD_SLASHW[] = {'/', 0};
static const WCHAR BACK_SLASHW[] = {'\\', 0};
#define SWAP_INT(a,b) { int t = a; a = b; b = t; }
static int tabstop = 8;
static int tabstop;
static int tabwidth;
static int spacewidth;
static int prefix_offset;
/* ### start build ### */
extern WORD CALLBACK TEXT_CallTo16_word_wlw(GRAYSTRINGPROC16,WORD,LONG,WORD);
/* ### stop build ### */
struct gray_string_info
{
GRAYSTRINGPROC16 proc;
LPARAM param;
};
/* callback for 16-bit gray string proc */
static BOOL CALLBACK gray_string_callback( HDC hdc, LPARAM param, INT len )
{
const struct gray_string_info *info = (struct gray_string_info *)param;
return TEXT_CallTo16_word_wlw( info->proc, hdc, info->param, len );
}
/*********************************************************************
* Return next line of text from a string.
......@@ -220,25 +210,6 @@ static const WCHAR *TEXT_NextLineW( HDC hdc, const WCHAR *str, int *count,
}
/***********************************************************************
* DrawText (USER.85)
*/
INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT16 flags )
{
INT16 ret;
if (rect)
{
RECT rect32;
CONV_RECT16TO32( rect, &rect32 );
ret = DrawTextA( hdc, str, count, &rect32, flags );
CONV_RECT32TO16( &rect32, rect );
}
else ret = DrawTextA( hdc, str, count, NULL, flags);
return ret;
}
/***********************************************************************
* DrawTextExW (USER32.@)
*/
......@@ -284,8 +255,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
dtp->uiLengthDrawn = 0; /* This param RECEIVES number of chars processed */
}
if (flags & DT_TABSTOP)
tabstop = dtp ? dtp->iTabLength : flags >> 8;
tabstop = ((flags & DT_TABSTOP) && dtp) ? dtp->iTabLength : 8;
if (flags & DT_EXPANDTABS)
{
......@@ -482,7 +452,15 @@ INT WINAPI DrawTextExA( HDC hdc, LPSTR str, INT count,
*/
INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags )
{
return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, NULL);
DRAWTEXTPARAMS dtp;
memset (&dtp, 0, sizeof(dtp));
if (flags & DT_TABSTOP)
{
dtp.iTabLength = (flags >> 8) && 0xff;
flags &= 0xffff00ff;
}
return DrawTextExW(hdc, (LPWSTR)str, count, rect, flags, &dtp);
}
/***********************************************************************
......@@ -490,7 +468,56 @@ INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags )
*/
INT WINAPI DrawTextA( HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags )
{
return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, NULL );
DRAWTEXTPARAMS dtp;
memset (&dtp, 0, sizeof(dtp));
if (flags & DT_TABSTOP)
{
dtp.iTabLength = (flags >> 8) && 0xff;
flags &= 0xffff00ff;
}
return DrawTextExA( hdc, (LPSTR)str, count, rect, flags, &dtp );
}
/***********************************************************************
* DrawText (USER.85)
*/
INT16 WINAPI DrawText16( HDC16 hdc, LPCSTR str, INT16 count, LPRECT16 rect, UINT16 flags )
{
INT16 ret;
if (rect)
{
RECT rect32;
CONV_RECT16TO32( rect, &rect32 );
ret = DrawTextA( hdc, str, count, &rect32, flags );
CONV_RECT32TO16( &rect32, rect );
}
else ret = DrawTextA( hdc, str, count, NULL, flags);
return ret;
}
/***********************************************************************
*
* GrayString functions
*/
/* ### start build ### */
extern WORD CALLBACK TEXT_CallTo16_word_wlw(GRAYSTRINGPROC16,WORD,LONG,WORD);
/* ### stop build ### */
struct gray_string_info
{
GRAYSTRINGPROC16 proc;
LPARAM param;
};
/* callback for 16-bit gray string proc */
static BOOL CALLBACK gray_string_callback( HDC hdc, LPARAM param, INT len )
{
const struct gray_string_info *info = (struct gray_string_info *)param;
return TEXT_CallTo16_word_wlw( info->proc, hdc, info->param, len );
}
/***********************************************************************
......@@ -637,6 +664,11 @@ BOOL WINAPI GrayStringW( HDC hdc, HBRUSH hbr, GRAYSTRINGPROC gsprc,
TRUE, TRUE);
}
/***********************************************************************
*
* TabbedText functions
*/
/***********************************************************************
* TEXT_TabbedTextOut
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment