home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / UTILS / A-G / ALPHAL / ALPHAE.C < prev    next >
C/C++ Source or Header  |  1994-10-30  |  10KB  |  173 lines

  1. /*************** AlphaE.C - Exit procedure for Alpha  *********************/
  2. /*                                                                        */                
  3. /* PROGRAM NAME: ALPHA.EXE                                                */
  4. /* -------------                                                          */                
  5. /*  Presentation Manager  C Program                                       */
  6. /*                                                                        */                
  7. /* REVISION LEVEL: 2.1                                                    */
  8. /* ---------------                                                        */
  9. /*                                                                        */
  10. /* Lionel de Lambert - July 1994 - IBM - Hursley                          */
  11. /*                                                                        */
  12. /* WHAT THIS PROGRAM DOES:                                                */
  13. /* -----------------------                                                */     
  14. /*    Procedures -                                                        */
  15. /*                 Alpha_parse_exit                                       */
  16. /*                                                                        */
  17. /*    This procedure is called before Alpha writes the line of text.      */
  18. /*    It is called from the WM_PAINT section of the child window.         */
  19. /*    return code - 0 - Execute standard Alpha parsing etc.               */
  20. /*                  4 - Don't excute Alpha parsing - this routine has     */
  21. /*                      output the text.                                  */
  22. /*                                                                        */
  23. /* WHAT YOU NEED TO COMPILE THIS PROGRAM:                                 */
  24. /* --------------------------------------                                 */
  25. /*                                                                        */
  26. /*  REQUIRED FILES:                                                       */
  27. /*  ---------------                                                       */     
  28. /*                                                                        */     
  29. /*    ALPHAE.C      - Source code                                         */
  30. /*    ALPHAE.DEF    - Module definition file                              */
  31. /*    ALPHA.H       - Application header file                             */
  32. /*                                                                        */
  33. /*    OS2.H          - Presentation Manager include file                  */     
  34. /*    STRING.H       - String handling function declarations              */     
  35. /*                                                                        */     
  36. /*  REQUIRED LIBRARIES:                                                   */                                                  
  37. /*  -------------------                                                   */     
  38. /*                                                                        */     
  39. /*    OS2386.LIB     - Presentation Manager/OS2 library                   */
  40. /*                                                                        */
  41. /* Use C/SET2 compiler, e.g.                                              */
  42. /* icc /Ge- /Fealphae.dll alphae.c alphae.def                             */
  43. /*                                                                        */
  44. /*  REQUIRED PROGRAMS:                                                    */     
  45. /*  ------------------                                                    */     
  46. /*    IBM C Compiler - icc                                                */                                                                          
  47. /*    IBM Linker                                                          */
  48. /*                                                                        */     
  49. /**************************************************************************/
  50.      
  51. #define INCL_BASE
  52. #define INCL_WIN
  53. #define INCL_GPI
  54. #define INCL_WINWINDOWMGR     
  55.  
  56. #include <os2.h>                   /* PM header file                      */
  57. #include <stdio.h>                 /* standard io                         */
  58. #include <CTYPE.H>
  59. #include <MALLOC.H>
  60. #include <STDLIB.H>
  61. #include <string.h>
  62.  
  63. /* External - global varialbles                                           */
  64.  
  65. #include "ALPHA.h"                 /* Resource symbolic identifiers       */
  66.  
  67.  
  68. #pragma subtitle("Alpha_parse_exit")
  69. #pragma page(1)
  70.  
  71. APIRET Alpha_parse_exit( HAB hab, FATTRS fat, FONTMETRICS fm,
  72.                        struct child pchild, char *ptr,
  73.                       int l, char *ptr0,
  74.                       int l0, int Cmt, int cmt_end, int recno,
  75.                       POINTL pAPTL[Max_record_size] )
  76. {
  77. /* hab       - PM anchor block handle                                     */
  78. /* fat       - Attributes of font                                         */
  79. /* fm        - Currently selected font metrics                            */
  80. /* pchild    - pointer to child structure                                 */
  81. /* ptr       - pointer to text string including offset                    */
  82. /* l         - length of record less offset                               */
  83. /* ptr0      - pointer to complete record                                 */
  84. /* l0        - length of complete record                                  */
  85. /* Cmt       - start position of comment in record or 0                   */
  86. /* cmt_end   - end position of comment in record or 0 - continued         */
  87. /* recno     - record number                                              */
  88. /* pAPTL     - pointer to array of character positions                    */
  89. /*                                                                        */
  90. /* return code - 0 - Execute standard Alpha parsing                       */
  91. /*               4 - Don't excute Alpha parsing - this routine has output */
  92. /*                   the text.                                            */
  93.  
  94.  
  95.  int e, i, m, p, q, s, w;
  96.  int cmt_start;
  97.  POINTL CurPos;                    /* Current end of line position        */
  98.  USHORT Left, Right = FALSE;       /* State of end of keywords            */
  99.  char Upp_rec[Max_record_size];    /* upper case copy of record           */
  100.  RECTL rc;
  101.  COLOR Text_clr = CLR_DARKBLUE;
  102.  COLOR Back_clr = CLR_WHITE;
  103.  COLOR Select_clr = CLR_RED;
  104.  COLOR Cmmt_Back_clr = CLR_GREEN;
  105.  COLOR Cmmt_clr = CLR_BLACK;
  106.  int Chr_height = 20;
  107.  HPS   Chps;                       /* Presentation Space handle           */
  108.  ERRORID  erridErrorCode;
  109.  
  110.  
  111.  
  112.  
  113.  Chps = WinGetPS(pchild.hwnd);
  114.  
  115.  GpiCreateLogFont( Chps, NULL, 1L, &fat ); /* create font 1               */
  116.  GpiSetCharSet( Chps , 1L );      /* select font                          */
  117.  
  118.  Chr_height =   fm.lMaxBaselineExt; /* chr. height                        */
  119.  
  120.  WinQueryWindowRect( pchild.hwnd, &rc ); /* reset window  rectangle       */
  121.  
  122.  
  123.  GpiSetBackMix( Chps, BM_OVERPAINT ); /*                                  */
  124.  GpiSetMix( Chps, FM_OVERPAINT );   /*                                    */
  125.  GpiSetColor( Chps, Text_clr );     /* colour of the text part            */
  126.  GpiSetBackColor( Chps, Back_clr ); /* colour of the text background      */
  127.  
  128.  
  129. /*                 |----select------|                                     */
  130. /*     -------------------------------------------------------            */
  131. /*     |  text               |           comment             |            */
  132. /*     -------------------------------------------------------            */
  133. /*     a           b         c      d                        e            */
  134. /*                                                                        */
  135.  
  136.  cmt_start = Cmt;
  137.  if (cmt_start >= 1)               /* =0 if no comment part               */
  138.   if (cmt_start>pchild.Offset)     /*                                     */
  139.    {                               /* reset comment start from offset     */
  140.     cmt_start = cmt_start - pchild.Offset;  /*                            */
  141.    }                               /*                                     */
  142.   else cmt_start = 1;              /* offset beyond comment start         */
  143.  
  144.  
  145.  if (cmt_start>0)
  146.     {
  147.       GpiCharStringAt( Chps, &pAPTL[0], cmt_start, ptr ); /* write text   */
  148.  
  149.                                    /* write out the comment part          */
  150.                                    /* colour of the comment background    */
  151.       GpiSetBackColor( Chps, Cmmt_Back_clr ); /*                          */
  152.       GpiSetColor( Chps, Cmmt_clr ); /* colour of the comment text part   */
  153.       GpiCharStringAt( Chps, &pAPTL[cmt_start-1],l-cmt_start+1,
  154.                               &ptr[cmt_start-1] );
  155.     }
  156.  else
  157.     {
  158.      GpiCharStringAt( Chps, &pAPTL[0], l, ptr ); /* write text            */
  159.     };
  160.                                    /* Need to fill rest of line           */
  161.  GpiQueryCurrentPosition( Chps, &CurPos );  /* get end of line            */
  162.  WinQueryWindowRect( pchild.hwnd, &rc ); /* get window  rectangle         */
  163.  rc.xLeft = CurPos.x;
  164.  rc.yBottom = CurPos.y - fm.lMaxDescender;
  165.  rc.yTop = CurPos.y + Chr_height - fm.lMaxDescender;
  166.  WinFillRect( Chps, &rc, CLR_BACKGROUND ); /* fill rectangle              */
  167.  
  168.  WinReleasePS(Chps);
  169.  
  170.  return (4);                       /* Don't call Alpha parsing            */
  171. };                                 /* end of Alpha_parse_exit             */
  172.  
  173.