Changeset 53
- Timestamp:
- Apr 2, 2001, 12:38:55 PM (24 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/dosh.h
r48 r53 315 315 BOOL doshQueryDirExist(const char *pcszDir); 316 316 317 APIRET doshCreatePath( PSZ pszPath,317 APIRET doshCreatePath(const char *pcszPath, 318 318 BOOL fHidden); 319 319 -
trunk/include/helpers/gpih.h
r34 r53 136 136 typedef GPIHSPLITPRESFONT *PGPIHSPLITPRESFONT; 137 137 138 BOOL XWPENTRY gpihLockLCIDs(VOID); 139 typedef BOOL XWPENTRY GPIHLOCKLCIDS(VOID); 140 typedef GPIHLOCKLCIDS *PGPIHLOCKLCIDS; 141 142 VOID XWPENTRY gpihUnlockLCIDs(VOID); 143 typedef VOID XWPENTRY GPIHUNLOCKLCIDS(VOID); 144 typedef GPIHUNLOCKLCIDS *PGPIHUNLOCKLCIDS; 145 138 146 LONG XWPENTRY gpihFindFont(HPS hps, 139 147 LONG lSize, … … 153 161 BOOL fInherit, 154 162 HPS hps, 155 PSZ pszDefaultFont,163 const char *pcszDefaultFont, 156 164 PFONTMETRICS pFontMetrics, 157 165 PLONG plSize); … … 159 167 BOOL fInherit, 160 168 HPS hps, 161 PSZ pszDefaultFont,169 const char *pcszDefaultFont, 162 170 PFONTMETRICS pFontMetrics, 163 171 PLONG plSize); -
trunk/include/helpers/linklist.h
r41 r53 10 10 */ 11 11 12 /* Copyright (C) 1997-200 0Ulrich Mller.12 /* Copyright (C) 1997-2001 Ulrich Mller. 13 13 * This file is part of the "XWorkplace helpers" source package. 14 14 * This is free software; you can redistribute it and/or modify … … 98 98 // changed V0.9.0 (99-10-22) [umoeller] 99 99 typedef FNSORTLIST *PFNSORTLIST; 100 101 /* 102 *@@ FOR_ALL_NODES: 103 * helper macro to iterator over all nodes in 104 * a list. 105 * 106 * Usage: 107 + 108 + PLINKLIST pll = ...; 109 + PLISTNODE pNode; 110 + 111 + FOR_ALL_NODES(pll, pNode) 112 + { 113 + PVOID pData = (PVOID)pNode->pItemData; 114 + } 115 + 116 * This really is a "for" loop, so you can "break" 117 * out of the loop. 118 * 119 *@@added V0.9.9 (2001-04-01) [umoeller] 120 */ 121 122 #define FOR_ALL_NODES(pll, pNode) for (pNode = lstQueryFirstNode(pll); (pNode); pNode = pNode->pNext) 100 123 101 124 /* ****************************************************************** -
trunk/src/helpers/comctl.c
r21 r53 584 584 */ 585 585 586 case WM_TIMER: { 586 case WM_TIMER: 587 { 587 588 pa->usAniCurrent++; 588 589 if (pa->usAniCurrent >= pa->usAniCount) … … 590 591 591 592 WinSendMsg(hwndStatic, 592 SM_SETHANDLE,593 (MPARAM)pa->ahptrAniIcons[pa->usAniCurrent],594 (MPARAM)NULL);593 SM_SETHANDLE, 594 (MPARAM)pa->ahptrAniIcons[pa->usAniCurrent], 595 (MPARAM)NULL); 595 596 break; } 596 597 … … 606 607 SIZEL szlPage; 607 608 608 LONG lBkgndColor = winhQueryPresColor(609 610 PP_BACKGROUNDCOLOR,611 FALSE,612 SYSCLR_DIALOGBACKGROUND);609 LONG lBkgndColor 610 = winhQueryPresColor(WinQueryWindow(hwndStatic, QW_PARENT), 611 PP_BACKGROUNDCOLOR, 612 FALSE, 613 SYSCLR_DIALOGBACKGROUND); 613 614 614 615 HPS hps = WinGetPS(hwndStatic); … … 632 633 szlPage.cx = pa->rclIcon.xRight - pa->rclIcon.xLeft; 633 634 szlPage.cy = pa->rclIcon.yTop - pa->rclIcon.yBottom; 634 if (gpihCreateMemPS(pa->hab, &szlPage, &hdcMem, &hpsMem)) 635 if (gpihCreateMemPS(pa->hab, 636 &szlPage, 637 &hdcMem, 638 &hpsMem)) 635 639 { 636 640 // switch the memory PS to RGB mode too … … 653 657 ptl.y = pa->rclIcon.yTop; 654 658 GpiSetColor(hpsMem, 655 lBkgndColor);659 lBkgndColor); 656 660 GpiBox(hpsMem, 657 658 659 661 DRO_FILL, // interior only 662 &ptl, 663 0, 0); // no corner rounding 660 664 661 665 /* … … 689 693 690 694 if (hbmSource) 691 gpihStretchBitmap(hpsMem, 692 hbmSource, 695 gpihStretchBitmap(hpsMem, // target 696 hbmSource, // source 693 697 NULL, // use size of bitmap 694 & (pa->rclIcon),698 &pa->rclIcon, 695 699 ((pa->ulFlags & ANF_PROPORTIONAL) 696 700 != 0)); … … 720 724 */ 721 725 722 case WM_PAINT: { 726 case WM_PAINT: 727 { 723 728 RECTL rcl; 724 729 HPS hps = WinBeginPaint(hwndStatic, NULLHANDLE, &rcl); -
trunk/src/helpers/dosh.c
r52 r53 1344 1344 */ 1345 1345 1346 APIRET doshCreatePath( PSZ pszPath,1346 APIRET doshCreatePath(const char *pcszPath, 1347 1347 BOOL fHidden) // in: if TRUE, the new directories will get FILE_HIDDEN 1348 1348 { … … 1352 1352 ULONG cbPath; 1353 1353 1354 strcpy(path, p szPath);1354 strcpy(path, pcszPath); 1355 1355 cbPath = strlen(path); 1356 1356 -
trunk/src/helpers/gpih.c
r46 r53 33 33 // as unsigned char 34 34 35 #define INCL_DOSSEMAPHORES 35 36 #define INCL_DOSERRORS 36 37 37 38 #define INCL_WINWINDOWMGR 39 #define INCL_WINMESSAGEMGR 38 40 #define INCL_WINPOINTERS 39 41 #define INCL_WINSYS … … 92 94 * By contrast, the GpiBox expects an inclusive-inclusive rectangle. 93 95 */ 96 97 /* ****************************************************************** 98 * 99 * Global variables 100 * 101 ********************************************************************/ 102 103 static HMTX G_hmtxLCIDs = NULLHANDLE; 94 104 95 105 /* ****************************************************************** … … 492 502 493 503 /* 504 *@@ gpihLockLCIDs: 505 * requests the mutex for serializing the 506 * lcids. 507 * 508 * With GPI, lcids are a process-wide resource and not 509 * guaranteed to be unique. In the worst case, while your 510 * font routines are running, another thread modifies the 511 * lcids and you get garbage. If your fonts suddenly 512 * turn to "System Proportional", you know this has 513 * happened. 514 * 515 * As a result, whenever you work on lcids, request this 516 * mutex during your processing. If you do this consistently 517 * across all your code, you should be safe. 518 * 519 * gpihFindFont uses this mutex. If you call GpiCreateLogFont 520 * yourself somewhere, do this after you called this function. 521 * 522 * Call gpihUnlockLCIDs to unlock. 523 * 524 *@@added V0.9.9 (2001-04-01) [umoeller] 525 */ 526 527 BOOL gpihLockLCIDs(VOID) 528 { 529 BOOL brc = FALSE; 530 531 if (G_hmtxLCIDs == NULLHANDLE) 532 // first call: create 533 brc = !DosCreateMutexSem(NULL, 534 &G_hmtxLCIDs, 535 0, 536 TRUE); // request! 537 else 538 // subsequent calls: request 539 brc = !WinRequestMutexSem(G_hmtxLCIDs, SEM_INDEFINITE_WAIT); 540 541 return (brc); 542 } 543 544 /* 545 *@@ UnlockLCIDs: 546 * releases the mutex for serializing the 547 * lcids. 548 * 549 *@@added V0.9.9 (2001-04-01) [umoeller] 550 */ 551 552 VOID gpihUnlockLCIDs(VOID) 553 { 554 DosReleaseMutexSem(G_hmtxLCIDs); 555 } 556 557 /* 494 558 *@@ gpihQueryNextLCID: 495 559 * returns the next available lcid for the given HPS. … … 498 562 * Gets called by gpihFindFont automatically. 499 563 * 500 * This is possibly the sickest code I've ever written. 501 * 502 * Warning: This function is _not_ thread-safe. 503 * We use GpiQueryNumberSetIds to find out the no. of 504 * LCID's in use by the process. In the worst case, 505 * between that call and the call to GpiCreateLogFont, 506 * another font has been created, and you'll get garbage. 564 * WARNING: This function by itself is not thread-safe. 565 * See gpihLockLCIDs for how to serialize this. 507 566 * 508 567 *@@added V0.9.3 (2000-05-06) [umoeller] 568 *@@changed V0.9.9 (2001-04-01) [umoeller]: removed all those sick sub-allocs 509 569 */ 510 570 … … 524 584 else 525 585 { 526 #define GQNCL_BLOCK_SIZE 400*sizeof(LONG) 586 // #define GQNCL_BLOCK_SIZE 400*sizeof(LONG) 587 588 PLONG alTypes = NULL; // object types 589 PSTR8 aNames = NULL; // font names 590 PLONG allcids = NULL; // local identifiers 591 592 if ( (alTypes = (PLONG)malloc(lCount * sizeof(LONG))) 593 && (aNames = (PSTR8)malloc(lCount * sizeof(STR8))) 594 && (allcids = (PLONG)malloc(lCount * sizeof(LONG))) 595 ) 596 { 597 if (GpiQuerySetIds(hps, 598 lCount, 599 alTypes, 600 aNames, 601 allcids)) 602 { 603 // FINALLY we have all the lcids in use. 604 BOOL fContinue = TRUE; 605 lcidNext = 1; 606 607 // now, check if this lcid is in use already: 608 while (fContinue) 609 { 610 BOOL fFound = FALSE; 611 ULONG ul; 612 fContinue = FALSE; 613 for (ul = 0; 614 ul < lCount; 615 ul++) 616 { 617 if (allcids[ul] == lcidNext) 618 { 619 fFound = TRUE; 620 break; 621 } 622 } 623 624 if (fFound) 625 { 626 // lcid found: 627 // try next higher one 628 lcidNext++; 629 fContinue = TRUE; 630 } 631 // else: return that one 632 } 633 } 634 } 635 636 if (alTypes) 637 free(alTypes); 638 if (aNames) 639 free(aNames); 640 if (allcids) 641 free(allcids); 642 643 /* 527 644 PLONG pBase; 528 529 645 APIRET arc; 530 646 … … 612 728 arc = DosFreeMem(pBase); 613 729 } 730 */ 614 731 } 615 732 … … 744 861 * certain point sizes only. 745 862 * 746 * 4) <B>Warning: This function is _not_ thread-safe.</B>747 * Since logical font IDs are shared across the748 * process, this function should _not_ be called749 * from several threads at the same time.863 * 4) Since logical font IDs are shared across the 864 * process, a mutex is requested while the lcids are 865 * being queried and/or manipulated. In other words, 866 * this func is now thread-safe (V0.9.9). 750 867 * 751 868 * This calls gpihQueryNextFontID in turn to find the 752 869 * next free lcid. See remarks there. 753 * If your fonts suddenly change to "System Proportional"754 * in your application, you probably have a serialization755 * problem.756 *757 * To make this thread-safe, create your own wrapper758 * function which calls this function while a mutex759 * semaphore is held by the wrapper. Then use only760 * the wrapper in your code.761 870 * 762 871 * <B>Font metrics:</B> … … 793 902 *@@changed V0.9.3 (2000-05-06) [umoeller]: usFormat didn't work; fixed 794 903 *@@changed V0.9.4 (2000-08-08) [umoeller]: added fFamily 904 *@@changed V0.9.9 (2001-04-01) [umoeller]: made this thread-safe, finally 795 905 */ 796 906 … … 981 1091 free(pfm); 982 1092 983 // new logical font ID: last used plus one 984 lLCIDReturn = gpihQueryNextFontID(hps); 985 986 GpiCreateLogFont(hps, 987 NULL, // don't create "logical font name" (STR8) 988 lLCIDReturn, 989 &FontAttrs); 1093 if (gpihLockLCIDs()) // V0.9.9 (2001-04-01) [umoeller] 1094 { 1095 // new logical font ID: last used plus one 1096 lLCIDReturn = gpihQueryNextFontID(hps); 1097 1098 GpiCreateLogFont(hps, 1099 NULL, // don't create "logical font name" (STR8) 1100 lLCIDReturn, 1101 &FontAttrs); 1102 1103 gpihUnlockLCIDs(); 1104 } 990 1105 991 1106 return (lLCIDReturn); … … 1025 1140 * 1026 1141 *@@added V0.9.0 [umoeller] 1027 */ 1028 1029 LONG gpihFindPresFont(HWND hwnd, // in: window to search for presparam 1142 *@@changed V0.9.9 (2001-04-01) [umoeller]: now supporting NULLHANDLE hwnd 1143 */ 1144 1145 LONG gpihFindPresFont(HWND hwnd, // in: window to search for presparam or NULLHANDLE 1030 1146 BOOL fInherit, // in: search parent windows too? 1031 1147 HPS hps, // in: HPS for font selection 1032 PSZ pszDefaultFont, // in: default font if not found (i.e. "8.Helv")1148 const char *pcszDefaultFont, // in: default font if not found (i.e. "8.Helv") 1033 1149 PFONTMETRICS pFontMetrics, // out: font metrics of created font (optional) 1034 1150 PLONG plSize) // out: presparam's point size (optional) 1035 1151 { 1036 1152 CHAR szPPFont[200] = ""; 1037 PSZ pszFontFound = 0;1153 const char *pcszFontFound = 0; 1038 1154 CHAR szFaceName[300] = ""; 1039 1155 ULONG ulFontSize = 0; 1040 1156 1041 if (WinQueryPresParam(hwnd, 1042 PP_FONTNAMESIZE, // first PP to query 1043 0, // second PP to query 1044 NULL, // out: which one is returned 1045 (ULONG)sizeof(szPPFont), // in: buffer size 1046 (PVOID)&szPPFont, // out: PP value returned 1047 (fInherit) 1048 ? 0 1049 : QPF_NOINHERIT)) 1157 if ( (hwnd) // V0.9.9 (2001-04-01) [umoeller] 1158 && (WinQueryPresParam(hwnd, 1159 PP_FONTNAMESIZE, // first PP to query 1160 0, // second PP to query 1161 NULL, // out: which one is returned 1162 (ULONG)sizeof(szPPFont), // in: buffer size 1163 (PVOID)&szPPFont, // out: PP value returned 1164 (fInherit) 1165 ? 0 1166 : QPF_NOINHERIT)) 1167 ) 1050 1168 // PP found: 1051 p szFontFound = szPPFont;1169 pcszFontFound = szPPFont; 1052 1170 else 1053 p szFontFound = pszDefaultFont;1054 1055 if (p szFontFound)1171 pcszFontFound = pcszDefaultFont; 1172 1173 if (pcszFontFound) 1056 1174 { 1057 PCHAR pcDot = strchr(pszFontFound, '.');1175 const char *pcDot = strchr(pcszFontFound, '.'); 1058 1176 if (pcDot) 1059 1177 { 1060 1178 // _Pmpf(("Found font PP: %s", pszFontFound)); 1061 sscanf(p szFontFound, "%lu", &ulFontSize);1179 sscanf(pcszFontFound, "%lu", &ulFontSize); 1062 1180 if (plSize) 1063 1181 *plSize = ulFontSize; -
trunk/src/helpers/helpers_post.in
r38 r53 85 85 $(HLPINC)\dosh.h $(HLPINC)\stringh.h $(HLPINC)\xstring.h 86 86 87 $(OUTPUTDIR)\datetime.obj: $(@B).c $(HLPINC)\$(@B).h \ 88 $(PROJECTINC)\setup.h 89 90 $(OUTPUTDIR)\debug.obj: $(@B).c $(HLPINC)\$(@B).h \ 91 $(PROJECTINC)\setup.h \ 92 $(HLPINC)\dosh.h 93 94 $(OUTPUTDIR)\dialog.obj: $(@B).c $(HLPINC)\$(@B).h \ 95 $(PROJECTINC)\setup.h \ 96 $(HLPINC)\comctl.h $(HLPINC)\gpih.h $(HLPINC)\linklist.h \ 97 $(HLPINC)\standards.h $(HLPINC)\stringh.h \ 98 $(HLPINC)\winh.h 99 100 $(OUTPUTDIR)\dosh.obj: $(@B).c $(HLPINC)\$(@B).h \ 101 $(PROJECTINC)\setup.h 102 103 $(OUTPUTDIR)\dosh2.obj: $(@B).c $(HLPINC)\dosh.h \ 104 $(PROJECTINC)\setup.h \ 105 $(HLPINC)\stringh.h 106 107 $(OUTPUTDIR)\eah.obj: $(@B).c $(HLPINC)\$(@B).h \ 108 $(PROJECTINC)\setup.h 109 87 110 $(OUTPUTDIR)\encodings.obj: $(@B).c $(INC)\encodings\*.h \ 88 $(PROJECTINC)\setup.h89 90 $(OUTPUTDIR)\datetime.obj: $(@B).c $(HLPINC)\$(@B).h \91 $(PROJECTINC)\setup.h92 93 $(OUTPUTDIR)\debug.obj: $(@B).c $(HLPINC)\$(@B).h \94 $(PROJECTINC)\setup.h \95 $(HLPINC)\dosh.h96 97 $(OUTPUTDIR)\dosh.obj: $(@B).c $(HLPINC)\$(@B).h \98 $(PROJECTINC)\setup.h99 100 $(OUTPUTDIR)\dosh2.obj: $(@B).c $(HLPINC)\dosh.h \101 $(PROJECTINC)\setup.h \102 $(HLPINC)\stringh.h103 104 $(OUTPUTDIR)\eah.obj: $(@B).c $(HLPINC)\$(@B).h \105 111 $(PROJECTINC)\setup.h 106 112 -
trunk/src/helpers/helpers_pre.in
r35 r53 80 80 $(OUTPUTDIR)\configsys.obj \ 81 81 $(OUTPUTDIR)\cnrh.obj \ 82 $(OUTPUTDIR)\dialog.obj \ 82 83 $(OUTPUTDIR)\gpih.obj \ 83 84 $(OUTPUTDIR)\memdebug.obj \ -
trunk/src/helpers/linklist.c
r47 r53 1071 1071 * a pseudo-stack LIFO LINKLIST using lstPush. 1072 1072 * 1073 * Note that to really "pop" the item, i.e. remove 1074 * it from the list, you MUST call lstRemoveNode 1075 * with the list node returned from this function, 1076 * or otherwise you keep getting the same last item 1077 * on subsequent calls. 1073 * If (fRemove == TRUE), the item is also removed 1074 * from the stack. Otherwise it remains there so the 1075 * next lstPop would return the next item. 1078 1076 * 1079 1077 * Example: … … 1081 1079 + LINKLIST ll; 1082 1080 + PLISTNODE pNode; 1083 + lstInit(&ll, FALSE ;1081 + lstInit(&ll, FALSE); 1084 1082 + 1085 1083 + lstPush(&ll, (PVOID)1); 1086 1084 + lstPush(&ll, (PVOID)2); 1087 1085 + 1088 + pNode = lstPop(&ll); 1086 + pNode = lstPop(&ll); // returns the node containing "2" 1089 1087 + lstRemoveNode(pNode); 1090 + pNode = lstPop(&ll); // returns the node containing "1" 1091 + lstRemoveNode(pNode); 1088 + pNode = lstPop(&ll); // returns the node containing "1" 1092 1089 * 1093 1090 *@@added V0.9.3 (2000-05-18) [umoeller] … … 1097 1094 { 1098 1095 return (pList->pLast); 1099 /* unsigned long cItems = lstCountItems(pList); 1100 if (cItems) 1101 { 1102 // list not empty: 1103 // get last item on the list 1104 pNodeReturn = lstNodeFromIndex(pList, 1105 cItems - 1); 1106 } 1107 return (pNodeReturn); */ 1108 } 1109 1096 } 1097 1098 -
trunk/src/helpers/tmsgfile.c
r47 r53 541 541 GetTimeStamp(&fs3MessageFile, szFileStampCurrent, sizeof(szFileStampCurrent)); 542 542 543 _Pmpf((" Timestamp for %s: '%s'", pszMessageFile, szFileStampCurrent));543 // _Pmpf((" Timestamp for %s: '%s'", pszMessageFile, szFileStampCurrent)); 544 544 545 545 // determine saved timestamp … … 550 550 &ulStampLength); 551 551 552 _Pmpf((" Saved timestamp for %s: '%s'", pszMessageFile, szFileStampOld));552 // _Pmpf((" Saved timestamp for %s: '%s'", pszMessageFile, szFileStampOld)); 553 553 554 554 // compare timestamps … … 587 587 if (rc == NO_ERROR) 588 588 { 589 _Pmpf((" --> using precompiled table"));589 // _Pmpf((" --> using precompiled table")); 590 590 break; 591 591 } 592 592 } // end if 593 593 594 _Pmpf((" --> recompiling table"));594 // _Pmpf((" --> recompiling table")); 595 595 596 596 // recompilation needed: … … 735 735 ulCurrentMessageLen); 736 736 737 _Pmpf(("Found %s at %d, length %d",737 /* _Pmpf(("Found %s at %d, length %d", 738 738 pCurrentNameStart, 739 739 ulCurrentMessagePos, 740 ulCurrentMessageLen)); 740 ulCurrentMessageLen)); */ 741 741 742 742 // need more space ? … … 744 744 { 745 745 PBYTE pbTmp; 746 _Pmpf((" Re-allocating!!"));746 // _Pmpf((" Re-allocating!!")); 747 747 748 748 cbTableDataAllocated += ulFileDataLength / 2; … … 790 790 { 791 791 // restore original "last write" date 792 _Pmpf(("Resetting file date"));792 // _Pmpf(("Resetting file date")); 793 793 fs3Tmp.fdateLastWrite = fs3MessageFile.fdateLastWrite; 794 794 fs3Tmp.ftimeLastWrite = fs3MessageFile.ftimeLastWrite;
Note:
See TracChangeset
for help on using the changeset viewer.