diff src/device-msw.c @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c42ec1d1cded
children e11d67e05968
line wrap: on
line diff
--- a/src/device-msw.c	Mon Aug 13 10:33:19 2007 +0200
+++ b/src/device-msw.c	Mon Aug 13 10:34:13 2007 +0200
@@ -44,10 +44,12 @@
 #endif
 
 /* win32 DDE management library globals */
+#ifdef HAVE_DRAGNDROP
 DWORD mswindows_dde_mlid;
 HSZ mswindows_dde_service;
 HSZ mswindows_dde_topic_system;
 HSZ mswindows_dde_item_open;
+#endif
 
 /* Control conversion of upper case file names to lower case.
    nil means no, t means yes. */
@@ -115,7 +117,9 @@
 static void
 mswindows_finish_init_device (struct device *d, Lisp_Object props)
 {
-  /* Initialise DDE management library and our related globals */
+  /* Initialise DDE management library and our related globals. We execute a
+   * dde Open("file") by simulating a drop, so this depends on dnd support. */
+#ifdef HAVE_DRAGNDROP
   mswindows_dde_mlid = 0;
   DdeInitialize (&mswindows_dde_mlid, (PFNCALLBACK)mswindows_dde_callback,
 		 APPCMD_FILTERINITS|CBF_FAIL_SELFCONNECTIONS|CBF_FAIL_ADVISES|
@@ -126,13 +130,51 @@
   mswindows_dde_item_open = DdeCreateStringHandle (mswindows_dde_mlid,
 						   TEXT(MSWINDOWS_DDE_ITEM_OPEN), 0);
   DdeNameService (mswindows_dde_mlid, mswindows_dde_service, 0L, DNS_REGISTER);
+#endif
 }
 
 static void
 mswindows_delete_device (struct device *d)
 {
+#ifdef HAVE_DRAGNDROP
   DdeNameService (mswindows_dde_mlid, 0L, 0L, DNS_REGISTER);
   DdeUninitialize (mswindows_dde_mlid);
+#endif
+}
+
+static Lisp_Object
+build_syscolor_string (int index)
+{
+  DWORD clr;
+  char buf[16];
+
+  if (index < 0)
+    return Qnil;
+
+  clr = GetSysColor (index);
+  sprintf (buf, "#%02X%02X%02X",
+	   GetRValue (clr),
+	   GetGValue (clr),
+	   GetBValue (clr));
+  return build_string (buf);
+}
+
+static Lisp_Object
+build_syscolor_cons (int index1, int index2)
+{
+  Lisp_Object color1, color2;
+  struct gcpro gcpro1;
+  GCPRO1 (color1);
+  color1 = build_syscolor_string (index1);
+  color2 = build_syscolor_string (index2);
+  RETURN_UNGCPRO (Fcons (color1, color2));
+}
+
+static Lisp_Object
+build_sysmetrics_cons (int index1, int index2)
+{
+  return Fcons (index1 < 0 ? Qnil : make_int (GetSystemMetrics (index1)),
+		index2 < 0 ? Qnil : make_int (GetSystemMetrics (index2)));
 }
 
 static Lisp_Object
@@ -141,24 +183,83 @@
 {
   switch (m)
     {
-    case size_device:
+    case DM_size_device:
       return Fcons (make_int (DEVICE_MSWINDOWS_HORZRES(d)),
 		    make_int (DEVICE_MSWINDOWS_VERTRES(d)));
       break;
-    case size_device_mm:
+    case DM_size_device_mm:
       return Fcons (make_int (DEVICE_MSWINDOWS_HORZSIZE(d)),
 		    make_int (DEVICE_MSWINDOWS_VERTSIZE(d)));
       break;
-    case num_bit_planes:
+    case DM_num_bit_planes:
       return make_int (DEVICE_MSWINDOWS_PLANES(d));
       break;
-    case num_color_cells:
+    case DM_num_color_cells:
       return make_int (DEVICE_MSWINDOWS_CELLS(d));
       break;
+
+      /*** Colors ***/
+#define FROB(met, index1, index2)			\
+    case DM_##met:					\
+      return build_syscolor_cons (index1, index2);
+      
+      FROB (color_default, COLOR_WINDOW, COLOR_WINDOWTEXT);
+      FROB (color_select, COLOR_HIGHLIGHT, COLOR_HIGHLIGHTTEXT);
+      FROB (color_balloon, COLOR_INFOBK, COLOR_INFOTEXT);
+      FROB (color_3d_face, COLOR_3DFACE, COLOR_BTNTEXT);
+      FROB (color_3d_light, COLOR_3DLIGHT, COLOR_3DHILIGHT);
+      FROB (color_3d_dark, COLOR_3DSHADOW, COLOR_3DDKSHADOW);
+      FROB (color_menu, COLOR_MENU, COLOR_MENUTEXT);
+      FROB (color_menu_highlight, COLOR_HIGHLIGHT, COLOR_HIGHLIGHTTEXT);
+      FROB (color_menu_button, COLOR_MENU, COLOR_MENUTEXT);
+      FROB (color_menu_disabled, COLOR_MENU, COLOR_GRAYTEXT);
+      FROB (color_toolbar, COLOR_BTNFACE, COLOR_BTNTEXT);
+      FROB (color_scrollbar, COLOR_SCROLLBAR, COLOR_CAPTIONTEXT);
+      FROB (color_desktop, -1, COLOR_DESKTOP);
+      FROB (color_workspace, -1, COLOR_APPWORKSPACE);
+#undef FROB
+
+      /*** Sizes ***/
+#define FROB(met, index1, index2)			\
+    case DM_##met:					\
+      return build_sysmetrics_cons (index1, index2);
+
+      FROB (size_cursor, SM_CXCURSOR, SM_CYCURSOR);
+      FROB (size_scrollbar, SM_CXVSCROLL, SM_CYHSCROLL);
+      FROB (size_menu, -1, SM_CYMENU);
+      FROB (size_icon, SM_CXICON, SM_CYICON);
+      FROB (size_icon_small, SM_CXSMICON, SM_CYSMICON);
+#undef FROB
+
+    case DM_size_workspace:
+      {
+	RECT rc;
+	SystemParametersInfo (SPI_GETWORKAREA, 0, &rc, 0);
+	return Fcons (make_int (rc.right - rc.left),
+		      make_int (rc.bottom - rc.top));
+      }
+      /*
+	case DM_size_toolbar:
+	case DM_size_toolbar_button:
+	case DM_size_toolbar_border:
+      */
+
+      /*** Features ***/
+#define FROB(met, index)			\
+    case DM_##met:				\
+      return make_int (GetSystemMetrics (index));
+
+      FROB (mouse_buttons, SM_CMOUSEBUTTONS);
+      FROB (swap_buttons, SM_SWAPBUTTON);
+      FROB (show_sounds, SM_SHOWSOUNDS);
+      FROB (slow_device, SM_SLOWMACHINE);
+      FROB (security, SM_SECURE);
+#undef FROB
+
     }
 
   /* Do not know such property */
-  return Qnil;
+  return Qunbound;
 }
 
 static unsigned int