changeset 798:1f5108485fe7

[xemacs-hg @ 2002-03-29 18:26:33 by jhar] Fix win32 printing margins when machine is set up for metric units
author jhar
date Fri, 29 Mar 2002 18:26:49 +0000
parents 776fcda0ee36
children 03d9f9084848
files src/ChangeLog src/device-msw.c src/intl-auto-encap-win32.c src/intl-auto-encap-win32.h src/intl-encap-win32.c
diffstat 5 files changed, 143 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Mar 29 13:51:50 2002 +0000
+++ b/src/ChangeLog	Fri Mar 29 18:26:49 2002 +0000
@@ -1,3 +1,15 @@
+2002-03-29  Jonathan Harris  <jonathan@xemacs.org>
+
+	* device-msw.c (plist_get_margin): Add arg specifying mm or inches
+	* device-msw.c (plist_set_margin): Fix multiplicand used for mm
+	* device-msw.c (mswindows_handle_page_setup_dialog_box):
+	Detect and handle case where machine is set up for metric units
+	
+	* intl-auto-encap-win32.c:
+	* intl-auto-encap-win32.h:
+	* intl-encap-win32.c:
+	Add Get & SetLocaleInfo from winnls.h
+
 2002-03-29  William M. Perry  <wmperry@gnu.org>
 
 	* ui-gtk.c (Fgtk_import_function_internal): 
--- a/src/device-msw.c	Fri Mar 29 13:51:50 2002 +0000
+++ b/src/device-msw.c	Fri Mar 29 18:26:49 2002 +0000
@@ -811,20 +811,20 @@
 }
 
 static int
-plist_get_margin (Lisp_Object plist, Lisp_Object prop)
+plist_get_margin (Lisp_Object plist, Lisp_Object prop, int mm_p)
 {
   Lisp_Object val =
     Fplist_get (plist, prop, make_int (mswindows_get_default_margin (prop)));
   if (!INTP (val))
     invalid_argument ("Margin value must be an integer", val);
 
-  return MulDiv (XINT (val), 100, 144);
+  return MulDiv (XINT (val), mm_p ? 254 : 100, 144);
 }
 
 static Lisp_Object
 plist_set_margin (Lisp_Object plist, Lisp_Object prop, int margin, int mm_p)
 {
-  Lisp_Object val = make_int (MulDiv (margin, 144, mm_p ? 2450 : 100));
+  Lisp_Object val = make_int (MulDiv (margin, 144, mm_p ? 254 : 100));
   return Fcons (prop, Fcons (val, plist));
 }
 
@@ -868,15 +868,20 @@
   {
     Lisp_Devmode *ldm = decode_devmode (device);
     PAGESETUPDLGW pd;
+    DWORD data;
+
+    qxeGetLocaleInfo (LOCALE_USER_DEFAULT,
+		      LOCALE_IMEASURE|LOCALE_RETURN_NUMBER,
+		      (Extbyte *) &data, sizeof(data));
 
     memset (&pd, 0, sizeof (pd));
     pd.lStructSize = sizeof (pd);
     pd.hwndOwner = mswindows_get_selected_frame_hwnd ();
     pd.Flags = PSD_MARGINS;
-    pd.rtMargin.left   = plist_get_margin (plist, Qleft_margin);
-    pd.rtMargin.top    = plist_get_margin (plist, Qtop_margin);
-    pd.rtMargin.right  = plist_get_margin (plist, Qright_margin);
-    pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin);
+    pd.rtMargin.left   = plist_get_margin (plist, Qleft_margin, !data);
+    pd.rtMargin.top    = plist_get_margin (plist, Qtop_margin, !data);
+    pd.rtMargin.right  = plist_get_margin (plist, Qright_margin, !data);
+    pd.rtMargin.bottom = plist_get_margin (plist, Qbottom_margin, !data);
     pd.hDevMode = devmode_to_hglobal (ldm);
 
     if (!qxePageSetupDlg (&pd))
--- a/src/intl-auto-encap-win32.c	Fri Mar 29 13:51:50 2002 +0000
+++ b/src/intl-auto-encap-win32.c	Fri Mar 29 18:26:49 2002 +0000
@@ -13,6 +13,61 @@
 
 
 /*----------------------------------------------------------------------*/
+/*                       Processing file WINNLS.H                       */
+/*----------------------------------------------------------------------*/
+
+/* Error if GetCPInfoEx used: not used, not examined yet */
+
+/* Error if CompareString used: not used, not examined yet */
+
+/* Error if LCMapString used: not used, not examined yet */
+
+int
+qxeGetLocaleInfo (LCID Locale, LCTYPE LCType, Extbyte * lpLCData, int cchData)
+{
+  if (XEUNICODE_P)
+    return GetLocaleInfoW (Locale, LCType, (LPWSTR) lpLCData, cchData);
+  else
+    return GetLocaleInfoA (Locale, LCType, (LPSTR) lpLCData, cchData);
+}
+
+BOOL
+qxeSetLocaleInfo (LCID Locale, LCTYPE LCType, const Extbyte * lpLCData)
+{
+  if (XEUNICODE_P)
+    return SetLocaleInfoW (Locale, LCType, (LPCWSTR) lpLCData);
+  else
+    return SetLocaleInfoA (Locale, LCType, (LPCSTR) lpLCData);
+}
+
+/* Error if GetTimeFormat used: not used, not examined yet */
+
+/* Error if GetDateFormat used: not used, not examined yet */
+
+/* Error if GetNumberFormat used: not used, not examined yet */
+
+/* Error if GetCurrencyFormat used: not used, not examined yet */
+
+/* Error if EnumCalendarInfo used: not used, not examined yet */
+
+/* Error if EnumCalendarInfoEx used: not used, not examined yet */
+
+/* Error if EnumTimeFormats used: not used, not examined yet */
+
+/* Error if EnumDateFormats used: not used, not examined yet */
+
+/* Error if EnumDateFormatsEx used: not used, not examined yet */
+
+/* Error if GetStringTypeEx used: not used, not examined yet */
+
+/* Error if FoldString used: not used, not examined yet */
+
+/* Error if EnumSystemLocales used: not used, not examined yet */
+
+/* Error if EnumSystemCodePages used: not used, not examined yet */
+
+
+/*----------------------------------------------------------------------*/
 /*                      Processing file WINSPOOL.H                      */
 /*----------------------------------------------------------------------*/
 
--- a/src/intl-auto-encap-win32.h	Fri Mar 29 13:51:50 2002 +0000
+++ b/src/intl-auto-encap-win32.h	Fri Mar 29 18:26:49 2002 +0000
@@ -3,6 +3,43 @@
 */
 
 
+/* Processing file WINNLS.H */
+
+#undef GetCPInfoEx
+#define GetCPInfoEx error not used, not examined yet
+#undef CompareString
+#define CompareString error not used, not examined yet
+#undef LCMapString
+#define LCMapString error not used, not examined yet
+int qxeGetLocaleInfo (LCID Locale, LCTYPE LCType, Extbyte * lpLCData, int cchData);
+BOOL qxeSetLocaleInfo (LCID Locale, LCTYPE LCType, const Extbyte * lpLCData);
+#undef GetTimeFormat
+#define GetTimeFormat error not used, not examined yet
+#undef GetDateFormat
+#define GetDateFormat error not used, not examined yet
+#undef GetNumberFormat
+#define GetNumberFormat error not used, not examined yet
+#undef GetCurrencyFormat
+#define GetCurrencyFormat error not used, not examined yet
+#undef EnumCalendarInfo
+#define EnumCalendarInfo error not used, not examined yet
+#undef EnumCalendarInfoEx
+#define EnumCalendarInfoEx error not used, not examined yet
+#undef EnumTimeFormats
+#define EnumTimeFormats error not used, not examined yet
+#undef EnumDateFormats
+#define EnumDateFormats error not used, not examined yet
+#undef EnumDateFormatsEx
+#define EnumDateFormatsEx error not used, not examined yet
+#undef GetStringTypeEx
+#define GetStringTypeEx error not used, not examined yet
+#undef FoldString
+#define FoldString error not used, not examined yet
+#undef EnumSystemLocales
+#define EnumSystemLocales error not used, not examined yet
+#undef EnumSystemCodePages
+#define EnumSystemCodePages error not used, not examined yet
+
 /* Processing file WINSPOOL.H */
 
 #if defined (HAVE_MS_WINDOWS)
--- a/src/intl-encap-win32.c	Fri Mar 29 13:51:50 2002 +0000
+++ b/src/intl-encap-win32.c	Fri Mar 29 18:26:49 2002 +0000
@@ -1025,35 +1025,35 @@
 // split flag SHARD_PATH; we intercept SHAddToRecentDocs
 skip SHGetDataFromIDList split-sized WIN32_FIND_DATA or split-simple NETRESOURCE, missing from Cygwin libraries
 
-end-unicode-encapsulation-script
-
 file WINNLS.H
 
-LOCALE_ENUMPROC
-CODEPAGE_ENUMPROC
-DATEFMT_ENUMPROC
-DATEFMT_ENUMPROCEX
-TIMEFMT_ENUMPROC
-CALINFO_ENUMPROC
-CALINFO_ENUMPROCEX
-GetCPInfoEx
-CompareString
-LCMapString
-GetLocaleInfo
-SetLocaleInfo
-GetTimeFormat
-GetDateFormat
-GetNumberFormat
-GetCurrencyFormat
-EnumCalendarInfo
-EnumCalendarInfoEx
-EnumTimeFormats
-EnumDateFormats
-EnumDateFormatsEx
-GetStringTypeEx
-FoldString
-EnumSystemLocales
-EnumSystemCodePages
+no LOCALE_ENUMPROC not used, not examined yet
+no CODEPAGE_ENUMPROC not used, not examined yet
+no DATEFMT_ENUMPROC not used, not examined yet
+no DATEFMT_ENUMPROCEX not used, not examined yet
+no TIMEFMT_ENUMPROC not used, not examined yet
+no CALINFO_ENUMPROC not used, not examined yet
+no CALINFO_ENUMPROCEX not used, not examined yet
+no GetCPInfoEx not used, not examined yet
+no CompareString not used, not examined yet
+no LCMapString not used, not examined yet
+yes GetLocaleInfo
+yes SetLocaleInfo
+no GetTimeFormat not used, not examined yet
+no GetDateFormat not used, not examined yet
+no GetNumberFormat not used, not examined yet
+no GetCurrencyFormat not used, not examined yet
+no EnumCalendarInfo not used, not examined yet
+no EnumCalendarInfoEx not used, not examined yet
+no EnumTimeFormats not used, not examined yet
+no EnumDateFormats not used, not examined yet
+no EnumDateFormatsEx not used, not examined yet
+no GetStringTypeEx not used, not examined yet
+no FoldString not used, not examined yet
+no EnumSystemLocales not used, not examined yet
+no EnumSystemCodePages not used, not examined yet
+
+end-unicode-encapsulation-script
 
 file WINVER.H