Commit 8e05ddb1 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

wordpad: Use SetRect() instead of open coding it.

parent 925217b8
......@@ -88,12 +88,7 @@ void registry_read_pagemargins(HKEY hKey)
if(!hKey || RegQueryValueExW(hKey, var_pagemargin, 0, NULL, (LPBYTE)&margins,
&size) != ERROR_SUCCESS || size != sizeof(RECT))
{
margins.top = 1417;
margins.bottom = 1417;
margins.left = 1757;
margins.right = 1757;
}
SetRect(&margins, 1757, 1417, 1757, 1417);
}
void registry_set_previewpages(HKEY hKey)
......@@ -201,10 +196,7 @@ static RECT get_print_rect(HDC hdc)
height = centmm_to_twips(27000);
}
rc.left = margins.left;
rc.right = width - margins.right;
rc.top = margins.top;
rc.bottom = height - margins.bottom;
SetRect(&rc, margins.left, margins.top, width - margins.right, height - margins.bottom);
return rc;
}
......@@ -452,10 +444,7 @@ static void print(LPPRINTDLGW pd, LPWSTR wszFileName)
fr.hdcTarget = pd->hDC;
fr.rc = get_print_rect(fr.hdc);
fr.rcPage.left = 0;
fr.rcPage.right = fr.rc.right + margins.right;
fr.rcPage.top = 0;
fr.rcPage.bottom = fr.rc.bottom + margins.bottom;
SetRect(&fr.rcPage, 0, 0, fr.rc.right + margins.right, fr.rc.bottom + margins.bottom);
ZeroMemory(&di, sizeof(di));
di.cbSize = sizeof(di);
......@@ -512,19 +501,15 @@ void dialog_printsetup(HWND hMainWnd)
ps.lStructSize = sizeof(ps);
ps.hwndOwner = hMainWnd;
ps.Flags = PSD_INHUNDREDTHSOFMILLIMETERS | PSD_MARGINS;
ps.rtMargin.left = twips_to_centmm(margins.left);
ps.rtMargin.right = twips_to_centmm(margins.right);
ps.rtMargin.top = twips_to_centmm(margins.top);
ps.rtMargin.bottom = twips_to_centmm(margins.bottom);
SetRect(&ps.rtMargin, twips_to_centmm(margins.left), twips_to_centmm(margins.top),
twips_to_centmm(margins.right), twips_to_centmm(margins.bottom));
ps.hDevMode = devMode;
ps.hDevNames = devNames;
if(PageSetupDlgW(&ps))
{
margins.left = centmm_to_twips(ps.rtMargin.left);
margins.right = centmm_to_twips(ps.rtMargin.right);
margins.top = centmm_to_twips(ps.rtMargin.top);
margins.bottom = centmm_to_twips(ps.rtMargin.bottom);
SetRect(&margins, centmm_to_twips(ps.rtMargin.left), centmm_to_twips(ps.rtMargin.top),
centmm_to_twips(ps.rtMargin.right), centmm_to_twips(ps.rtMargin.bottom));
devMode = ps.hDevMode;
devNames = ps.hDevNames;
update_ruler(get_ruler_wnd(hMainWnd));
......@@ -713,10 +698,8 @@ static void draw_margin_lines(HDC hdc, int x, int y, float ratio)
dpi.cx = GetDeviceCaps(hdc, LOGPIXELSX);
dpi.cy = GetDeviceCaps(hdc, LOGPIXELSY);
page_margin.left = preview.rcPage.left + margins.left;
page_margin.top = preview.rcPage.top + margins.top;
page_margin.bottom = preview.rcPage.bottom - margins.bottom;
page_margin.right = preview.rcPage.right - margins.right;
SetRect(&page_margin, preview.rcPage.left + margins.left, preview.rcPage.top + margins.top,
preview.rcPage.right - margins.right, preview.rcPage.bottom - margins.bottom);
page_margin.left = (int)((float)twips_to_pixels(page_margin.left, dpi.cx) * ratio);
page_margin.top = (int)((float)twips_to_pixels(page_margin.top, dpi.cy) * ratio);
......@@ -860,10 +843,8 @@ static LRESULT print_preview(HWND hwndPreview)
/* draw page outlines */
hPen = CreatePen(PS_SOLID|PS_INSIDEFRAME, 2, RGB(0,0,0));
oldPen = SelectObject(hdc, hPen);
background.left = x - 2;
background.right = x + preview.bmScaledSize.cx + 2;
background.top = y - 2;
background.bottom = y + preview.bmScaledSize.cy + 2;
SetRect(&background, x - 2, y - 2, x + preview.bmScaledSize.cx + 2,
y + preview.bmScaledSize.cy + 2);
Rectangle(hdc, background.left, background.top,
background.right, background.bottom);
excl_rgn = CreateRectRgnIndirect(&background);
......@@ -956,10 +937,7 @@ static void update_preview(HWND hMainWnd)
fr.chrg.cpMin = 0;
fr.chrg.cpMax = preview.textlength;
paper.left = 0;
paper.right = preview.bmSize.cx;
paper.top = 0;
paper.bottom = preview.bmSize.cy;
SetRect(&paper, 0, 0, preview.bmSize.cx, preview.bmSize.cy);
if (!preview.hdc) {
preview.hdc = CreateCompatibleDC(hdc);
......
......@@ -114,12 +114,7 @@ void registry_read_winrect(RECT* rc)
if(registry_get_handle(&hKey, 0, key_options) != ERROR_SUCCESS ||
RegQueryValueExW(hKey, var_framerect, 0, NULL, (LPBYTE)rc, &size) !=
ERROR_SUCCESS || size != sizeof(RECT))
{
rc->top = 0;
rc->left = 0;
rc->bottom = 300;
rc->right = 600;
}
SetRect(rc, 0, 0, 600, 300);
RegCloseKey(hKey);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment