diff src/w32fns.c @ 21735:711a61942023

(x_set_vertical_scroll_bars): Put scroll bars on the right, as is conventional on MS-Windows. (w32_wnd_proc): Add code to draw popup menu titles. Ensure mouse capture is released before running popup menu.
author Geoff Voelker <voelker@cs.washington.edu>
date Thu, 23 Apr 1998 23:40:16 +0000
parents d191a8737145
children c0871d40073e
line wrap: on
line diff
--- a/src/w32fns.c	Thu Apr 23 23:38:50 1998 +0000
+++ b/src/w32fns.c	Thu Apr 23 23:40:16 1998 +0000
@@ -2311,9 +2311,11 @@
     {
       FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = NILP (arg) ?
 	vertical_scroll_bar_none :
-	EQ (Qright, arg)
-	? vertical_scroll_bar_right 
-	: vertical_scroll_bar_left;
+	/* Put scroll bars on the right by default, as is conventional
+           on MS-Windows.  */
+	EQ (Qleft, arg)
+	? vertical_scroll_bar_left 
+	: vertical_scroll_bar_right;
 
       /* We set this parameter before creating the window for the
 	 frame, so we can get the geometry right from the start.
@@ -3656,6 +3658,75 @@
 	f->output_data.w32->menubar_active = 0;
       goto dflt;
 
+    case WM_MEASUREITEM:
+      f = x_window_to_frame (dpyinfo, hwnd);
+      if (f)
+	{
+	  MEASUREITEMSTRUCT * pMis = (MEASUREITEMSTRUCT *) lParam;
+
+	  if (pMis->CtlType == ODT_MENU)
+	    {
+	      /* Work out dimensions for popup menu titles. */
+	      char * title = (char *) pMis->itemData;
+	      HDC hdc = GetDC (hwnd);
+	      HFONT menu_font = GetCurrentObject (hdc, OBJ_FONT);
+	      LOGFONT menu_logfont;
+	      HFONT old_font;
+	      SIZE size;
+
+	      GetObject (menu_font, sizeof (menu_logfont), &menu_logfont);
+	      menu_logfont.lfWeight = FW_BOLD;
+	      menu_font = CreateFontIndirect (&menu_logfont);
+	      old_font = SelectObject (hdc, menu_font);
+
+	      GetTextExtentPoint32 (hdc, title, strlen (title), &size);
+	      pMis->itemWidth = size.cx;
+	      pMis->itemHeight = GetSystemMetrics (SM_CYMENUSIZE);
+	      if (pMis->itemHeight < size.cy)
+		pMis->itemHeight = size.cy;
+
+	      SelectObject (hdc, old_font);
+	      DeleteObject (menu_font);
+	      ReleaseDC (hwnd, hdc);
+	      return TRUE;
+	    }
+	}
+      return 0;
+
+    case WM_DRAWITEM:
+      f = x_window_to_frame (dpyinfo, hwnd);
+      if (f)
+	{
+	  DRAWITEMSTRUCT * pDis = (DRAWITEMSTRUCT *) lParam;
+
+	  if (pDis->CtlType == ODT_MENU)
+	    {
+	      /* Draw popup menu title. */
+	      char * title = (char *) pDis->itemData;
+	      HDC hdc = pDis->hDC;
+	      HFONT menu_font = GetCurrentObject (hdc, OBJ_FONT);
+	      LOGFONT menu_logfont;
+	      HFONT old_font;
+
+	      GetObject (menu_font, sizeof (menu_logfont), &menu_logfont);
+	      menu_logfont.lfWeight = FW_BOLD;
+	      menu_font = CreateFontIndirect (&menu_logfont);
+	      old_font = SelectObject (hdc, menu_font);
+
+	      /* Always draw title as if not selected.  */
+	      ExtTextOut (hdc,
+			  pDis->rcItem.left + GetSystemMetrics (SM_CXMENUCHECK),
+			  pDis->rcItem.top,
+			  ETO_OPAQUE, &pDis->rcItem,
+			  title, strlen (title), NULL);
+
+	      SelectObject (hdc, old_font);
+	      DeleteObject (menu_font);
+	      return TRUE;
+	    }
+	}
+      return 0;
+
 #if 0
       /* Still not right - can't distinguish between clicks in the
 	 client area of the frame from clicks forwarded from the scroll
@@ -3800,6 +3871,10 @@
 	else if (button_state & RMOUSE)
 	  flags |= TPM_RIGHTBUTTON;
 	
+	/* Remember we did a SetCapture on the initial mouse down event,
+	   so for safety, we make sure the capture is cancelled now.  */
+	ReleaseCapture ();
+
 	/* Use menubar_active to indicate that WM_INITMENU is from
            TrackPopupMenu below, and should be ignored.  */
 	f = x_window_to_frame (dpyinfo, hwnd);
@@ -3823,12 +3898,6 @@
 		retval = 0;
 	      }
 	    button_state = 0;
-
-	    /* Remember we did a SetCapture on the initial mouse down
-	       event, but window focus will usually have changed to the
-	       popup menu before we released the mouse button.  For
-	       safety, we make sure the capture is cancelled now.  */
-	    ReleaseCapture ();
 	  }
 	else
 	  {