Changeset 1565 for trunk/src/comctl32/tooltips.c
- Timestamp:
- Nov 2, 1999, 10:44:04 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/tooltips.c
r1431 r1565 1 /* $Id: tooltips.c,v 1.1 5 1999-10-24 22:49:49 sandervlExp $ */1 /* $Id: tooltips.c,v 1.16 1999-11-02 21:44:03 achimha Exp $ */ 2 2 /* 3 3 * Tool tip control … … 22 22 */ 23 23 24 /* WINE 99 0923level */24 /* WINE 991031 level */ 25 25 26 26 #include <string.h> … … 253 253 } 254 254 255 static VOID 256 TOOLTIPS_CalcTipSize (HWND hwnd, TOOLTIPS_INFO *infoPtr, LPSIZE lpSize) 257 { 258 HDC hdc; 259 HFONT hOldFont; 260 UINT uFlags = DT_EXTERNALLEADING | DT_CALCRECT; 261 RECT rc = {0, 0, 0, 0}; 262 263 if (infoPtr->nMaxTipWidth > -1) { 264 rc.right = infoPtr->nMaxTipWidth; 265 uFlags |= DT_WORDBREAK; 266 } 267 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX) 268 uFlags |= DT_NOPREFIX; 269 // TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText)); 270 271 hdc = GetDC (hwnd); 272 hOldFont = SelectObject (hdc, infoPtr->hFont); 273 DrawTextW (hdc, infoPtr->szTipText, -1, &rc, uFlags); 274 SelectObject (hdc, hOldFont); 275 ReleaseDC (hwnd, hdc); 276 277 lpSize->cx = rc.right - rc.left + 4 + 278 infoPtr->rcMargin.left + infoPtr->rcMargin.right; 279 lpSize->cy = rc.bottom - rc.top + 4 + 280 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top; 281 } 255 282 256 283 static VOID … … 258 285 { 259 286 TTTOOL_INFO *toolPtr; 260 RECT rect; 287 RECT rect, wndrect; 288 SIZE size; 261 289 HDC hdc; 262 290 NMHDR hdr; 263 291 264 if (infoPtr->nTool == -1) 265 { 266 // TRACE (tooltips, "invalid tool (-1)!\n"); 267 return; 292 if (infoPtr->nTool == -1) { 293 TRACE("invalid tool (-1)!\n"); 294 return; 268 295 } 269 296 270 297 infoPtr->nCurrentTool = infoPtr->nTool; 271 298 272 // TRACE (tooltips,"Show tooltip pre %d!\n", infoPtr->nTool);273 TOOLTIPS_GetTipText(hwnd,infoPtr,infoPtr->nCurrentTool); 274 275 if (infoPtr->szTipText[0] == '\0') 276 {277 278 279 } 280 281 // TRACE (tooltips,"Show tooltip %d!\n", infoPtr->nCurrentTool);299 TRACE("Show tooltip pre %d!\n", infoPtr->nTool); 300 301 TOOLTIPS_GetTipText (hwnd, infoPtr, infoPtr->nCurrentTool); 302 303 if (infoPtr->szTipText[0] == L'\0') { 304 infoPtr->nCurrentTool = -1; 305 return; 306 } 307 308 TRACE("Show tooltip %d!\n", infoPtr->nCurrentTool); 282 309 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; 283 310 … … 285 312 hdr.idFrom = toolPtr->uId; 286 313 hdr.code = TTN_SHOW; 287 SendMessageA(toolPtr->hwnd,WM_NOTIFY, 288 (WPARAM)toolPtr->uId,(LPARAM)&hdr); 289 290 // TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText)); 291 292 TOOLTIPS_CalcTipRect(hwnd,infoPtr,toolPtr,&rect); 293 294 SetWindowPos (hwnd,HWND_TOP,rect.left,rect.top, 295 rect.right-rect.left,rect.bottom-rect.top, 296 SWP_SHOWWINDOW | SWP_NOACTIVATE); 314 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 315 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 316 317 // TRACE("\"%s\"\n", debugstr_w(infoPtr->szTipText)); 318 319 TOOLTIPS_CalcTipSize (hwnd, infoPtr, &size); 320 TRACE("size %d - %d\n", size.cx, size.cy); 321 322 if (toolPtr->uFlags & TTF_CENTERTIP) { 323 RECT rc; 324 325 if (toolPtr->uFlags & TTF_IDISHWND) 326 GetWindowRect ((HWND)toolPtr->uId, &rc); 327 else { 328 rc = toolPtr->rect; 329 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2); 330 } 331 rect.left = (rc.left + rc.right - size.cx) / 2; 332 rect.top = rc.bottom + 2; 333 } 334 else { 335 GetCursorPos ((LPPOINT)&rect); 336 rect.top += 20; 337 } 338 339 TRACE("pos %d - %d\n", rect.left, rect.top); 340 341 rect.right = rect.left + size.cx; 342 rect.bottom = rect.top + size.cy; 343 344 /* check position */ 345 wndrect.right = GetSystemMetrics( SM_CXSCREEN ); 346 if( rect.right > wndrect.right ) { 347 rect.left -= rect.right - wndrect.right + 2; 348 rect.right = wndrect.right - 2; 349 } 350 wndrect.bottom = GetSystemMetrics( SM_CYSCREEN ); 351 if( rect.bottom > wndrect.bottom ) { 352 RECT rc; 353 354 if (toolPtr->uFlags & TTF_IDISHWND) 355 GetWindowRect ((HWND)toolPtr->uId, &rc); 356 else { 357 rc = toolPtr->rect; 358 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2); 359 } 360 rect.bottom = rc.top - 2; 361 rect.top = rect.bottom - size.cy; 362 } 363 364 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE), 365 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE)); 366 367 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top, 368 rect.right - rect.left, rect.bottom - rect.top, 369 SWP_SHOWWINDOW | SWP_NOACTIVATE); 297 370 298 371 /* repaint the tooltip */ 299 hdc = GetDC (hwnd);300 TOOLTIPS_Refresh (hwnd,hdc);301 ReleaseDC (hwnd,hdc);302 303 SetTimer (hwnd, ID_TIMERPOP,infoPtr->nAutoPopTime,0);372 hdc = GetDC (hwnd); 373 TOOLTIPS_Refresh (hwnd, hdc); 374 ReleaseDC (hwnd, hdc); 375 376 SetTimer (hwnd, ID_TIMERPOP, infoPtr->nAutoPopTime, 0); 304 377 } 305 378
Note:
See TracChangeset
for help on using the changeset viewer.