Andrey Turkin : wordpad: Use inches instead of cm in calculations.
Alexandre Julliard
julliard at winehq.org
Mon Oct 13 06:39:10 CDT 2008
Module: wine
Branch: master
Commit: ef23ef93357689335749310957f68a3ad9179d4a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ef23ef93357689335749310957f68a3ad9179d4a
Author: Andrey Turkin <andrey.turkin at gmail.com>
Date: Sun Oct 12 15:13:08 2008 +0400
wordpad: Use inches instead of cm in calculations.
---
programs/wordpad/print.c | 12 +++++-------
programs/wordpad/wordpad.c | 6 +++---
programs/wordpad/wordpad.h | 3 ++-
3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c
index d3c13e6..3e181b0 100644
--- a/programs/wordpad/print.c
+++ b/programs/wordpad/print.c
@@ -132,24 +132,22 @@ static HDC make_dc(void)
static LONG twips_to_centmm(int twips)
{
- return MulDiv(twips, 1000, TWIPS_PER_CM);
+ return MulDiv(twips, CENTMM_PER_INCH, TWIPS_PER_INCH);
}
static LONG centmm_to_twips(int mm)
{
- return MulDiv(mm, TWIPS_PER_CM, 1000);
+ return MulDiv(mm, TWIPS_PER_INCH, CENTMM_PER_INCH);
}
static LONG twips_to_pixels(int twips, int dpi)
{
- float ret = ((float)twips / ((float)TWIPS_PER_CM * 2.54)) * (float)dpi;
- return (LONG)ret;
+ return MulDiv(twips, dpi, TWIPS_PER_INCH);
}
static LONG devunits_to_twips(int units, int dpi)
{
- float ret = ((float)units / (float)dpi) * (float)TWIPS_PER_CM * 2.54;
- return (LONG)ret;
+ return MulDiv(units, TWIPS_PER_INCH, dpi);
}
@@ -502,7 +500,7 @@ static void add_ruler_units(HDC hdcRuler, RECT* drawRect, BOOL NewMetrics, long
hdc = CreateCompatibleDC(0);
- CmPixels = twips_to_pixels(TWIPS_PER_CM, GetDeviceCaps(hdc, LOGPIXELSX));
+ CmPixels = twips_to_pixels(centmm_to_twips(1000), GetDeviceCaps(hdc, LOGPIXELSX));
QuarterCmPixels = (int)((float)CmPixels / 4.0);
hBitmap = CreateCompatibleBitmap(hdc, drawRect->right, drawRect->bottom);
diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c
index 7c92fcf..4186689 100644
--- a/programs/wordpad/wordpad.c
+++ b/programs/wordpad/wordpad.c
@@ -1271,7 +1271,7 @@ static void dialog_find(LPFINDREPLACEW fr, BOOL replace)
static int current_units_to_twips(float number)
{
- int twips = (int)(number * TWIPS_PER_CM);
+ int twips = (int)(number * 1000.0 / (float)CENTMM_PER_INCH * (float)TWIPS_PER_INCH);
return twips;
}
@@ -1284,10 +1284,10 @@ static void append_current_units(LPWSTR buffer)
static void number_with_units(LPWSTR buffer, int number)
{
- float converted = (float)number / TWIPS_PER_CM;
static const WCHAR fmt[] = {'%','.','2','f',' ','%','s','\0'};
+ float converted = (float)number / (float)TWIPS_PER_INCH *(float)CENTMM_PER_INCH / 1000.0;
- sprintfW(buffer, fmt, converted, units_cmW);
+ wsprintfW(buffer, fmt, converted, units_cmW);
}
static BOOL get_comboexlist_selection(HWND hComboEx, LPWSTR wszBuffer, UINT bufferLength)
diff --git a/programs/wordpad/wordpad.h b/programs/wordpad/wordpad.h
index 8884e28..6a1bcfb 100644
--- a/programs/wordpad/wordpad.h
+++ b/programs/wordpad/wordpad.h
@@ -19,7 +19,8 @@
#define MAX_STRING_LEN 255
-#define TWIPS_PER_CM 567
+#define TWIPS_PER_INCH 1440
+#define CENTMM_PER_INCH 2540
#define ID_FILE_EXIT 1000
#define ID_FILE_OPEN 1001
More information about the wine-cvs
mailing list