return GdipIsVisibleRect(graphics, (REAL)x, (REAL)y, (REAL)width, (REAL)height, result);
}
-typedef GpStatus (*gdip_format_string_callback)(GpGraphics *graphics,
+typedef GpStatus (*gdip_format_string_callback)(HDC hdc,
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
INT lineno, const RectF *bounds, void *user_data);
-static GpStatus gdip_format_string(GpGraphics *graphics,
+static GpStatus gdip_format_string(HDC hdc,
GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font,
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
gdip_format_string_callback callback, void *user_data)
else halign = StringAlignmentNear;
while(sum < length){
- GetTextExtentExPointW(graphics->hdc, stringdup + sum, length - sum,
+ GetTextExtentExPointW(hdc, stringdup + sum, length - sum,
nwidth, &fit, NULL, &size);
fitcpy = fit;
else
lineend = fit;
- GetTextExtentExPointW(graphics->hdc, stringdup + sum, lineend,
+ GetTextExtentExPointW(hdc, stringdup + sum, lineend,
nwidth, &j, NULL, &size);
bounds.Width = size.cx;
break;
}
- stat = callback(graphics, stringdup, sum, lineend,
+ stat = callback(hdc, stringdup, sum, lineend,
font, rect, format, lineno, &bounds, user_data);
if (stat != Ok)
GpRegion **regions;
};
-static GpStatus measure_ranges_callback(GpGraphics *graphics,
+static GpStatus measure_ranges_callback(HDC hdc,
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
INT lineno, const RectF *bounds, void *user_data)
range_rect.Y = bounds->Y;
range_rect.Height = bounds->Height;
- GetTextExtentExPointW(graphics->hdc, string + index, range_start - index,
+ GetTextExtentExPointW(hdc, string + index, range_start - index,
INT_MAX, NULL, NULL, &range_size);
range_rect.X = bounds->X + range_size.cx;
- GetTextExtentExPointW(graphics->hdc, string + index, range_end - index,
+ GetTextExtentExPointW(hdc, string + index, range_end - index,
INT_MAX, NULL, NULL, &range_size);
range_rect.Width = (bounds->X + range_size.cx) - range_rect.X;
int i;
HFONT oldfont;
struct measure_ranges_args args;
- HDC temp_hdc=NULL;
+ HDC hdc, temp_hdc=NULL;
TRACE("(%p %s %d %p %s %p %d %p)\n", graphics, debugstr_w(string),
length, font, debugstr_rectf(layoutRect), stringFormat, regionCount, regions);
if(!graphics->hdc)
{
- temp_hdc = graphics->hdc = CreateCompatibleDC(0);
+ hdc = temp_hdc = CreateCompatibleDC(0);
if (!temp_hdc) return OutOfMemory;
}
+ else
+ hdc = graphics->hdc;
if (stringFormat->attr)
TRACE("may be ignoring some format flags: attr %x\n", stringFormat->attr);
- oldfont = SelectObject(graphics->hdc, CreateFontIndirectW(&font->lfw));
+ oldfont = SelectObject(hdc, CreateFontIndirectW(&font->lfw));
for (i=0; i<stringFormat->range_count; i++)
{
args.regions = regions;
- stat = gdip_format_string(graphics, string, length, font, layoutRect, stringFormat,
+ stat = gdip_format_string(hdc, string, length, font, layoutRect, stringFormat,
measure_ranges_callback, &args);
- DeleteObject(SelectObject(graphics->hdc, oldfont));
+ DeleteObject(SelectObject(hdc, oldfont));
if (temp_hdc)
- {
- graphics->hdc = NULL;
DeleteDC(temp_hdc);
- }
return stat;
}
INT *linesfilled;
};
-static GpStatus measure_string_callback(GpGraphics *graphics,
+static GpStatus measure_string_callback(HDC hdc,
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
INT lineno, const RectF *bounds, void *user_data)
if(!graphics->hdc)
{
- temp_hdc = graphics->hdc = CreateCompatibleDC(0);
+ temp_hdc = CreateCompatibleDC(0);
if (!temp_hdc) return OutOfMemory;
}
args.codepointsfitted = codepointsfitted;
args.linesfilled = linesfilled;
- gdip_format_string(graphics, string, length, font, rect, format,
+ gdip_format_string(graphics->hdc ? graphics->hdc : temp_hdc, string, length, font, rect, format,
measure_string_callback, &args);
DeleteObject(SelectObject(graphics->hdc, oldfont));
if (temp_hdc)
- {
- graphics->hdc = NULL;
DeleteDC(temp_hdc);
- }
return Ok;
}
REAL ang_cos, ang_sin;
};
-static GpStatus draw_string_callback(GpGraphics *graphics,
+static GpStatus draw_string_callback(HDC hdc,
GDIPCONST WCHAR *string, INT index, INT length, GDIPCONST GpFont *font,
GDIPCONST RectF *rect, GDIPCONST GpStringFormat *format,
INT lineno, const RectF *bounds, void *user_data)
drawcoord.left = drawcoord.right = args->drawbase.x + roundr(args->ang_sin * bounds->Y);
drawcoord.top = drawcoord.bottom = args->drawbase.y + roundr(args->ang_cos * bounds->Y);
- DrawTextW(graphics->hdc, string + index, length, &drawcoord, args->drawflags);
+ DrawTextW(hdc, string + index, length, &drawcoord, args->drawflags);
return Ok;
}
args.drawflags = DT_NOCLIP | DT_EXPANDTABS | DT_RIGHT;
}
- gdip_format_string(graphics, string, length, font, &scaled_rect, format,
+ gdip_format_string(graphics->hdc, string, length, font, &scaled_rect, format,
draw_string_callback, &args);
DeleteObject(rgn);