wordpad: Use inches instead of cm in calculations.
This commit is contained in:
parent
f229469de3
commit
ef23ef9335
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue