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