Mercurial > vim
comparison src/gui_w32.c @ 435:73f016dbb279
updated for version 7.0112
author | vimboss |
---|---|
date | Thu, 21 Jul 2005 21:08:21 +0000 |
parents | f713fc55bf7b |
children | a5fcf36ef512 |
comparison
equal
deleted
inserted
replaced
434:9595cf1d80a7 | 435:73f016dbb279 |
---|---|
186 static VOID CALLBACK BevalTimerProc __ARGS((HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)); | 186 static VOID CALLBACK BevalTimerProc __ARGS((HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)); |
187 | 187 |
188 static BalloonEval *cur_beval = NULL; | 188 static BalloonEval *cur_beval = NULL; |
189 static UINT BevalTimerId = 0; | 189 static UINT BevalTimerId = 0; |
190 static DWORD LastActivity = 0; | 190 static DWORD LastActivity = 0; |
191 #endif | 191 |
192 /* | |
193 * excerpts from headers since this may not be presented | |
194 * in the extremelly old compilers | |
195 */ | |
196 #include <pshpack1.h> | |
197 | |
198 typedef struct _DllVersionInfo | |
199 { | |
200 DWORD cbSize; | |
201 DWORD dwMajorVersion; | |
202 DWORD dwMinorVersion; | |
203 DWORD dwBuildNumber; | |
204 DWORD dwPlatformID; | |
205 } DLLVERSIONINFO; | |
206 | |
207 typedef struct tagTOOLINFOA_NEW | |
208 { | |
209 UINT cbSize; | |
210 UINT uFlags; | |
211 HWND hwnd; | |
212 UINT uId; | |
213 RECT rect; | |
214 HINSTANCE hinst; | |
215 LPSTR lpszText; | |
216 LPARAM lParam; | |
217 } TOOLINFO_NEW; | |
218 | |
219 typedef struct tagNMTTDISPINFO_NEW | |
220 { | |
221 NMHDR hdr; | |
222 LPTSTR lpszText; | |
223 char szText[80]; | |
224 HINSTANCE hinst; | |
225 UINT uFlags; | |
226 LPARAM lParam; | |
227 } NMTTDISPINFO_NEW; | |
228 | |
229 #include <poppack.h> | |
230 | |
231 typedef HRESULT (WINAPI* DLLGETVERSIONPROC)(DLLVERSIONINFO *); | |
232 #ifndef TTM_SETMAXTIPWIDTH | |
233 # define TTM_SETMAXTIPWIDTH (WM_USER+24) | |
234 #endif | |
235 | |
236 #ifndef TTF_DI_SETITEM | |
237 # define TTF_DI_SETITEM 0x8000 | |
238 #endif | |
239 | |
240 #ifndef TTN_GETDISPINFO | |
241 # define TTN_GETDISPINFO (TTN_FIRST - 0) | |
242 #endif | |
243 | |
244 #endif /* defined(FEAT_BEVAL) */ | |
192 | 245 |
193 /* Local variables: */ | 246 /* Local variables: */ |
194 | 247 |
195 #ifdef FEAT_MENU | 248 #ifdef FEAT_MENU |
196 static UINT s_menu_id = 100; | 249 static UINT s_menu_id = 100; |
4019 * 4) gui_mch_post_balloon (invoked from netbeans.c) creates tooltip control | 4072 * 4) gui_mch_post_balloon (invoked from netbeans.c) creates tooltip control |
4020 * and performs some actions to show it ASAP | 4073 * and performs some actions to show it ASAP |
4021 * 5) WM_NOTOFY:TTN_POP destroys created tooltip | 4074 * 5) WM_NOTOFY:TTN_POP destroys created tooltip |
4022 */ | 4075 */ |
4023 | 4076 |
4077 /* | |
4078 * determine whether installed Common Controls support multiline tooltips | |
4079 * (i.e. their version is >= 4.70 | |
4080 */ | |
4081 int | |
4082 multiline_balloon_available(void) | |
4083 { | |
4084 HINSTANCE hDll; | |
4085 static char comctl_dll[] = "comctl32.dll"; | |
4086 static int multiline_tip = MAYBE; | |
4087 | |
4088 if (multiline_tip != MAYBE) | |
4089 return multiline_tip; | |
4090 | |
4091 hDll = GetModuleHandle(comctl_dll); | |
4092 if (hDll != NULL) | |
4093 { | |
4094 DLLGETVERSIONPROC pGetVer; | |
4095 pGetVer = (DLLGETVERSIONPROC)GetProcAddress(hDll, "DllGetVersion"); | |
4096 | |
4097 if (pGetVer != NULL) | |
4098 { | |
4099 DLLVERSIONINFO dvi; | |
4100 HRESULT hr; | |
4101 | |
4102 ZeroMemory(&dvi, sizeof(dvi)); | |
4103 dvi.cbSize = sizeof(dvi); | |
4104 | |
4105 hr = (*pGetVer)(&dvi); | |
4106 | |
4107 if (SUCCEEDED(hr) | |
4108 && (dvi.dwMajorVersion > 4 | |
4109 || (dvi.dwMajorVersion == 4 && dvi.dwMinorVersion >= 70))) | |
4110 { | |
4111 multiline_tip = TRUE; | |
4112 return multiline_tip; | |
4113 } | |
4114 } | |
4115 else | |
4116 { | |
4117 /* there is chance we have ancient CommCtl 4.70 | |
4118 which doesn't export DllGetVersion */ | |
4119 DWORD dwHandle = 0; | |
4120 DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle); | |
4121 if (len > 0) | |
4122 { | |
4123 VS_FIXEDFILEINFO *ver; | |
4124 UINT vlen = 0; | |
4125 void *data = alloc(len); | |
4126 | |
4127 if (data != NULL | |
4128 && GetFileVersionInfo(comctl_dll, 0, len, data) | |
4129 && VerQueryValue(data, "\\", (void **)&ver, &vlen) | |
4130 && vlen | |
4131 && HIWORD(ver->dwFileVersionMS) > 4 | |
4132 || (HIWORD(ver->dwFileVersionMS) == 4 | |
4133 && LOWORD(ver->dwFileVersionMS) >= 70)) | |
4134 { | |
4135 vim_free(data); | |
4136 multiline_tip = TRUE; | |
4137 return multiline_tip; | |
4138 } | |
4139 vim_free(data); | |
4140 } | |
4141 } | |
4142 } | |
4143 multiline_tip = FALSE; | |
4144 return multiline_tip; | |
4145 } | |
4146 | |
4024 static void | 4147 static void |
4025 make_tooltip(beval, text, pt) | 4148 make_tooltip(beval, text, pt) |
4026 BalloonEval *beval; | 4149 BalloonEval *beval; |
4027 char *text; | 4150 char *text; |
4028 POINT pt; | 4151 POINT pt; |
4029 { | 4152 { |
4030 TOOLINFO ti; | 4153 TOOLINFO *pti; |
4154 int ToolInfoSize; | |
4155 | |
4156 if (multiline_balloon_available() == TRUE) | |
4157 ToolInfoSize = sizeof(TOOLINFO_NEW); | |
4158 else | |
4159 ToolInfoSize = sizeof(TOOLINFO); | |
4160 | |
4161 pti = (TOOLINFO *)alloc(ToolInfoSize); | |
4162 if (pti == NULL) | |
4163 return; | |
4031 | 4164 |
4032 beval->balloon = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, | 4165 beval->balloon = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, |
4033 NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, | 4166 NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, |
4034 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, | 4167 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, |
4035 beval->target, NULL, s_hinst, NULL); | 4168 beval->target, NULL, s_hinst, NULL); |
4036 | 4169 |
4037 SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0, | 4170 SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0, |
4038 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | 4171 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); |
4039 | 4172 |
4040 ti.cbSize = sizeof(TOOLINFO); | 4173 pti->cbSize = ToolInfoSize; |
4041 ti.uFlags = TTF_SUBCLASS; | 4174 pti->uFlags = TTF_SUBCLASS; |
4042 ti.hwnd = beval->target; | 4175 pti->hwnd = beval->target; |
4043 ti.hinst = 0; /* Don't use string resources */ | 4176 pti->hinst = 0; /* Don't use string resources */ |
4044 ti.uId = ID_BEVAL_TOOLTIP; | 4177 pti->uId = ID_BEVAL_TOOLTIP; |
4045 ti.lpszText = text; | 4178 |
4179 if (multiline_balloon_available() == TRUE) | |
4180 { | |
4181 RECT rect; | |
4182 TOOLINFO_NEW *ptin = (TOOLINFO_NEW *)pti; | |
4183 pti->lpszText = LPSTR_TEXTCALLBACK; | |
4184 ptin->lParam = (LPARAM)text; | |
4185 if (GetClientRect(s_textArea, &rect)) /* switch multiline tooltips on */ | |
4186 SendMessage(beval->balloon, TTM_SETMAXTIPWIDTH, 0, | |
4187 (LPARAM)rect.right); | |
4188 } | |
4189 else | |
4190 pti->lpszText = text; /* do this old way */ | |
4046 | 4191 |
4047 /* Limit ballooneval bounding rect to CursorPos neighbourhood */ | 4192 /* Limit ballooneval bounding rect to CursorPos neighbourhood */ |
4048 ti.rect.left = pt.x - 3; | 4193 pti->rect.left = pt.x - 3; |
4049 ti.rect.top = pt.y - 3; | 4194 pti->rect.top = pt.y - 3; |
4050 ti.rect.right = pt.x + 3; | 4195 pti->rect.right = pt.x + 3; |
4051 ti.rect.bottom = pt.y + 3; | 4196 pti->rect.bottom = pt.y + 3; |
4052 | 4197 |
4053 SendMessage(beval->balloon, TTM_ADDTOOL, 0, (LPARAM)&ti); | 4198 SendMessage(beval->balloon, TTM_ADDTOOL, 0, (LPARAM)pti); |
4054 /* Make tooltip appear sooner */ | 4199 /* Make tooltip appear sooner */ |
4055 SendMessage(beval->balloon, TTM_SETDELAYTIME, TTDT_INITIAL, 10); | 4200 SendMessage(beval->balloon, TTM_SETDELAYTIME, TTDT_INITIAL, 10); |
4056 /* | 4201 /* |
4057 * HACK: force tooltip to appear, because it'll not appear until | 4202 * HACK: force tooltip to appear, because it'll not appear until |
4058 * first mouse move. D*mn M$ | 4203 * first mouse move. D*mn M$ |
4059 */ | 4204 */ |
4060 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0); | 4205 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0); |
4061 mouse_event(MOUSEEVENTF_MOVE, (DWORD)-1, (DWORD)-1, 0, 0); | 4206 mouse_event(MOUSEEVENTF_MOVE, (DWORD)-1, (DWORD)-1, 0, 0); |
4207 vim_free(pti); | |
4062 } | 4208 } |
4063 | 4209 |
4064 static void | 4210 static void |
4065 delete_tooltip(beval) | 4211 delete_tooltip(beval) |
4066 BalloonEval *beval; | 4212 BalloonEval *beval; |
4185 beval->msg = mesg; | 4331 beval->msg = mesg; |
4186 beval->msgCB = mesgCB; | 4332 beval->msgCB = mesgCB; |
4187 beval->clientData = clientData; | 4333 beval->clientData = clientData; |
4188 | 4334 |
4189 InitCommonControls(); | 4335 InitCommonControls(); |
4190 | |
4191 cur_beval = beval; | 4336 cur_beval = beval; |
4192 | 4337 |
4193 if (p_beval) | 4338 if (p_beval) |
4194 gui_mch_enable_beval_area(beval); | 4339 gui_mch_enable_beval_area(beval); |
4195 | 4340 |
4206 if (pnmh->idFrom != ID_BEVAL_TOOLTIP) /* it is not our tooltip */ | 4351 if (pnmh->idFrom != ID_BEVAL_TOOLTIP) /* it is not our tooltip */ |
4207 return; | 4352 return; |
4208 | 4353 |
4209 if (cur_beval != NULL) | 4354 if (cur_beval != NULL) |
4210 { | 4355 { |
4211 if (pnmh->code == TTN_SHOW) | 4356 switch (pnmh->code) |
4212 { | 4357 { |
4358 case TTN_SHOW: | |
4213 // TRACE0("TTN_SHOW {{{"); | 4359 // TRACE0("TTN_SHOW {{{"); |
4214 // TRACE0("TTN_SHOW }}}"); | 4360 // TRACE0("TTN_SHOW }}}"); |
4215 } | 4361 break; |
4216 else if (pnmh->code == TTN_POP) /* Before tooltip disappear */ | 4362 case TTN_POP: /* Before tooltip disappear */ |
4217 { | |
4218 // TRACE0("TTN_POP {{{"); | 4363 // TRACE0("TTN_POP {{{"); |
4219 delete_tooltip(cur_beval); | 4364 delete_tooltip(cur_beval); |
4220 gui_mch_enable_beval_area(cur_beval); | 4365 gui_mch_enable_beval_area(cur_beval); |
4221 // TRACE0("TTN_POP }}}"); | 4366 // TRACE0("TTN_POP }}}"); |
4222 | 4367 |
4223 cur_beval->showState = ShS_NEUTRAL; | 4368 cur_beval->showState = ShS_NEUTRAL; |
4369 break; | |
4370 case TTN_GETDISPINFO: | |
4371 { | |
4372 /* if you get there then we have new common controls */ | |
4373 NMTTDISPINFO_NEW *info = (NMTTDISPINFO_NEW *)pnmh; | |
4374 info->lpszText = (LPSTR)info->lParam; | |
4375 info->uFlags |= TTF_DI_SETITEM; | |
4376 } | |
4377 break; | |
4224 } | 4378 } |
4225 } | 4379 } |
4226 } | 4380 } |
4227 | 4381 |
4228 static void | 4382 static void |