Changeset 242 for trunk/src/helpers/gpih.c
- Timestamp:
- Jan 19, 2003, 8:42:16 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/gpih.c
r240 r242 61 61 #endif 62 62 #include "helpers\dosh.h" 63 #include "helpers\gpih.h" 63 64 #include "helpers\winh.h" 64 #include "helpers\ gpih.h"65 #include "helpers\stringh.h" 65 66 66 67 #pragma hdrstop … … 459 460 */ 460 461 461 VOID gpihDrawThickFrame(HPS hps, 462 PRECTL prcl, 463 ULONG ulWidth) 462 VOID gpihDrawThickFrame(HPS hps, // in: presentation space for output 463 PRECTL prcl, // in: rectangle to draw (inclusive) 464 ULONG ulWidth) // in: line width (>= 1) 464 465 { 465 466 ULONG ul = 0; … … 506 507 */ 507 508 508 VOID gpihDraw3DFrame2(HPS hps, 509 PRECTL prcl, // in: rectangle (inclusive)510 USHORT usWidth, // in: line width (>= 1)511 LONG lColorLeft, // in: color to use for left and top; e.g. SYSCLR_BUTTONLIGHT512 LONG lColorRight) // in: color to use for right and bottom; e.g. SYSCLR_BUTTONDARK509 VOID gpihDraw3DFrame2(HPS hps, // in: presentation space for output 510 PRECTL prcl, // in: rectangle (inclusive) 511 USHORT usWidth, // in: line width (>= 1) 512 LONG lColorLeft, // in: color to use for left and top; e.g. SYSCLR_BUTTONLIGHT 513 LONG lColorRight) // in: color to use for right and bottom; e.g. SYSCLR_BUTTONDARK 513 514 { 514 515 USHORT us; … … 553 554 */ 554 555 555 VOID gpihDraw3DFrame(HPS hps, 556 VOID gpihDraw3DFrame(HPS hps, // in: presentation space for output 556 557 PRECTL prcl, // in: rectangle (inclusive) 557 558 USHORT usWidth, // in: line width (>= 1) … … 576 577 */ 577 578 578 LONG gpihCharStringPosAt(HPS hps, 579 LONG gpihCharStringPosAt(HPS hps, // in: presentation space for output 579 580 PPOINTL pptlStart, 580 581 PRECTL prclRect, … … 628 629 629 630 /* 631 *@@ gpihCalcTextExtent: 632 * 633 *@@added V1.0.1 (2003-01-17) [umoeller] 634 */ 635 636 VOID gpihCalcTextExtent(HPS hps, // in: presentation space for output 637 PCSZ pcsz, // in: string to test 638 PLONG pcx, // out: max width occupied by a line in the string 639 PULONG pcLines) // out: no. of lines 640 { 641 LONG cxLineThis; 642 PCSZ pThis = pcsz; 643 *pcx = 0; 644 645 *pcLines = 0; 646 647 if (!pThis) 648 return; 649 650 while (*pThis) 651 { 652 ULONG lenThis; 653 PCSZ pNext = strhFindEOL(pThis, &lenThis); 654 655 ++(*pcLines); 656 657 if (lenThis) 658 { 659 POINTL aptl[TXTBOX_COUNT]; 660 GpiQueryTextBox(hps, 661 lenThis, 662 (PCH)pThis, 663 TXTBOX_COUNT, 664 aptl); 665 666 cxLineThis = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_BOTTOMLEFT].x; 667 668 if (cxLineThis > *pcx) 669 *pcx = cxLineThis; 670 } 671 672 if (*pNext == '\r') 673 pNext++; 674 pThis = pNext; 675 } 676 } 677 678 /* 679 *@@ gpihDrawString: 680 * replacement for WinDrawText that can still align 681 * properly with multi-line strings. 682 * 683 * fl works as with WinDrawText, that is: 684 * 685 * -- specify one of DT_LEFT, DT_CENTER, DT_RIGHT; 686 * 687 * -- specifiy one of DT_TOP, DT_VCENTER, DT_BOTTOM. 688 * 689 * The alignment definitions are: 690 * 691 * -- DT_LEFT 0x00000000 692 * -- DT_CENTER 0x00000100 693 * -- DT_RIGHT 0x00000200 694 * -- DT_TOP 0x00000000 695 * -- DT_VCENTER 0x00000400 696 * -- DT_BOTTOM 0x00000800 697 * 698 * Other flags: 699 * 700 * -- DT_QUERYEXTENT 0x00000002 (not supported) 701 * -- DT_UNDERSCORE 0x00000010 (not supported) 702 * -- DT_STRIKEOUT 0x00000020 (not supported) 703 * -- DT_TEXTATTRS 0x00000040 (always enabled) 704 * -- DT_EXTERNALLEADING 0x00000080 (not supported) 705 * -- DT_HALFTONE 0x00001000 (not supported) 706 * -- DT_MNEMONIC 0x00002000 (not supported) 707 * -- DT_WORDBREAK 0x00004000 (always enabled) 708 * -- DT_ERASERECT 0x00008000 (not supported) 709 * 710 *@@added V1.0.1 (2003-01-17) [umoeller] 711 */ 712 713 VOID gpihDrawString(HPS hps, // in: presentation space for output 714 PCSZ pcsz, // in: string to test 715 PRECTL prcl, // in: clipping rectangle (inclusive!) 716 ULONG fl, // in: alignment flags 717 PFONTMETRICS pfm) 718 { 719 PCSZ pThis = pcsz; 720 POINTL ptlRun, 721 ptlUse; 722 LONG cxRect, 723 cyRect, 724 cyString; 725 726 if (!pThis || !prcl || !pfm) 727 return; 728 729 ptlRun.x = prcl->xLeft; 730 ptlRun.y = prcl->yTop; 731 732 cxRect = prcl->xRight - prcl->xLeft + 1; 733 cyRect = prcl->yTop - prcl->yBottom + 1; 734 735 // vertical alignment: 736 if (fl & (DT_VCENTER | DT_BOTTOM)) 737 { 738 ULONG cLines = strhCount(pcsz, '\n') + 1; 739 cyString = cLines * (pfm->lMaxBaselineExt + pfm->lExternalLeading); 740 741 if (fl & DT_VCENTER) 742 ptlRun.y += (cyRect - cyString) / 2; 743 else 744 ptlRun.y += cyRect - cyString; 745 } 746 747 while (*pThis) 748 { 749 ULONG lenThis; 750 PCSZ pNext = strhFindEOL(pThis, &lenThis); 751 752 ptlRun.y -= pfm->lMaxBaselineExt; 753 754 if (lenThis) 755 { 756 // horizontal alignment: 757 if (!(fl & (DT_CENTER | DT_RIGHT))) 758 ptlUse.x = ptlRun.x; 759 else 760 { 761 POINTL aptl[TXTBOX_COUNT]; 762 LONG cxString; 763 GpiQueryTextBox(hps, 764 lenThis, 765 (PCH)pThis, 766 TXTBOX_COUNT, 767 aptl); 768 769 cxString = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_BOTTOMLEFT].x; 770 771 if (fl & DT_CENTER) 772 ptlUse.x = ptlRun.x + (cxRect - cxString) / 2; 773 else 774 // right 775 ptlUse.x = ptlRun.x + cxRect - cxString; 776 } 777 778 ptlUse.y = ptlRun.y + pfm->lMaxDescender; 779 780 GpiCharStringPosAt(hps, 781 &ptlUse, 782 prcl, 783 CHS_CLIP, 784 lenThis, 785 (PCH)pThis, 786 NULL); 787 } 788 789 ptlRun.y -= pfm->lExternalLeading; 790 791 if (*pNext == '\r') 792 pNext++; 793 pThis = pNext; 794 } 795 } 796 797 /* 630 798 *@@ gpihFillBackground: 631 799 * fills the specified rectangle in the way … … 647 815 */ 648 816 649 VOID gpihFillBackground(HPS hps, // in: PS to paint into817 VOID gpihFillBackground(HPS hps, // in: presentation space for output 650 818 PRECTL prcl, // in: rectangle (inclusive!) 651 819 PBKGNDINFO pInfo) // in: background into … … 818 986 */ 819 987 820 BOOL gpihMatchFont(HPS hps, 821 LONG lSize, // in: font point size822 BOOL fFamily, // in: if TRUE, pszName specifies font family;823 // if FALSE, pszName specifies font face824 const char *pcszName, // in: font family or face name (without point size)825 USHORT usFormat, // in: none, one or several of:826 // -- FATTR_SEL_ITALIC827 // -- FATTR_SEL_UNDERSCORE (underline)828 // -- FATTR_SEL_BOLD829 // -- FATTR_SEL_STRIKEOUT830 // -- FATTR_SEL_OUTLINE (hollow)831 FATTRS *pfa, // out: font attributes if found988 BOOL gpihMatchFont(HPS hps, // in: presentation space for output 989 LONG lSize, // in: font point size 990 BOOL fFamily, // in: if TRUE, pszName specifies font family; 991 // if FALSE, pszName specifies font face 992 const char *pcszName, // in: font family or face name (without point size) 993 USHORT usFormat, // in: none, one or several of: 994 // -- FATTR_SEL_ITALIC 995 // -- FATTR_SEL_UNDERSCORE (underline) 996 // -- FATTR_SEL_BOLD 997 // -- FATTR_SEL_STRIKEOUT 998 // -- FATTR_SEL_OUTLINE (hollow) 999 FATTRS *pfa, // out: font attributes if found 832 1000 PFONTMETRICS pFontMetrics) // out: font metrics of created font (optional) 833 1001 { … … 1130 1298 */ 1131 1299 1132 LONG gpihQueryNextFontID(HPS hps) 1300 LONG gpihQueryNextFontID(HPS hps) // in: presentation space for output 1133 1301 { 1134 1302 LONG lcidNext = -1; … … 1228 1396 */ 1229 1397 1230 LONG gpihCreateFont(HPS hps, 1398 LONG gpihCreateFont(HPS hps, // in: presentation space for output 1231 1399 FATTRS *pfa) 1232 1400 { … … 1404 1572 */ 1405 1573 1406 LONG gpihFindFont(HPS hps, // in: HPS for font selection1574 LONG gpihFindFont(HPS hps, // in: presentation space for output 1407 1575 LONG lSize, // in: font point size 1408 1576 BOOL fFamily, // in: if TRUE, pszName specifies font family; … … 1595 1763 */ 1596 1764 1597 LONG gpihQueryLineSpacing(HPS hps) 1765 LONG gpihQueryLineSpacing(HPS hps) // in: presentation space for output 1598 1766 { 1599 1767 FONTMETRICS fm;
Note:
See TracChangeset
for help on using the changeset viewer.