7
|
1 /* vi:set ts=8 sts=4 sw=4:
|
|
2 *
|
|
3 * VIM - Vi IMproved by Bram Moolenaar
|
|
4 * GUI support by Robert Webb
|
|
5 *
|
|
6 * Do ":help uganda" in Vim to read copying and usage conditions.
|
|
7 * Do ":help credits" in Vim to see a list of people who contributed.
|
|
8 * See README.txt for an overview of the Vim source code.
|
|
9 */
|
|
10 /*
|
|
11 * Windows GUI.
|
|
12 *
|
|
13 * GUI support for Microsoft Windows. Win32 initially; maybe Win16 later
|
|
14 *
|
|
15 * George V. Reilly <george@reilly.org> wrote the original Win32 GUI.
|
|
16 * Robert Webb reworked it to use the existing GUI stuff and added menu,
|
|
17 * scrollbars, etc.
|
|
18 *
|
|
19 * Note: Clipboard stuff, for cutting and pasting text to other windows, is in
|
|
20 * os_win32.c. (It can also be done from the terminal version).
|
|
21 *
|
|
22 * TODO: Some of the function signatures ought to be updated for Win64;
|
|
23 * e.g., replace LONG with LONG_PTR, etc.
|
|
24 */
|
|
25
|
|
26 /*
|
|
27 * These are new in Windows ME/XP, only defined in recent compilers.
|
|
28 */
|
|
29 #ifndef HANDLE_WM_XBUTTONUP
|
|
30 # define HANDLE_WM_XBUTTONUP(hwnd, wParam, lParam, fn) \
|
|
31 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
32 #endif
|
|
33 #ifndef HANDLE_WM_XBUTTONDOWN
|
|
34 # define HANDLE_WM_XBUTTONDOWN(hwnd, wParam, lParam, fn) \
|
|
35 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
36 #endif
|
|
37 #ifndef HANDLE_WM_XBUTTONDBLCLK
|
|
38 # define HANDLE_WM_XBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
|
|
39 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
40 #endif
|
|
41
|
|
42 /*
|
|
43 * Include the common stuff for MS-Windows GUI.
|
|
44 */
|
|
45 #include "gui_w48.c"
|
|
46
|
|
47 #ifdef FEAT_XPM_W32
|
|
48 # include "xpm_w32.h"
|
|
49 #endif
|
|
50
|
|
51 #ifdef PROTO
|
|
52 # define WINAPI
|
|
53 #endif
|
|
54
|
|
55 #ifdef __MINGW32__
|
|
56 /*
|
|
57 * Add a lot of missing defines.
|
|
58 * They are not always missing, we need the #ifndef's.
|
|
59 */
|
|
60 # ifndef _cdecl
|
|
61 # define _cdecl
|
|
62 # endif
|
|
63 # ifndef IsMinimized
|
|
64 # define IsMinimized(hwnd) IsIconic(hwnd)
|
|
65 # endif
|
|
66 # ifndef IsMaximized
|
|
67 # define IsMaximized(hwnd) IsZoomed(hwnd)
|
|
68 # endif
|
|
69 # ifndef SelectFont
|
|
70 # define SelectFont(hdc, hfont) ((HFONT)SelectObject((hdc), (HGDIOBJ)(HFONT)(hfont)))
|
|
71 # endif
|
|
72 # ifndef GetStockBrush
|
|
73 # define GetStockBrush(i) ((HBRUSH)GetStockObject(i))
|
|
74 # endif
|
|
75 # ifndef DeleteBrush
|
|
76 # define DeleteBrush(hbr) DeleteObject((HGDIOBJ)(HBRUSH)(hbr))
|
|
77 # endif
|
|
78
|
|
79 # ifndef HANDLE_WM_RBUTTONDBLCLK
|
|
80 # define HANDLE_WM_RBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
|
|
81 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
82 # endif
|
|
83 # ifndef HANDLE_WM_MBUTTONUP
|
|
84 # define HANDLE_WM_MBUTTONUP(hwnd, wParam, lParam, fn) \
|
|
85 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
86 # endif
|
|
87 # ifndef HANDLE_WM_MBUTTONDBLCLK
|
|
88 # define HANDLE_WM_MBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
|
|
89 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
90 # endif
|
|
91 # ifndef HANDLE_WM_LBUTTONDBLCLK
|
|
92 # define HANDLE_WM_LBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
|
|
93 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
94 # endif
|
|
95 # ifndef HANDLE_WM_RBUTTONDOWN
|
|
96 # define HANDLE_WM_RBUTTONDOWN(hwnd, wParam, lParam, fn) \
|
|
97 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
98 # endif
|
|
99 # ifndef HANDLE_WM_MOUSEMOVE
|
|
100 # define HANDLE_WM_MOUSEMOVE(hwnd, wParam, lParam, fn) \
|
|
101 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
102 # endif
|
|
103 # ifndef HANDLE_WM_RBUTTONUP
|
|
104 # define HANDLE_WM_RBUTTONUP(hwnd, wParam, lParam, fn) \
|
|
105 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
106 # endif
|
|
107 # ifndef HANDLE_WM_MBUTTONDOWN
|
|
108 # define HANDLE_WM_MBUTTONDOWN(hwnd, wParam, lParam, fn) \
|
|
109 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
110 # endif
|
|
111 # ifndef HANDLE_WM_LBUTTONUP
|
|
112 # define HANDLE_WM_LBUTTONUP(hwnd, wParam, lParam, fn) \
|
|
113 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
114 # endif
|
|
115 # ifndef HANDLE_WM_LBUTTONDOWN
|
|
116 # define HANDLE_WM_LBUTTONDOWN(hwnd, wParam, lParam, fn) \
|
|
117 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
|
|
118 # endif
|
|
119 # ifndef HANDLE_WM_SYSCHAR
|
|
120 # define HANDLE_WM_SYSCHAR(hwnd, wParam, lParam, fn) \
|
|
121 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
|
|
122 # endif
|
|
123 # ifndef HANDLE_WM_ACTIVATEAPP
|
|
124 # define HANDLE_WM_ACTIVATEAPP(hwnd, wParam, lParam, fn) \
|
|
125 ((fn)((hwnd), (BOOL)(wParam), (DWORD)(lParam)), 0L)
|
|
126 # endif
|
|
127 # ifndef HANDLE_WM_WINDOWPOSCHANGING
|
|
128 # define HANDLE_WM_WINDOWPOSCHANGING(hwnd, wParam, lParam, fn) \
|
|
129 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (LPWINDOWPOS)(lParam))
|
|
130 # endif
|
|
131 # ifndef HANDLE_WM_VSCROLL
|
|
132 # define HANDLE_WM_VSCROLL(hwnd, wParam, lParam, fn) \
|
|
133 ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
|
|
134 # endif
|
|
135 # ifndef HANDLE_WM_SETFOCUS
|
|
136 # define HANDLE_WM_SETFOCUS(hwnd, wParam, lParam, fn) \
|
|
137 ((fn)((hwnd), (HWND)(wParam)), 0L)
|
|
138 # endif
|
|
139 # ifndef HANDLE_WM_KILLFOCUS
|
|
140 # define HANDLE_WM_KILLFOCUS(hwnd, wParam, lParam, fn) \
|
|
141 ((fn)((hwnd), (HWND)(wParam)), 0L)
|
|
142 # endif
|
|
143 # ifndef HANDLE_WM_HSCROLL
|
|
144 # define HANDLE_WM_HSCROLL(hwnd, wParam, lParam, fn) \
|
|
145 ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
|
|
146 # endif
|
|
147 # ifndef HANDLE_WM_DROPFILES
|
|
148 # define HANDLE_WM_DROPFILES(hwnd, wParam, lParam, fn) \
|
|
149 ((fn)((hwnd), (HDROP)(wParam)), 0L)
|
|
150 # endif
|
|
151 # ifndef HANDLE_WM_CHAR
|
|
152 # define HANDLE_WM_CHAR(hwnd, wParam, lParam, fn) \
|
|
153 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
|
|
154 # endif
|
|
155 # ifndef HANDLE_WM_SYSDEADCHAR
|
|
156 # define HANDLE_WM_SYSDEADCHAR(hwnd, wParam, lParam, fn) \
|
|
157 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
|
|
158 # endif
|
|
159 # ifndef HANDLE_WM_DEADCHAR
|
|
160 # define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \
|
|
161 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
|
|
162 # endif
|
|
163 #endif /* __MINGW32__ */
|
|
164
|
|
165
|
|
166 /* Some parameters for tearoff menus. All in pixels. */
|
|
167 #define TEAROFF_PADDING_X 2
|
|
168 #define TEAROFF_BUTTON_PAD_X 8
|
|
169 #define TEAROFF_MIN_WIDTH 200
|
|
170 #define TEAROFF_SUBMENU_LABEL ">>"
|
|
171 #define TEAROFF_COLUMN_PADDING 3 // # spaces to pad column with.
|
|
172
|
|
173
|
|
174 /* For the Intellimouse: */
|
|
175 #ifndef WM_MOUSEWHEEL
|
|
176 #define WM_MOUSEWHEEL 0x20a
|
|
177 #endif
|
|
178
|
|
179
|
|
180 #ifdef FEAT_BEVAL
|
|
181 # define ID_BEVAL_TOOLTIP 200
|
|
182 # define BEVAL_TEXT_LEN MAXPATHL
|
|
183
|
843
|
184 #if _MSC_VER < 1300
|
|
185 /* Work around old versions of basetsd.h which wrongly declare
|
|
186 * UINT_PTR as unsigned long */
|
837
|
187 # define UINT_PTR UINT
|
|
188 #endif
|
840
|
189
|
|
190 static void make_tooltip __ARGS((BalloonEval *beval, char *text, POINT pt));
|
|
191 static void delete_tooltip __ARGS((BalloonEval *beval));
|
|
192 static VOID CALLBACK BevalTimerProc __ARGS((HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime));
|
|
193
|
7
|
194 static BalloonEval *cur_beval = NULL;
|
835
|
195 static UINT_PTR BevalTimerId = 0;
|
7
|
196 static DWORD LastActivity = 0;
|
435
|
197
|
|
198 /*
|
|
199 * excerpts from headers since this may not be presented
|
843
|
200 * in the extremely old compilers
|
435
|
201 */
|
|
202 #include <pshpack1.h>
|
|
203
|
|
204 typedef struct _DllVersionInfo
|
|
205 {
|
|
206 DWORD cbSize;
|
|
207 DWORD dwMajorVersion;
|
|
208 DWORD dwMinorVersion;
|
|
209 DWORD dwBuildNumber;
|
|
210 DWORD dwPlatformID;
|
|
211 } DLLVERSIONINFO;
|
|
212
|
|
213 typedef struct tagTOOLINFOA_NEW
|
|
214 {
|
|
215 UINT cbSize;
|
|
216 UINT uFlags;
|
|
217 HWND hwnd;
|
|
218 UINT uId;
|
|
219 RECT rect;
|
|
220 HINSTANCE hinst;
|
|
221 LPSTR lpszText;
|
|
222 LPARAM lParam;
|
|
223 } TOOLINFO_NEW;
|
|
224
|
|
225 typedef struct tagNMTTDISPINFO_NEW
|
|
226 {
|
|
227 NMHDR hdr;
|
|
228 LPTSTR lpszText;
|
|
229 char szText[80];
|
|
230 HINSTANCE hinst;
|
|
231 UINT uFlags;
|
|
232 LPARAM lParam;
|
|
233 } NMTTDISPINFO_NEW;
|
|
234
|
|
235 #include <poppack.h>
|
|
236
|
|
237 typedef HRESULT (WINAPI* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
|
|
238 #ifndef TTM_SETMAXTIPWIDTH
|
842
|
239 # define TTM_SETMAXTIPWIDTH (WM_USER+24)
|
7
|
240 #endif
|
|
241
|
435
|
242 #ifndef TTF_DI_SETITEM
|
842
|
243 # define TTF_DI_SETITEM 0x8000
|
435
|
244 #endif
|
|
245
|
|
246 #ifndef TTN_GETDISPINFO
|
842
|
247 # define TTN_GETDISPINFO (TTN_FIRST - 0)
|
435
|
248 #endif
|
|
249
|
|
250 #endif /* defined(FEAT_BEVAL) */
|
|
251
|
842
|
252 #ifndef TTN_GETDISPINFOW
|
|
253 # define TTN_GETDISPINFOW (TTN_FIRST - 10)
|
|
254 #endif
|
|
255
|
7
|
256 /* Local variables: */
|
|
257
|
|
258 #ifdef FEAT_MENU
|
|
259 static UINT s_menu_id = 100;
|
|
260
|
|
261 /*
|
|
262 * Use the system font for dialogs and tear-off menus. Remove this line to
|
|
263 * use DLG_FONT_NAME.
|
|
264 */
|
|
265 # define USE_SYSMENU_FONT
|
|
266 #endif
|
|
267
|
|
268 #define VIM_NAME "vim"
|
|
269 #define VIM_CLASS "Vim"
|
|
270 #define VIM_CLASSW L"Vim"
|
|
271
|
|
272 /* Initial size for the dialog template. For gui_mch_dialog() it's fixed,
|
|
273 * thus there should be room for every dialog. For tearoffs it's made bigger
|
|
274 * when needed. */
|
|
275 #define DLG_ALLOC_SIZE 16 * 1024
|
|
276
|
|
277 /*
|
|
278 * stuff for dialogs, menus, tearoffs etc.
|
|
279 */
|
|
280 static LRESULT APIENTRY dialog_callback(HWND, UINT, WPARAM, LPARAM);
|
|
281 static LRESULT APIENTRY tearoff_callback(HWND, UINT, WPARAM, LPARAM);
|
|
282 static PWORD
|
|
283 add_dialog_element(
|
|
284 PWORD p,
|
|
285 DWORD lStyle,
|
|
286 WORD x,
|
|
287 WORD y,
|
|
288 WORD w,
|
|
289 WORD h,
|
|
290 WORD Id,
|
|
291 WORD clss,
|
|
292 const char *caption);
|
|
293 static LPWORD lpwAlign(LPWORD);
|
|
294 static int nCopyAnsiToWideChar(LPWORD, LPSTR);
|
|
295 static void gui_mch_tearoff(char_u *title, vimmenu_T *menu, int initX, int initY);
|
|
296 static void get_dialog_font_metrics(void);
|
|
297
|
|
298 static int dialog_default_button = -1;
|
|
299
|
|
300 /* Intellimouse support */
|
|
301 static int mouse_scroll_lines = 0;
|
|
302 static UINT msh_msgmousewheel = 0;
|
|
303
|
|
304 static int s_usenewlook; /* emulate W95/NT4 non-bold dialogs */
|
|
305 #ifdef FEAT_TOOLBAR
|
|
306 static void initialise_toolbar(void);
|
|
307 static int get_toolbar_bitmap(vimmenu_T *menu);
|
|
308 #endif
|
|
309
|
810
|
310 #ifdef FEAT_GUI_TABLINE
|
|
311 static void initialise_tabline(void);
|
|
312 #endif
|
|
313
|
7
|
314 #ifdef FEAT_MBYTE_IME
|
|
315 static LRESULT _OnImeComposition(HWND hwnd, WPARAM dbcs, LPARAM param);
|
|
316 static char_u *GetResultStr(HWND hwnd, int GCS, int *lenp);
|
|
317 #endif
|
|
318 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
|
|
319 # ifdef NOIME
|
|
320 typedef struct tagCOMPOSITIONFORM {
|
|
321 DWORD dwStyle;
|
|
322 POINT ptCurrentPos;
|
|
323 RECT rcArea;
|
|
324 } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, FAR *LPCOMPOSITIONFORM;
|
|
325 typedef HANDLE HIMC;
|
|
326 # endif
|
|
327
|
344
|
328 static HINSTANCE hLibImm = NULL;
|
|
329 static LONG (WINAPI *pImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD);
|
|
330 static LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
|
|
331 static HIMC (WINAPI *pImmGetContext)(HWND);
|
|
332 static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC);
|
|
333 static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC);
|
|
334 static BOOL (WINAPI *pImmGetOpenStatus)(HIMC);
|
|
335 static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL);
|
|
336 static BOOL (WINAPI *pImmGetCompositionFont)(HIMC, LPLOGFONTA);
|
|
337 static BOOL (WINAPI *pImmSetCompositionFont)(HIMC, LPLOGFONTA);
|
|
338 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
|
|
339 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
|
777
|
340 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD);
|
7
|
341 static void dyn_imm_load(void);
|
|
342 #else
|
|
343 # define pImmGetCompositionStringA ImmGetCompositionStringA
|
|
344 # define pImmGetCompositionStringW ImmGetCompositionStringW
|
|
345 # define pImmGetContext ImmGetContext
|
|
346 # define pImmAssociateContext ImmAssociateContext
|
|
347 # define pImmReleaseContext ImmReleaseContext
|
|
348 # define pImmGetOpenStatus ImmGetOpenStatus
|
|
349 # define pImmSetOpenStatus ImmSetOpenStatus
|
|
350 # define pImmGetCompositionFont ImmGetCompositionFontA
|
|
351 # define pImmSetCompositionFont ImmSetCompositionFontA
|
|
352 # define pImmSetCompositionWindow ImmSetCompositionWindow
|
|
353 # define pImmGetConversionStatus ImmGetConversionStatus
|
777
|
354 # define pImmSetConversionStatus ImmSetConversionStatus
|
7
|
355 #endif
|
|
356
|
|
357 #ifndef ETO_IGNORELANGUAGE
|
|
358 # define ETO_IGNORELANGUAGE 0x1000
|
|
359 #endif
|
|
360
|
|
361 /* multi monitor support */
|
|
362 typedef struct _MONITORINFOstruct
|
|
363 {
|
|
364 DWORD cbSize;
|
|
365 RECT rcMonitor;
|
|
366 RECT rcWork;
|
|
367 DWORD dwFlags;
|
|
368 } _MONITORINFO;
|
|
369
|
|
370 typedef HANDLE _HMONITOR;
|
|
371 typedef _HMONITOR (WINAPI *TMonitorFromWindow)(HWND, DWORD);
|
|
372 typedef BOOL (WINAPI *TGetMonitorInfo)(_HMONITOR, _MONITORINFO *);
|
|
373
|
|
374 static TMonitorFromWindow pMonitorFromWindow = NULL;
|
|
375 static TGetMonitorInfo pGetMonitorInfo = NULL;
|
|
376 static HANDLE user32_lib = NULL;
|
|
377 #ifdef FEAT_NETBEANS_INTG
|
|
378 int WSInitialized = FALSE; /* WinSock is initialized */
|
|
379 #endif
|
|
380 /*
|
|
381 * Return TRUE when running under Windows NT 3.x or Win32s, both of which have
|
|
382 * less fancy GUI APIs.
|
|
383 */
|
|
384 static int
|
|
385 is_winnt_3(void)
|
|
386 {
|
|
387 return ((os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
|
|
388 && os_version.dwMajorVersion == 3)
|
|
389 || (os_version.dwPlatformId == VER_PLATFORM_WIN32s));
|
|
390 }
|
|
391
|
|
392 /*
|
|
393 * Return TRUE when running under Win32s.
|
|
394 */
|
|
395 int
|
|
396 gui_is_win32s(void)
|
|
397 {
|
|
398 return (os_version.dwPlatformId == VER_PLATFORM_WIN32s);
|
|
399 }
|
|
400
|
|
401 #ifdef FEAT_MENU
|
|
402 /*
|
|
403 * Figure out how high the menu bar is at the moment.
|
|
404 */
|
|
405 static int
|
|
406 gui_mswin_get_menu_height(
|
|
407 int fix_window) /* If TRUE, resize window if menu height changed */
|
|
408 {
|
|
409 static int old_menu_height = -1;
|
|
410
|
|
411 RECT rc1, rc2;
|
|
412 int num;
|
|
413 int menu_height;
|
|
414
|
|
415 if (gui.menu_is_active)
|
|
416 num = GetMenuItemCount(s_menuBar);
|
|
417 else
|
|
418 num = 0;
|
|
419
|
|
420 if (num == 0)
|
|
421 menu_height = 0;
|
|
422 else
|
|
423 {
|
|
424 if (is_winnt_3()) /* for NT 3.xx */
|
|
425 {
|
|
426 if (gui.starting)
|
|
427 menu_height = GetSystemMetrics(SM_CYMENU);
|
|
428 else
|
|
429 {
|
|
430 RECT r1, r2;
|
|
431 int frameht = GetSystemMetrics(SM_CYFRAME);
|
|
432 int capht = GetSystemMetrics(SM_CYCAPTION);
|
|
433
|
|
434 /* get window rect of s_hwnd
|
|
435 * get client rect of s_hwnd
|
|
436 * get cap height
|
|
437 * subtract from window rect, the sum of client height,
|
|
438 * (if not maximized)frame thickness, and caption height.
|
|
439 */
|
|
440 GetWindowRect(s_hwnd, &r1);
|
|
441 GetClientRect(s_hwnd, &r2);
|
|
442 menu_height = r1.bottom - r1.top - (r2.bottom - r2.top
|
|
443 + 2 * frameht * (!IsZoomed(s_hwnd)) + capht);
|
|
444 }
|
|
445 }
|
|
446 else /* win95 and variants (NT 4.0, I guess) */
|
|
447 {
|
|
448 /*
|
|
449 * In case 'lines' is set in _vimrc/_gvimrc window width doesn't
|
|
450 * seem to have been set yet, so menu wraps in default window
|
|
451 * width which is very narrow. Instead just return height of a
|
|
452 * single menu item. Will still be wrong when the menu really
|
|
453 * should wrap over more than one line.
|
|
454 */
|
|
455 GetMenuItemRect(s_hwnd, s_menuBar, 0, &rc1);
|
|
456 if (gui.starting)
|
|
457 menu_height = rc1.bottom - rc1.top + 1;
|
|
458 else
|
|
459 {
|
|
460 GetMenuItemRect(s_hwnd, s_menuBar, num - 1, &rc2);
|
|
461 menu_height = rc2.bottom - rc1.top + 1;
|
|
462 }
|
|
463 }
|
|
464 }
|
|
465
|
|
466 if (fix_window && menu_height != old_menu_height)
|
|
467 {
|
|
468 old_menu_height = menu_height;
|
812
|
469 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
|
7
|
470 }
|
|
471
|
|
472 return menu_height;
|
|
473 }
|
|
474 #endif /*FEAT_MENU*/
|
|
475
|
|
476
|
|
477 /*
|
|
478 * Setup for the Intellimouse
|
|
479 */
|
|
480 static void
|
|
481 init_mouse_wheel(void)
|
|
482 {
|
|
483
|
|
484 #ifndef SPI_GETWHEELSCROLLLINES
|
|
485 # define SPI_GETWHEELSCROLLLINES 104
|
|
486 #endif
|
336
|
487 #ifndef SPI_SETWHEELSCROLLLINES
|
|
488 # define SPI_SETWHEELSCROLLLINES 105
|
|
489 #endif
|
7
|
490
|
|
491 #define VMOUSEZ_CLASSNAME "MouseZ" /* hidden wheel window class */
|
|
492 #define VMOUSEZ_TITLE "Magellan MSWHEEL" /* hidden wheel window title */
|
|
493 #define VMSH_MOUSEWHEEL "MSWHEEL_ROLLMSG"
|
|
494 #define VMSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG"
|
|
495
|
|
496 HWND hdl_mswheel;
|
|
497 UINT msh_msgscrolllines;
|
|
498
|
|
499 msh_msgmousewheel = 0;
|
|
500 mouse_scroll_lines = 3; /* reasonable default */
|
|
501
|
|
502 if ((os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
|
|
503 && os_version.dwMajorVersion >= 4)
|
|
504 || (os_version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS
|
|
505 && ((os_version.dwMajorVersion == 4
|
|
506 && os_version.dwMinorVersion >= 10)
|
|
507 || os_version.dwMajorVersion >= 5)))
|
|
508 {
|
|
509 /* if NT 4.0+ (or Win98) get scroll lines directly from system */
|
|
510 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
|
|
511 &mouse_scroll_lines, 0);
|
|
512 }
|
|
513 else if (os_version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS
|
|
514 || (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
|
|
515 && os_version.dwMajorVersion < 4))
|
|
516 { /*
|
|
517 * If Win95 or NT 3.51,
|
|
518 * try to find the hidden point32 window.
|
|
519 */
|
|
520 hdl_mswheel = FindWindow(VMOUSEZ_CLASSNAME, VMOUSEZ_TITLE);
|
|
521 if (hdl_mswheel)
|
|
522 {
|
|
523 msh_msgscrolllines = RegisterWindowMessage(VMSH_SCROLL_LINES);
|
|
524 if (msh_msgscrolllines)
|
|
525 {
|
|
526 mouse_scroll_lines = (int)SendMessage(hdl_mswheel,
|
|
527 msh_msgscrolllines, 0, 0);
|
|
528 msh_msgmousewheel = RegisterWindowMessage(VMSH_MOUSEWHEEL);
|
|
529 }
|
|
530 }
|
|
531 }
|
|
532 }
|
|
533
|
|
534
|
|
535 /* Intellimouse wheel handler */
|
|
536 static void
|
|
537 _OnMouseWheel(
|
|
538 HWND hwnd,
|
|
539 short zDelta)
|
|
540 {
|
|
541 /* Treat a mouse wheel event as if it were a scroll request */
|
|
542 int i;
|
|
543 int size;
|
|
544 HWND hwndCtl;
|
|
545
|
|
546 if (curwin->w_scrollbars[SBAR_RIGHT].id != 0)
|
|
547 {
|
|
548 hwndCtl = curwin->w_scrollbars[SBAR_RIGHT].id;
|
|
549 size = curwin->w_scrollbars[SBAR_RIGHT].size;
|
|
550 }
|
|
551 else if (curwin->w_scrollbars[SBAR_LEFT].id != 0)
|
|
552 {
|
|
553 hwndCtl = curwin->w_scrollbars[SBAR_LEFT].id;
|
|
554 size = curwin->w_scrollbars[SBAR_LEFT].size;
|
|
555 }
|
|
556 else
|
|
557 return;
|
|
558
|
|
559 size = curwin->w_height;
|
|
560 if (mouse_scroll_lines == 0)
|
|
561 init_mouse_wheel();
|
|
562
|
|
563 if (mouse_scroll_lines > 0
|
|
564 && mouse_scroll_lines < (size > 2 ? size - 2 : 1))
|
|
565 {
|
|
566 for (i = mouse_scroll_lines; i > 0; --i)
|
|
567 _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_LINEUP : SB_LINEDOWN, 0);
|
|
568 }
|
|
569 else
|
|
570 _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN, 0);
|
|
571 }
|
|
572
|
843
|
573 #ifdef USE_SYSMENU_FONT
|
|
574 /*
|
|
575 * Get Menu Font.
|
|
576 * Return OK or FAIL.
|
|
577 */
|
|
578 static int
|
|
579 gui_w32_get_menu_font(LOGFONT *lf)
|
|
580 {
|
|
581 NONCLIENTMETRICS nm;
|
|
582
|
|
583 nm.cbSize = sizeof(NONCLIENTMETRICS);
|
|
584 if (!SystemParametersInfo(
|
|
585 SPI_GETNONCLIENTMETRICS,
|
|
586 sizeof(NONCLIENTMETRICS),
|
|
587 &nm,
|
|
588 0))
|
|
589 return FAIL;
|
|
590 *lf = nm.lfMenuFont;
|
|
591 return OK;
|
|
592 }
|
|
593 #endif
|
|
594
|
|
595
|
|
596 #if defined(FEAT_GUI_TABLINE) && defined(USE_SYSMENU_FONT)
|
|
597 /*
|
|
598 * Set the GUI tabline font to the system menu font
|
|
599 */
|
|
600 static void
|
|
601 set_tabline_font(void)
|
|
602 {
|
|
603 LOGFONT lfSysmenu;
|
|
604 HFONT font;
|
|
605 HWND hwnd;
|
|
606 HDC hdc;
|
|
607 HFONT hfntOld;
|
|
608 TEXTMETRIC tm;
|
|
609
|
|
610 if (gui_w32_get_menu_font(&lfSysmenu) != OK)
|
|
611 return;
|
|
612
|
|
613 font = CreateFontIndirect(&lfSysmenu);
|
|
614
|
|
615 SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE);
|
|
616
|
|
617 /*
|
|
618 * Compute the height of the font used for the tab text
|
|
619 */
|
|
620 hwnd = GetDesktopWindow();
|
|
621 hdc = GetWindowDC(hwnd);
|
|
622 hfntOld = SelectFont(hdc, font);
|
|
623
|
|
624 GetTextMetrics(hdc, &tm);
|
|
625
|
|
626 SelectFont(hdc, hfntOld);
|
|
627 ReleaseDC(hwnd, hdc);
|
|
628
|
|
629 /*
|
|
630 * The space used by the tab border and the space between the tab label
|
|
631 * and the tab border is included as 7.
|
|
632 */
|
|
633 gui.tabline_height = tm.tmHeight + tm.tmInternalLeading + 7;
|
|
634 }
|
|
635 #endif
|
|
636
|
333
|
637 /*
|
|
638 * Invoked when a setting was changed.
|
|
639 */
|
|
640 static LRESULT CALLBACK
|
|
641 _OnSettingChange(UINT n)
|
|
642 {
|
|
643 if (n == SPI_SETWHEELSCROLLLINES)
|
|
644 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
|
|
645 &mouse_scroll_lines, 0);
|
843
|
646 #if defined(FEAT_GUI_TABLINE) && defined(USE_SYSMENU_FONT)
|
|
647 if (n == SPI_SETNONCLIENTMETRICS)
|
|
648 set_tabline_font();
|
|
649 #endif
|
333
|
650 return 0;
|
|
651 }
|
|
652
|
7
|
653 #if 0 /* disabled, a gap appears below and beside the window, and the window
|
|
654 can be moved (in a strange way) */
|
|
655 /*
|
|
656 * Even though we have _DuringSizing() which makes the rubber band a valid
|
|
657 * size, we need this for when the user maximises the window.
|
|
658 * TODO: Doesn't seem to adjust the width though for some reason.
|
|
659 */
|
|
660 static BOOL
|
|
661 _OnWindowPosChanging(
|
|
662 HWND hwnd,
|
|
663 LPWINDOWPOS lpwpos)
|
|
664 {
|
|
665 RECT workarea_rect;
|
|
666
|
|
667 if (!(lpwpos->flags & SWP_NOSIZE))
|
|
668 {
|
|
669 if (IsMaximized(hwnd)
|
|
670 && (os_version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS
|
|
671 || (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
|
|
672 && os_version.dwMajorVersion >= 4)))
|
|
673 {
|
|
674 SystemParametersInfo(SPI_GETWORKAREA, 0, &workarea_rect, 0);
|
|
675 lpwpos->x = workarea_rect.left;
|
|
676 lpwpos->y = workarea_rect.top;
|
|
677 lpwpos->cx = workarea_rect.right - workarea_rect.left;
|
|
678 lpwpos->cy = workarea_rect.bottom - workarea_rect.top;
|
|
679 }
|
|
680 gui_mswin_get_valid_dimensions(lpwpos->cx, lpwpos->cy,
|
|
681 &lpwpos->cx, &lpwpos->cy);
|
|
682 }
|
|
683 return 0;
|
|
684 }
|
|
685 #endif
|
|
686
|
|
687 #ifdef FEAT_NETBEANS_INTG
|
|
688 static void
|
|
689 _OnWindowPosChanged(
|
|
690 HWND hwnd,
|
|
691 const LPWINDOWPOS lpwpos)
|
|
692 {
|
|
693 static int x = 0, y = 0, cx = 0, cy = 0;
|
|
694
|
|
695 if (WSInitialized && (lpwpos->x != x || lpwpos->y != y
|
|
696 || lpwpos->cx != cx || lpwpos->cy != cy))
|
|
697 {
|
|
698 x = lpwpos->x;
|
|
699 y = lpwpos->y;
|
|
700 cx = lpwpos->cx;
|
|
701 cy = lpwpos->cy;
|
|
702 netbeans_frame_moved(x, y);
|
|
703 }
|
|
704 /* Allow to send WM_SIZE and WM_MOVE */
|
|
705 FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, MyWindowProc);
|
|
706 }
|
|
707 #endif
|
|
708
|
|
709 static int
|
|
710 _DuringSizing(
|
|
711 UINT fwSide,
|
|
712 LPRECT lprc)
|
|
713 {
|
|
714 int w, h;
|
|
715 int valid_w, valid_h;
|
|
716 int w_offset, h_offset;
|
|
717
|
|
718 w = lprc->right - lprc->left;
|
|
719 h = lprc->bottom - lprc->top;
|
|
720 gui_mswin_get_valid_dimensions(w, h, &valid_w, &valid_h);
|
|
721 w_offset = w - valid_w;
|
|
722 h_offset = h - valid_h;
|
|
723
|
|
724 if (fwSide == WMSZ_LEFT || fwSide == WMSZ_TOPLEFT
|
|
725 || fwSide == WMSZ_BOTTOMLEFT)
|
|
726 lprc->left += w_offset;
|
|
727 else if (fwSide == WMSZ_RIGHT || fwSide == WMSZ_TOPRIGHT
|
|
728 || fwSide == WMSZ_BOTTOMRIGHT)
|
|
729 lprc->right -= w_offset;
|
|
730
|
|
731 if (fwSide == WMSZ_TOP || fwSide == WMSZ_TOPLEFT
|
|
732 || fwSide == WMSZ_TOPRIGHT)
|
|
733 lprc->top += h_offset;
|
|
734 else if (fwSide == WMSZ_BOTTOM || fwSide == WMSZ_BOTTOMLEFT
|
|
735 || fwSide == WMSZ_BOTTOMRIGHT)
|
|
736 lprc->bottom -= h_offset;
|
|
737 return TRUE;
|
|
738 }
|
|
739
|
|
740
|
|
741
|
|
742 static LRESULT CALLBACK
|
|
743 _WndProc(
|
|
744 HWND hwnd,
|
|
745 UINT uMsg,
|
|
746 WPARAM wParam,
|
|
747 LPARAM lParam)
|
|
748 {
|
|
749 /*
|
|
750 TRACE("WndProc: hwnd = %08x, msg = %x, wParam = %x, lParam = %x\n",
|
|
751 hwnd, uMsg, wParam, lParam);
|
|
752 */
|
|
753
|
|
754 HandleMouseHide(uMsg, lParam);
|
|
755
|
|
756 s_uMsg = uMsg;
|
|
757 s_wParam = wParam;
|
|
758 s_lParam = lParam;
|
|
759
|
|
760 switch (uMsg)
|
|
761 {
|
|
762 HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar);
|
|
763 HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar);
|
|
764 /* HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate); */
|
|
765 HANDLE_MSG(hwnd, WM_CLOSE, _OnClose);
|
|
766 /* HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand); */
|
|
767 HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy);
|
|
768 HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles);
|
|
769 HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll);
|
|
770 HANDLE_MSG(hwnd, WM_KILLFOCUS, _OnKillFocus);
|
|
771 #ifdef FEAT_MENU
|
|
772 HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu);
|
|
773 #endif
|
|
774 /* HANDLE_MSG(hwnd, WM_MOVE, _OnMove); */
|
|
775 /* HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate); */
|
|
776 HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus);
|
|
777 HANDLE_MSG(hwnd, WM_SIZE, _OnSize);
|
|
778 /* HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand); */
|
|
779 /* HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey); */
|
|
780 HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll);
|
|
781 // HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging);
|
|
782 HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp);
|
|
783 #ifdef FEAT_NETBEANS_INTG
|
|
784 HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGED, _OnWindowPosChanged);
|
|
785 #endif
|
|
786
|
812
|
787 #ifdef FEAT_GUI_TABLINE
|
|
788 case WM_RBUTTONUP:
|
|
789 {
|
|
790 if (gui_mch_showing_tabline())
|
|
791 {
|
|
792 POINT pt;
|
|
793 RECT rect;
|
|
794
|
|
795 /*
|
|
796 * If the cursor is on the tabline, display the tab menu
|
|
797 */
|
|
798 GetCursorPos((LPPOINT)&pt);
|
|
799 GetWindowRect(s_textArea, &rect);
|
|
800 if (pt.y < rect.top)
|
|
801 {
|
|
802 show_tabline_popup_menu();
|
|
803 return 0;
|
|
804 }
|
|
805 }
|
|
806 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
807 }
|
819
|
808 case WM_LBUTTONDBLCLK:
|
|
809 {
|
|
810 /*
|
|
811 * If the user double clicked the tabline, create a new tab
|
|
812 */
|
|
813 if (gui_mch_showing_tabline())
|
|
814 {
|
|
815 POINT pt;
|
|
816 RECT rect;
|
|
817
|
|
818 GetCursorPos((LPPOINT)&pt);
|
|
819 GetWindowRect(s_textArea, &rect);
|
|
820 if (pt.y < rect.top)
|
824
|
821 send_tabline_menu_event(0, TABLINE_MENU_NEW);
|
819
|
822 }
|
|
823 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
824 }
|
812
|
825 #endif
|
|
826
|
7
|
827 case WM_QUERYENDSESSION: /* System wants to go down. */
|
|
828 gui_shell_closed(); /* Will exit when no changed buffers. */
|
|
829 return FALSE; /* Do NOT allow system to go down. */
|
|
830
|
|
831 case WM_ENDSESSION:
|
|
832 if (wParam) /* system only really goes down when wParam is TRUE */
|
|
833 _OnEndSession();
|
|
834 break;
|
|
835
|
|
836 case WM_CHAR:
|
|
837 /* Don't use HANDLE_MSG() for WM_CHAR, it truncates wParam to a single
|
|
838 * byte while we want the UTF-16 character value. */
|
835
|
839 _OnChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam));
|
7
|
840 return 0L;
|
|
841
|
|
842 case WM_SYSCHAR:
|
|
843 /*
|
|
844 * if 'winaltkeys' is "no", or it's "menu" and it's not a menu
|
|
845 * shortcut key, handle like a typed ALT key, otherwise call Windows
|
|
846 * ALT key handling.
|
|
847 */
|
|
848 #ifdef FEAT_MENU
|
|
849 if ( !gui.menu_is_active
|
|
850 || p_wak[0] == 'n'
|
|
851 || (p_wak[0] == 'm' && !gui_is_menu_shortcut((int)wParam))
|
|
852 )
|
|
853 #endif
|
|
854 {
|
835
|
855 _OnSysChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam));
|
7
|
856 return 0L;
|
|
857 }
|
|
858 #ifdef FEAT_MENU
|
|
859 else
|
|
860 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
861 #endif
|
|
862
|
|
863 case WM_SYSKEYUP:
|
|
864 #ifdef FEAT_MENU
|
|
865 /* This used to be done only when menu is active: ALT key is used for
|
|
866 * that. But that caused problems when menu is disabled and using
|
|
867 * Alt-Tab-Esc: get into a strange state where no mouse-moved events
|
|
868 * are received, mouse pointer remains hidden. */
|
|
869 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
870 #else
|
|
871 return 0;
|
|
872 #endif
|
|
873
|
|
874 case WM_SIZING: /* HANDLE_MSG doesn't seem to handle this one */
|
323
|
875 return _DuringSizing((UINT)wParam, (LPRECT)lParam);
|
7
|
876
|
|
877 case WM_MOUSEWHEEL:
|
|
878 _OnMouseWheel(hwnd, HIWORD(wParam));
|
|
879 break;
|
|
880
|
333
|
881 /* Notification for change in SystemParametersInfo() */
|
|
882 case WM_SETTINGCHANGE:
|
|
883 return _OnSettingChange((UINT)wParam);
|
|
884
|
810
|
885 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
|
7
|
886 case WM_NOTIFY:
|
|
887 switch (((LPNMHDR) lParam)->code)
|
|
888 {
|
840
|
889 # ifdef FEAT_MBYTE
|
|
890 case TTN_GETDISPINFOW:
|
|
891 # endif
|
948
|
892 case TTN_GETDISPINFO:
|
7
|
893 {
|
948
|
894 LPNMHDR hdr = (LPNMHDR)lParam;
|
|
895 char_u *str = NULL;
|
|
896 static void *tt_text = NULL;
|
|
897
|
|
898 vim_free(tt_text);
|
|
899 tt_text = NULL;
|
|
900
|
|
901 # ifdef FEAT_GUI_TABLINE
|
|
902 if (gui_mch_showing_tabline()
|
|
903 && hdr->hwndFrom == TabCtrl_GetToolTips(s_tabhwnd))
|
840
|
904 {
|
948
|
905 POINT pt;
|
840
|
906 /*
|
948
|
907 * Mouse is over the GUI tabline. Display the
|
|
908 * tooltip for the tab under the cursor
|
|
909 *
|
|
910 * Get the cursor position within the tab control
|
840
|
911 */
|
948
|
912 GetCursorPos(&pt);
|
|
913 if (ScreenToClient(s_tabhwnd, &pt) != 0)
|
840
|
914 {
|
948
|
915 TCHITTESTINFO htinfo;
|
|
916 int idx;
|
|
917
|
|
918 /*
|
|
919 * Get the tab under the cursor
|
|
920 */
|
|
921 htinfo.pt.x = pt.x;
|
|
922 htinfo.pt.y = pt.y;
|
|
923 idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
|
|
924 if (idx != -1)
|
840
|
925 {
|
948
|
926 tabpage_T *tp;
|
|
927
|
|
928 tp = find_tabpage(idx + 1);
|
|
929 if (tp != NULL)
|
840
|
930 {
|
948
|
931 get_tabline_label(tp, TRUE);
|
|
932 str = NameBuff;
|
840
|
933 }
|
|
934 }
|
|
935 }
|
|
936 }
|
|
937 # endif
|
|
938 # ifdef FEAT_TOOLBAR
|
948
|
939 # ifdef FEAT_GUI_TABLINE
|
|
940 else
|
|
941 # endif
|
|
942 {
|
|
943 UINT idButton;
|
|
944 vimmenu_T *pMenu;
|
|
945
|
|
946 idButton = (UINT) hdr->idFrom;
|
|
947 pMenu = gui_mswin_find_menu(root_menu, idButton);
|
|
948 if (pMenu)
|
|
949 str = pMenu->strings[MENU_INDEX_TIP];
|
|
950 }
|
|
951 # endif
|
|
952 if (str != NULL)
|
7
|
953 {
|
948
|
954 # ifdef FEAT_MBYTE
|
|
955 if (hdr->code == TTN_GETDISPINFOW)
|
7
|
956 {
|
948
|
957 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
|
|
958
|
|
959 tt_text = enc_to_ucs2(str, NULL);
|
|
960 lpdi->lpszText = tt_text;
|
|
961 /* can't show tooltip if failed */
|
|
962 }
|
|
963 else
|
|
964 # endif
|
|
965 {
|
|
966 LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam;
|
|
967
|
|
968 if (STRLEN(str) < sizeof(lpdi->szText)
|
|
969 || ((tt_text = vim_strsave(str)) == NULL))
|
|
970 vim_strncpy(lpdi->szText, str,
|
|
971 sizeof(lpdi->szText) - 1);
|
|
972 else
|
|
973 lpdi->lpszText = tt_text;
|
7
|
974 }
|
|
975 }
|
|
976 }
|
|
977 break;
|
810
|
978 # ifdef FEAT_GUI_TABLINE
|
|
979 case TCN_SELCHANGE:
|
|
980 if (gui_mch_showing_tabline()
|
|
981 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd)
|
|
982 send_tabline_event(TabCtrl_GetCurSel(s_tabhwnd) + 1);
|
|
983 break;
|
812
|
984
|
|
985 case NM_RCLICK:
|
|
986 if (gui_mch_showing_tabline()
|
|
987 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd)
|
|
988 show_tabline_popup_menu();
|
|
989 break;
|
810
|
990 # endif
|
7
|
991 default:
|
810
|
992 # ifdef FEAT_GUI_TABLINE
|
|
993 if (gui_mch_showing_tabline()
|
|
994 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd)
|
|
995 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
996 # endif
|
7
|
997 break;
|
|
998 }
|
|
999 break;
|
|
1000 #endif
|
|
1001 #if defined(MENUHINTS) && defined(FEAT_MENU)
|
|
1002 case WM_MENUSELECT:
|
|
1003 if (((UINT) HIWORD(wParam)
|
|
1004 & (0xffff ^ (MF_MOUSESELECT + MF_BITMAP + MF_POPUP)))
|
|
1005 == MF_HILITE
|
|
1006 && (State & CMDLINE) == 0)
|
|
1007 {
|
|
1008 UINT idButton;
|
|
1009 vimmenu_T *pMenu;
|
|
1010 static int did_menu_tip = FALSE;
|
|
1011
|
|
1012 if (did_menu_tip)
|
|
1013 {
|
|
1014 msg_clr_cmdline();
|
|
1015 setcursor();
|
|
1016 out_flush();
|
|
1017 did_menu_tip = FALSE;
|
|
1018 }
|
|
1019
|
|
1020 idButton = (UINT)LOWORD(wParam);
|
|
1021 pMenu = gui_mswin_find_menu(root_menu, idButton);
|
|
1022 if (pMenu != NULL && pMenu->strings[MENU_INDEX_TIP] != 0
|
|
1023 && GetMenuState(s_menuBar, pMenu->id, MF_BYCOMMAND) != -1)
|
|
1024 {
|
|
1025 msg(pMenu->strings[MENU_INDEX_TIP]);
|
|
1026 setcursor();
|
|
1027 out_flush();
|
|
1028 did_menu_tip = TRUE;
|
|
1029 }
|
|
1030 }
|
|
1031 break;
|
|
1032 #endif
|
|
1033 case WM_NCHITTEST:
|
|
1034 {
|
|
1035 LRESULT result;
|
|
1036 int x, y;
|
|
1037 int xPos = GET_X_LPARAM(lParam);
|
|
1038
|
|
1039 result = MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
1040 if (result == HTCLIENT)
|
|
1041 {
|
810
|
1042 #ifdef FEAT_GUI_TABLINE
|
|
1043 if (gui_mch_showing_tabline())
|
|
1044 {
|
|
1045 int yPos = GET_Y_LPARAM(lParam);
|
|
1046 RECT rct;
|
|
1047
|
|
1048 /* If the cursor is on the GUI tabline, don't process this
|
|
1049 * event */
|
|
1050 GetWindowRect(s_textArea, &rct);
|
|
1051 if (yPos < rct.top)
|
|
1052 return result;
|
|
1053 }
|
|
1054 #endif
|
7
|
1055 gui_mch_get_winpos(&x, &y);
|
|
1056 xPos -= x;
|
|
1057
|
|
1058 if (xPos < 48) /* <VN> TODO should use system metric? */
|
|
1059 return HTBOTTOMLEFT;
|
|
1060 else
|
|
1061 return HTBOTTOMRIGHT;
|
|
1062 }
|
|
1063 else
|
|
1064 return result;
|
|
1065 }
|
|
1066 /* break; notreached */
|
|
1067
|
|
1068 #ifdef FEAT_MBYTE_IME
|
|
1069 case WM_IME_NOTIFY:
|
|
1070 if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam))
|
|
1071 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
1072 break;
|
|
1073 case WM_IME_COMPOSITION:
|
|
1074 if (!_OnImeComposition(hwnd, wParam, lParam))
|
|
1075 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
1076 break;
|
|
1077 #endif
|
|
1078
|
|
1079 default:
|
|
1080 if (uMsg == msh_msgmousewheel && msh_msgmousewheel != 0)
|
|
1081 { /* handle MSH_MOUSEWHEEL messages for Intellimouse */
|
|
1082 _OnMouseWheel(hwnd, HIWORD(wParam));
|
|
1083 break;
|
|
1084 }
|
|
1085 #ifdef MSWIN_FIND_REPLACE
|
36
|
1086 else if (uMsg == s_findrep_msg && s_findrep_msg != 0)
|
7
|
1087 {
|
|
1088 _OnFindRepl();
|
|
1089 }
|
|
1090 #endif
|
|
1091 return MyWindowProc(hwnd, uMsg, wParam, lParam);
|
|
1092 }
|
|
1093
|
|
1094 return 1;
|
|
1095 }
|
|
1096
|
|
1097 /*
|
|
1098 * End of call-back routines
|
|
1099 */
|
|
1100
|
|
1101 /* parent window, if specified with -P */
|
|
1102 HWND vim_parent_hwnd = NULL;
|
|
1103
|
|
1104 static BOOL CALLBACK
|
|
1105 FindWindowTitle(HWND hwnd, LPARAM lParam)
|
|
1106 {
|
|
1107 char buf[2048];
|
|
1108 char *title = (char *)lParam;
|
|
1109
|
|
1110 if (GetWindowText(hwnd, buf, sizeof(buf)))
|
|
1111 {
|
|
1112 if (strstr(buf, title) != NULL)
|
|
1113 {
|
9
|
1114 /* Found it. Store the window ref. and quit searching if MDI
|
|
1115 * works. */
|
7
|
1116 vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL);
|
9
|
1117 if (vim_parent_hwnd != NULL)
|
|
1118 return FALSE;
|
7
|
1119 }
|
|
1120 }
|
|
1121 return TRUE; /* continue searching */
|
|
1122 }
|
|
1123
|
|
1124 /*
|
|
1125 * Invoked for '-P "title"' argument: search for parent application to open
|
|
1126 * our window in.
|
|
1127 */
|
|
1128 void
|
|
1129 gui_mch_set_parent(char *title)
|
|
1130 {
|
|
1131 EnumWindows(FindWindowTitle, (LPARAM)title);
|
|
1132 if (vim_parent_hwnd == NULL)
|
|
1133 {
|
|
1134 EMSG2(_("E671: Cannot find window title \"%s\""), title);
|
|
1135 mch_exit(2);
|
|
1136 }
|
|
1137 }
|
|
1138
|
323
|
1139 #ifndef FEAT_OLE
|
7
|
1140 static void
|
|
1141 ole_error(char *arg)
|
|
1142 {
|
|
1143 EMSG2(_("E243: Argument not supported: \"-%s\"; Use the OLE version."),
|
|
1144 arg);
|
|
1145 }
|
323
|
1146 #endif
|
7
|
1147
|
|
1148 /*
|
|
1149 * Parse the GUI related command-line arguments. Any arguments used are
|
|
1150 * deleted from argv, and *argc is decremented accordingly. This is called
|
|
1151 * when vim is started, whether or not the GUI has been started.
|
|
1152 */
|
|
1153 void
|
|
1154 gui_mch_prepare(int *argc, char **argv)
|
|
1155 {
|
|
1156 int silent = FALSE;
|
|
1157 int idx;
|
|
1158
|
|
1159 /* Check for special OLE command line parameters */
|
|
1160 if ((*argc == 2 || *argc == 3) && (argv[1][0] == '-' || argv[1][0] == '/'))
|
|
1161 {
|
|
1162 /* Check for a "-silent" argument first. */
|
|
1163 if (*argc == 3 && STRICMP(argv[1] + 1, "silent") == 0
|
|
1164 && (argv[2][0] == '-' || argv[2][0] == '/'))
|
|
1165 {
|
|
1166 silent = TRUE;
|
|
1167 idx = 2;
|
|
1168 }
|
|
1169 else
|
|
1170 idx = 1;
|
|
1171
|
|
1172 /* Register Vim as an OLE Automation server */
|
|
1173 if (STRICMP(argv[idx] + 1, "register") == 0)
|
|
1174 {
|
|
1175 #ifdef FEAT_OLE
|
|
1176 RegisterMe(silent);
|
|
1177 mch_exit(0);
|
|
1178 #else
|
|
1179 if (!silent)
|
|
1180 ole_error("register");
|
|
1181 mch_exit(2);
|
|
1182 #endif
|
|
1183 }
|
|
1184
|
|
1185 /* Unregister Vim as an OLE Automation server */
|
|
1186 if (STRICMP(argv[idx] + 1, "unregister") == 0)
|
|
1187 {
|
|
1188 #ifdef FEAT_OLE
|
|
1189 UnregisterMe(!silent);
|
|
1190 mch_exit(0);
|
|
1191 #else
|
|
1192 if (!silent)
|
|
1193 ole_error("unregister");
|
|
1194 mch_exit(2);
|
|
1195 #endif
|
|
1196 }
|
|
1197
|
|
1198 /* Ignore an -embedding argument. It is only relevant if the
|
|
1199 * application wants to treat the case when it is started manually
|
|
1200 * differently from the case where it is started via automation (and
|
|
1201 * we don't).
|
|
1202 */
|
|
1203 if (STRICMP(argv[idx] + 1, "embedding") == 0)
|
|
1204 {
|
|
1205 #ifdef FEAT_OLE
|
|
1206 *argc = 1;
|
|
1207 #else
|
|
1208 ole_error("embedding");
|
|
1209 mch_exit(2);
|
|
1210 #endif
|
|
1211 }
|
|
1212 }
|
|
1213
|
|
1214 #ifdef FEAT_OLE
|
|
1215 {
|
|
1216 int bDoRestart = FALSE;
|
|
1217
|
|
1218 InitOLE(&bDoRestart);
|
|
1219 /* automatically exit after registering */
|
|
1220 if (bDoRestart)
|
|
1221 mch_exit(0);
|
|
1222 }
|
|
1223 #endif
|
|
1224
|
|
1225 #ifdef FEAT_NETBEANS_INTG
|
|
1226 {
|
|
1227 /* stolen from gui_x11.x */
|
|
1228 int arg;
|
|
1229
|
|
1230 for (arg = 1; arg < *argc; arg++)
|
|
1231 if (strncmp("-nb", argv[arg], 3) == 0)
|
|
1232 {
|
|
1233 usingNetbeans++;
|
|
1234 netbeansArg = argv[arg];
|
|
1235 mch_memmove(&argv[arg], &argv[arg + 1],
|
|
1236 (--*argc - arg) * sizeof(char *));
|
|
1237 argv[*argc] = NULL;
|
|
1238 break; /* enough? */
|
|
1239 }
|
|
1240
|
|
1241 if (usingNetbeans)
|
|
1242 {
|
|
1243 WSADATA wsaData;
|
|
1244 int wsaerr;
|
|
1245
|
|
1246 /* Init WinSock */
|
|
1247 wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
|
1248 if (wsaerr == 0)
|
|
1249 WSInitialized = TRUE;
|
|
1250 }
|
|
1251 }
|
|
1252 #endif
|
|
1253
|
|
1254 /* get the OS version info */
|
|
1255 os_version.dwOSVersionInfoSize = sizeof(os_version);
|
|
1256 GetVersionEx(&os_version); /* this call works on Win32s, Win95 and WinNT */
|
|
1257
|
|
1258 /* try and load the user32.dll library and get the entry points for
|
|
1259 * multi-monitor-support. */
|
|
1260 if ((user32_lib = LoadLibrary("User32.dll")) != NULL)
|
|
1261 {
|
|
1262 pMonitorFromWindow = (TMonitorFromWindow)GetProcAddress(user32_lib,
|
|
1263 "MonitorFromWindow");
|
|
1264
|
|
1265 /* there are ...A and ...W version of GetMonitorInfo - looking at
|
|
1266 * winuser.h, they have exactly the same declaration. */
|
|
1267 pGetMonitorInfo = (TGetMonitorInfo)GetProcAddress(user32_lib,
|
|
1268 "GetMonitorInfoA");
|
|
1269 }
|
|
1270 }
|
|
1271
|
|
1272 /*
|
|
1273 * Initialise the GUI. Create all the windows, set up all the call-backs
|
|
1274 * etc.
|
|
1275 */
|
|
1276 int
|
|
1277 gui_mch_init(void)
|
|
1278 {
|
|
1279 const char szVimWndClass[] = VIM_CLASS;
|
|
1280 const char szTextAreaClass[] = "VimTextArea";
|
|
1281 WNDCLASS wndclass;
|
|
1282 #ifdef FEAT_MBYTE
|
|
1283 const WCHAR szVimWndClassW[] = VIM_CLASSW;
|
|
1284 WNDCLASSW wndclassw;
|
|
1285 #endif
|
|
1286 #ifdef GLOBAL_IME
|
|
1287 ATOM atom;
|
|
1288 #endif
|
|
1289
|
|
1290 /* Return here if the window was already opened (happens when
|
|
1291 * gui_mch_dialog() is called early). */
|
|
1292 if (s_hwnd != NULL)
|
153
|
1293 goto theend;
|
7
|
1294
|
|
1295 /*
|
|
1296 * Load the tearoff bitmap
|
|
1297 */
|
|
1298 #ifdef FEAT_TEAROFF
|
|
1299 s_htearbitmap = LoadBitmap(s_hinst, "IDB_TEAROFF");
|
|
1300 #endif
|
|
1301
|
|
1302 gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL);
|
|
1303 gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL);
|
|
1304 #ifdef FEAT_MENU
|
|
1305 gui.menu_height = 0; /* Windows takes care of this */
|
|
1306 #endif
|
|
1307 gui.border_width = 0;
|
|
1308
|
|
1309 s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
|
|
1310
|
|
1311 #ifdef FEAT_MBYTE
|
|
1312 /* First try using the wide version, so that we can use any title.
|
|
1313 * Otherwise only characters in the active codepage will work. */
|
|
1314 if (GetClassInfoW(s_hinst, szVimWndClassW, &wndclassw) == 0)
|
|
1315 {
|
819
|
1316 wndclassw.style = CS_DBLCLKS;
|
7
|
1317 wndclassw.lpfnWndProc = _WndProc;
|
|
1318 wndclassw.cbClsExtra = 0;
|
|
1319 wndclassw.cbWndExtra = 0;
|
|
1320 wndclassw.hInstance = s_hinst;
|
|
1321 wndclassw.hIcon = LoadIcon(wndclassw.hInstance, "IDR_VIM");
|
|
1322 wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
1323 wndclassw.hbrBackground = s_brush;
|
|
1324 wndclassw.lpszMenuName = NULL;
|
|
1325 wndclassw.lpszClassName = szVimWndClassW;
|
|
1326
|
|
1327 if ((
|
|
1328 #ifdef GLOBAL_IME
|
|
1329 atom =
|
|
1330 #endif
|
|
1331 RegisterClassW(&wndclassw)) == 0)
|
|
1332 {
|
|
1333 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
1334 return FAIL;
|
|
1335
|
|
1336 /* Must be Windows 98, fall back to non-wide function. */
|
|
1337 }
|
|
1338 else
|
|
1339 wide_WindowProc = TRUE;
|
|
1340 }
|
|
1341
|
|
1342 if (!wide_WindowProc)
|
|
1343 #endif
|
|
1344
|
|
1345 if (GetClassInfo(s_hinst, szVimWndClass, &wndclass) == 0)
|
|
1346 {
|
819
|
1347 wndclass.style = CS_DBLCLKS;
|
7
|
1348 wndclass.lpfnWndProc = _WndProc;
|
|
1349 wndclass.cbClsExtra = 0;
|
|
1350 wndclass.cbWndExtra = 0;
|
|
1351 wndclass.hInstance = s_hinst;
|
|
1352 wndclass.hIcon = LoadIcon(wndclass.hInstance, "IDR_VIM");
|
|
1353 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
1354 wndclass.hbrBackground = s_brush;
|
|
1355 wndclass.lpszMenuName = NULL;
|
|
1356 wndclass.lpszClassName = szVimWndClass;
|
|
1357
|
|
1358 if ((
|
|
1359 #ifdef GLOBAL_IME
|
|
1360 atom =
|
|
1361 #endif
|
|
1362 RegisterClass(&wndclass)) == 0)
|
|
1363 return FAIL;
|
|
1364 }
|
|
1365
|
|
1366 if (vim_parent_hwnd != NULL)
|
|
1367 {
|
|
1368 #ifdef HAVE_TRY_EXCEPT
|
|
1369 __try
|
|
1370 {
|
|
1371 #endif
|
|
1372 /* Open inside the specified parent window.
|
|
1373 * TODO: last argument should point to a CLIENTCREATESTRUCT
|
|
1374 * structure. */
|
|
1375 s_hwnd = CreateWindowEx(
|
|
1376 WS_EX_MDICHILD,
|
|
1377 szVimWndClass, "Vim MSWindows GUI",
|
|
1378 WS_OVERLAPPEDWINDOW | WS_CHILD | WS_CLIPSIBLINGS | 0xC000,
|
|
1379 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
|
|
1380 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
|
|
1381 100, /* Any value will do */
|
|
1382 100, /* Any value will do */
|
|
1383 vim_parent_hwnd, NULL,
|
|
1384 s_hinst, NULL);
|
|
1385 #ifdef HAVE_TRY_EXCEPT
|
|
1386 }
|
|
1387 __except(EXCEPTION_EXECUTE_HANDLER)
|
|
1388 {
|
|
1389 /* NOP */
|
|
1390 }
|
|
1391 #endif
|
|
1392 if (s_hwnd == NULL)
|
|
1393 {
|
|
1394 EMSG(_("E672: Unable to open window inside MDI application"));
|
|
1395 mch_exit(2);
|
|
1396 }
|
|
1397 }
|
|
1398 else
|
|
1399 /* Open toplevel window. */
|
|
1400 s_hwnd = CreateWindow(
|
|
1401 szVimWndClass, "Vim MSWindows GUI",
|
|
1402 WS_OVERLAPPEDWINDOW,
|
|
1403 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
|
|
1404 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
|
|
1405 100, /* Any value will do */
|
|
1406 100, /* Any value will do */
|
|
1407 NULL, NULL,
|
|
1408 s_hinst, NULL);
|
|
1409
|
|
1410 if (s_hwnd == NULL)
|
|
1411 return FAIL;
|
|
1412
|
|
1413 #ifdef GLOBAL_IME
|
|
1414 global_ime_init(atom, s_hwnd);
|
|
1415 #endif
|
|
1416 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
|
|
1417 dyn_imm_load();
|
|
1418 #endif
|
|
1419
|
|
1420 /* Create the text area window */
|
|
1421 if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0)
|
|
1422 {
|
|
1423 wndclass.style = CS_OWNDC;
|
|
1424 wndclass.lpfnWndProc = _TextAreaWndProc;
|
|
1425 wndclass.cbClsExtra = 0;
|
|
1426 wndclass.cbWndExtra = 0;
|
|
1427 wndclass.hInstance = s_hinst;
|
|
1428 wndclass.hIcon = NULL;
|
|
1429 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
1430 wndclass.hbrBackground = NULL;
|
|
1431 wndclass.lpszMenuName = NULL;
|
|
1432 wndclass.lpszClassName = szTextAreaClass;
|
|
1433
|
|
1434 if (RegisterClass(&wndclass) == 0)
|
|
1435 return FAIL;
|
|
1436 }
|
|
1437 s_textArea = CreateWindowEx(
|
|
1438 WS_EX_CLIENTEDGE,
|
|
1439 szTextAreaClass, "Vim text area",
|
|
1440 WS_CHILD | WS_VISIBLE, 0, 0,
|
|
1441 100, /* Any value will do for now */
|
|
1442 100, /* Any value will do for now */
|
|
1443 s_hwnd, NULL,
|
|
1444 s_hinst, NULL);
|
|
1445
|
|
1446 if (s_textArea == NULL)
|
|
1447 return FAIL;
|
|
1448
|
|
1449 #ifdef FEAT_MENU
|
|
1450 s_menuBar = CreateMenu();
|
|
1451 #endif
|
|
1452 s_hdc = GetDC(s_textArea);
|
|
1453
|
|
1454 #ifdef MSWIN16_FASTTEXT
|
|
1455 SetBkMode(s_hdc, OPAQUE);
|
|
1456 #endif
|
|
1457
|
|
1458 #ifdef FEAT_WINDOWS
|
|
1459 DragAcceptFiles(s_hwnd, TRUE);
|
|
1460 #endif
|
|
1461
|
|
1462 /* Do we need to bother with this? */
|
|
1463 /* m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); */
|
|
1464
|
|
1465 /* Get background/foreground colors from the system */
|
|
1466 gui_mch_def_colors();
|
|
1467
|
|
1468 /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc
|
|
1469 * file) */
|
|
1470 set_normal_colors();
|
|
1471
|
|
1472 /*
|
|
1473 * Check that none of the colors are the same as the background color.
|
|
1474 * Then store the current values as the defaults.
|
|
1475 */
|
|
1476 gui_check_colors();
|
|
1477 gui.def_norm_pixel = gui.norm_pixel;
|
|
1478 gui.def_back_pixel = gui.back_pixel;
|
|
1479
|
|
1480 /* Get the colors for the highlight groups (gui_check_colors() might have
|
|
1481 * changed them) */
|
|
1482 highlight_gui_started();
|
|
1483
|
|
1484 /*
|
|
1485 * Start out by adding the configured border width into the border offset
|
|
1486 */
|
|
1487 gui.border_offset = gui.border_width + 2; /*CLIENT EDGE*/
|
|
1488
|
|
1489 /*
|
|
1490 * Set up for Intellimouse processing
|
|
1491 */
|
|
1492 init_mouse_wheel();
|
|
1493
|
|
1494 /*
|
|
1495 * compute a couple of metrics used for the dialogs
|
|
1496 */
|
|
1497 get_dialog_font_metrics();
|
|
1498 #ifdef FEAT_TOOLBAR
|
|
1499 /*
|
|
1500 * Create the toolbar
|
|
1501 */
|
|
1502 initialise_toolbar();
|
|
1503 #endif
|
810
|
1504 #ifdef FEAT_GUI_TABLINE
|
|
1505 /*
|
|
1506 * Create the tabline
|
|
1507 */
|
|
1508 initialise_tabline();
|
|
1509 #endif
|
7
|
1510 #ifdef MSWIN_FIND_REPLACE
|
|
1511 /*
|
|
1512 * Initialise the dialog box stuff
|
|
1513 */
|
|
1514 s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING);
|
|
1515
|
|
1516 /* Initialise the struct */
|
|
1517 s_findrep_struct.lStructSize = sizeof(s_findrep_struct);
|
|
1518 s_findrep_struct.lpstrFindWhat = alloc(MSWIN_FR_BUFSIZE);
|
|
1519 s_findrep_struct.lpstrFindWhat[0] = NUL;
|
|
1520 s_findrep_struct.lpstrReplaceWith = alloc(MSWIN_FR_BUFSIZE);
|
|
1521 s_findrep_struct.lpstrReplaceWith[0] = NUL;
|
|
1522 s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
|
|
1523 s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
|
|
1524 #endif
|
|
1525
|
153
|
1526 theend:
|
|
1527 /* Display any pending error messages */
|
|
1528 display_errors();
|
|
1529
|
7
|
1530 return OK;
|
|
1531 }
|
|
1532
|
|
1533 /*
|
|
1534 * Get the size of the screen, taking position on multiple monitors into
|
|
1535 * account (if supported).
|
|
1536 */
|
|
1537 static void
|
|
1538 get_work_area(RECT *spi_rect)
|
|
1539 {
|
|
1540 _HMONITOR mon;
|
|
1541 _MONITORINFO moninfo;
|
|
1542
|
|
1543 /* use these functions only if available */
|
|
1544 if (pMonitorFromWindow != NULL && pGetMonitorInfo != NULL)
|
|
1545 {
|
|
1546 /* work out which monitor the window is on, and get *it's* work area */
|
|
1547 mon = pMonitorFromWindow(s_hwnd, 1 /*MONITOR_DEFAULTTOPRIMARY*/);
|
|
1548 if (mon != NULL)
|
|
1549 {
|
|
1550 moninfo.cbSize = sizeof(_MONITORINFO);
|
|
1551 if (pGetMonitorInfo(mon, &moninfo))
|
|
1552 {
|
|
1553 *spi_rect = moninfo.rcWork;
|
|
1554 return;
|
|
1555 }
|
|
1556 }
|
|
1557 }
|
|
1558 /* this is the old method... */
|
|
1559 SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0);
|
|
1560 }
|
|
1561
|
|
1562 /*
|
|
1563 * Set the size of the window to the given width and height in pixels.
|
|
1564 */
|
323
|
1565 /*ARGSUSED*/
|
7
|
1566 void
|
|
1567 gui_mch_set_shellsize(int width, int height,
|
812
|
1568 int min_width, int min_height, int base_width, int base_height,
|
|
1569 int direction)
|
7
|
1570 {
|
|
1571 RECT workarea_rect;
|
|
1572 int win_width, win_height;
|
|
1573 int win_xpos, win_ypos;
|
|
1574 WINDOWPLACEMENT wndpl;
|
872
|
1575 int workarea_left;
|
7
|
1576
|
819
|
1577 /* Try to keep window completely on screen. */
|
|
1578 /* Get position of the screen work area. This is the part that is not
|
|
1579 * used by the taskbar or appbars. */
|
7
|
1580 get_work_area(&workarea_rect);
|
|
1581
|
819
|
1582 /* Get current posision of our window. Note that the .left and .top are
|
|
1583 * relative to the work area. */
|
7
|
1584 wndpl.length = sizeof(WINDOWPLACEMENT);
|
|
1585 GetWindowPlacement(s_hwnd, &wndpl);
|
|
1586
|
|
1587 /* Resizing a maximized window looks very strange, unzoom it first.
|
|
1588 * But don't do it when still starting up, it may have been requested in
|
|
1589 * the shortcut. */
|
|
1590 if (wndpl.showCmd == SW_SHOWMAXIMIZED && starting == 0)
|
|
1591 {
|
|
1592 ShowWindow(s_hwnd, SW_SHOWNORMAL);
|
|
1593 /* Need to get the settings of the normal window. */
|
|
1594 GetWindowPlacement(s_hwnd, &wndpl);
|
|
1595 }
|
|
1596
|
|
1597 win_xpos = wndpl.rcNormalPosition.left;
|
|
1598 win_ypos = wndpl.rcNormalPosition.top;
|
|
1599
|
|
1600 /* compute the size of the outside of the window */
|
|
1601 win_width = width + GetSystemMetrics(SM_CXFRAME) * 2;
|
|
1602 win_height = height + GetSystemMetrics(SM_CYFRAME) * 2
|
|
1603 + GetSystemMetrics(SM_CYCAPTION)
|
|
1604 #ifdef FEAT_MENU
|
|
1605 + gui_mswin_get_menu_height(FALSE)
|
|
1606 #endif
|
|
1607 ;
|
|
1608
|
872
|
1609 /* There is an inconsistency when using two monitors and Vim is on the
|
|
1610 * second (right) one: win_xpos will be the offset from the workarea of
|
|
1611 * the left monitor. While with one monitor it's the offset from the
|
|
1612 * workarea (including a possible taskbar on the left). Detect the second
|
|
1613 * monitor by checking for the left offset to be quite big. */
|
|
1614 if (workarea_rect.left > 300)
|
|
1615 workarea_left = 0;
|
|
1616 else
|
|
1617 workarea_left = workarea_rect.left;
|
|
1618
|
819
|
1619 /* If the window is going off the screen, move it on to the screen.
|
|
1620 * win_xpos and win_ypos are relative to the workarea. */
|
|
1621 if ((direction & RESIZE_HOR)
|
872
|
1622 && workarea_left + win_xpos + win_width > workarea_rect.right)
|
|
1623 win_xpos = workarea_rect.right - win_width - workarea_left;
|
819
|
1624
|
|
1625 if ((direction & RESIZE_HOR) && win_xpos < 0)
|
|
1626 win_xpos = 0;
|
7
|
1627
|
812
|
1628 if ((direction & RESIZE_VERT)
|
819
|
1629 && workarea_rect.top + win_ypos + win_height > workarea_rect.bottom)
|
|
1630 win_ypos = workarea_rect.bottom - win_height - workarea_rect.top;
|
|
1631
|
|
1632 if ((direction & RESIZE_VERT) && win_ypos < 0)
|
|
1633 win_ypos = 0;
|
7
|
1634
|
|
1635 wndpl.rcNormalPosition.left = win_xpos;
|
|
1636 wndpl.rcNormalPosition.right = win_xpos + win_width;
|
|
1637 wndpl.rcNormalPosition.top = win_ypos;
|
|
1638 wndpl.rcNormalPosition.bottom = win_ypos + win_height;
|
|
1639
|
|
1640 /* set window position - we should use SetWindowPlacement rather than
|
|
1641 * SetWindowPos as the MSDN docs say the coord systems returned by
|
|
1642 * these two are not compatible. */
|
|
1643 SetWindowPlacement(s_hwnd, &wndpl);
|
|
1644
|
|
1645 SetActiveWindow(s_hwnd);
|
|
1646 SetFocus(s_hwnd);
|
|
1647
|
|
1648 #ifdef FEAT_MENU
|
|
1649 /* Menu may wrap differently now */
|
|
1650 gui_mswin_get_menu_height(!gui.starting);
|
|
1651 #endif
|
|
1652 }
|
|
1653
|
|
1654
|
|
1655 void
|
|
1656 gui_mch_set_scrollbar_thumb(
|
|
1657 scrollbar_T *sb,
|
|
1658 long val,
|
|
1659 long size,
|
|
1660 long max)
|
|
1661 {
|
|
1662 SCROLLINFO info;
|
|
1663
|
|
1664 sb->scroll_shift = 0;
|
|
1665 while (max > 32767)
|
|
1666 {
|
|
1667 max = (max + 1) >> 1;
|
|
1668 val >>= 1;
|
|
1669 size >>= 1;
|
|
1670 ++sb->scroll_shift;
|
|
1671 }
|
|
1672
|
|
1673 if (sb->scroll_shift > 0)
|
|
1674 ++size;
|
|
1675
|
|
1676 info.cbSize = sizeof(info);
|
|
1677 info.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
|
|
1678 info.nPos = val;
|
|
1679 info.nMin = 0;
|
|
1680 info.nMax = max;
|
|
1681 info.nPage = size;
|
|
1682 SetScrollInfo(sb->id, SB_CTL, &info, TRUE);
|
|
1683 }
|
|
1684
|
|
1685
|
|
1686 /*
|
|
1687 * Set the current text font.
|
|
1688 */
|
|
1689 void
|
|
1690 gui_mch_set_font(GuiFont font)
|
|
1691 {
|
|
1692 gui.currFont = font;
|
|
1693 }
|
|
1694
|
|
1695
|
|
1696 /*
|
|
1697 * Set the current text foreground color.
|
|
1698 */
|
|
1699 void
|
|
1700 gui_mch_set_fg_color(guicolor_T color)
|
|
1701 {
|
|
1702 gui.currFgColor = color;
|
|
1703 }
|
|
1704
|
|
1705 /*
|
|
1706 * Set the current text background color.
|
|
1707 */
|
|
1708 void
|
|
1709 gui_mch_set_bg_color(guicolor_T color)
|
|
1710 {
|
|
1711 gui.currBgColor = color;
|
|
1712 }
|
|
1713
|
205
|
1714 /*
|
|
1715 * Set the current text special color.
|
|
1716 */
|
|
1717 void
|
|
1718 gui_mch_set_sp_color(guicolor_T color)
|
|
1719 {
|
|
1720 gui.currSpColor = color;
|
|
1721 }
|
|
1722
|
7
|
1723 #if defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)
|
|
1724 /*
|
|
1725 * Multi-byte handling, originally by Sung-Hoon Baek.
|
|
1726 * First static functions (no prototypes generated).
|
|
1727 */
|
|
1728 #ifdef _MSC_VER
|
|
1729 # include <ime.h> /* Apparently not needed for Cygwin, MingW or Borland. */
|
|
1730 #endif
|
|
1731 #include <imm.h>
|
|
1732
|
|
1733 /*
|
|
1734 * handle WM_IME_NOTIFY message
|
|
1735 */
|
344
|
1736 /*ARGSUSED*/
|
7
|
1737 static LRESULT
|
|
1738 _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData)
|
|
1739 {
|
|
1740 LRESULT lResult = 0;
|
|
1741 HIMC hImc;
|
|
1742
|
|
1743 if (!pImmGetContext || (hImc = pImmGetContext(hWnd)) == (HIMC)0)
|
|
1744 return lResult;
|
|
1745 switch (dwCommand)
|
|
1746 {
|
|
1747 case IMN_SETOPENSTATUS:
|
|
1748 if (pImmGetOpenStatus(hImc))
|
|
1749 {
|
|
1750 pImmSetCompositionFont(hImc, &norm_logfont);
|
|
1751 im_set_position(gui.row, gui.col);
|
|
1752
|
|
1753 /* Disable langmap */
|
|
1754 State &= ~LANGMAP;
|
|
1755 if (State & INSERT)
|
|
1756 {
|
|
1757 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
|
|
1758 /* Unshown 'keymap' in status lines */
|
|
1759 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
|
|
1760 {
|
|
1761 /* Save cursor position */
|
|
1762 int old_row = gui.row;
|
|
1763 int old_col = gui.col;
|
|
1764
|
|
1765 // This must be called here before
|
|
1766 // status_redraw_curbuf(), otherwise the mode
|
|
1767 // message may appear in the wrong position.
|
|
1768 showmode();
|
|
1769 status_redraw_curbuf();
|
|
1770 update_screen(0);
|
|
1771 /* Restore cursor position */
|
|
1772 gui.row = old_row;
|
|
1773 gui.col = old_col;
|
|
1774 }
|
|
1775 #endif
|
|
1776 }
|
|
1777 }
|
|
1778 gui_update_cursor(TRUE, FALSE);
|
|
1779 lResult = 0;
|
|
1780 break;
|
|
1781 }
|
|
1782 pImmReleaseContext(hWnd, hImc);
|
|
1783 return lResult;
|
|
1784 }
|
|
1785
|
344
|
1786 /*ARGSUSED*/
|
7
|
1787 static LRESULT
|
|
1788 _OnImeComposition(HWND hwnd, WPARAM dbcs, LPARAM param)
|
|
1789 {
|
|
1790 char_u *ret;
|
|
1791 int len;
|
|
1792
|
|
1793 if ((param & GCS_RESULTSTR) == 0) /* Composition unfinished. */
|
|
1794 return 0;
|
|
1795
|
|
1796 ret = GetResultStr(hwnd, GCS_RESULTSTR, &len);
|
|
1797 if (ret != NULL)
|
|
1798 {
|
|
1799 add_to_input_buf_csi(ret, len);
|
|
1800 vim_free(ret);
|
|
1801 return 1;
|
|
1802 }
|
|
1803 return 0;
|
|
1804 }
|
|
1805
|
|
1806 /*
|
|
1807 * get the current composition string, in UCS-2; *lenp is the number of
|
|
1808 * *lenp is the number of Unicode characters.
|
|
1809 */
|
|
1810 static short_u *
|
|
1811 GetCompositionString_inUCS2(HIMC hIMC, DWORD GCS, int *lenp)
|
|
1812 {
|
|
1813 LONG ret;
|
|
1814 LPWSTR wbuf = NULL;
|
|
1815 char_u *buf;
|
|
1816
|
|
1817 if (!pImmGetContext)
|
|
1818 return NULL; /* no imm32.dll */
|
|
1819
|
|
1820 /* Try Unicode; this'll always work on NT regardless of codepage. */
|
|
1821 ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0);
|
|
1822 if (ret == 0)
|
|
1823 return NULL; /* empty */
|
|
1824
|
|
1825 if (ret > 0)
|
|
1826 {
|
|
1827 /* Allocate the requested buffer plus space for the NUL character. */
|
|
1828 wbuf = (LPWSTR)alloc(ret + sizeof(WCHAR));
|
|
1829 if (wbuf != NULL)
|
|
1830 {
|
|
1831 pImmGetCompositionStringW(hIMC, GCS, wbuf, ret);
|
|
1832 *lenp = ret / sizeof(WCHAR);
|
|
1833 }
|
|
1834 return (short_u *)wbuf;
|
|
1835 }
|
|
1836
|
|
1837 /* ret < 0; we got an error, so try the ANSI version. This'll work
|
|
1838 * on 9x/ME, but only if the codepage happens to be set to whatever
|
|
1839 * we're inputting. */
|
|
1840 ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0);
|
|
1841 if (ret <= 0)
|
|
1842 return NULL; /* empty or error */
|
|
1843
|
|
1844 buf = alloc(ret);
|
|
1845 if (buf == NULL)
|
|
1846 return NULL;
|
|
1847 pImmGetCompositionStringA(hIMC, GCS, buf, ret);
|
|
1848
|
|
1849 /* convert from codepage to UCS-2 */
|
|
1850 MultiByteToWideChar_alloc(GetACP(), 0, buf, ret, &wbuf, lenp);
|
|
1851 vim_free(buf);
|
|
1852
|
|
1853 return (short_u *)wbuf;
|
|
1854 }
|
|
1855
|
|
1856 /*
|
|
1857 * void GetResultStr()
|
|
1858 *
|
|
1859 * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on.
|
|
1860 * get complete composition string
|
|
1861 */
|
|
1862 static char_u *
|
|
1863 GetResultStr(HWND hwnd, int GCS, int *lenp)
|
|
1864 {
|
|
1865 HIMC hIMC; /* Input context handle. */
|
|
1866 short_u *buf = NULL;
|
|
1867 char_u *convbuf = NULL;
|
|
1868
|
|
1869 if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0)
|
|
1870 return NULL;
|
|
1871
|
|
1872 /* Reads in the composition string. */
|
|
1873 buf = GetCompositionString_inUCS2(hIMC, GCS, lenp);
|
|
1874 if (buf == NULL)
|
|
1875 return NULL;
|
|
1876
|
|
1877 convbuf = ucs2_to_enc(buf, lenp);
|
|
1878 pImmReleaseContext(hwnd, hIMC);
|
|
1879 vim_free(buf);
|
|
1880 return convbuf;
|
|
1881 }
|
|
1882 #endif
|
|
1883
|
|
1884 /* For global functions we need prototypes. */
|
|
1885 #if (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) || defined(PROTO)
|
|
1886
|
|
1887 /*
|
|
1888 * set font to IM.
|
|
1889 */
|
|
1890 void
|
|
1891 im_set_font(LOGFONT *lf)
|
|
1892 {
|
|
1893 HIMC hImc;
|
|
1894
|
|
1895 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
|
|
1896 {
|
|
1897 pImmSetCompositionFont(hImc, lf);
|
|
1898 pImmReleaseContext(s_hwnd, hImc);
|
|
1899 }
|
|
1900 }
|
|
1901
|
|
1902 /*
|
|
1903 * Notify cursor position to IM.
|
|
1904 */
|
|
1905 void
|
|
1906 im_set_position(int row, int col)
|
|
1907 {
|
|
1908 HIMC hImc;
|
|
1909
|
|
1910 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
|
|
1911 {
|
|
1912 COMPOSITIONFORM cfs;
|
|
1913
|
|
1914 cfs.dwStyle = CFS_POINT;
|
|
1915 cfs.ptCurrentPos.x = FILL_X(col);
|
|
1916 cfs.ptCurrentPos.y = FILL_Y(row);
|
|
1917 MapWindowPoints(s_textArea, s_hwnd, &cfs.ptCurrentPos, 1);
|
|
1918 pImmSetCompositionWindow(hImc, &cfs);
|
|
1919
|
|
1920 pImmReleaseContext(s_hwnd, hImc);
|
|
1921 }
|
|
1922 }
|
|
1923
|
|
1924 /*
|
|
1925 * Set IM status on ("active" is TRUE) or off ("active" is FALSE).
|
|
1926 */
|
|
1927 void
|
|
1928 im_set_active(int active)
|
|
1929 {
|
|
1930 HIMC hImc;
|
|
1931 static HIMC hImcOld = (HIMC)0;
|
|
1932
|
|
1933 if (pImmGetContext) /* if NULL imm32.dll wasn't loaded (yet) */
|
|
1934 {
|
|
1935 if (p_imdisable)
|
|
1936 {
|
|
1937 if (hImcOld == (HIMC)0)
|
|
1938 {
|
|
1939 hImcOld = pImmGetContext(s_hwnd);
|
|
1940 if (hImcOld)
|
|
1941 pImmAssociateContext(s_hwnd, (HIMC)0);
|
|
1942 }
|
|
1943 active = FALSE;
|
|
1944 }
|
|
1945 else if (hImcOld != (HIMC)0)
|
|
1946 {
|
|
1947 pImmAssociateContext(s_hwnd, hImcOld);
|
|
1948 hImcOld = (HIMC)0;
|
|
1949 }
|
|
1950
|
|
1951 hImc = pImmGetContext(s_hwnd);
|
|
1952 if (hImc)
|
|
1953 {
|
777
|
1954 /*
|
|
1955 * for Korean ime
|
|
1956 */
|
|
1957 HKL hKL = GetKeyboardLayout(0);
|
|
1958
|
|
1959 if (LOWORD(hKL) == MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN))
|
|
1960 {
|
|
1961 static DWORD dwConversionSaved = 0, dwSentenceSaved = 0;
|
|
1962 static BOOL bSaved = FALSE;
|
|
1963
|
|
1964 if (active)
|
|
1965 {
|
|
1966 /* if we have a saved conversion status, restore it */
|
|
1967 if (bSaved)
|
|
1968 pImmSetConversionStatus(hImc, dwConversionSaved,
|
|
1969 dwSentenceSaved);
|
|
1970 bSaved = FALSE;
|
|
1971 }
|
|
1972 else
|
|
1973 {
|
|
1974 /* save conversion status and disable korean */
|
|
1975 if (pImmGetConversionStatus(hImc, &dwConversionSaved,
|
|
1976 &dwSentenceSaved))
|
|
1977 {
|
|
1978 bSaved = TRUE;
|
|
1979 pImmSetConversionStatus(hImc,
|
|
1980 dwConversionSaved & ~(IME_CMODE_NATIVE
|
|
1981 | IME_CMODE_FULLSHAPE),
|
|
1982 dwSentenceSaved);
|
|
1983 }
|
|
1984 }
|
|
1985 }
|
|
1986
|
7
|
1987 pImmSetOpenStatus(hImc, active);
|
|
1988 pImmReleaseContext(s_hwnd, hImc);
|
|
1989 }
|
|
1990 }
|
|
1991 }
|
|
1992
|
|
1993 /*
|
|
1994 * Get IM status. When IM is on, return not 0. Else return 0.
|
|
1995 */
|
|
1996 int
|
|
1997 im_get_status()
|
|
1998 {
|
|
1999 int status = 0;
|
|
2000 HIMC hImc;
|
|
2001
|
|
2002 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
|
|
2003 {
|
|
2004 status = pImmGetOpenStatus(hImc) ? 1 : 0;
|
|
2005 pImmReleaseContext(s_hwnd, hImc);
|
|
2006 }
|
|
2007 return status;
|
|
2008 }
|
|
2009
|
|
2010 #endif /* FEAT_MBYTE && FEAT_MBYTE_IME */
|
|
2011
|
|
2012 #if defined(FEAT_MBYTE) && !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
|
|
2013 /* Win32 with GLOBAL IME */
|
|
2014
|
|
2015 /*
|
|
2016 * Notify cursor position to IM.
|
|
2017 */
|
|
2018 void
|
|
2019 im_set_position(int row, int col)
|
|
2020 {
|
|
2021 /* Win32 with GLOBAL IME */
|
|
2022 POINT p;
|
|
2023
|
|
2024 p.x = FILL_X(col);
|
|
2025 p.y = FILL_Y(row);
|
|
2026 MapWindowPoints(s_textArea, s_hwnd, &p, 1);
|
|
2027 global_ime_set_position(&p);
|
|
2028 }
|
|
2029
|
|
2030 /*
|
|
2031 * Set IM status on ("active" is TRUE) or off ("active" is FALSE).
|
|
2032 */
|
|
2033 void
|
|
2034 im_set_active(int active)
|
|
2035 {
|
|
2036 global_ime_set_status(active);
|
|
2037 }
|
|
2038
|
|
2039 /*
|
|
2040 * Get IM status. When IM is on, return not 0. Else return 0.
|
|
2041 */
|
|
2042 int
|
|
2043 im_get_status()
|
|
2044 {
|
|
2045 return global_ime_get_status();
|
|
2046 }
|
|
2047 #endif
|
|
2048
|
26
|
2049 #ifdef FEAT_MBYTE
|
|
2050 /*
|
786
|
2051 * Convert latin9 text "text[len]" to ucs-2 in "unicodebuf".
|
26
|
2052 */
|
|
2053 static void
|
|
2054 latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf)
|
|
2055 {
|
|
2056 int c;
|
|
2057
|
777
|
2058 while (--len >= 0)
|
26
|
2059 {
|
|
2060 c = *text++;
|
|
2061 switch (c)
|
|
2062 {
|
|
2063 case 0xa4: c = 0x20ac; break; /* euro */
|
|
2064 case 0xa6: c = 0x0160; break; /* S hat */
|
|
2065 case 0xa8: c = 0x0161; break; /* S -hat */
|
|
2066 case 0xb4: c = 0x017d; break; /* Z hat */
|
|
2067 case 0xb8: c = 0x017e; break; /* Z -hat */
|
|
2068 case 0xbc: c = 0x0152; break; /* OE */
|
|
2069 case 0xbd: c = 0x0153; break; /* oe */
|
|
2070 case 0xbe: c = 0x0178; break; /* Y */
|
|
2071 }
|
|
2072 *unicodebuf++ = c;
|
|
2073 }
|
|
2074 }
|
|
2075 #endif
|
7
|
2076
|
|
2077 #ifdef FEAT_RIGHTLEFT
|
|
2078 /*
|
|
2079 * What is this for? In the case where you are using Win98 or Win2K or later,
|
|
2080 * and you are using a Hebrew font (or Arabic!), Windows does you a favor and
|
|
2081 * reverses the string sent to the TextOut... family. This sucks, because we
|
|
2082 * go to a lot of effort to do the right thing, and there doesn't seem to be a
|
|
2083 * way to tell Windblows not to do this!
|
|
2084 *
|
|
2085 * The short of it is that this 'RevOut' only gets called if you are running
|
|
2086 * one of the new, "improved" MS OSes, and only if you are running in
|
|
2087 * 'rightleft' mode. It makes display take *slightly* longer, but not
|
|
2088 * noticeably so.
|
|
2089 */
|
|
2090 static void
|
|
2091 RevOut( HDC s_hdc,
|
|
2092 int col,
|
|
2093 int row,
|
|
2094 UINT foptions,
|
|
2095 CONST RECT *pcliprect,
|
|
2096 LPCTSTR text,
|
|
2097 UINT len,
|
|
2098 CONST INT *padding)
|
|
2099 {
|
|
2100 int ix;
|
|
2101 static int special = -1;
|
|
2102
|
|
2103 if (special == -1)
|
|
2104 {
|
|
2105 /* Check windows version: special treatment is needed if it is NT 5 or
|
|
2106 * Win98 or higher. */
|
|
2107 if ((os_version.dwPlatformId == VER_PLATFORM_WIN32_NT
|
|
2108 && os_version.dwMajorVersion >= 5)
|
|
2109 || (os_version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS
|
|
2110 && (os_version.dwMajorVersion > 4
|
|
2111 || (os_version.dwMajorVersion == 4
|
|
2112 && os_version.dwMinorVersion > 0))))
|
|
2113 special = 1;
|
|
2114 else
|
|
2115 special = 0;
|
|
2116 }
|
|
2117
|
|
2118 if (special)
|
|
2119 for (ix = 0; ix < (int)len; ++ix)
|
|
2120 ExtTextOut(s_hdc, col + TEXT_X(ix), row, foptions,
|
|
2121 pcliprect, text + ix, 1, padding);
|
|
2122 else
|
|
2123 ExtTextOut(s_hdc, col, row, foptions, pcliprect, text, len, padding);
|
|
2124 }
|
|
2125 #endif
|
|
2126
|
|
2127 void
|
|
2128 gui_mch_draw_string(
|
|
2129 int row,
|
|
2130 int col,
|
|
2131 char_u *text,
|
|
2132 int len,
|
|
2133 int flags)
|
|
2134 {
|
|
2135 static int *padding = NULL;
|
|
2136 static int pad_size = 0;
|
|
2137 int i;
|
|
2138 const RECT *pcliprect = NULL;
|
|
2139 UINT foptions = 0;
|
|
2140 #ifdef FEAT_MBYTE
|
|
2141 static WCHAR *unicodebuf = NULL;
|
|
2142 static int *unicodepdy = NULL;
|
236
|
2143 static int unibuflen = 0;
|
7
|
2144 int n = 0;
|
|
2145 #endif
|
|
2146 HPEN hpen, old_pen;
|
|
2147 int y;
|
|
2148
|
|
2149 #ifndef MSWIN16_FASTTEXT
|
|
2150 /*
|
|
2151 * Italic and bold text seems to have an extra row of pixels at the bottom
|
|
2152 * (below where the bottom of the character should be). If we draw the
|
|
2153 * characters with a solid background, the top row of pixels in the
|
|
2154 * character below will be overwritten. We can fix this by filling in the
|
|
2155 * background ourselves, to the correct character proportions, and then
|
|
2156 * writing the character in transparent mode. Still have a problem when
|
|
2157 * the character is "_", which gets written on to the character below.
|
|
2158 * New fix: set gui.char_ascent to -1. This shifts all characters up one
|
|
2159 * pixel in their slots, which fixes the problem with the bottom row of
|
|
2160 * pixels. We still need this code because otherwise the top row of pixels
|
|
2161 * becomes a problem. - webb.
|
|
2162 */
|
|
2163 static HBRUSH hbr_cache[2] = {NULL, NULL};
|
|
2164 static guicolor_T brush_color[2] = {INVALCOLOR, INVALCOLOR};
|
|
2165 static int brush_lru = 0;
|
|
2166 HBRUSH hbr;
|
|
2167 RECT rc;
|
|
2168
|
|
2169 if (!(flags & DRAW_TRANSP))
|
|
2170 {
|
|
2171 /*
|
|
2172 * Clear background first.
|
|
2173 * Note: FillRect() excludes right and bottom of rectangle.
|
|
2174 */
|
|
2175 rc.left = FILL_X(col);
|
|
2176 rc.top = FILL_Y(row);
|
|
2177 #ifdef FEAT_MBYTE
|
|
2178 if (has_mbyte)
|
|
2179 {
|
|
2180 int cell_len = 0;
|
|
2181
|
|
2182 /* Compute the length in display cells. */
|
|
2183 for (n = 0; n < len; n += MB_BYTE2LEN(text[n]))
|
|
2184 cell_len += (*mb_ptr2cells)(text + n);
|
|
2185 rc.right = FILL_X(col + cell_len);
|
|
2186 }
|
|
2187 else
|
|
2188 #endif
|
|
2189 rc.right = FILL_X(col + len);
|
|
2190 rc.bottom = FILL_Y(row + 1);
|
|
2191
|
|
2192 /* Cache the created brush, that saves a lot of time. We need two:
|
|
2193 * one for cursor background and one for the normal background. */
|
|
2194 if (gui.currBgColor == brush_color[0])
|
|
2195 {
|
|
2196 hbr = hbr_cache[0];
|
|
2197 brush_lru = 1;
|
|
2198 }
|
|
2199 else if (gui.currBgColor == brush_color[1])
|
|
2200 {
|
|
2201 hbr = hbr_cache[1];
|
|
2202 brush_lru = 0;
|
|
2203 }
|
|
2204 else
|
|
2205 {
|
|
2206 if (hbr_cache[brush_lru] != NULL)
|
|
2207 DeleteBrush(hbr_cache[brush_lru]);
|
|
2208 hbr_cache[brush_lru] = CreateSolidBrush(gui.currBgColor);
|
|
2209 brush_color[brush_lru] = gui.currBgColor;
|
|
2210 hbr = hbr_cache[brush_lru];
|
|
2211 brush_lru = !brush_lru;
|
|
2212 }
|
|
2213 FillRect(s_hdc, &rc, hbr);
|
|
2214
|
|
2215 SetBkMode(s_hdc, TRANSPARENT);
|
|
2216
|
|
2217 /*
|
|
2218 * When drawing block cursor, prevent inverted character spilling
|
|
2219 * over character cell (can happen with bold/italic)
|
|
2220 */
|
|
2221 if (flags & DRAW_CURSOR)
|
|
2222 {
|
|
2223 pcliprect = &rc;
|
|
2224 foptions = ETO_CLIPPED;
|
|
2225 }
|
|
2226 }
|
|
2227 #else
|
|
2228 /*
|
|
2229 * The alternative would be to write the characters in opaque mode, but
|
|
2230 * when the text is not exactly the same proportions as normal text, too
|
|
2231 * big or too little a rectangle gets drawn for the background.
|
|
2232 */
|
|
2233 SetBkMode(s_hdc, OPAQUE);
|
|
2234 SetBkColor(s_hdc, gui.currBgColor);
|
|
2235 #endif
|
|
2236 SetTextColor(s_hdc, gui.currFgColor);
|
|
2237 SelectFont(s_hdc, gui.currFont);
|
|
2238
|
|
2239 if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
|
|
2240 {
|
|
2241 vim_free(padding);
|
|
2242 pad_size = Columns;
|
|
2243
|
537
|
2244 /* Don't give an out-of-memory message here, it would call us
|
|
2245 * recursively. */
|
|
2246 padding = (int *)lalloc(pad_size * sizeof(int), FALSE);
|
7
|
2247 if (padding != NULL)
|
|
2248 for (i = 0; i < pad_size; i++)
|
|
2249 padding[i] = gui.char_width;
|
|
2250 }
|
|
2251
|
|
2252 /* On NT, tell the font renderer not to "help" us with Hebrew and Arabic
|
|
2253 * text. This doesn't work in 9x, so we have to deal with it manually on
|
|
2254 * those systems. */
|
|
2255 if (os_version.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
|
2256 foptions |= ETO_IGNORELANGUAGE;
|
|
2257
|
|
2258 /*
|
|
2259 * We have to provide the padding argument because italic and bold versions
|
|
2260 * of fixed-width fonts are often one pixel or so wider than their normal
|
|
2261 * versions.
|
|
2262 * No check for DRAW_BOLD, Windows will have done it already.
|
|
2263 */
|
|
2264
|
|
2265 #ifdef FEAT_MBYTE
|
|
2266 /* Check if there are any UTF-8 characters. If not, use normal text
|
|
2267 * output to speed up output. */
|
|
2268 if (enc_utf8)
|
|
2269 for (n = 0; n < len; ++n)
|
|
2270 if (text[n] >= 0x80)
|
|
2271 break;
|
|
2272
|
|
2273 /* Check if the Unicode buffer exists and is big enough. Create it
|
236
|
2274 * with the same length as the multi-byte string, the number of wide
|
7
|
2275 * characters is always equal or smaller. */
|
26
|
2276 if ((enc_utf8
|
|
2277 || (enc_codepage > 0 && (int)GetACP() != enc_codepage)
|
|
2278 || enc_latin9)
|
7
|
2279 && (unicodebuf == NULL || len > unibuflen))
|
|
2280 {
|
|
2281 vim_free(unicodebuf);
|
537
|
2282 unicodebuf = (WCHAR *)lalloc(len * sizeof(WCHAR), FALSE);
|
7
|
2283
|
|
2284 vim_free(unicodepdy);
|
537
|
2285 unicodepdy = (int *)lalloc(len * sizeof(int), FALSE);
|
7
|
2286
|
|
2287 unibuflen = len;
|
|
2288 }
|
|
2289
|
|
2290 if (enc_utf8 && n < len && unicodebuf != NULL)
|
|
2291 {
|
|
2292 /* Output UTF-8 characters. Caller has already separated
|
|
2293 * composing characters. */
|
777
|
2294 int i;
|
|
2295 int wlen; /* string length in words */
|
|
2296 int clen; /* string length in characters */
|
7
|
2297 int cells; /* cell width of string up to composing char */
|
|
2298 int cw; /* width of current cell */
|
714
|
2299 int c;
|
777
|
2300
|
782
|
2301 wlen = 0;
|
777
|
2302 clen = 0;
|
7
|
2303 cells = 0;
|
777
|
2304 for (i = 0; i < len; )
|
7
|
2305 {
|
714
|
2306 c = utf_ptr2char(text + i);
|
|
2307 if (c >= 0x10000)
|
|
2308 {
|
|
2309 /* Turn into UTF-16 encoding. */
|
777
|
2310 unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800;
|
|
2311 unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00;
|
714
|
2312 }
|
|
2313 else
|
|
2314 {
|
777
|
2315 unicodebuf[wlen++] = c;
|
714
|
2316 }
|
|
2317 cw = utf_char2cells(c);
|
7
|
2318 if (cw > 2) /* don't use 4 for unprintable char */
|
|
2319 cw = 1;
|
|
2320 if (unicodepdy != NULL)
|
|
2321 {
|
|
2322 /* Use unicodepdy to make characters fit as we expect, even
|
|
2323 * when the font uses different widths (e.g., bold character
|
|
2324 * is wider). */
|
|
2325 unicodepdy[clen] = cw * gui.char_width;
|
|
2326 }
|
|
2327 cells += cw;
|
474
|
2328 i += utfc_ptr2len_len(text + i, len - i);
|
777
|
2329 ++clen;
|
7
|
2330 }
|
|
2331 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
|
777
|
2332 foptions, pcliprect, unicodebuf, wlen, unicodepdy);
|
7
|
2333 len = cells; /* used for underlining */
|
|
2334 }
|
26
|
2335 else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
|
7
|
2336 {
|
|
2337 /* If we want to display codepage data, and the current CP is not the
|
|
2338 * ANSI one, we need to go via Unicode. */
|
|
2339 if (unicodebuf != NULL)
|
|
2340 {
|
26
|
2341 if (enc_latin9)
|
|
2342 latin9_to_ucs(text, len, unicodebuf);
|
|
2343 else
|
|
2344 len = MultiByteToWideChar(enc_codepage,
|
7
|
2345 MB_PRECOMPOSED,
|
|
2346 (char *)text, len,
|
|
2347 (LPWSTR)unicodebuf, unibuflen);
|
|
2348 if (len != 0)
|
179
|
2349 {
|
|
2350 /* Use unicodepdy to make characters fit as we expect, even
|
|
2351 * when the font uses different widths (e.g., bold character
|
|
2352 * is wider). */
|
|
2353 if (unicodepdy != NULL)
|
|
2354 {
|
|
2355 int i;
|
|
2356 int cw;
|
|
2357
|
|
2358 for (i = 0; i < len; ++i)
|
|
2359 {
|
|
2360 cw = utf_char2cells(unicodebuf[i]);
|
|
2361 if (cw > 2)
|
|
2362 cw = 1;
|
|
2363 unicodepdy[i] = cw * gui.char_width;
|
|
2364 }
|
|
2365 }
|
7
|
2366 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
|
179
|
2367 foptions, pcliprect, unicodebuf, len, unicodepdy);
|
|
2368 }
|
7
|
2369 }
|
|
2370 }
|
|
2371 else
|
|
2372 #endif
|
|
2373 {
|
|
2374 #ifdef FEAT_RIGHTLEFT
|
|
2375 /* If we can't use ETO_IGNORELANGUAGE, we can't tell Windows not to
|
|
2376 * mess up RL text, so we have to draw it character-by-character.
|
|
2377 * Only do this if RL is on, since it's slow. */
|
|
2378 if (curwin->w_p_rl && !(foptions & ETO_IGNORELANGUAGE))
|
|
2379 RevOut(s_hdc, TEXT_X(col), TEXT_Y(row),
|
|
2380 foptions, pcliprect, (char *)text, len, padding);
|
|
2381 else
|
|
2382 #endif
|
|
2383 ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row),
|
|
2384 foptions, pcliprect, (char *)text, len, padding);
|
|
2385 }
|
|
2386
|
205
|
2387 /* Underline */
|
7
|
2388 if (flags & DRAW_UNDERL)
|
|
2389 {
|
|
2390 hpen = CreatePen(PS_SOLID, 1, gui.currFgColor);
|
|
2391 old_pen = SelectObject(s_hdc, hpen);
|
|
2392 /* When p_linespace is 0, overwrite the bottom row of pixels.
|
|
2393 * Otherwise put the line just below the character. */
|
|
2394 y = FILL_Y(row + 1) - 1;
|
|
2395 #ifndef MSWIN16_FASTTEXT
|
|
2396 if (p_linespace > 1)
|
|
2397 y -= p_linespace - 1;
|
|
2398 #endif
|
|
2399 MoveToEx(s_hdc, FILL_X(col), y, NULL);
|
|
2400 /* Note: LineTo() excludes the last pixel in the line. */
|
|
2401 LineTo(s_hdc, FILL_X(col + len), y);
|
|
2402 DeleteObject(SelectObject(s_hdc, old_pen));
|
|
2403 }
|
205
|
2404
|
|
2405 /* Undercurl */
|
|
2406 if (flags & DRAW_UNDERC)
|
|
2407 {
|
|
2408 int x;
|
|
2409 int offset;
|
323
|
2410 static const int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
|
205
|
2411
|
|
2412 y = FILL_Y(row + 1) - 1;
|
|
2413 for (x = FILL_X(col); x < FILL_X(col + len); ++x)
|
|
2414 {
|
|
2415 offset = val[x % 8];
|
|
2416 SetPixel(s_hdc, x, y - offset, gui.currSpColor);
|
|
2417 }
|
|
2418 }
|
7
|
2419 }
|
|
2420
|
|
2421
|
|
2422 /*
|
|
2423 * Output routines.
|
|
2424 */
|
|
2425
|
|
2426 /* Flush any output to the screen */
|
|
2427 void
|
|
2428 gui_mch_flush(void)
|
|
2429 {
|
|
2430 # if defined(__BORLANDC__)
|
|
2431 /*
|
|
2432 * The GdiFlush declaration (in Borland C 5.01 <wingdi.h>) is not a
|
|
2433 * prototype declaration.
|
|
2434 * The compiler complains if __stdcall is not used in both declarations.
|
|
2435 */
|
|
2436 BOOL __stdcall GdiFlush(void);
|
|
2437 # endif
|
|
2438
|
|
2439 GdiFlush();
|
|
2440 }
|
|
2441
|
|
2442 static void
|
|
2443 clear_rect(RECT *rcp)
|
|
2444 {
|
|
2445 HBRUSH hbr;
|
|
2446
|
|
2447 hbr = CreateSolidBrush(gui.back_pixel);
|
|
2448 FillRect(s_hdc, rcp, hbr);
|
|
2449 DeleteBrush(hbr);
|
|
2450 }
|
|
2451
|
|
2452
|
636
|
2453 void
|
|
2454 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
|
|
2455 {
|
|
2456 RECT workarea_rect;
|
|
2457
|
|
2458 get_work_area(&workarea_rect);
|
|
2459
|
819
|
2460 *screen_w = workarea_rect.right - workarea_rect.left
|
856
|
2461 - GetSystemMetrics(SM_CXFRAME) * 2;
|
636
|
2462
|
|
2463 /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include
|
|
2464 * the menubar for MSwin, we subtract it from the screen height, so that
|
|
2465 * the window size can be made to fit on the screen. */
|
819
|
2466 *screen_h = workarea_rect.bottom - workarea_rect.top
|
856
|
2467 - GetSystemMetrics(SM_CYFRAME) * 2
|
636
|
2468 - GetSystemMetrics(SM_CYCAPTION)
|
|
2469 #ifdef FEAT_MENU
|
856
|
2470 - gui_mswin_get_menu_height(FALSE)
|
636
|
2471 #endif
|
856
|
2472 ;
|
636
|
2473 }
|
|
2474
|
|
2475
|
7
|
2476 #if defined(FEAT_MENU) || defined(PROTO)
|
|
2477 /*
|
|
2478 * Add a sub menu to the menu bar.
|
|
2479 */
|
|
2480 void
|
|
2481 gui_mch_add_menu(
|
|
2482 vimmenu_T *menu,
|
|
2483 int pos)
|
|
2484 {
|
|
2485 vimmenu_T *parent = menu->parent;
|
|
2486
|
|
2487 menu->submenu_id = CreatePopupMenu();
|
|
2488 menu->id = s_menu_id++;
|
|
2489
|
|
2490 if (menu_is_menubar(menu->name))
|
|
2491 {
|
|
2492 if (is_winnt_3())
|
|
2493 {
|
|
2494 InsertMenu((parent == NULL) ? s_menuBar : parent->submenu_id,
|
|
2495 (UINT)pos, MF_POPUP | MF_STRING | MF_BYPOSITION,
|
840
|
2496 (long_u)menu->submenu_id, (LPCTSTR) menu->name);
|
7
|
2497 }
|
|
2498 else
|
|
2499 {
|
|
2500 #ifdef FEAT_MBYTE
|
|
2501 WCHAR *wn = NULL;
|
|
2502 int n;
|
|
2503
|
|
2504 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
|
2505 {
|
|
2506 /* 'encoding' differs from active codepage: convert menu name
|
|
2507 * and use wide function */
|
|
2508 wn = enc_to_ucs2(menu->name, NULL);
|
|
2509 if (wn != NULL)
|
|
2510 {
|
|
2511 MENUITEMINFOW infow;
|
|
2512
|
|
2513 infow.cbSize = sizeof(infow);
|
|
2514 infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID
|
|
2515 | MIIM_SUBMENU;
|
840
|
2516 infow.dwItemData = (long_u)menu;
|
7
|
2517 infow.wID = menu->id;
|
|
2518 infow.fType = MFT_STRING;
|
|
2519 infow.dwTypeData = wn;
|
835
|
2520 infow.cch = (UINT)wcslen(wn);
|
7
|
2521 infow.hSubMenu = menu->submenu_id;
|
|
2522 n = InsertMenuItemW((parent == NULL)
|
|
2523 ? s_menuBar : parent->submenu_id,
|
|
2524 (UINT)pos, TRUE, &infow);
|
|
2525 vim_free(wn);
|
|
2526 if (n == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
2527 /* Failed, try using non-wide function. */
|
|
2528 wn = NULL;
|
|
2529 }
|
|
2530 }
|
|
2531
|
|
2532 if (wn == NULL)
|
|
2533 #endif
|
|
2534 {
|
|
2535 MENUITEMINFO info;
|
|
2536
|
|
2537 info.cbSize = sizeof(info);
|
|
2538 info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID | MIIM_SUBMENU;
|
840
|
2539 info.dwItemData = (long_u)menu;
|
7
|
2540 info.wID = menu->id;
|
|
2541 info.fType = MFT_STRING;
|
|
2542 info.dwTypeData = (LPTSTR)menu->name;
|
|
2543 info.cch = (UINT)STRLEN(menu->name);
|
|
2544 info.hSubMenu = menu->submenu_id;
|
|
2545 InsertMenuItem((parent == NULL)
|
|
2546 ? s_menuBar : parent->submenu_id,
|
|
2547 (UINT)pos, TRUE, &info);
|
|
2548 }
|
|
2549 }
|
|
2550 }
|
|
2551
|
|
2552 /* Fix window size if menu may have wrapped */
|
|
2553 if (parent == NULL)
|
|
2554 gui_mswin_get_menu_height(!gui.starting);
|
|
2555 #ifdef FEAT_TEAROFF
|
|
2556 else if (IsWindow(parent->tearoff_handle))
|
|
2557 rebuild_tearoff(parent);
|
|
2558 #endif
|
|
2559 }
|
|
2560
|
|
2561 void
|
|
2562 gui_mch_show_popupmenu(vimmenu_T *menu)
|
|
2563 {
|
|
2564 POINT mp;
|
|
2565
|
|
2566 (void)GetCursorPos((LPPOINT)&mp);
|
|
2567 gui_mch_show_popupmenu_at(menu, (int)mp.x, (int)mp.y);
|
|
2568 }
|
|
2569
|
|
2570 void
|
401
|
2571 gui_make_popup(char_u *path_name, int mouse_pos)
|
7
|
2572 {
|
|
2573 vimmenu_T *menu = gui_find_menu(path_name);
|
|
2574
|
|
2575 if (menu != NULL)
|
|
2576 {
|
|
2577 POINT p;
|
|
2578
|
|
2579 /* Find the position of the current cursor */
|
|
2580 GetDCOrgEx(s_hdc, &p);
|
401
|
2581 if (mouse_pos)
|
|
2582 {
|
|
2583 int mx, my;
|
|
2584
|
|
2585 gui_mch_getmouse(&mx, &my);
|
|
2586 p.x += mx;
|
|
2587 p.y += my;
|
|
2588 }
|
|
2589 else if (curwin != NULL)
|
7
|
2590 {
|
|
2591 p.x += TEXT_X(W_WINCOL(curwin) + curwin->w_wcol + 1);
|
|
2592 p.y += TEXT_Y(W_WINROW(curwin) + curwin->w_wrow + 1);
|
|
2593 }
|
|
2594 msg_scroll = FALSE;
|
|
2595 gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
|
|
2596 }
|
|
2597 }
|
|
2598
|
|
2599 #if defined(FEAT_TEAROFF) || defined(PROTO)
|
|
2600 /*
|
|
2601 * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy and
|
|
2602 * create it as a pseudo-"tearoff menu".
|
|
2603 */
|
|
2604 void
|
|
2605 gui_make_tearoff(char_u *path_name)
|
|
2606 {
|
|
2607 vimmenu_T *menu = gui_find_menu(path_name);
|
|
2608
|
|
2609 /* Found the menu, so tear it off. */
|
|
2610 if (menu != NULL)
|
|
2611 gui_mch_tearoff(menu->dname, menu, 0xffffL, 0xffffL);
|
|
2612 }
|
|
2613 #endif
|
|
2614
|
|
2615 /*
|
|
2616 * Add a menu item to a menu
|
|
2617 */
|
|
2618 void
|
|
2619 gui_mch_add_menu_item(
|
|
2620 vimmenu_T *menu,
|
|
2621 int idx)
|
|
2622 {
|
|
2623 vimmenu_T *parent = menu->parent;
|
|
2624
|
|
2625 menu->id = s_menu_id++;
|
|
2626 menu->submenu_id = NULL;
|
|
2627
|
|
2628 #ifdef FEAT_TEAROFF
|
|
2629 if (STRNCMP(menu->name, TEAR_STRING, TEAR_LEN) == 0)
|
|
2630 {
|
|
2631 InsertMenu(parent->submenu_id, (UINT)idx, MF_BITMAP|MF_BYPOSITION,
|
|
2632 (UINT)menu->id, (LPCTSTR) s_htearbitmap);
|
|
2633 }
|
|
2634 else
|
|
2635 #endif
|
|
2636 #ifdef FEAT_TOOLBAR
|
|
2637 if (menu_is_toolbar(parent->name))
|
|
2638 {
|
|
2639 TBBUTTON newtb;
|
|
2640
|
|
2641 vim_memset(&newtb, 0, sizeof(newtb));
|
|
2642 if (menu_is_separator(menu->name))
|
|
2643 {
|
|
2644 newtb.iBitmap = 0;
|
|
2645 newtb.fsStyle = TBSTYLE_SEP;
|
|
2646 }
|
|
2647 else
|
|
2648 {
|
|
2649 newtb.iBitmap = get_toolbar_bitmap(menu);
|
|
2650 newtb.fsStyle = TBSTYLE_BUTTON;
|
|
2651 }
|
|
2652 newtb.idCommand = menu->id;
|
|
2653 newtb.fsState = TBSTATE_ENABLED;
|
|
2654 newtb.iString = 0;
|
|
2655 SendMessage(s_toolbarhwnd, TB_INSERTBUTTON, (WPARAM)idx,
|
|
2656 (LPARAM)&newtb);
|
|
2657 menu->submenu_id = (HMENU)-1;
|
|
2658 }
|
|
2659 else
|
|
2660 #endif
|
|
2661 {
|
|
2662 #ifdef FEAT_MBYTE
|
|
2663 WCHAR *wn = NULL;
|
|
2664 int n;
|
|
2665
|
|
2666 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
|
2667 {
|
|
2668 /* 'encoding' differs from active codepage: convert menu item name
|
|
2669 * and use wide function */
|
|
2670 wn = enc_to_ucs2(menu->name, NULL);
|
|
2671 if (wn != NULL)
|
|
2672 {
|
|
2673 n = InsertMenuW(parent->submenu_id, (UINT)idx,
|
|
2674 (menu_is_separator(menu->name)
|
|
2675 ? MF_SEPARATOR : MF_STRING) | MF_BYPOSITION,
|
|
2676 (UINT)menu->id, wn);
|
|
2677 vim_free(wn);
|
|
2678 if (n == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
2679 /* Failed, try using non-wide function. */
|
|
2680 wn = NULL;
|
|
2681 }
|
|
2682 }
|
|
2683 if (wn == NULL)
|
|
2684 #endif
|
|
2685 InsertMenu(parent->submenu_id, (UINT)idx,
|
|
2686 (menu_is_separator(menu->name) ? MF_SEPARATOR : MF_STRING)
|
|
2687 | MF_BYPOSITION,
|
|
2688 (UINT)menu->id, (LPCTSTR)menu->name);
|
|
2689 #ifdef FEAT_TEAROFF
|
|
2690 if (IsWindow(parent->tearoff_handle))
|
|
2691 rebuild_tearoff(parent);
|
|
2692 #endif
|
|
2693 }
|
|
2694 }
|
|
2695
|
|
2696 /*
|
|
2697 * Destroy the machine specific menu widget.
|
|
2698 */
|
|
2699 void
|
|
2700 gui_mch_destroy_menu(vimmenu_T *menu)
|
|
2701 {
|
|
2702 #ifdef FEAT_TOOLBAR
|
|
2703 /*
|
|
2704 * is this a toolbar button?
|
|
2705 */
|
|
2706 if (menu->submenu_id == (HMENU)-1)
|
|
2707 {
|
|
2708 int iButton;
|
|
2709
|
|
2710 iButton = (int)SendMessage(s_toolbarhwnd, TB_COMMANDTOINDEX,
|
|
2711 (WPARAM)menu->id, 0);
|
|
2712 SendMessage(s_toolbarhwnd, TB_DELETEBUTTON, (WPARAM)iButton, 0);
|
|
2713 }
|
|
2714 else
|
|
2715 #endif
|
|
2716 {
|
|
2717 if (menu->parent != NULL
|
|
2718 && menu_is_popup(menu->parent->dname)
|
|
2719 && menu->parent->submenu_id != NULL)
|
|
2720 RemoveMenu(menu->parent->submenu_id, menu->id, MF_BYCOMMAND);
|
|
2721 else
|
|
2722 RemoveMenu(s_menuBar, menu->id, MF_BYCOMMAND);
|
|
2723 if (menu->submenu_id != NULL)
|
|
2724 DestroyMenu(menu->submenu_id);
|
|
2725 #ifdef FEAT_TEAROFF
|
|
2726 if (IsWindow(menu->tearoff_handle))
|
|
2727 DestroyWindow(menu->tearoff_handle);
|
|
2728 if (menu->parent != NULL
|
|
2729 && menu->parent->children != NULL
|
|
2730 && IsWindow(menu->parent->tearoff_handle))
|
|
2731 {
|
|
2732 /* This menu must not show up when rebuilding the tearoff window. */
|
|
2733 menu->modes = 0;
|
|
2734 rebuild_tearoff(menu->parent);
|
|
2735 }
|
|
2736 #endif
|
|
2737 }
|
|
2738 }
|
|
2739
|
|
2740 #ifdef FEAT_TEAROFF
|
|
2741 static void
|
|
2742 rebuild_tearoff(vimmenu_T *menu)
|
|
2743 {
|
|
2744 /*hackish*/
|
|
2745 char_u tbuf[128];
|
|
2746 RECT trect;
|
|
2747 RECT rct;
|
|
2748 RECT roct;
|
|
2749 int x, y;
|
|
2750
|
|
2751 HWND thwnd = menu->tearoff_handle;
|
|
2752
|
|
2753 GetWindowText(thwnd, tbuf, 127);
|
|
2754 if (GetWindowRect(thwnd, &trect)
|
|
2755 && GetWindowRect(s_hwnd, &rct)
|
|
2756 && GetClientRect(s_hwnd, &roct))
|
|
2757 {
|
|
2758 x = trect.left - rct.left;
|
|
2759 y = (trect.top - rct.bottom + roct.bottom);
|
|
2760 }
|
|
2761 else
|
|
2762 {
|
|
2763 x = y = 0xffffL;
|
|
2764 }
|
|
2765 DestroyWindow(thwnd);
|
|
2766 if (menu->children != NULL)
|
|
2767 {
|
|
2768 gui_mch_tearoff(tbuf, menu, x, y);
|
|
2769 if (IsWindow(menu->tearoff_handle))
|
|
2770 (void) SetWindowPos(menu->tearoff_handle,
|
|
2771 NULL,
|
|
2772 (int)trect.left,
|
|
2773 (int)trect.top,
|
|
2774 0, 0,
|
|
2775 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
|
2776 }
|
|
2777 }
|
|
2778 #endif /* FEAT_TEAROFF */
|
|
2779
|
|
2780 /*
|
|
2781 * Make a menu either grey or not grey.
|
|
2782 */
|
|
2783 void
|
|
2784 gui_mch_menu_grey(
|
|
2785 vimmenu_T *menu,
|
|
2786 int grey)
|
|
2787 {
|
|
2788 #ifdef FEAT_TOOLBAR
|
|
2789 /*
|
|
2790 * is this a toolbar button?
|
|
2791 */
|
|
2792 if (menu->submenu_id == (HMENU)-1)
|
|
2793 {
|
|
2794 SendMessage(s_toolbarhwnd, TB_ENABLEBUTTON,
|
|
2795 (WPARAM)menu->id, (LPARAM) MAKELONG((grey ? FALSE : TRUE), 0) );
|
|
2796 }
|
|
2797 else
|
|
2798 #endif
|
|
2799 if (grey)
|
|
2800 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_GRAYED);
|
|
2801 else
|
|
2802 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_ENABLED);
|
|
2803
|
|
2804 #ifdef FEAT_TEAROFF
|
|
2805 if ((menu->parent != NULL) && (IsWindow(menu->parent->tearoff_handle)))
|
|
2806 {
|
|
2807 WORD menuID;
|
|
2808 HWND menuHandle;
|
|
2809
|
|
2810 /*
|
|
2811 * A tearoff button has changed state.
|
|
2812 */
|
|
2813 if (menu->children == NULL)
|
|
2814 menuID = (WORD)(menu->id);
|
|
2815 else
|
840
|
2816 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
|
7
|
2817 menuHandle = GetDlgItem(menu->parent->tearoff_handle, menuID);
|
|
2818 if (menuHandle)
|
|
2819 EnableWindow(menuHandle, !grey);
|
|
2820
|
|
2821 }
|
|
2822 #endif
|
|
2823 }
|
|
2824
|
|
2825 #endif /* FEAT_MENU */
|
|
2826
|
|
2827
|
|
2828 /* define some macros used to make the dialogue creation more readable */
|
|
2829
|
|
2830 #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1)
|
|
2831 #define add_word(x) *p++ = (x)
|
615
|
2832 #define add_long(x) dwp = (DWORD *)p; *dwp++ = (x); p = (WORD *)dwp
|
7
|
2833
|
|
2834 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
|
|
2835 /*
|
|
2836 * stuff for dialogs
|
|
2837 */
|
|
2838
|
|
2839 /*
|
|
2840 * The callback routine used by all the dialogs. Very simple. First,
|
|
2841 * acknowledges the INITDIALOG message so that Windows knows to do standard
|
|
2842 * dialog stuff (Return = default, Esc = cancel....) Second, if a button is
|
|
2843 * pressed, return that button's ID - IDCANCEL (2), which is the button's
|
|
2844 * number.
|
|
2845 */
|
323
|
2846 /*ARGSUSED*/
|
7
|
2847 static LRESULT CALLBACK
|
|
2848 dialog_callback(
|
|
2849 HWND hwnd,
|
|
2850 UINT message,
|
|
2851 WPARAM wParam,
|
|
2852 LPARAM lParam)
|
|
2853 {
|
|
2854 if (message == WM_INITDIALOG)
|
|
2855 {
|
|
2856 CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER));
|
|
2857 /* Set focus to the dialog. Set the default button, if specified. */
|
|
2858 (void)SetFocus(hwnd);
|
|
2859 if (dialog_default_button > IDCANCEL)
|
|
2860 (void)SetFocus(GetDlgItem(hwnd, dialog_default_button));
|
|
2861 return FALSE;
|
|
2862 }
|
|
2863
|
|
2864 if (message == WM_COMMAND)
|
|
2865 {
|
|
2866 int button = LOWORD(wParam);
|
|
2867
|
|
2868 /* Don't end the dialog if something was selected that was
|
|
2869 * not a button.
|
|
2870 */
|
|
2871 if (button >= DLG_NONBUTTON_CONTROL)
|
|
2872 return TRUE;
|
|
2873
|
|
2874 /* If the edit box exists, copy the string. */
|
|
2875 if (s_textfield != NULL)
|
|
2876 GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
|
|
2877 s_textfield, IOSIZE);
|
|
2878
|
|
2879 /*
|
|
2880 * Need to check for IDOK because if the user just hits Return to
|
|
2881 * accept the default value, some reason this is what we get.
|
|
2882 */
|
|
2883 if (button == IDOK)
|
|
2884 {
|
|
2885 if (dialog_default_button > IDCANCEL)
|
|
2886 EndDialog(hwnd, dialog_default_button);
|
|
2887 }
|
|
2888 else
|
|
2889 EndDialog(hwnd, button - IDCANCEL);
|
|
2890 return TRUE;
|
|
2891 }
|
|
2892
|
|
2893 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
|
|
2894 {
|
|
2895 EndDialog(hwnd, 0);
|
|
2896 return TRUE;
|
|
2897 }
|
|
2898 return FALSE;
|
|
2899 }
|
|
2900
|
|
2901 /*
|
|
2902 * Create a dialog dynamically from the parameter strings.
|
|
2903 * type = type of dialog (question, alert, etc.)
|
|
2904 * title = dialog title. may be NULL for default title.
|
|
2905 * message = text to display. Dialog sizes to accommodate it.
|
|
2906 * buttons = '\n' separated list of button captions, default first.
|
|
2907 * dfltbutton = number of default button.
|
|
2908 *
|
|
2909 * This routine returns 1 if the first button is pressed,
|
|
2910 * 2 for the second, etc.
|
|
2911 *
|
|
2912 * 0 indicates Esc was pressed.
|
|
2913 * -1 for unexpected error
|
|
2914 *
|
|
2915 * If stubbing out this fn, return 1.
|
|
2916 */
|
|
2917
|
|
2918 static const char_u *dlg_icons[] = /* must match names in resource file */
|
|
2919 {
|
|
2920 "IDR_VIM",
|
|
2921 "IDR_VIM_ERROR",
|
|
2922 "IDR_VIM_ALERT",
|
|
2923 "IDR_VIM_INFO",
|
|
2924 "IDR_VIM_QUESTION"
|
|
2925 };
|
|
2926
|
|
2927 int
|
|
2928 gui_mch_dialog(
|
|
2929 int type,
|
|
2930 char_u *title,
|
|
2931 char_u *message,
|
|
2932 char_u *buttons,
|
|
2933 int dfltbutton,
|
|
2934 char_u *textfield)
|
|
2935 {
|
|
2936 WORD *p, *pdlgtemplate, *pnumitems;
|
615
|
2937 DWORD *dwp;
|
7
|
2938 int numButtons;
|
|
2939 int *buttonWidths, *buttonPositions;
|
|
2940 int buttonYpos;
|
|
2941 int nchar, i;
|
|
2942 DWORD lStyle;
|
|
2943 int dlgwidth = 0;
|
|
2944 int dlgheight;
|
|
2945 int editboxheight;
|
|
2946 int horizWidth = 0;
|
|
2947 int msgheight;
|
|
2948 char_u *pstart;
|
|
2949 char_u *pend;
|
158
|
2950 char_u *last_white;
|
7
|
2951 char_u *tbuffer;
|
|
2952 RECT rect;
|
|
2953 HWND hwnd;
|
|
2954 HDC hdc;
|
|
2955 HFONT font, oldFont;
|
|
2956 TEXTMETRIC fontInfo;
|
|
2957 int fontHeight;
|
|
2958 int textWidth, minButtonWidth, messageWidth;
|
|
2959 int maxDialogWidth;
|
153
|
2960 int maxDialogHeight;
|
|
2961 int scroll_flag = 0;
|
7
|
2962 int vertical;
|
|
2963 int dlgPaddingX;
|
|
2964 int dlgPaddingY;
|
|
2965 #ifdef USE_SYSMENU_FONT
|
|
2966 LOGFONT lfSysmenu;
|
|
2967 int use_lfSysmenu = FALSE;
|
|
2968 #endif
|
158
|
2969 garray_T ga;
|
|
2970 int l;
|
7
|
2971
|
|
2972 #ifndef NO_CONSOLE
|
|
2973 /* Don't output anything in silent mode ("ex -s") */
|
|
2974 if (silent_mode)
|
|
2975 return dfltbutton; /* return default option */
|
|
2976 #endif
|
|
2977
|
153
|
2978 #if 0
|
7
|
2979 /* If there is no window yet, open it. */
|
|
2980 if (s_hwnd == NULL && gui_mch_init() == FAIL)
|
|
2981 return dfltbutton;
|
153
|
2982 #else
|
|
2983 if (s_hwnd == NULL)
|
|
2984 get_dialog_font_metrics();
|
|
2985 #endif
|
7
|
2986
|
|
2987 if ((type < 0) || (type > VIM_LAST_TYPE))
|
|
2988 type = 0;
|
|
2989
|
|
2990 /* allocate some memory for dialog template */
|
39
|
2991 /* TODO should compute this really */
|
158
|
2992 pdlgtemplate = p = (PWORD)LocalAlloc(LPTR,
|
840
|
2993 DLG_ALLOC_SIZE + STRLEN(message) * 2);
|
7
|
2994
|
|
2995 if (p == NULL)
|
|
2996 return -1;
|
|
2997
|
|
2998 /*
|
|
2999 * make a copy of 'buttons' to fiddle with it. complier grizzles because
|
|
3000 * vim_strsave() doesn't take a const arg (why not?), so cast away the
|
|
3001 * const.
|
|
3002 */
|
|
3003 tbuffer = vim_strsave(buttons);
|
|
3004 if (tbuffer == NULL)
|
|
3005 return -1;
|
|
3006
|
|
3007 --dfltbutton; /* Change from one-based to zero-based */
|
|
3008
|
|
3009 /* Count buttons */
|
|
3010 numButtons = 1;
|
|
3011 for (i = 0; tbuffer[i] != '\0'; i++)
|
|
3012 {
|
|
3013 if (tbuffer[i] == DLG_BUTTON_SEP)
|
|
3014 numButtons++;
|
|
3015 }
|
|
3016 if (dfltbutton >= numButtons)
|
|
3017 dfltbutton = -1;
|
|
3018
|
|
3019 /* Allocate array to hold the width of each button */
|
537
|
3020 buttonWidths = (int *)lalloc(numButtons * sizeof(int), TRUE);
|
7
|
3021 if (buttonWidths == NULL)
|
|
3022 return -1;
|
|
3023
|
|
3024 /* Allocate array to hold the X position of each button */
|
537
|
3025 buttonPositions = (int *)lalloc(numButtons * sizeof(int), TRUE);
|
7
|
3026 if (buttonPositions == NULL)
|
|
3027 return -1;
|
|
3028
|
|
3029 /*
|
|
3030 * Calculate how big the dialog must be.
|
|
3031 */
|
|
3032 hwnd = GetDesktopWindow();
|
|
3033 hdc = GetWindowDC(hwnd);
|
|
3034 #ifdef USE_SYSMENU_FONT
|
|
3035 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
|
3036 {
|
|
3037 font = CreateFontIndirect(&lfSysmenu);
|
|
3038 use_lfSysmenu = TRUE;
|
|
3039 }
|
|
3040 else
|
|
3041 #endif
|
|
3042 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
3043 VARIABLE_PITCH , DLG_FONT_NAME);
|
|
3044 if (s_usenewlook)
|
|
3045 {
|
|
3046 oldFont = SelectFont(hdc, font);
|
|
3047 dlgPaddingX = DLG_PADDING_X;
|
|
3048 dlgPaddingY = DLG_PADDING_Y;
|
|
3049 }
|
|
3050 else
|
|
3051 {
|
|
3052 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
|
|
3053 dlgPaddingX = DLG_OLD_STYLE_PADDING_X;
|
|
3054 dlgPaddingY = DLG_OLD_STYLE_PADDING_Y;
|
|
3055 }
|
|
3056 GetTextMetrics(hdc, &fontInfo);
|
|
3057 fontHeight = fontInfo.tmHeight;
|
|
3058
|
|
3059 /* Minimum width for horizontal button */
|
|
3060 minButtonWidth = GetTextWidth(hdc, "Cancel", 6);
|
|
3061
|
|
3062 /* Maximum width of a dialog, if possible */
|
158
|
3063 if (s_hwnd == NULL)
|
|
3064 {
|
|
3065 RECT workarea_rect;
|
|
3066
|
636
|
3067 /* We don't have a window, use the desktop area. */
|
158
|
3068 get_work_area(&workarea_rect);
|
|
3069 maxDialogWidth = workarea_rect.right - workarea_rect.left - 100;
|
|
3070 if (maxDialogWidth > 600)
|
|
3071 maxDialogWidth = 600;
|
|
3072 maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 100;
|
|
3073 }
|
|
3074 else
|
|
3075 {
|
|
3076 /* Use our own window for the size, unless it's very small. */
|
|
3077 GetWindowRect(s_hwnd, &rect);
|
|
3078 maxDialogWidth = rect.right - rect.left
|
|
3079 - GetSystemMetrics(SM_CXFRAME) * 2;
|
|
3080 if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
|
|
3081 maxDialogWidth = DLG_MIN_MAX_WIDTH;
|
|
3082
|
|
3083 maxDialogHeight = rect.bottom - rect.top
|
|
3084 - GetSystemMetrics(SM_CXFRAME) * 2;
|
|
3085 if (maxDialogHeight < DLG_MIN_MAX_HEIGHT)
|
|
3086 maxDialogHeight = DLG_MIN_MAX_HEIGHT;
|
|
3087 }
|
|
3088
|
|
3089 /* Set dlgwidth to width of message.
|
|
3090 * Copy the message into "ga", changing NL to CR-NL and inserting line
|
|
3091 * breaks where needed. */
|
7
|
3092 pstart = message;
|
|
3093 messageWidth = 0;
|
158
|
3094 msgheight = 0;
|
|
3095 ga_init2(&ga, sizeof(char), 500);
|
7
|
3096 do
|
|
3097 {
|
158
|
3098 msgheight += fontHeight; /* at least one line */
|
|
3099
|
|
3100 /* Need to figure out where to break the string. The system does it
|
|
3101 * at a word boundary, which would mean we can't compute the number of
|
|
3102 * wrapped lines. */
|
|
3103 textWidth = 0;
|
|
3104 last_white = NULL;
|
|
3105 for (pend = pstart; *pend != NUL && *pend != '\n'; )
|
153
|
3106 {
|
158
|
3107 #ifdef FEAT_MBYTE
|
474
|
3108 l = (*mb_ptr2len)(pend);
|
158
|
3109 #else
|
|
3110 l = 1;
|
|
3111 #endif
|
|
3112 if (l == 1 && vim_iswhite(*pend)
|
|
3113 && textWidth > maxDialogWidth * 3 / 4)
|
|
3114 last_white = pend;
|
|
3115 textWidth += GetTextWidth(hdc, pend, l);
|
|
3116 if (textWidth >= maxDialogWidth)
|
153
|
3117 {
|
158
|
3118 /* Line will wrap. */
|
|
3119 messageWidth = maxDialogWidth;
|
153
|
3120 msgheight += fontHeight;
|
158
|
3121 textWidth = 0;
|
|
3122
|
|
3123 if (last_white != NULL)
|
|
3124 {
|
|
3125 /* break the line just after a space */
|
835
|
3126 ga.ga_len -= (int)(pend - (last_white + 1));
|
158
|
3127 pend = last_white + 1;
|
|
3128 last_white = NULL;
|
|
3129 }
|
|
3130 ga_append(&ga, '\r');
|
|
3131 ga_append(&ga, '\n');
|
|
3132 continue;
|
153
|
3133 }
|
158
|
3134
|
|
3135 while (--l >= 0)
|
|
3136 ga_append(&ga, *pend++);
|
153
|
3137 }
|
158
|
3138 if (textWidth > messageWidth)
|
7
|
3139 messageWidth = textWidth;
|
158
|
3140
|
|
3141 ga_append(&ga, '\r');
|
|
3142 ga_append(&ga, '\n');
|
7
|
3143 pstart = pend + 1;
|
|
3144 } while (*pend != NUL);
|
153
|
3145
|
158
|
3146 if (ga.ga_data != NULL)
|
|
3147 message = ga.ga_data;
|
|
3148
|
153
|
3149 messageWidth += 10; /* roundoff space */
|
|
3150
|
|
3151 /* Restrict the size to a maximum. Causes a scrollbar to show up. */
|
|
3152 if (msgheight > maxDialogHeight)
|
|
3153 {
|
|
3154 msgheight = maxDialogHeight;
|
|
3155 scroll_flag = WS_VSCROLL;
|
158
|
3156 messageWidth += GetSystemMetrics(SM_CXVSCROLL);
|
153
|
3157 }
|
7
|
3158
|
|
3159 /* Add width of icon to dlgwidth, and some space */
|
153
|
3160 dlgwidth = messageWidth + DLG_ICON_WIDTH + 3 * dlgPaddingX;
|
7
|
3161
|
|
3162 if (msgheight < DLG_ICON_HEIGHT)
|
|
3163 msgheight = DLG_ICON_HEIGHT;
|
|
3164
|
|
3165 /*
|
|
3166 * Check button names. A long one will make the dialog wider.
|
|
3167 */
|
|
3168 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
|
|
3169 if (!vertical)
|
|
3170 {
|
|
3171 // Place buttons horizontally if they fit.
|
|
3172 horizWidth = dlgPaddingX;
|
|
3173 pstart = tbuffer;
|
|
3174 i = 0;
|
|
3175 do
|
|
3176 {
|
|
3177 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
|
|
3178 if (pend == NULL)
|
|
3179 pend = pstart + STRLEN(pstart); // Last button name.
|
|
3180 textWidth = GetTextWidth(hdc, pstart, (int)(pend - pstart));
|
|
3181 if (textWidth < minButtonWidth)
|
|
3182 textWidth = minButtonWidth;
|
|
3183 textWidth += dlgPaddingX; /* Padding within button */
|
|
3184 buttonWidths[i] = textWidth;
|
|
3185 buttonPositions[i++] = horizWidth;
|
|
3186 horizWidth += textWidth + dlgPaddingX; /* Pad between buttons */
|
|
3187 pstart = pend + 1;
|
|
3188 } while (*pend != NUL);
|
|
3189
|
|
3190 if (horizWidth > maxDialogWidth)
|
|
3191 vertical = TRUE; // Too wide to fit on the screen.
|
|
3192 else if (horizWidth > dlgwidth)
|
|
3193 dlgwidth = horizWidth;
|
|
3194 }
|
|
3195
|
|
3196 if (vertical)
|
|
3197 {
|
|
3198 // Stack buttons vertically.
|
|
3199 pstart = tbuffer;
|
|
3200 do
|
|
3201 {
|
|
3202 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
|
|
3203 if (pend == NULL)
|
|
3204 pend = pstart + STRLEN(pstart); // Last button name.
|
|
3205 textWidth = GetTextWidth(hdc, pstart, (int)(pend - pstart));
|
|
3206 textWidth += dlgPaddingX; /* Padding within button */
|
|
3207 textWidth += DLG_VERT_PADDING_X * 2; /* Padding around button */
|
|
3208 if (textWidth > dlgwidth)
|
|
3209 dlgwidth = textWidth;
|
|
3210 pstart = pend + 1;
|
|
3211 } while (*pend != NUL);
|
|
3212 }
|
|
3213
|
|
3214 if (dlgwidth < DLG_MIN_WIDTH)
|
|
3215 dlgwidth = DLG_MIN_WIDTH; /* Don't allow a really thin dialog!*/
|
|
3216
|
|
3217 /* start to fill in the dlgtemplate information. addressing by WORDs */
|
|
3218 if (s_usenewlook)
|
|
3219 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE |DS_SETFONT;
|
|
3220 else
|
|
3221 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE;
|
|
3222
|
|
3223 add_long(lStyle);
|
|
3224 add_long(0); // (lExtendedStyle)
|
|
3225 pnumitems = p; /*save where the number of items must be stored*/
|
|
3226 add_word(0); // NumberOfItems(will change later)
|
|
3227 add_word(10); // x
|
|
3228 add_word(10); // y
|
|
3229 add_word(PixelToDialogX(dlgwidth)); // cx
|
|
3230
|
|
3231 // Dialog height.
|
|
3232 if (vertical)
|
|
3233 dlgheight = msgheight + 2 * dlgPaddingY +
|
|
3234 DLG_VERT_PADDING_Y + 2 * fontHeight * numButtons;
|
|
3235 else
|
|
3236 dlgheight = msgheight + 3 * dlgPaddingY + 2 * fontHeight;
|
|
3237
|
|
3238 // Dialog needs to be taller if contains an edit box.
|
|
3239 editboxheight = fontHeight + dlgPaddingY + 4 * DLG_VERT_PADDING_Y;
|
|
3240 if (textfield != NULL)
|
|
3241 dlgheight += editboxheight;
|
|
3242
|
|
3243 add_word(PixelToDialogY(dlgheight));
|
|
3244
|
|
3245 add_word(0); // Menu
|
|
3246 add_word(0); // Class
|
|
3247
|
|
3248 /* copy the title of the dialog */
|
|
3249 nchar = nCopyAnsiToWideChar(p, (title ?
|
|
3250 (LPSTR)title :
|
|
3251 (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
|
|
3252 p += nchar;
|
|
3253
|
|
3254 if (s_usenewlook)
|
|
3255 {
|
|
3256 /* do the font, since DS_3DLOOK doesn't work properly */
|
|
3257 #ifdef USE_SYSMENU_FONT
|
|
3258 if (use_lfSysmenu)
|
|
3259 {
|
|
3260 /* point size */
|
|
3261 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
|
|
3262 GetDeviceCaps(hdc, LOGPIXELSY));
|
|
3263 nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
|
|
3264 }
|
|
3265 else
|
|
3266 #endif
|
|
3267 {
|
|
3268 *p++ = DLG_FONT_POINT_SIZE; // point size
|
|
3269 nchar = nCopyAnsiToWideChar(p, TEXT(DLG_FONT_NAME));
|
|
3270 }
|
|
3271 p += nchar;
|
|
3272 }
|
|
3273
|
|
3274 buttonYpos = msgheight + 2 * dlgPaddingY;
|
|
3275
|
|
3276 if (textfield != NULL)
|
|
3277 buttonYpos += editboxheight;
|
|
3278
|
|
3279 pstart = tbuffer;
|
|
3280 if (!vertical)
|
|
3281 horizWidth = (dlgwidth - horizWidth) / 2; /* Now it's X offset */
|
|
3282 for (i = 0; i < numButtons; i++)
|
|
3283 {
|
|
3284 /* get end of this button. */
|
|
3285 for ( pend = pstart;
|
|
3286 *pend && (*pend != DLG_BUTTON_SEP);
|
|
3287 pend++)
|
|
3288 ;
|
|
3289
|
|
3290 if (*pend)
|
|
3291 *pend = '\0';
|
|
3292
|
|
3293 /*
|
|
3294 * old NOTE:
|
|
3295 * setting the BS_DEFPUSHBUTTON style doesn't work because Windows sets
|
|
3296 * the focus to the first tab-able button and in so doing makes that
|
|
3297 * the default!! Grrr. Workaround: Make the default button the only
|
|
3298 * one with WS_TABSTOP style. Means user can't tab between buttons, but
|
|
3299 * he/she can use arrow keys.
|
|
3300 *
|
|
3301 * new NOTE: BS_DEFPUSHBUTTON is required to be able to select the
|
|
3302 * right buttun when hitting <Enter>. E.g., for the ":confirm quit"
|
|
3303 * dialog. Also needed for when the textfield is the default control.
|
|
3304 * It appears to work now (perhaps not on Win95?).
|
|
3305 */
|
|
3306 if (vertical)
|
|
3307 {
|
|
3308 p = add_dialog_element(p,
|
|
3309 (i == dfltbutton
|
|
3310 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
|
|
3311 PixelToDialogX(DLG_VERT_PADDING_X),
|
|
3312 PixelToDialogY(buttonYpos /* TBK */
|
|
3313 + 2 * fontHeight * i),
|
|
3314 PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X),
|
|
3315 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
|
|
3316 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, pstart);
|
|
3317 }
|
|
3318 else
|
|
3319 {
|
|
3320 p = add_dialog_element(p,
|
|
3321 (i == dfltbutton
|
|
3322 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
|
|
3323 PixelToDialogX(horizWidth + buttonPositions[i]),
|
|
3324 PixelToDialogY(buttonYpos), /* TBK */
|
|
3325 PixelToDialogX(buttonWidths[i]),
|
|
3326 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
|
|
3327 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, pstart);
|
|
3328 }
|
|
3329 pstart = pend + 1; /*next button*/
|
|
3330 }
|
|
3331 *pnumitems += numButtons;
|
|
3332
|
|
3333 /* Vim icon */
|
|
3334 p = add_dialog_element(p, SS_ICON,
|
|
3335 PixelToDialogX(dlgPaddingX),
|
|
3336 PixelToDialogY(dlgPaddingY),
|
|
3337 PixelToDialogX(DLG_ICON_WIDTH),
|
|
3338 PixelToDialogY(DLG_ICON_HEIGHT),
|
|
3339 DLG_NONBUTTON_CONTROL + 0, (WORD)0x0082,
|
|
3340 dlg_icons[type]);
|
|
3341
|
153
|
3342 #if 0
|
7
|
3343 /* Dialog message */
|
|
3344 p = add_dialog_element(p, SS_LEFT,
|
|
3345 PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH),
|
|
3346 PixelToDialogY(dlgPaddingY),
|
|
3347 (WORD)(PixelToDialogX(messageWidth) + 1),
|
|
3348 PixelToDialogY(msgheight),
|
|
3349 DLG_NONBUTTON_CONTROL + 1, (WORD)0x0082, message);
|
153
|
3350 #else
|
|
3351 /* Dialog message */
|
|
3352 p = add_dialog_element(p, ES_LEFT|scroll_flag|ES_MULTILINE|ES_READONLY,
|
|
3353 PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH),
|
|
3354 PixelToDialogY(dlgPaddingY),
|
|
3355 (WORD)(PixelToDialogX(messageWidth) + 1),
|
|
3356 PixelToDialogY(msgheight),
|
|
3357 DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, message);
|
|
3358 #endif
|
7
|
3359
|
|
3360 /* Edit box */
|
|
3361 if (textfield != NULL)
|
|
3362 {
|
|
3363 p = add_dialog_element(p, ES_LEFT|ES_AUTOHSCROLL|WS_TABSTOP|WS_BORDER,
|
|
3364 PixelToDialogX(2 * dlgPaddingX),
|
|
3365 PixelToDialogY(2 * dlgPaddingY + msgheight),
|
|
3366 PixelToDialogX(dlgwidth - 4 * dlgPaddingX),
|
|
3367 PixelToDialogY(fontHeight + dlgPaddingY),
|
|
3368 DLG_NONBUTTON_CONTROL + 2, (WORD)0x0081, textfield);
|
|
3369 *pnumitems += 1;
|
|
3370 }
|
|
3371
|
|
3372 *pnumitems += 2;
|
|
3373
|
|
3374 SelectFont(hdc, oldFont);
|
|
3375 DeleteObject(font);
|
|
3376 ReleaseDC(hwnd, hdc);
|
|
3377
|
|
3378 /* Let the dialog_callback() function know which button to make default
|
|
3379 * If we have an edit box, make that the default. We also need to tell
|
|
3380 * dialog_callback() if this dialog contains an edit box or not. We do
|
|
3381 * this by setting s_textfield if it does.
|
|
3382 */
|
|
3383 if (textfield != NULL)
|
|
3384 {
|
|
3385 dialog_default_button = DLG_NONBUTTON_CONTROL + 2;
|
|
3386 s_textfield = textfield;
|
|
3387 }
|
|
3388 else
|
|
3389 {
|
|
3390 dialog_default_button = IDCANCEL + 1 + dfltbutton;
|
|
3391 s_textfield = NULL;
|
|
3392 }
|
|
3393
|
|
3394 /* show the dialog box modally and get a return value */
|
|
3395 nchar = (int)DialogBoxIndirect(
|
|
3396 s_hinst,
|
|
3397 (LPDLGTEMPLATE)pdlgtemplate,
|
|
3398 s_hwnd,
|
|
3399 (DLGPROC)dialog_callback);
|
|
3400
|
|
3401 LocalFree(LocalHandle(pdlgtemplate));
|
|
3402 vim_free(tbuffer);
|
|
3403 vim_free(buttonWidths);
|
|
3404 vim_free(buttonPositions);
|
158
|
3405 vim_free(ga.ga_data);
|
7
|
3406
|
|
3407 /* Focus back to our window (for when MDI is used). */
|
|
3408 (void)SetFocus(s_hwnd);
|
|
3409
|
|
3410 return nchar;
|
|
3411 }
|
|
3412
|
|
3413 #endif /* FEAT_GUI_DIALOG */
|
840
|
3414
|
7
|
3415 /*
|
|
3416 * Put a simple element (basic class) onto a dialog template in memory.
|
|
3417 * return a pointer to where the next item should be added.
|
|
3418 *
|
|
3419 * parameters:
|
|
3420 * lStyle = additional style flags
|
|
3421 * (be careful, NT3.51 & Win32s will ignore the new ones)
|
|
3422 * x,y = x & y positions IN DIALOG UNITS
|
|
3423 * w,h = width and height IN DIALOG UNITS
|
|
3424 * Id = ID used in messages
|
|
3425 * clss = class ID, e.g 0x0080 for a button, 0x0082 for a static
|
|
3426 * caption = usually text or resource name
|
|
3427 *
|
|
3428 * TODO: use the length information noted here to enable the dialog creation
|
|
3429 * routines to work out more exactly how much memory they need to alloc.
|
|
3430 */
|
|
3431 static PWORD
|
|
3432 add_dialog_element(
|
|
3433 PWORD p,
|
|
3434 DWORD lStyle,
|
|
3435 WORD x,
|
|
3436 WORD y,
|
|
3437 WORD w,
|
|
3438 WORD h,
|
|
3439 WORD Id,
|
|
3440 WORD clss,
|
|
3441 const char *caption)
|
|
3442 {
|
|
3443 int nchar;
|
|
3444
|
|
3445 p = lpwAlign(p); /* Align to dword boundary*/
|
|
3446 lStyle = lStyle | WS_VISIBLE | WS_CHILD;
|
|
3447 *p++ = LOWORD(lStyle);
|
|
3448 *p++ = HIWORD(lStyle);
|
|
3449 *p++ = 0; // LOWORD (lExtendedStyle)
|
|
3450 *p++ = 0; // HIWORD (lExtendedStyle)
|
|
3451 *p++ = x;
|
|
3452 *p++ = y;
|
|
3453 *p++ = w;
|
|
3454 *p++ = h;
|
|
3455 *p++ = Id; //9 or 10 words in all
|
|
3456
|
|
3457 *p++ = (WORD)0xffff;
|
|
3458 *p++ = clss; //2 more here
|
|
3459
|
|
3460 nchar = nCopyAnsiToWideChar(p, (LPSTR)caption); //strlen(caption)+1
|
|
3461 p += nchar;
|
|
3462
|
|
3463 *p++ = 0; // advance pointer over nExtraStuff WORD - 2 more
|
|
3464
|
|
3465 return p; //total = 15+ (strlen(caption)) words
|
|
3466 // = 30 + 2(strlen(caption) bytes reqd
|
|
3467 }
|
|
3468
|
|
3469
|
|
3470 /*
|
|
3471 * Helper routine. Take an input pointer, return closest pointer that is
|
|
3472 * aligned on a DWORD (4 byte) boundary. Taken from the Win32SDK samples.
|
|
3473 */
|
|
3474 static LPWORD
|
|
3475 lpwAlign(
|
|
3476 LPWORD lpIn)
|
|
3477 {
|
840
|
3478 long_u ul;
|
|
3479
|
|
3480 ul = (long_u)lpIn;
|
7
|
3481 ul += 3;
|
|
3482 ul >>= 2;
|
|
3483 ul <<= 2;
|
|
3484 return (LPWORD)ul;
|
|
3485 }
|
|
3486
|
|
3487 /*
|
|
3488 * Helper routine. Takes second parameter as Ansi string, copies it to first
|
|
3489 * parameter as wide character (16-bits / char) string, and returns integer
|
|
3490 * number of wide characters (words) in string (including the trailing wide
|
|
3491 * char NULL). Partly taken from the Win32SDK samples.
|
|
3492 */
|
|
3493 static int
|
|
3494 nCopyAnsiToWideChar(
|
|
3495 LPWORD lpWCStr,
|
|
3496 LPSTR lpAnsiIn)
|
|
3497 {
|
|
3498 int nChar = 0;
|
|
3499 #ifdef FEAT_MBYTE
|
|
3500 int len = lstrlen(lpAnsiIn) + 1; /* include NUL character */
|
|
3501 int i;
|
|
3502 WCHAR *wn;
|
|
3503
|
|
3504 if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
|
|
3505 {
|
|
3506 /* Not a codepage, use our own conversion function. */
|
|
3507 wn = enc_to_ucs2(lpAnsiIn, NULL);
|
|
3508 if (wn != NULL)
|
|
3509 {
|
|
3510 wcscpy(lpWCStr, wn);
|
835
|
3511 nChar = (int)wcslen(wn) + 1;
|
7
|
3512 vim_free(wn);
|
|
3513 }
|
|
3514 }
|
|
3515 if (nChar == 0)
|
|
3516 /* Use Win32 conversion function. */
|
|
3517 nChar = MultiByteToWideChar(
|
|
3518 enc_codepage > 0 ? enc_codepage : CP_ACP,
|
|
3519 MB_PRECOMPOSED,
|
|
3520 lpAnsiIn, len,
|
|
3521 lpWCStr, len);
|
|
3522 for (i = 0; i < nChar; ++i)
|
|
3523 if (lpWCStr[i] == (WORD)'\t') /* replace tabs with spaces */
|
|
3524 lpWCStr[i] = (WORD)' ';
|
|
3525 #else
|
|
3526 do
|
|
3527 {
|
|
3528 if (*lpAnsiIn == '\t')
|
|
3529 *lpWCStr++ = (WORD)' ';
|
|
3530 else
|
|
3531 *lpWCStr++ = (WORD)*lpAnsiIn;
|
|
3532 nChar++;
|
|
3533 } while (*lpAnsiIn++);
|
|
3534 #endif
|
|
3535
|
|
3536 return nChar;
|
|
3537 }
|
|
3538
|
|
3539
|
|
3540 #ifdef FEAT_TEAROFF
|
|
3541 /*
|
|
3542 * The callback function for all the modeless dialogs that make up the
|
|
3543 * "tearoff menus" Very simple - forward button presses (to fool Vim into
|
|
3544 * thinking its menus have been clicked), and go away when closed.
|
|
3545 */
|
|
3546 static LRESULT CALLBACK
|
|
3547 tearoff_callback(
|
|
3548 HWND hwnd,
|
|
3549 UINT message,
|
|
3550 WPARAM wParam,
|
|
3551 LPARAM lParam)
|
|
3552 {
|
|
3553 if (message == WM_INITDIALOG)
|
|
3554 return (TRUE);
|
|
3555
|
|
3556 /* May show the mouse pointer again. */
|
|
3557 HandleMouseHide(message, lParam);
|
|
3558
|
|
3559 if (message == WM_COMMAND)
|
|
3560 {
|
|
3561 if ((WORD)(LOWORD(wParam)) & 0x8000)
|
|
3562 {
|
|
3563 POINT mp;
|
|
3564 RECT rect;
|
|
3565
|
|
3566 if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
|
|
3567 {
|
|
3568 (void)TrackPopupMenu(
|
840
|
3569 (HMENU)(long_u)(LOWORD(wParam) ^ 0x8000),
|
7
|
3570 TPM_LEFTALIGN | TPM_LEFTBUTTON,
|
|
3571 (int)rect.right - 8,
|
|
3572 (int)mp.y,
|
|
3573 (int)0, /*reserved param*/
|
|
3574 s_hwnd,
|
|
3575 NULL);
|
|
3576 /*
|
|
3577 * NOTE: The pop-up menu can eat the mouse up event.
|
|
3578 * We deal with this in normal.c.
|
|
3579 */
|
|
3580 }
|
|
3581 }
|
|
3582 else
|
|
3583 /* Pass on messages to the main Vim window */
|
|
3584 PostMessage(s_hwnd, WM_COMMAND, LOWORD(wParam), 0);
|
|
3585 /*
|
|
3586 * Give main window the focus back: this is so after
|
|
3587 * choosing a tearoff button you can start typing again
|
|
3588 * straight away.
|
|
3589 */
|
|
3590 (void)SetFocus(s_hwnd);
|
|
3591 return TRUE;
|
|
3592 }
|
|
3593 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
|
|
3594 {
|
|
3595 DestroyWindow(hwnd);
|
|
3596 return TRUE;
|
|
3597 }
|
|
3598
|
|
3599 /* When moved around, give main window the focus back. */
|
|
3600 if (message == WM_EXITSIZEMOVE)
|
|
3601 (void)SetActiveWindow(s_hwnd);
|
|
3602
|
|
3603 return FALSE;
|
|
3604 }
|
|
3605 #endif
|
|
3606
|
|
3607
|
|
3608 /*
|
|
3609 * Decide whether to use the "new look" (small, non-bold font) or the "old
|
|
3610 * look" (big, clanky font) for dialogs, and work out a few values for use
|
|
3611 * later accordingly.
|
|
3612 */
|
|
3613 static void
|
|
3614 get_dialog_font_metrics(void)
|
|
3615 {
|
|
3616 HDC hdc;
|
|
3617 HFONT hfontTools = 0;
|
|
3618 DWORD dlgFontSize;
|
|
3619 SIZE size;
|
|
3620 #ifdef USE_SYSMENU_FONT
|
|
3621 LOGFONT lfSysmenu;
|
|
3622 #endif
|
|
3623
|
|
3624 s_usenewlook = FALSE;
|
|
3625
|
|
3626 /*
|
|
3627 * For NT3.51 and Win32s, we stick with the old look
|
|
3628 * because it matches everything else.
|
|
3629 */
|
|
3630 if (!is_winnt_3())
|
|
3631 {
|
|
3632 #ifdef USE_SYSMENU_FONT
|
|
3633 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
|
3634 hfontTools = CreateFontIndirect(&lfSysmenu);
|
|
3635 else
|
|
3636 #endif
|
|
3637 hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
|
|
3638 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME);
|
|
3639
|
|
3640 if (hfontTools)
|
|
3641 {
|
|
3642 hdc = GetDC(s_hwnd);
|
|
3643 SelectObject(hdc, hfontTools);
|
|
3644 /*
|
|
3645 * GetTextMetrics() doesn't return the right value in
|
|
3646 * tmAveCharWidth, so we have to figure out the dialog base units
|
|
3647 * ourselves.
|
|
3648 */
|
|
3649 GetTextExtentPoint(hdc,
|
|
3650 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
3651 52, &size);
|
|
3652 ReleaseDC(s_hwnd, hdc);
|
|
3653
|
|
3654 s_dlgfntwidth = (WORD)((size.cx / 26 + 1) / 2);
|
|
3655 s_dlgfntheight = (WORD)size.cy;
|
|
3656 s_usenewlook = TRUE;
|
|
3657 }
|
|
3658 }
|
|
3659
|
|
3660 if (!s_usenewlook)
|
|
3661 {
|
|
3662 dlgFontSize = GetDialogBaseUnits(); /* fall back to big old system*/
|
|
3663 s_dlgfntwidth = LOWORD(dlgFontSize);
|
|
3664 s_dlgfntheight = HIWORD(dlgFontSize);
|
|
3665 }
|
|
3666 }
|
|
3667
|
|
3668 #if defined(FEAT_MENU) && defined(FEAT_TEAROFF)
|
|
3669 /*
|
|
3670 * Create a pseudo-"tearoff menu" based on the child
|
|
3671 * items of a given menu pointer.
|
|
3672 */
|
|
3673 static void
|
|
3674 gui_mch_tearoff(
|
|
3675 char_u *title,
|
|
3676 vimmenu_T *menu,
|
|
3677 int initX,
|
|
3678 int initY)
|
|
3679 {
|
|
3680 WORD *p, *pdlgtemplate, *pnumitems, *ptrueheight;
|
|
3681 int template_len;
|
|
3682 int nchar, textWidth, submenuWidth;
|
|
3683 DWORD lStyle;
|
|
3684 DWORD lExtendedStyle;
|
|
3685 WORD dlgwidth;
|
|
3686 WORD menuID;
|
|
3687 vimmenu_T *pmenu;
|
|
3688 vimmenu_T *the_menu = menu;
|
|
3689 HWND hwnd;
|
|
3690 HDC hdc;
|
|
3691 HFONT font, oldFont;
|
|
3692 int col, spaceWidth, len;
|
|
3693 int columnWidths[2];
|
|
3694 char_u *label, *text;
|
|
3695 int acLen = 0;
|
|
3696 int nameLen;
|
|
3697 int padding0, padding1, padding2 = 0;
|
|
3698 int sepPadding=0;
|
87
|
3699 int x;
|
|
3700 int y;
|
7
|
3701 #ifdef USE_SYSMENU_FONT
|
|
3702 LOGFONT lfSysmenu;
|
|
3703 int use_lfSysmenu = FALSE;
|
|
3704 #endif
|
|
3705
|
|
3706 /*
|
|
3707 * If this menu is already torn off, move it to the mouse position.
|
|
3708 */
|
|
3709 if (IsWindow(menu->tearoff_handle))
|
|
3710 {
|
|
3711 POINT mp;
|
|
3712 if (GetCursorPos((LPPOINT)&mp))
|
|
3713 {
|
|
3714 SetWindowPos(menu->tearoff_handle, NULL, mp.x, mp.y, 0, 0,
|
|
3715 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
|
|
3716 }
|
|
3717 return;
|
|
3718 }
|
|
3719
|
|
3720 /*
|
|
3721 * Create a new tearoff.
|
|
3722 */
|
|
3723 if (*title == MNU_HIDDEN_CHAR)
|
|
3724 title++;
|
|
3725
|
|
3726 /* Allocate memory to store the dialog template. It's made bigger when
|
|
3727 * needed. */
|
|
3728 template_len = DLG_ALLOC_SIZE;
|
|
3729 pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len);
|
|
3730 if (p == NULL)
|
|
3731 return;
|
|
3732
|
|
3733 hwnd = GetDesktopWindow();
|
|
3734 hdc = GetWindowDC(hwnd);
|
|
3735 #ifdef USE_SYSMENU_FONT
|
|
3736 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
|
|
3737 {
|
|
3738 font = CreateFontIndirect(&lfSysmenu);
|
|
3739 use_lfSysmenu = TRUE;
|
|
3740 }
|
|
3741 else
|
|
3742 #endif
|
|
3743 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
3744 VARIABLE_PITCH , DLG_FONT_NAME);
|
|
3745 if (s_usenewlook)
|
|
3746 oldFont = SelectFont(hdc, font);
|
|
3747 else
|
|
3748 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
|
|
3749
|
|
3750 /* Calculate width of a single space. Used for padding columns to the
|
|
3751 * right width. */
|
|
3752 spaceWidth = GetTextWidth(hdc, " ", 1);
|
|
3753
|
|
3754 /* Figure out max width of the text column, the accelerator column and the
|
|
3755 * optional submenu column. */
|
|
3756 submenuWidth = 0;
|
|
3757 for (col = 0; col < 2; col++)
|
|
3758 {
|
|
3759 columnWidths[col] = 0;
|
|
3760 for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next)
|
|
3761 {
|
|
3762 /* Use "dname" here to compute the width of the visible text. */
|
|
3763 text = (col == 0) ? pmenu->dname : pmenu->actext;
|
|
3764 if (text != NULL && *text != NUL)
|
|
3765 {
|
|
3766 textWidth = GetTextWidthEnc(hdc, text, (int)STRLEN(text));
|
|
3767 if (textWidth > columnWidths[col])
|
|
3768 columnWidths[col] = textWidth;
|
|
3769 }
|
|
3770 if (pmenu->children != NULL)
|
|
3771 submenuWidth = TEAROFF_COLUMN_PADDING * spaceWidth;
|
|
3772 }
|
|
3773 }
|
|
3774 if (columnWidths[1] == 0)
|
|
3775 {
|
|
3776 /* no accelerators */
|
|
3777 if (submenuWidth != 0)
|
|
3778 columnWidths[0] += submenuWidth;
|
|
3779 else
|
|
3780 columnWidths[0] += spaceWidth;
|
|
3781 }
|
|
3782 else
|
|
3783 {
|
|
3784 /* there is an accelerator column */
|
|
3785 columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth;
|
|
3786 columnWidths[1] += submenuWidth;
|
|
3787 }
|
|
3788
|
|
3789 /*
|
|
3790 * Now find the total width of our 'menu'.
|
|
3791 */
|
|
3792 textWidth = columnWidths[0] + columnWidths[1];
|
|
3793 if (submenuWidth != 0)
|
|
3794 {
|
|
3795 submenuWidth = GetTextWidth(hdc, TEAROFF_SUBMENU_LABEL,
|
|
3796 (int)STRLEN(TEAROFF_SUBMENU_LABEL));
|
|
3797 textWidth += submenuWidth;
|
|
3798 }
|
|
3799 dlgwidth = GetTextWidthEnc(hdc, title, (int)STRLEN(title));
|
|
3800 if (textWidth > dlgwidth)
|
|
3801 dlgwidth = textWidth;
|
|
3802 dlgwidth += 2 * TEAROFF_PADDING_X + TEAROFF_BUTTON_PAD_X;
|
|
3803
|
|
3804 /* W95 can't do thin dialogs, they look v. weird! */
|
|
3805 if (mch_windows95() && dlgwidth < TEAROFF_MIN_WIDTH)
|
|
3806 dlgwidth = TEAROFF_MIN_WIDTH;
|
|
3807
|
|
3808 /* start to fill in the dlgtemplate information. addressing by WORDs */
|
|
3809 if (s_usenewlook)
|
|
3810 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU |DS_SETFONT| WS_VISIBLE;
|
|
3811 else
|
|
3812 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU | WS_VISIBLE;
|
|
3813
|
|
3814 lExtendedStyle = WS_EX_TOOLWINDOW|WS_EX_STATICEDGE;
|
|
3815 *p++ = LOWORD(lStyle);
|
|
3816 *p++ = HIWORD(lStyle);
|
|
3817 *p++ = LOWORD(lExtendedStyle);
|
|
3818 *p++ = HIWORD(lExtendedStyle);
|
|
3819 pnumitems = p; /* save where the number of items must be stored */
|
|
3820 *p++ = 0; // NumberOfItems(will change later)
|
87
|
3821 gui_mch_getmouse(&x, &y);
|
7
|
3822 if (initX == 0xffffL)
|
87
|
3823 *p++ = PixelToDialogX(x); // x
|
7
|
3824 else
|
|
3825 *p++ = PixelToDialogX(initX); // x
|
|
3826 if (initY == 0xffffL)
|
87
|
3827 *p++ = PixelToDialogY(y); // y
|
7
|
3828 else
|
|
3829 *p++ = PixelToDialogY(initY); // y
|
|
3830 *p++ = PixelToDialogX(dlgwidth); // cx
|
|
3831 ptrueheight = p;
|
|
3832 *p++ = 0; // dialog height: changed later anyway
|
|
3833 *p++ = 0; // Menu
|
|
3834 *p++ = 0; // Class
|
|
3835
|
|
3836 /* copy the title of the dialog */
|
|
3837 nchar = nCopyAnsiToWideChar(p, ((*title)
|
|
3838 ? (LPSTR)title
|
|
3839 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
|
|
3840 p += nchar;
|
|
3841
|
|
3842 if (s_usenewlook)
|
|
3843 {
|
|
3844 /* do the font, since DS_3DLOOK doesn't work properly */
|
|
3845 #ifdef USE_SYSMENU_FONT
|
|
3846 if (use_lfSysmenu)
|
|
3847 {
|
|
3848 /* point size */
|
|
3849 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
|
|
3850 GetDeviceCaps(hdc, LOGPIXELSY));
|
|
3851 nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
|
|
3852 }
|
|
3853 else
|
|
3854 #endif
|
|
3855 {
|
|
3856 *p++ = DLG_FONT_POINT_SIZE; // point size
|
|
3857 nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
|
|
3858 }
|
|
3859 p += nchar;
|
|
3860 }
|
|
3861
|
|
3862 /*
|
|
3863 * Loop over all the items in the menu.
|
|
3864 * But skip over the tearbar.
|
|
3865 */
|
|
3866 if (STRCMP(menu->children->name, TEAR_STRING) == 0)
|
|
3867 menu = menu->children->next;
|
|
3868 else
|
|
3869 menu = menu->children;
|
|
3870 for ( ; menu != NULL; menu = menu->next)
|
|
3871 {
|
|
3872 if (menu->modes == 0) /* this menu has just been deleted */
|
|
3873 continue;
|
|
3874 if (menu_is_separator(menu->dname))
|
|
3875 {
|
|
3876 sepPadding += 3;
|
|
3877 continue;
|
|
3878 }
|
|
3879
|
|
3880 /* Check if there still is plenty of room in the template. Make it
|
|
3881 * larger when needed. */
|
|
3882 if (((char *)p - (char *)pdlgtemplate) + 1000 > template_len)
|
|
3883 {
|
|
3884 WORD *newp;
|
|
3885
|
|
3886 newp = (WORD *)LocalAlloc(LPTR, template_len + 4096);
|
|
3887 if (newp != NULL)
|
|
3888 {
|
|
3889 template_len += 4096;
|
|
3890 mch_memmove(newp, pdlgtemplate,
|
|
3891 (char *)p - (char *)pdlgtemplate);
|
|
3892 p = newp + (p - pdlgtemplate);
|
|
3893 pnumitems = newp + (pnumitems - pdlgtemplate);
|
|
3894 ptrueheight = newp + (ptrueheight - pdlgtemplate);
|
|
3895 LocalFree(LocalHandle(pdlgtemplate));
|
|
3896 pdlgtemplate = newp;
|
|
3897 }
|
|
3898 }
|
|
3899
|
|
3900 /* Figure out minimal length of this menu label. Use "name" for the
|
|
3901 * actual text, "dname" for estimating the displayed size. "name"
|
|
3902 * has "&a" for mnemonic and includes the accelerator. */
|
|
3903 len = nameLen = (int)STRLEN(menu->name);
|
|
3904 padding0 = (columnWidths[0] - GetTextWidthEnc(hdc, menu->dname,
|
|
3905 (int)STRLEN(menu->dname))) / spaceWidth;
|
|
3906 len += padding0;
|
|
3907
|
|
3908 if (menu->actext != NULL)
|
|
3909 {
|
|
3910 acLen = (int)STRLEN(menu->actext);
|
|
3911 len += acLen;
|
|
3912 textWidth = GetTextWidthEnc(hdc, menu->actext, acLen);
|
|
3913 }
|
|
3914 else
|
|
3915 textWidth = 0;
|
|
3916 padding1 = (columnWidths[1] - textWidth) / spaceWidth;
|
|
3917 len += padding1;
|
|
3918
|
|
3919 if (menu->children == NULL)
|
|
3920 {
|
|
3921 padding2 = submenuWidth / spaceWidth;
|
|
3922 len += padding2;
|
|
3923 menuID = (WORD)(menu->id);
|
|
3924 }
|
|
3925 else
|
|
3926 {
|
|
3927 len += (int)STRLEN(TEAROFF_SUBMENU_LABEL);
|
840
|
3928 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
|
7
|
3929 }
|
|
3930
|
|
3931 /* Allocate menu label and fill it in */
|
|
3932 text = label = alloc((unsigned)len + 1);
|
|
3933 if (label == NULL)
|
|
3934 break;
|
|
3935
|
419
|
3936 vim_strncpy(text, menu->name, nameLen);
|
7
|
3937 text = vim_strchr(text, TAB); /* stop at TAB before actext */
|
|
3938 if (text == NULL)
|
|
3939 text = label + nameLen; /* no actext, use whole name */
|
|
3940 while (padding0-- > 0)
|
|
3941 *text++ = ' ';
|
|
3942 if (menu->actext != NULL)
|
|
3943 {
|
|
3944 STRNCPY(text, menu->actext, acLen);
|
|
3945 text += acLen;
|
|
3946 }
|
|
3947 while (padding1-- > 0)
|
|
3948 *text++ = ' ';
|
|
3949 if (menu->children != NULL)
|
|
3950 {
|
|
3951 STRCPY(text, TEAROFF_SUBMENU_LABEL);
|
|
3952 text += STRLEN(TEAROFF_SUBMENU_LABEL);
|
|
3953 }
|
|
3954 else
|
|
3955 {
|
|
3956 while (padding2-- > 0)
|
|
3957 *text++ = ' ';
|
|
3958 }
|
|
3959 *text = NUL;
|
|
3960
|
|
3961 /*
|
|
3962 * BS_LEFT will just be ignored on Win32s/NT3.5x - on
|
|
3963 * W95/NT4 it makes the tear-off look more like a menu.
|
|
3964 */
|
|
3965 p = add_dialog_element(p,
|
|
3966 BS_PUSHBUTTON|BS_LEFT,
|
|
3967 (WORD)PixelToDialogX(TEAROFF_PADDING_X),
|
|
3968 (WORD)(sepPadding + 1 + 13 * (*pnumitems)),
|
|
3969 (WORD)PixelToDialogX(dlgwidth - 2 * TEAROFF_PADDING_X),
|
|
3970 (WORD)12,
|
|
3971 menuID, (WORD)0x0080, label);
|
|
3972 vim_free(label);
|
|
3973 (*pnumitems)++;
|
|
3974 }
|
|
3975
|
|
3976 *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems));
|
|
3977
|
|
3978
|
|
3979 /* show modelessly */
|
|
3980 the_menu->tearoff_handle = CreateDialogIndirect(
|
|
3981 s_hinst,
|
|
3982 (LPDLGTEMPLATE)pdlgtemplate,
|
|
3983 s_hwnd,
|
|
3984 (DLGPROC)tearoff_callback);
|
|
3985
|
|
3986 LocalFree(LocalHandle(pdlgtemplate));
|
|
3987 SelectFont(hdc, oldFont);
|
|
3988 DeleteObject(font);
|
|
3989 ReleaseDC(hwnd, hdc);
|
|
3990
|
|
3991 /*
|
|
3992 * Reassert ourselves as the active window. This is so that after creating
|
|
3993 * a tearoff, the user doesn't have to click with the mouse just to start
|
|
3994 * typing again!
|
|
3995 */
|
|
3996 (void)SetActiveWindow(s_hwnd);
|
|
3997
|
|
3998 /* make sure the right buttons are enabled */
|
|
3999 force_menu_update = TRUE;
|
|
4000 }
|
|
4001 #endif
|
|
4002
|
|
4003 #if defined(FEAT_TOOLBAR) || defined(PROTO)
|
|
4004 #include "gui_w32_rc.h"
|
|
4005
|
|
4006 /* This not defined in older SDKs */
|
|
4007 # ifndef TBSTYLE_FLAT
|
|
4008 # define TBSTYLE_FLAT 0x0800
|
|
4009 # endif
|
|
4010
|
|
4011 /*
|
|
4012 * Create the toolbar, initially unpopulated.
|
|
4013 * (just like the menu, there are no defaults, it's all
|
|
4014 * set up through menu.vim)
|
|
4015 */
|
|
4016 static void
|
|
4017 initialise_toolbar(void)
|
|
4018 {
|
|
4019 InitCommonControls();
|
|
4020 s_toolbarhwnd = CreateToolbarEx(
|
|
4021 s_hwnd,
|
|
4022 WS_CHILD | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,
|
|
4023 4000, //any old big number
|
|
4024 31, //number of images in inital bitmap
|
|
4025 s_hinst,
|
|
4026 IDR_TOOLBAR1, // id of initial bitmap
|
|
4027 NULL,
|
|
4028 0, // initial number of buttons
|
|
4029 TOOLBAR_BUTTON_WIDTH, //api guide is wrong!
|
|
4030 TOOLBAR_BUTTON_HEIGHT,
|
|
4031 TOOLBAR_BUTTON_WIDTH,
|
|
4032 TOOLBAR_BUTTON_HEIGHT,
|
|
4033 sizeof(TBBUTTON)
|
|
4034 );
|
|
4035
|
|
4036 gui_mch_show_toolbar(vim_strchr(p_go, GO_TOOLBAR) != NULL);
|
|
4037 }
|
|
4038
|
|
4039 static int
|
|
4040 get_toolbar_bitmap(vimmenu_T *menu)
|
|
4041 {
|
|
4042 int i = -1;
|
|
4043
|
|
4044 /*
|
|
4045 * Check user bitmaps first, unless builtin is specified.
|
|
4046 */
|
|
4047 if (!is_winnt_3() && !menu->icon_builtin)
|
|
4048 {
|
|
4049 char_u fname[MAXPATHL];
|
|
4050 HANDLE hbitmap = NULL;
|
|
4051
|
|
4052 if (menu->iconfile != NULL)
|
|
4053 {
|
|
4054 gui_find_iconfile(menu->iconfile, fname, "bmp");
|
|
4055 hbitmap = LoadImage(
|
|
4056 NULL,
|
|
4057 fname,
|
|
4058 IMAGE_BITMAP,
|
|
4059 TOOLBAR_BUTTON_WIDTH,
|
|
4060 TOOLBAR_BUTTON_HEIGHT,
|
|
4061 LR_LOADFROMFILE |
|
|
4062 LR_LOADMAP3DCOLORS
|
|
4063 );
|
|
4064 }
|
|
4065
|
|
4066 /*
|
|
4067 * If the LoadImage call failed, or the "icon=" file
|
|
4068 * didn't exist or wasn't specified, try the menu name
|
|
4069 */
|
|
4070 if (hbitmap == NULL
|
|
4071 && (gui_find_bitmap(menu->name, fname, "bmp") == OK))
|
|
4072 hbitmap = LoadImage(
|
|
4073 NULL,
|
|
4074 fname,
|
|
4075 IMAGE_BITMAP,
|
|
4076 TOOLBAR_BUTTON_WIDTH,
|
|
4077 TOOLBAR_BUTTON_HEIGHT,
|
|
4078 LR_LOADFROMFILE |
|
|
4079 LR_LOADMAP3DCOLORS
|
|
4080 );
|
|
4081
|
|
4082 if (hbitmap != NULL)
|
|
4083 {
|
|
4084 TBADDBITMAP tbAddBitmap;
|
|
4085
|
|
4086 tbAddBitmap.hInst = NULL;
|
840
|
4087 tbAddBitmap.nID = (long_u)hbitmap;
|
7
|
4088
|
|
4089 i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP,
|
|
4090 (WPARAM)1, (LPARAM)&tbAddBitmap);
|
|
4091 /* i will be set to -1 if it fails */
|
|
4092 }
|
|
4093 }
|
|
4094 if (i == -1 && menu->iconidx >= 0 && menu->iconidx < TOOLBAR_BITMAP_COUNT)
|
|
4095 i = menu->iconidx;
|
|
4096
|
|
4097 return i;
|
|
4098 }
|
|
4099 #endif
|
|
4100
|
810
|
4101 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
|
|
4102 static void
|
|
4103 initialise_tabline(void)
|
|
4104 {
|
|
4105 InitCommonControls();
|
|
4106
|
819
|
4107 s_tabhwnd = CreateWindow(WC_TABCONTROL, "Vim tabline",
|
840
|
4108 WS_CHILD|TCS_FOCUSNEVER|TCS_TOOLTIPS,
|
810
|
4109 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
4110 CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL);
|
819
|
4111
|
843
|
4112 gui.tabline_height = TABLINE_HEIGHT;
|
|
4113
|
819
|
4114 # ifdef USE_SYSMENU_FONT
|
843
|
4115 set_tabline_font();
|
819
|
4116 # endif
|
810
|
4117 }
|
|
4118 #endif
|
|
4119
|
7
|
4120 #if defined(FEAT_OLE) || defined(FEAT_EVAL) || defined(PROTO)
|
|
4121 /*
|
|
4122 * Make the GUI window come to the foreground.
|
|
4123 */
|
|
4124 void
|
|
4125 gui_mch_set_foreground(void)
|
|
4126 {
|
|
4127 if (IsIconic(s_hwnd))
|
|
4128 SendMessage(s_hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
|
|
4129 SetForegroundWindow(s_hwnd);
|
|
4130 }
|
|
4131 #endif
|
|
4132
|
|
4133 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
|
|
4134 static void
|
|
4135 dyn_imm_load(void)
|
|
4136 {
|
|
4137 hLibImm = LoadLibrary("imm32.dll");
|
|
4138 if (hLibImm == NULL)
|
|
4139 return;
|
|
4140
|
|
4141 pImmGetCompositionStringA
|
|
4142 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringA");
|
|
4143 pImmGetCompositionStringW
|
|
4144 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringW");
|
|
4145 pImmGetContext
|
|
4146 = (void *)GetProcAddress(hLibImm, "ImmGetContext");
|
|
4147 pImmAssociateContext
|
|
4148 = (void *)GetProcAddress(hLibImm, "ImmAssociateContext");
|
|
4149 pImmReleaseContext
|
|
4150 = (void *)GetProcAddress(hLibImm, "ImmReleaseContext");
|
|
4151 pImmGetOpenStatus
|
|
4152 = (void *)GetProcAddress(hLibImm, "ImmGetOpenStatus");
|
|
4153 pImmSetOpenStatus
|
|
4154 = (void *)GetProcAddress(hLibImm, "ImmSetOpenStatus");
|
|
4155 pImmGetCompositionFont
|
|
4156 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionFontA");
|
|
4157 pImmSetCompositionFont
|
|
4158 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontA");
|
|
4159 pImmSetCompositionWindow
|
|
4160 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow");
|
|
4161 pImmGetConversionStatus
|
|
4162 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus");
|
777
|
4163 pImmSetConversionStatus
|
|
4164 = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus");
|
7
|
4165
|
|
4166 if ( pImmGetCompositionStringA == NULL
|
|
4167 || pImmGetCompositionStringW == NULL
|
|
4168 || pImmGetContext == NULL
|
|
4169 || pImmAssociateContext == NULL
|
|
4170 || pImmReleaseContext == NULL
|
|
4171 || pImmGetOpenStatus == NULL
|
|
4172 || pImmSetOpenStatus == NULL
|
|
4173 || pImmGetCompositionFont == NULL
|
|
4174 || pImmSetCompositionFont == NULL
|
|
4175 || pImmSetCompositionWindow == NULL
|
777
|
4176 || pImmGetConversionStatus == NULL
|
|
4177 || pImmSetConversionStatus == NULL)
|
7
|
4178 {
|
|
4179 FreeLibrary(hLibImm);
|
|
4180 hLibImm = NULL;
|
|
4181 pImmGetContext = NULL;
|
|
4182 return;
|
|
4183 }
|
|
4184
|
|
4185 return;
|
|
4186 }
|
|
4187
|
|
4188 # if 0 /* not used */
|
|
4189 int
|
|
4190 dyn_imm_unload(void)
|
|
4191 {
|
|
4192 if (!hLibImm)
|
|
4193 return FALSE;
|
|
4194 FreeLibrary(hLibImm);
|
|
4195 hLibImm = NULL;
|
|
4196 return TRUE;
|
|
4197 }
|
|
4198 # endif
|
|
4199
|
|
4200 #endif
|
|
4201
|
|
4202 #if defined(FEAT_SIGN_ICONS) || defined(PROTO)
|
|
4203
|
|
4204 # ifdef FEAT_XPM_W32
|
|
4205 # define IMAGE_XPM 100
|
|
4206 # endif
|
|
4207
|
|
4208 typedef struct _signicon_t
|
|
4209 {
|
|
4210 HANDLE hImage;
|
|
4211 UINT uType;
|
|
4212 #ifdef FEAT_XPM_W32
|
|
4213 HANDLE hShape; /* Mask bitmap handle */
|
|
4214 #endif
|
|
4215 } signicon_t;
|
|
4216
|
|
4217 void
|
|
4218 gui_mch_drawsign(row, col, typenr)
|
|
4219 int row;
|
|
4220 int col;
|
|
4221 int typenr;
|
|
4222 {
|
|
4223 signicon_t *sign;
|
|
4224 int x, y, w, h;
|
|
4225
|
|
4226 if (!gui.in_use || (sign = (signicon_t *)sign_get_image(typenr)) == NULL)
|
|
4227 return;
|
|
4228
|
|
4229 x = TEXT_X(col);
|
|
4230 y = TEXT_Y(row);
|
|
4231 w = gui.char_width * 2;
|
|
4232 h = gui.char_height;
|
|
4233 switch (sign->uType)
|
|
4234 {
|
|
4235 case IMAGE_BITMAP:
|
|
4236 {
|
|
4237 HDC hdcMem;
|
|
4238 HBITMAP hbmpOld;
|
|
4239
|
|
4240 hdcMem = CreateCompatibleDC(s_hdc);
|
|
4241 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hImage);
|
|
4242 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCCOPY);
|
|
4243 SelectObject(hdcMem, hbmpOld);
|
|
4244 DeleteDC(hdcMem);
|
|
4245 }
|
|
4246 break;
|
|
4247 case IMAGE_ICON:
|
|
4248 case IMAGE_CURSOR:
|
|
4249 DrawIconEx(s_hdc, x, y, (HICON)sign->hImage, w, h, 0, NULL, DI_NORMAL);
|
|
4250 break;
|
|
4251 #ifdef FEAT_XPM_W32
|
|
4252 case IMAGE_XPM:
|
|
4253 {
|
|
4254 HDC hdcMem;
|
|
4255 HBITMAP hbmpOld;
|
|
4256
|
|
4257 hdcMem = CreateCompatibleDC(s_hdc);
|
|
4258 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hShape);
|
|
4259 /* Make hole */
|
|
4260 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCAND);
|
|
4261
|
|
4262 SelectObject(hdcMem, sign->hImage);
|
|
4263 /* Paint sign */
|
|
4264 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCPAINT);
|
|
4265 SelectObject(hdcMem, hbmpOld);
|
|
4266 DeleteDC(hdcMem);
|
|
4267 }
|
|
4268 break;
|
|
4269 #endif
|
|
4270 }
|
|
4271 }
|
|
4272
|
|
4273 static void
|
|
4274 close_signicon_image(signicon_t *sign)
|
|
4275 {
|
|
4276 if (sign)
|
|
4277 switch (sign->uType)
|
|
4278 {
|
|
4279 case IMAGE_BITMAP:
|
|
4280 DeleteObject((HGDIOBJ)sign->hImage);
|
|
4281 break;
|
|
4282 case IMAGE_CURSOR:
|
|
4283 DestroyCursor((HCURSOR)sign->hImage);
|
|
4284 break;
|
|
4285 case IMAGE_ICON:
|
|
4286 DestroyIcon((HICON)sign->hImage);
|
|
4287 break;
|
|
4288 #ifdef FEAT_XPM_W32
|
|
4289 case IMAGE_XPM:
|
|
4290 DeleteObject((HBITMAP)sign->hImage);
|
|
4291 DeleteObject((HBITMAP)sign->hShape);
|
|
4292 break;
|
|
4293 #endif
|
|
4294 }
|
|
4295 }
|
|
4296
|
|
4297 void *
|
|
4298 gui_mch_register_sign(signfile)
|
|
4299 char_u *signfile;
|
|
4300 {
|
|
4301 signicon_t sign, *psign;
|
|
4302 char_u *ext;
|
|
4303
|
|
4304 if (is_winnt_3())
|
|
4305 {
|
|
4306 EMSG(_(e_signdata));
|
|
4307 return NULL;
|
|
4308 }
|
|
4309
|
|
4310 sign.hImage = NULL;
|
|
4311 ext = signfile + STRLEN(signfile) - 4; /* get extention */
|
|
4312 if (ext > signfile)
|
|
4313 {
|
|
4314 int do_load = 1;
|
|
4315
|
|
4316 if (!STRICMP(ext, ".bmp"))
|
|
4317 sign.uType = IMAGE_BITMAP;
|
|
4318 else if (!STRICMP(ext, ".ico"))
|
|
4319 sign.uType = IMAGE_ICON;
|
|
4320 else if (!STRICMP(ext, ".cur") || !STRICMP(ext, ".ani"))
|
|
4321 sign.uType = IMAGE_CURSOR;
|
|
4322 else
|
|
4323 do_load = 0;
|
|
4324
|
|
4325 if (do_load)
|
|
4326 sign.hImage = (HANDLE)LoadImage(NULL, signfile, sign.uType,
|
|
4327 gui.char_width * 2, gui.char_height,
|
|
4328 LR_LOADFROMFILE | LR_CREATEDIBSECTION);
|
|
4329 #ifdef FEAT_XPM_W32
|
|
4330 if (!STRICMP(ext, ".xpm"))
|
|
4331 {
|
|
4332 sign.uType = IMAGE_XPM;
|
|
4333 LoadXpmImage(signfile, (HBITMAP *)&sign.hImage, (HBITMAP *)&sign.hShape);
|
|
4334 }
|
|
4335 #endif
|
|
4336 }
|
|
4337
|
|
4338 psign = NULL;
|
|
4339 if (sign.hImage && (psign = (signicon_t *)alloc(sizeof(signicon_t)))
|
|
4340 != NULL)
|
|
4341 *psign = sign;
|
|
4342
|
|
4343 if (!psign)
|
|
4344 {
|
|
4345 if (sign.hImage)
|
|
4346 close_signicon_image(&sign);
|
|
4347 EMSG(_(e_signdata));
|
|
4348 }
|
|
4349 return (void *)psign;
|
|
4350
|
|
4351 }
|
|
4352
|
|
4353 void
|
|
4354 gui_mch_destroy_sign(sign)
|
|
4355 void *sign;
|
|
4356 {
|
|
4357 if (sign)
|
|
4358 {
|
|
4359 close_signicon_image((signicon_t *)sign);
|
|
4360 vim_free(sign);
|
|
4361 }
|
|
4362 }
|
293
|
4363 #endif
|
7
|
4364
|
|
4365 #if defined(FEAT_BEVAL) || defined(PROTO)
|
|
4366
|
|
4367 /* BALLOON-EVAL IMPLEMENTATION FOR WINDOWS.
|
148
|
4368 * Added by Sergey Khorev <sergey.khorev@gmail.com>
|
7
|
4369 *
|
189
|
4370 * The only reused thing is gui_beval.h and get_beval_info()
|
7
|
4371 * from gui_beval.c (note it uses x and y of the BalloonEval struct
|
|
4372 * to get current mouse position).
|
|
4373 *
|
|
4374 * Trying to use as more Windows services as possible, and as less
|
|
4375 * IE version as possible :)).
|
|
4376 *
|
|
4377 * 1) Don't create ToolTip in gui_mch_create_beval_area, only initialize
|
|
4378 * BalloonEval struct.
|
|
4379 * 2) Enable/Disable simply create/kill BalloonEval Timer
|
|
4380 * 3) When there was enough inactivity, timer procedure posts
|
|
4381 * async request to debugger
|
|
4382 * 4) gui_mch_post_balloon (invoked from netbeans.c) creates tooltip control
|
|
4383 * and performs some actions to show it ASAP
|
|
4384 * 5) WM_NOTOFY:TTN_POP destroys created tooltip
|
|
4385 */
|
|
4386
|
435
|
4387 /*
|
|
4388 * determine whether installed Common Controls support multiline tooltips
|
|
4389 * (i.e. their version is >= 4.70
|
|
4390 */
|
|
4391 int
|
|
4392 multiline_balloon_available(void)
|
|
4393 {
|
|
4394 HINSTANCE hDll;
|
|
4395 static char comctl_dll[] = "comctl32.dll";
|
|
4396 static int multiline_tip = MAYBE;
|
|
4397
|
|
4398 if (multiline_tip != MAYBE)
|
|
4399 return multiline_tip;
|
|
4400
|
|
4401 hDll = GetModuleHandle(comctl_dll);
|
|
4402 if (hDll != NULL)
|
|
4403 {
|
856
|
4404 DLLGETVERSIONPROC pGetVer;
|
|
4405 pGetVer = (DLLGETVERSIONPROC)GetProcAddress(hDll, "DllGetVersion");
|
|
4406
|
|
4407 if (pGetVer != NULL)
|
|
4408 {
|
|
4409 DLLVERSIONINFO dvi;
|
|
4410 HRESULT hr;
|
|
4411
|
|
4412 ZeroMemory(&dvi, sizeof(dvi));
|
|
4413 dvi.cbSize = sizeof(dvi);
|
|
4414
|
|
4415 hr = (*pGetVer)(&dvi);
|
|
4416
|
|
4417 if (SUCCEEDED(hr)
|
435
|
4418 && (dvi.dwMajorVersion > 4
|
856
|
4419 || (dvi.dwMajorVersion == 4
|
|
4420 && dvi.dwMinorVersion >= 70)))
|
435
|
4421 {
|
|
4422 multiline_tip = TRUE;
|
|
4423 return multiline_tip;
|
|
4424 }
|
856
|
4425 }
|
435
|
4426 else
|
|
4427 {
|
|
4428 /* there is chance we have ancient CommCtl 4.70
|
|
4429 which doesn't export DllGetVersion */
|
|
4430 DWORD dwHandle = 0;
|
|
4431 DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle);
|
|
4432 if (len > 0)
|
|
4433 {
|
|
4434 VS_FIXEDFILEINFO *ver;
|
|
4435 UINT vlen = 0;
|
|
4436 void *data = alloc(len);
|
|
4437
|
|
4438 if (data != NULL
|
|
4439 && GetFileVersionInfo(comctl_dll, 0, len, data)
|
|
4440 && VerQueryValue(data, "\\", (void **)&ver, &vlen)
|
|
4441 && vlen
|
|
4442 && HIWORD(ver->dwFileVersionMS) > 4
|
|
4443 || (HIWORD(ver->dwFileVersionMS) == 4
|
|
4444 && LOWORD(ver->dwFileVersionMS) >= 70))
|
|
4445 {
|
|
4446 vim_free(data);
|
|
4447 multiline_tip = TRUE;
|
|
4448 return multiline_tip;
|
|
4449 }
|
|
4450 vim_free(data);
|
|
4451 }
|
|
4452 }
|
|
4453 }
|
|
4454 multiline_tip = FALSE;
|
|
4455 return multiline_tip;
|
|
4456 }
|
|
4457
|
7
|
4458 static void
|
|
4459 make_tooltip(beval, text, pt)
|
|
4460 BalloonEval *beval;
|
|
4461 char *text;
|
|
4462 POINT pt;
|
|
4463 {
|
435
|
4464 TOOLINFO *pti;
|
|
4465 int ToolInfoSize;
|
|
4466
|
|
4467 if (multiline_balloon_available() == TRUE)
|
|
4468 ToolInfoSize = sizeof(TOOLINFO_NEW);
|
|
4469 else
|
|
4470 ToolInfoSize = sizeof(TOOLINFO);
|
|
4471
|
|
4472 pti = (TOOLINFO *)alloc(ToolInfoSize);
|
|
4473 if (pti == NULL)
|
|
4474 return;
|
7
|
4475
|
|
4476 beval->balloon = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS,
|
|
4477 NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
|
|
4478 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
4479 beval->target, NULL, s_hinst, NULL);
|
|
4480
|
|
4481 SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0,
|
|
4482 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
|
4483
|
435
|
4484 pti->cbSize = ToolInfoSize;
|
|
4485 pti->uFlags = TTF_SUBCLASS;
|
|
4486 pti->hwnd = beval->target;
|
|
4487 pti->hinst = 0; /* Don't use string resources */
|
|
4488 pti->uId = ID_BEVAL_TOOLTIP;
|
|
4489
|
|
4490 if (multiline_balloon_available() == TRUE)
|
|
4491 {
|
|
4492 RECT rect;
|
|
4493 TOOLINFO_NEW *ptin = (TOOLINFO_NEW *)pti;
|
|
4494 pti->lpszText = LPSTR_TEXTCALLBACK;
|
|
4495 ptin->lParam = (LPARAM)text;
|
|
4496 if (GetClientRect(s_textArea, &rect)) /* switch multiline tooltips on */
|
|
4497 SendMessage(beval->balloon, TTM_SETMAXTIPWIDTH, 0,
|
|
4498 (LPARAM)rect.right);
|
|
4499 }
|
|
4500 else
|
|
4501 pti->lpszText = text; /* do this old way */
|
7
|
4502
|
|
4503 /* Limit ballooneval bounding rect to CursorPos neighbourhood */
|
435
|
4504 pti->rect.left = pt.x - 3;
|
|
4505 pti->rect.top = pt.y - 3;
|
|
4506 pti->rect.right = pt.x + 3;
|
|
4507 pti->rect.bottom = pt.y + 3;
|
|
4508
|
|
4509 SendMessage(beval->balloon, TTM_ADDTOOL, 0, (LPARAM)pti);
|
7
|
4510 /* Make tooltip appear sooner */
|
|
4511 SendMessage(beval->balloon, TTM_SETDELAYTIME, TTDT_INITIAL, 10);
|
|
4512 /*
|
|
4513 * HACK: force tooltip to appear, because it'll not appear until
|
|
4514 * first mouse move. D*mn M$
|
|
4515 */
|
|
4516 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
|
|
4517 mouse_event(MOUSEEVENTF_MOVE, (DWORD)-1, (DWORD)-1, 0, 0);
|
435
|
4518 vim_free(pti);
|
7
|
4519 }
|
|
4520
|
|
4521 static void
|
|
4522 delete_tooltip(beval)
|
|
4523 BalloonEval *beval;
|
|
4524 {
|
|
4525 DestroyWindow(beval->balloon);
|
|
4526 }
|
|
4527
|
323
|
4528 /*ARGSUSED*/
|
7
|
4529 static VOID CALLBACK
|
|
4530 BevalTimerProc(hwnd, uMsg, idEvent, dwTime)
|
|
4531 HWND hwnd;
|
|
4532 UINT uMsg;
|
840
|
4533 UINT_PTR idEvent;
|
7
|
4534 DWORD dwTime;
|
|
4535 {
|
|
4536 POINT pt;
|
|
4537 RECT rect;
|
|
4538
|
|
4539 if (cur_beval == NULL || cur_beval->showState == ShS_SHOWING || !p_beval)
|
|
4540 return;
|
|
4541
|
|
4542 GetCursorPos(&pt);
|
|
4543 if (WindowFromPoint(pt) != s_textArea)
|
|
4544 return;
|
|
4545
|
|
4546 ScreenToClient(s_textArea, &pt);
|
|
4547 GetClientRect(s_textArea, &rect);
|
|
4548 if (!PtInRect(&rect, pt))
|
|
4549 return;
|
|
4550
|
|
4551 if (LastActivity > 0
|
|
4552 && (dwTime - LastActivity) >= (DWORD)p_bdlay
|
|
4553 && (cur_beval->showState != ShS_PENDING
|
|
4554 || abs(cur_beval->x - pt.x) > 3
|
|
4555 || abs(cur_beval->y - pt.y) > 3))
|
|
4556 {
|
|
4557 /* Pointer resting in one place long enough, it's time to show
|
|
4558 * the tooltip. */
|
|
4559 cur_beval->showState = ShS_PENDING;
|
|
4560 cur_beval->x = pt.x;
|
|
4561 cur_beval->y = pt.y;
|
|
4562
|
205
|
4563 // TRACE0("BevalTimerProc: sending request");
|
7
|
4564
|
|
4565 if (cur_beval->msgCB != NULL)
|
|
4566 (*cur_beval->msgCB)(cur_beval, 0);
|
|
4567 }
|
|
4568 }
|
|
4569
|
323
|
4570 /*ARGSUSED*/
|
7
|
4571 void
|
|
4572 gui_mch_disable_beval_area(beval)
|
|
4573 BalloonEval *beval;
|
|
4574 {
|
205
|
4575 // TRACE0("gui_mch_disable_beval_area {{{");
|
7
|
4576 KillTimer(s_textArea, BevalTimerId);
|
205
|
4577 // TRACE0("gui_mch_disable_beval_area }}}");
|
7
|
4578 }
|
|
4579
|
323
|
4580 /*ARGSUSED*/
|
7
|
4581 void
|
|
4582 gui_mch_enable_beval_area(beval)
|
|
4583 BalloonEval *beval;
|
|
4584 {
|
205
|
4585 // TRACE0("gui_mch_enable_beval_area |||");
|
7
|
4586 if (beval == NULL)
|
|
4587 return;
|
205
|
4588 // TRACE0("gui_mch_enable_beval_area {{{");
|
843
|
4589 BevalTimerId = SetTimer(s_textArea, 0, p_bdlay / 2, BevalTimerProc);
|
205
|
4590 // TRACE0("gui_mch_enable_beval_area }}}");
|
7
|
4591 }
|
|
4592
|
|
4593 void
|
|
4594 gui_mch_post_balloon(beval, mesg)
|
|
4595 BalloonEval *beval;
|
|
4596 char_u *mesg;
|
|
4597 {
|
|
4598 POINT pt;
|
205
|
4599 // TRACE0("gui_mch_post_balloon {{{");
|
7
|
4600 if (beval->showState == ShS_SHOWING)
|
|
4601 return;
|
|
4602 GetCursorPos(&pt);
|
|
4603 ScreenToClient(s_textArea, &pt);
|
|
4604
|
|
4605 if (abs(beval->x - pt.x) < 3 && abs(beval->y - pt.y) < 3)
|
|
4606 /* cursor is still here */
|
|
4607 {
|
|
4608 gui_mch_disable_beval_area(cur_beval);
|
|
4609 beval->showState = ShS_SHOWING;
|
|
4610 make_tooltip(beval, mesg, pt);
|
|
4611 }
|
205
|
4612 // TRACE0("gui_mch_post_balloon }}}");
|
7
|
4613 }
|
|
4614
|
344
|
4615 /*ARGSUSED*/
|
7
|
4616 BalloonEval *
|
|
4617 gui_mch_create_beval_area(target, mesg, mesgCB, clientData)
|
|
4618 void *target; /* ignored, always use s_textArea */
|
|
4619 char_u *mesg;
|
|
4620 void (*mesgCB)__ARGS((BalloonEval *, int));
|
|
4621 void *clientData;
|
|
4622 {
|
|
4623 /* partially stolen from gui_beval.c */
|
|
4624 BalloonEval *beval;
|
|
4625
|
|
4626 if (mesg != NULL && mesgCB != NULL)
|
|
4627 {
|
|
4628 EMSG(_("E232: Cannot create BalloonEval with both message and callback"));
|
|
4629 return NULL;
|
|
4630 }
|
|
4631
|
|
4632 beval = (BalloonEval *)alloc(sizeof(BalloonEval));
|
|
4633 if (beval != NULL)
|
|
4634 {
|
|
4635 beval->target = s_textArea;
|
|
4636 beval->balloon = NULL;
|
|
4637
|
|
4638 beval->showState = ShS_NEUTRAL;
|
|
4639 beval->x = 0;
|
|
4640 beval->y = 0;
|
|
4641 beval->msg = mesg;
|
|
4642 beval->msgCB = mesgCB;
|
|
4643 beval->clientData = clientData;
|
|
4644
|
|
4645 InitCommonControls();
|
|
4646 cur_beval = beval;
|
|
4647
|
|
4648 if (p_beval)
|
|
4649 gui_mch_enable_beval_area(beval);
|
|
4650
|
|
4651 }
|
|
4652 return beval;
|
|
4653 }
|
|
4654
|
323
|
4655 /*ARGSUSED*/
|
7
|
4656 static void
|
|
4657 Handle_WM_Notify(hwnd, pnmh)
|
|
4658 HWND hwnd;
|
|
4659 LPNMHDR pnmh;
|
|
4660 {
|
|
4661 if (pnmh->idFrom != ID_BEVAL_TOOLTIP) /* it is not our tooltip */
|
|
4662 return;
|
|
4663
|
|
4664 if (cur_beval != NULL)
|
|
4665 {
|
435
|
4666 switch (pnmh->code)
|
7
|
4667 {
|
435
|
4668 case TTN_SHOW:
|
205
|
4669 // TRACE0("TTN_SHOW {{{");
|
|
4670 // TRACE0("TTN_SHOW }}}");
|
435
|
4671 break;
|
|
4672 case TTN_POP: /* Before tooltip disappear */
|
205
|
4673 // TRACE0("TTN_POP {{{");
|
7
|
4674 delete_tooltip(cur_beval);
|
|
4675 gui_mch_enable_beval_area(cur_beval);
|
205
|
4676 // TRACE0("TTN_POP }}}");
|
7
|
4677
|
|
4678 cur_beval->showState = ShS_NEUTRAL;
|
435
|
4679 break;
|
|
4680 case TTN_GETDISPINFO:
|
|
4681 {
|
|
4682 /* if you get there then we have new common controls */
|
|
4683 NMTTDISPINFO_NEW *info = (NMTTDISPINFO_NEW *)pnmh;
|
|
4684 info->lpszText = (LPSTR)info->lParam;
|
|
4685 info->uFlags |= TTF_DI_SETITEM;
|
|
4686 }
|
|
4687 break;
|
7
|
4688 }
|
|
4689 }
|
|
4690 }
|
|
4691
|
|
4692 static void
|
|
4693 TrackUserActivity(UINT uMsg)
|
|
4694 {
|
|
4695 if ((uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST)
|
|
4696 || (uMsg >= WM_KEYFIRST && uMsg <= WM_KEYLAST))
|
|
4697 LastActivity = GetTickCount();
|
|
4698 }
|
|
4699
|
|
4700 void
|
|
4701 gui_mch_destroy_beval_area(beval)
|
|
4702 BalloonEval *beval;
|
|
4703 {
|
|
4704 vim_free(beval);
|
|
4705 }
|
|
4706 #endif /* FEAT_BEVAL */
|
|
4707
|
|
4708 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
|
|
4709 /*
|
|
4710 * We have multiple signs to draw at the same location. Draw the
|
|
4711 * multi-sign indicator (down-arrow) instead. This is the Win32 version.
|
|
4712 */
|
|
4713 void
|
|
4714 netbeans_draw_multisign_indicator(int row)
|
|
4715 {
|
|
4716 int i;
|
|
4717 int y;
|
|
4718 int x;
|
|
4719
|
|
4720 x = 0;
|
|
4721 y = TEXT_Y(row);
|
|
4722
|
|
4723 for (i = 0; i < gui.char_height - 3; i++)
|
|
4724 SetPixel(s_hdc, x+2, y++, gui.currFgColor);
|
|
4725
|
|
4726 SetPixel(s_hdc, x+0, y, gui.currFgColor);
|
|
4727 SetPixel(s_hdc, x+2, y, gui.currFgColor);
|
|
4728 SetPixel(s_hdc, x+4, y++, gui.currFgColor);
|
|
4729 SetPixel(s_hdc, x+1, y, gui.currFgColor);
|
|
4730 SetPixel(s_hdc, x+2, y, gui.currFgColor);
|
|
4731 SetPixel(s_hdc, x+3, y++, gui.currFgColor);
|
|
4732 SetPixel(s_hdc, x+2, y, gui.currFgColor);
|
|
4733 }
|
|
4734 #endif
|