Mercurial > emacs
comparison 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 |
comparison
equal
deleted
inserted
replaced
21734:807f4e7fa560 | 21735:711a61942023 |
---|---|
2309 || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f)) | 2309 || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f)) |
2310 || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f))) | 2310 || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f))) |
2311 { | 2311 { |
2312 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = NILP (arg) ? | 2312 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = NILP (arg) ? |
2313 vertical_scroll_bar_none : | 2313 vertical_scroll_bar_none : |
2314 EQ (Qright, arg) | 2314 /* Put scroll bars on the right by default, as is conventional |
2315 ? vertical_scroll_bar_right | 2315 on MS-Windows. */ |
2316 : vertical_scroll_bar_left; | 2316 EQ (Qleft, arg) |
2317 ? vertical_scroll_bar_left | |
2318 : vertical_scroll_bar_right; | |
2317 | 2319 |
2318 /* We set this parameter before creating the window for the | 2320 /* We set this parameter before creating the window for the |
2319 frame, so we can get the geometry right from the start. | 2321 frame, so we can get the geometry right from the start. |
2320 However, if the window hasn't been created yet, we shouldn't | 2322 However, if the window hasn't been created yet, we shouldn't |
2321 call x_set_window_size. */ | 2323 call x_set_window_size. */ |
3653 | 3655 |
3654 /* Indicate that menubar can be modified again. */ | 3656 /* Indicate that menubar can be modified again. */ |
3655 if (f) | 3657 if (f) |
3656 f->output_data.w32->menubar_active = 0; | 3658 f->output_data.w32->menubar_active = 0; |
3657 goto dflt; | 3659 goto dflt; |
3660 | |
3661 case WM_MEASUREITEM: | |
3662 f = x_window_to_frame (dpyinfo, hwnd); | |
3663 if (f) | |
3664 { | |
3665 MEASUREITEMSTRUCT * pMis = (MEASUREITEMSTRUCT *) lParam; | |
3666 | |
3667 if (pMis->CtlType == ODT_MENU) | |
3668 { | |
3669 /* Work out dimensions for popup menu titles. */ | |
3670 char * title = (char *) pMis->itemData; | |
3671 HDC hdc = GetDC (hwnd); | |
3672 HFONT menu_font = GetCurrentObject (hdc, OBJ_FONT); | |
3673 LOGFONT menu_logfont; | |
3674 HFONT old_font; | |
3675 SIZE size; | |
3676 | |
3677 GetObject (menu_font, sizeof (menu_logfont), &menu_logfont); | |
3678 menu_logfont.lfWeight = FW_BOLD; | |
3679 menu_font = CreateFontIndirect (&menu_logfont); | |
3680 old_font = SelectObject (hdc, menu_font); | |
3681 | |
3682 GetTextExtentPoint32 (hdc, title, strlen (title), &size); | |
3683 pMis->itemWidth = size.cx; | |
3684 pMis->itemHeight = GetSystemMetrics (SM_CYMENUSIZE); | |
3685 if (pMis->itemHeight < size.cy) | |
3686 pMis->itemHeight = size.cy; | |
3687 | |
3688 SelectObject (hdc, old_font); | |
3689 DeleteObject (menu_font); | |
3690 ReleaseDC (hwnd, hdc); | |
3691 return TRUE; | |
3692 } | |
3693 } | |
3694 return 0; | |
3695 | |
3696 case WM_DRAWITEM: | |
3697 f = x_window_to_frame (dpyinfo, hwnd); | |
3698 if (f) | |
3699 { | |
3700 DRAWITEMSTRUCT * pDis = (DRAWITEMSTRUCT *) lParam; | |
3701 | |
3702 if (pDis->CtlType == ODT_MENU) | |
3703 { | |
3704 /* Draw popup menu title. */ | |
3705 char * title = (char *) pDis->itemData; | |
3706 HDC hdc = pDis->hDC; | |
3707 HFONT menu_font = GetCurrentObject (hdc, OBJ_FONT); | |
3708 LOGFONT menu_logfont; | |
3709 HFONT old_font; | |
3710 | |
3711 GetObject (menu_font, sizeof (menu_logfont), &menu_logfont); | |
3712 menu_logfont.lfWeight = FW_BOLD; | |
3713 menu_font = CreateFontIndirect (&menu_logfont); | |
3714 old_font = SelectObject (hdc, menu_font); | |
3715 | |
3716 /* Always draw title as if not selected. */ | |
3717 ExtTextOut (hdc, | |
3718 pDis->rcItem.left + GetSystemMetrics (SM_CXMENUCHECK), | |
3719 pDis->rcItem.top, | |
3720 ETO_OPAQUE, &pDis->rcItem, | |
3721 title, strlen (title), NULL); | |
3722 | |
3723 SelectObject (hdc, old_font); | |
3724 DeleteObject (menu_font); | |
3725 return TRUE; | |
3726 } | |
3727 } | |
3728 return 0; | |
3658 | 3729 |
3659 #if 0 | 3730 #if 0 |
3660 /* Still not right - can't distinguish between clicks in the | 3731 /* Still not right - can't distinguish between clicks in the |
3661 client area of the frame from clicks forwarded from the scroll | 3732 client area of the frame from clicks forwarded from the scroll |
3662 bars - may have to hook WM_NCHITTEST to remember the mouse | 3733 bars - may have to hook WM_NCHITTEST to remember the mouse |
3798 if (button_state & LMOUSE) | 3869 if (button_state & LMOUSE) |
3799 flags |= TPM_LEFTBUTTON; | 3870 flags |= TPM_LEFTBUTTON; |
3800 else if (button_state & RMOUSE) | 3871 else if (button_state & RMOUSE) |
3801 flags |= TPM_RIGHTBUTTON; | 3872 flags |= TPM_RIGHTBUTTON; |
3802 | 3873 |
3874 /* Remember we did a SetCapture on the initial mouse down event, | |
3875 so for safety, we make sure the capture is cancelled now. */ | |
3876 ReleaseCapture (); | |
3877 | |
3803 /* Use menubar_active to indicate that WM_INITMENU is from | 3878 /* Use menubar_active to indicate that WM_INITMENU is from |
3804 TrackPopupMenu below, and should be ignored. */ | 3879 TrackPopupMenu below, and should be ignored. */ |
3805 f = x_window_to_frame (dpyinfo, hwnd); | 3880 f = x_window_to_frame (dpyinfo, hwnd); |
3806 if (f) | 3881 if (f) |
3807 f->output_data.w32->menubar_active = 1; | 3882 f->output_data.w32->menubar_active = 1; |
3821 else | 3896 else |
3822 { | 3897 { |
3823 retval = 0; | 3898 retval = 0; |
3824 } | 3899 } |
3825 button_state = 0; | 3900 button_state = 0; |
3826 | |
3827 /* Remember we did a SetCapture on the initial mouse down | |
3828 event, but window focus will usually have changed to the | |
3829 popup menu before we released the mouse button. For | |
3830 safety, we make sure the capture is cancelled now. */ | |
3831 ReleaseCapture (); | |
3832 } | 3901 } |
3833 else | 3902 else |
3834 { | 3903 { |
3835 retval = -1; | 3904 retval = -1; |
3836 } | 3905 } |