Changeset 2093 for trunk/src/user32/uitools.cpp
- Timestamp:
- Dec 16, 1999, 5:53:59 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/uitools.cpp
r1781 r2093 1 /* $Id: uitools.cpp,v 1.1 7 1999-11-19 17:59:35cbratschi Exp $ */1 /* $Id: uitools.cpp,v 1.18 1999-12-16 16:53:57 cbratschi Exp $ */ 2 2 /* 3 3 * User Interface Functions … … 1358 1358 return FALSE; 1359 1359 } 1360 1361 1362 /*****************************************************************************1363 * Name : int WIN32API DrawTextExA1364 * Purpose : The DrawTextEx function draw the text in the rectangle1365 * Parameters:1366 * Variables :1367 * Result : If the function succeeds, the return value is the height of the1368 * text, otherwise zero.1369 * Remark : TODO: Returned number of characters is always the entire string1370 * since there is no way to know the real answer this way.1371 * Status : PARTIALLY IMPLEMENTED AND TESTED1372 *1373 * Author : Rene Pronk [Thu, 1999/07/29 15:03]1374 * Christoph Bratschi: implemented DT_END_ELLIPSIS (Header control)1375 *****************************************************************************/1376 1377 int WIN32API DrawTextExA (HDC hdc, LPCSTR lpchText, int cchText, LPRECT lprc,1378 UINT dwDTFormat, LPDRAWTEXTPARAMS lpDTParams) {1379 1380 int result;1381 UINT oldDTFormat;1382 1383 dprintf(("USER32:DrawTextExA (%08xh,%s,%08xh,%08xh,%08xh,%08xh).\n",1384 hdc, lpchText, cchText, lprc, dwDTFormat, lpDTParams));1385 1386 if (lpDTParams != NULL) {1387 // 'create' margins1388 lprc->left += lpDTParams->iLeftMargin;1389 lprc->right -= lpDTParams->iRightMargin;1390 1391 // just assume all the text has been drawn1392 if (cchText != -1)1393 lpDTParams->uiLengthDrawn = cchText;1394 else {1395 // determine string length1396 int size = 0;1397 while ((BYTE) *(lpchText + size) != 0)1398 size ++;1399 lpDTParams->uiLengthDrawn = size;1400 }1401 }1402 1403 oldDTFormat = dwDTFormat & ~(DT_END_ELLIPSIS | DT_PATH_ELLIPSIS | DT_MODIFYSTRING | DT_EXPANDTABS);1404 if (dwDTFormat & DT_END_ELLIPSIS && lpchText && (cchText != 0))1405 {1406 int textWidth,width;1407 RECT rect;1408 1409 if (cchText == -1) cchText = lstrlenA(lpchText);1410 SetRectEmpty(&rect);1411 DrawTextA(hdc,lpchText,cchText,&rect,oldDTFormat | DT_CALCRECT);1412 width = lprc->right-lprc->left;1413 textWidth = rect.right-rect.left;1414 if (textWidth > width && width > 0)1415 {1416 char* newText;1417 int endWidth,newTextLen;1418 1419 DrawTextA(hdc,"...",3,&rect,DT_CALCRECT | DT_SINGLELINE | DT_LEFT);1420 endWidth = rect.right-rect.left;1421 newText = (char*)malloc(cchText+3);1422 lstrcpyA(newText,lpchText);1423 newTextLen = cchText+1;1424 do1425 {1426 newTextLen--;1427 DrawTextA(hdc,newText,newTextLen,&rect,oldDTFormat | DT_CALCRECT);1428 textWidth = rect.right-rect.left;1429 } while (textWidth+endWidth > width && newTextLen > 1);1430 1431 lstrcpyA(&newText[newTextLen],"...");1432 result = DrawTextA(hdc,newText,-1,lprc,oldDTFormat);;1433 1434 if (dwDTFormat & DT_MODIFYSTRING) lstrcpynA((LPSTR)lpchText,newText,cchText);1435 free(newText);1436 } else result = DrawTextA(hdc,lpchText,cchText,lprc,oldDTFormat);1437 } else1438 result = DrawTextA (hdc, lpchText, cchText, lprc, oldDTFormat);1439 1440 if (lpDTParams != NULL) {1441 // don't forget to restore the margins1442 lprc->left -= lpDTParams->iLeftMargin;1443 lprc->right += lpDTParams->iRightMargin;1444 }1445 1446 return result;1447 }1448 1449 1450 1451 /*****************************************************************************1452 * Name : int WIN32API DrawTextExW1453 * Purpose : The DrawTextEx function draw the text in the rectangle1454 * Parameters:1455 * Variables :1456 * Result : If the function succeeds, the return value is the height of the1457 * text, otherwise zero.1458 * Remark : TODO: Returned number of characters is always the entire string1459 * since there is no way to know the real answer this way.1460 * Status : PARTIALLY IMPLEMENTED AND TESTED1461 *1462 * Author : Rene Pronk [Thu, 1999/07/29 15:03]1463 *****************************************************************************/1464 1465 int WIN32API DrawTextExW (HDC hdc, LPWSTR lpchText, int cchText, LPRECT lprc,1466 UINT dwDTFormat, LPDRAWTEXTPARAMS lpDTParams) {1467 1468 char *astring = UnicodeToAsciiString((LPWSTR)lpchText);1469 int rc;1470 1471 dprintf(("USER32:DrawTextExW (%08xh,%s,%08xh,%08xh,%08xh,%08xh).\n",1472 hdc, astring, cchText, lprc, dwDTFormat, lpDTParams));1473 1474 rc = DrawTextExA (hdc, astring, cchText, lprc, dwDTFormat, lpDTParams);1475 if (dwDTFormat & DT_MODIFYSTRING) AsciiToUnicode(astring,lpchText);1476 FreeAsciiString(astring);1477 return(rc);1478 }1479 1480 1481 1360 /****************************************************************************** 1482 1361 * … … 1900 1779 return O32_DrawMenuBar(window->getOS2FrameWindowHandle()); 1901 1780 } 1902 //******************************************************************************1903 //******************************************************************************1904 int WIN32API DrawTextW( HDC hDC, LPCWSTR lpString, int nCount, PRECT lpRect, UINT nFormat)1905 {1906 char *astring = UnicodeToAsciiString((LPWSTR)lpString);1907 int rc;1908 1909 #ifdef DEBUG1910 WriteLog("USER32: DrawTextW %s\n", astring);1911 #endif1912 rc = O32_DrawText(hDC,astring,nCount,lpRect,nFormat);1913 FreeAsciiString(astring);1914 return(rc);1915 }1916 //******************************************************************************1917 //******************************************************************************1918 int WIN32API DrawTextA(HDC hDC, LPCSTR lpString, int nCount, PRECT lpRect, UINT nFormat)1919 {1920 #ifdef DEBUG1921 WriteLog("USER32: DrawTextA %s %d", lpString,nCount);1922 #endif1923 return O32_DrawText(hDC,lpString,nCount,lpRect,nFormat);1924 }1925 1781 /***************************************************************************** 1926 1782 * Name : BOOL WIN32API DrawAnimatedRects
Note:
See TracChangeset
for help on using the changeset viewer.