Mercurial > vim
comparison src/gui_w32.c @ 840:2c885fab04e3 v7.0e06
updated for version 7.0e06
author | vimboss |
---|---|
date | Sat, 22 Apr 2006 22:33:57 +0000 |
parents | 6bb1fa855dc9 |
children | a209672376fd |
comparison
equal
deleted
inserted
replaced
839:1f3b1021f002 | 840:2c885fab04e3 |
---|---|
179 | 179 |
180 #ifdef FEAT_BEVAL | 180 #ifdef FEAT_BEVAL |
181 # define ID_BEVAL_TOOLTIP 200 | 181 # define ID_BEVAL_TOOLTIP 200 |
182 # define BEVAL_TEXT_LEN MAXPATHL | 182 # define BEVAL_TEXT_LEN MAXPATHL |
183 | 183 |
184 #ifndef UINT_PTR | |
185 # define UINT_PTR UINT | |
186 #endif | |
187 | |
184 static void make_tooltip __ARGS((BalloonEval *beval, char *text, POINT pt)); | 188 static void make_tooltip __ARGS((BalloonEval *beval, char *text, POINT pt)); |
185 static void delete_tooltip __ARGS((BalloonEval *beval)); | 189 static void delete_tooltip __ARGS((BalloonEval *beval)); |
186 static VOID CALLBACK BevalTimerProc __ARGS((HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)); | 190 static VOID CALLBACK BevalTimerProc __ARGS((HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)); |
187 | 191 |
188 #ifndef UINT_PTR | |
189 # define UINT_PTR UINT | |
190 #endif | |
191 static BalloonEval *cur_beval = NULL; | 192 static BalloonEval *cur_beval = NULL; |
192 static UINT_PTR BevalTimerId = 0; | 193 static UINT_PTR BevalTimerId = 0; |
193 static DWORD LastActivity = 0; | 194 static DWORD LastActivity = 0; |
194 | 195 |
195 /* | 196 /* |
809 | 810 |
810 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE) | 811 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE) |
811 case WM_NOTIFY: | 812 case WM_NOTIFY: |
812 switch (((LPNMHDR) lParam)->code) | 813 switch (((LPNMHDR) lParam)->code) |
813 { | 814 { |
815 # ifdef FEAT_MBYTE | |
816 case TTN_GETDISPINFOW: | |
817 # endif | |
818 case TTN_NEEDTEXT: | |
819 # ifdef FEAT_GUI_TABLINE | |
820 if (gui_mch_showing_tabline() | |
821 && ((LPNMHDR)lParam)->hwndFrom == | |
822 TabCtrl_GetToolTips(s_tabhwnd)) | |
823 { | |
824 LPNMTTDISPINFO lpdi; | |
825 POINT pt; | |
826 static char *tt_text = NULL; | |
827 static int tt_text_len = 0; | |
828 | |
829 /* | |
830 * Mouse is over the GUI tabline. Display the tooltip | |
831 * for the tab under the cursor | |
832 */ | |
833 lpdi = (LPNMTTDISPINFO)lParam; | |
834 lpdi->hinst = NULL; | |
835 lpdi->szText[0] = '\0'; | |
836 | |
837 /* | |
838 * Get the cursor position within the tab control | |
839 */ | |
840 GetCursorPos(&pt); | |
841 if (ScreenToClient(s_tabhwnd, &pt) != 0) | |
842 { | |
843 TCHITTESTINFO htinfo; | |
844 int idx; | |
845 | |
846 /* | |
847 * Get the tab under the cursor | |
848 */ | |
849 htinfo.pt.x = pt.x; | |
850 htinfo.pt.y = pt.y; | |
851 idx = TabCtrl_HitTest(s_tabhwnd, &htinfo); | |
852 if (idx != -1) | |
853 { | |
854 tabpage_T *tp; | |
855 | |
856 tp = find_tabpage(idx + 1); | |
857 if (tp != NULL) | |
858 { | |
859 # ifdef FEAT_MBYTE | |
860 WCHAR *wstr = NULL; | |
861 # endif | |
862 get_tabline_label(tp, TRUE); | |
863 # ifdef FEAT_MBYTE | |
864 if (enc_codepage >= 0 | |
865 && (int)GetACP() != enc_codepage) | |
866 { | |
867 wstr = enc_to_ucs2(NameBuff, NULL); | |
868 if (wstr != NULL) | |
869 { | |
870 int wlen; | |
871 | |
872 wlen = (wcslen(wstr) + 1) | |
873 * sizeof(WCHAR); | |
874 if (tt_text_len < wlen) | |
875 { | |
876 tt_text = vim_realloc(tt_text, | |
877 wlen); | |
878 if (tt_text != NULL) | |
879 tt_text_len = wlen; | |
880 } | |
881 if (tt_text != NULL) | |
882 wcscpy((WCHAR *)tt_text, wstr); | |
883 lpdi->lpszText = tt_text; | |
884 vim_free(wstr); | |
885 } | |
886 } | |
887 if (wstr == NULL) | |
888 # endif | |
889 { | |
890 int len; | |
891 | |
892 len = STRLEN(NameBuff) + 1; | |
893 if (tt_text_len < len) | |
894 { | |
895 tt_text = vim_realloc(tt_text, len); | |
896 if (tt_text != NULL) | |
897 tt_text_len = len; | |
898 } | |
899 if (tt_text != NULL) | |
900 STRCPY(tt_text, NameBuff); | |
901 lpdi->lpszText = tt_text; | |
902 } | |
903 } | |
904 } | |
905 } | |
906 } | |
907 else | |
908 # endif | |
909 { | |
814 # ifdef FEAT_TOOLBAR | 910 # ifdef FEAT_TOOLBAR |
815 case TTN_NEEDTEXT: | |
816 { | |
817 LPTOOLTIPTEXT lpttt; | 911 LPTOOLTIPTEXT lpttt; |
818 UINT idButton; | 912 UINT idButton; |
819 int idx; | 913 int idx; |
820 vimmenu_T *pMenu; | 914 vimmenu_T *pMenu; |
821 | 915 |
829 { | 923 { |
830 lpttt->hinst = NULL; /* string, not resource */ | 924 lpttt->hinst = NULL; /* string, not resource */ |
831 lpttt->lpszText = pMenu->strings[idx]; | 925 lpttt->lpszText = pMenu->strings[idx]; |
832 } | 926 } |
833 } | 927 } |
928 # endif | |
834 } | 929 } |
835 break; | 930 break; |
836 # endif | |
837 # ifdef FEAT_GUI_TABLINE | 931 # ifdef FEAT_GUI_TABLINE |
838 case TCN_SELCHANGE: | 932 case TCN_SELCHANGE: |
839 if (gui_mch_showing_tabline() | 933 if (gui_mch_showing_tabline() |
840 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd) | 934 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd) |
841 send_tabline_event(TabCtrl_GetCurSel(s_tabhwnd) + 1); | 935 send_tabline_event(TabCtrl_GetCurSel(s_tabhwnd) + 1); |
2339 { | 2433 { |
2340 if (is_winnt_3()) | 2434 if (is_winnt_3()) |
2341 { | 2435 { |
2342 InsertMenu((parent == NULL) ? s_menuBar : parent->submenu_id, | 2436 InsertMenu((parent == NULL) ? s_menuBar : parent->submenu_id, |
2343 (UINT)pos, MF_POPUP | MF_STRING | MF_BYPOSITION, | 2437 (UINT)pos, MF_POPUP | MF_STRING | MF_BYPOSITION, |
2344 (UINT)menu->submenu_id, (LPCTSTR) menu->name); | 2438 (long_u)menu->submenu_id, (LPCTSTR) menu->name); |
2345 } | 2439 } |
2346 else | 2440 else |
2347 { | 2441 { |
2348 #ifdef FEAT_MBYTE | 2442 #ifdef FEAT_MBYTE |
2349 WCHAR *wn = NULL; | 2443 WCHAR *wn = NULL; |
2359 MENUITEMINFOW infow; | 2453 MENUITEMINFOW infow; |
2360 | 2454 |
2361 infow.cbSize = sizeof(infow); | 2455 infow.cbSize = sizeof(infow); |
2362 infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID | 2456 infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID |
2363 | MIIM_SUBMENU; | 2457 | MIIM_SUBMENU; |
2364 infow.dwItemData = (DWORD)menu; | 2458 infow.dwItemData = (long_u)menu; |
2365 infow.wID = menu->id; | 2459 infow.wID = menu->id; |
2366 infow.fType = MFT_STRING; | 2460 infow.fType = MFT_STRING; |
2367 infow.dwTypeData = wn; | 2461 infow.dwTypeData = wn; |
2368 infow.cch = (UINT)wcslen(wn); | 2462 infow.cch = (UINT)wcslen(wn); |
2369 infow.hSubMenu = menu->submenu_id; | 2463 infow.hSubMenu = menu->submenu_id; |
2382 { | 2476 { |
2383 MENUITEMINFO info; | 2477 MENUITEMINFO info; |
2384 | 2478 |
2385 info.cbSize = sizeof(info); | 2479 info.cbSize = sizeof(info); |
2386 info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID | MIIM_SUBMENU; | 2480 info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID | MIIM_SUBMENU; |
2387 info.dwItemData = (DWORD)menu; | 2481 info.dwItemData = (long_u)menu; |
2388 info.wID = menu->id; | 2482 info.wID = menu->id; |
2389 info.fType = MFT_STRING; | 2483 info.fType = MFT_STRING; |
2390 info.dwTypeData = (LPTSTR)menu->name; | 2484 info.dwTypeData = (LPTSTR)menu->name; |
2391 info.cch = (UINT)STRLEN(menu->name); | 2485 info.cch = (UINT)STRLEN(menu->name); |
2392 info.hSubMenu = menu->submenu_id; | 2486 info.hSubMenu = menu->submenu_id; |
2659 * A tearoff button has changed state. | 2753 * A tearoff button has changed state. |
2660 */ | 2754 */ |
2661 if (menu->children == NULL) | 2755 if (menu->children == NULL) |
2662 menuID = (WORD)(menu->id); | 2756 menuID = (WORD)(menu->id); |
2663 else | 2757 else |
2664 menuID = (WORD)((DWORD)(menu->submenu_id) | (DWORD)0x8000); | 2758 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000); |
2665 menuHandle = GetDlgItem(menu->parent->tearoff_handle, menuID); | 2759 menuHandle = GetDlgItem(menu->parent->tearoff_handle, menuID); |
2666 if (menuHandle) | 2760 if (menuHandle) |
2667 EnableWindow(menuHandle, !grey); | 2761 EnableWindow(menuHandle, !grey); |
2668 | 2762 |
2669 } | 2763 } |
2858 type = 0; | 2952 type = 0; |
2859 | 2953 |
2860 /* allocate some memory for dialog template */ | 2954 /* allocate some memory for dialog template */ |
2861 /* TODO should compute this really */ | 2955 /* TODO should compute this really */ |
2862 pdlgtemplate = p = (PWORD)LocalAlloc(LPTR, | 2956 pdlgtemplate = p = (PWORD)LocalAlloc(LPTR, |
2863 DLG_ALLOC_SIZE + STRLEN(message)); | 2957 DLG_ALLOC_SIZE + STRLEN(message) * 2); |
2864 | 2958 |
2865 if (p == NULL) | 2959 if (p == NULL) |
2866 return -1; | 2960 return -1; |
2867 | 2961 |
2868 /* | 2962 /* |
3279 | 3373 |
3280 return nchar; | 3374 return nchar; |
3281 } | 3375 } |
3282 | 3376 |
3283 #endif /* FEAT_GUI_DIALOG */ | 3377 #endif /* FEAT_GUI_DIALOG */ |
3378 | |
3284 /* | 3379 /* |
3285 * Put a simple element (basic class) onto a dialog template in memory. | 3380 * Put a simple element (basic class) onto a dialog template in memory. |
3286 * return a pointer to where the next item should be added. | 3381 * return a pointer to where the next item should be added. |
3287 * | 3382 * |
3288 * parameters: | 3383 * parameters: |
3342 */ | 3437 */ |
3343 static LPWORD | 3438 static LPWORD |
3344 lpwAlign( | 3439 lpwAlign( |
3345 LPWORD lpIn) | 3440 LPWORD lpIn) |
3346 { | 3441 { |
3347 ULONG ul; | 3442 long_u ul; |
3348 | 3443 |
3349 ul = (ULONG)lpIn; | 3444 ul = (long_u)lpIn; |
3350 ul += 3; | 3445 ul += 3; |
3351 ul >>= 2; | 3446 ul >>= 2; |
3352 ul <<= 2; | 3447 ul <<= 2; |
3353 return (LPWORD)ul; | 3448 return (LPWORD)ul; |
3354 } | 3449 } |
3433 RECT rect; | 3528 RECT rect; |
3434 | 3529 |
3435 if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect)) | 3530 if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect)) |
3436 { | 3531 { |
3437 (void)TrackPopupMenu( | 3532 (void)TrackPopupMenu( |
3438 (HMENU)(LOWORD(wParam) ^ 0x8000), | 3533 (HMENU)(long_u)(LOWORD(wParam) ^ 0x8000), |
3439 TPM_LEFTALIGN | TPM_LEFTBUTTON, | 3534 TPM_LEFTALIGN | TPM_LEFTBUTTON, |
3440 (int)rect.right - 8, | 3535 (int)rect.right - 8, |
3441 (int)mp.y, | 3536 (int)mp.y, |
3442 (int)0, /*reserved param*/ | 3537 (int)0, /*reserved param*/ |
3443 s_hwnd, | 3538 s_hwnd, |
3792 menuID = (WORD)(menu->id); | 3887 menuID = (WORD)(menu->id); |
3793 } | 3888 } |
3794 else | 3889 else |
3795 { | 3890 { |
3796 len += (int)STRLEN(TEAROFF_SUBMENU_LABEL); | 3891 len += (int)STRLEN(TEAROFF_SUBMENU_LABEL); |
3797 menuID = (WORD)((DWORD)(menu->submenu_id) | (DWORD)0x8000); | 3892 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000); |
3798 } | 3893 } |
3799 | 3894 |
3800 /* Allocate menu label and fill it in */ | 3895 /* Allocate menu label and fill it in */ |
3801 text = label = alloc((unsigned)len + 1); | 3896 text = label = alloc((unsigned)len + 1); |
3802 if (label == NULL) | 3897 if (label == NULL) |
3951 if (hbitmap != NULL) | 4046 if (hbitmap != NULL) |
3952 { | 4047 { |
3953 TBADDBITMAP tbAddBitmap; | 4048 TBADDBITMAP tbAddBitmap; |
3954 | 4049 |
3955 tbAddBitmap.hInst = NULL; | 4050 tbAddBitmap.hInst = NULL; |
3956 tbAddBitmap.nID = (UINT)hbitmap; | 4051 tbAddBitmap.nID = (long_u)hbitmap; |
3957 | 4052 |
3958 i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP, | 4053 i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP, |
3959 (WPARAM)1, (LPARAM)&tbAddBitmap); | 4054 (WPARAM)1, (LPARAM)&tbAddBitmap); |
3960 /* i will be set to -1 if it fails */ | 4055 /* i will be set to -1 if it fails */ |
3961 } | 4056 } |
3976 # endif | 4071 # endif |
3977 | 4072 |
3978 InitCommonControls(); | 4073 InitCommonControls(); |
3979 | 4074 |
3980 s_tabhwnd = CreateWindow(WC_TABCONTROL, "Vim tabline", | 4075 s_tabhwnd = CreateWindow(WC_TABCONTROL, "Vim tabline", |
3981 WS_CHILD|TCS_FOCUSNEVER, | 4076 WS_CHILD|TCS_FOCUSNEVER|TCS_TOOLTIPS, |
3982 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, | 4077 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
3983 CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL); | 4078 CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL); |
3984 | 4079 |
3985 # ifdef USE_SYSMENU_FONT | 4080 # ifdef USE_SYSMENU_FONT |
3986 if (gui_w32_get_menu_font(&lfSysmenu) == OK) | 4081 if (gui_w32_get_menu_font(&lfSysmenu) == OK) |
4402 /*ARGSUSED*/ | 4497 /*ARGSUSED*/ |
4403 static VOID CALLBACK | 4498 static VOID CALLBACK |
4404 BevalTimerProc(hwnd, uMsg, idEvent, dwTime) | 4499 BevalTimerProc(hwnd, uMsg, idEvent, dwTime) |
4405 HWND hwnd; | 4500 HWND hwnd; |
4406 UINT uMsg; | 4501 UINT uMsg; |
4407 UINT idEvent; | 4502 UINT_PTR idEvent; |
4408 DWORD dwTime; | 4503 DWORD dwTime; |
4409 { | 4504 { |
4410 POINT pt; | 4505 POINT pt; |
4411 RECT rect; | 4506 RECT rect; |
4412 | 4507 |