home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / os2tk21j / c / samples / tp / page.c__ / page.c
Encoding:
C/C++ Source or Header  |  1993-03-12  |  4.2 KB  |  158 lines

  1. #ifndef lint
  2. static char *sccsid = "@(#)page.c 1.3 1/22/92 16:10:49 [1/26/92] (c)IBM Corp. 1992";
  3. #endif
  4.  
  5. /*
  6.  * This class is adapted from the book
  7.  *   Class Construction in C and C++, Object Oriented Fundamentals
  8.  *   by Roger Sessions, Copyright (c) 1992 Prentice Hall.
  9.  * Reprinted with permission.
  10.  */
  11.  
  12. #define page_Class_Source
  13. #include <stdio.h>
  14. #include "page.ih"
  15.  
  16. #define MAX_WORDS_IN_HEADER 100
  17. #define MAX_WORDS_IN_FOOTER 100
  18.  
  19. /* ************************************************************ */
  20. SOM_Scope void SOMLINK pgPrint(page * somSelf,
  21.                 FILE * output)
  22. {
  23.     pageData *somThis = pageGetData(somSelf);
  24.     char buffer[10];
  25.     pageMethodDebug("page", "pgPrint");
  26.  
  27. /* Print header.
  28.    ------------- */
  29.     _pageNumber++;
  30.     if (_pageWord) {
  31.     sprintf(buffer, "%d", _pageNumber);
  32.     _wrdReplace(_pageWord, buffer);
  33.     }
  34.     fprintf(output, "\n\f");
  35.     if (_header)
  36.     _print(_header, output);
  37.     fprintf(output, "\n\n");
  38.  
  39. /* Print text.
  40.    ----------- */
  41.     if (_columns)
  42.     _print(_columns, output);
  43.     fprintf(output, "\n\n");
  44.  
  45. /* Print footer.
  46.    ------------- */
  47.     if (_footer)
  48.     _print(_footer, output);
  49.  
  50. /* Clear out text from somThis column block.
  51.    -------------------------------------- */
  52.     _somFree(_columns);
  53.     _columns = 0;
  54. }
  55.  
  56. /* ************************************************************ */
  57. SOM_Scope void SOMLINK pgSetHeight(page * somSelf,
  58.                     int newHeight)
  59. {
  60.     pageData *somThis = pageGetData(somSelf);
  61.     pageMethodDebug("page", "pgSetHeight");
  62.     _height = newHeight;
  63. }
  64.  
  65. /* ************************************************************ */
  66. SOM_Scope void SOMLINK pgSetWidth(page * somSelf,
  67.                    int newWidth)
  68. {
  69.     pageData *somThis = pageGetData(somSelf);
  70.     pageMethodDebug("page", "pgSetWidth");
  71.     _width = newWidth;
  72.  
  73. }
  74.  
  75. /* ************************************************************ */
  76. SOM_Scope void SOMLINK pgSetNumberOfColumns(page * somSelf,
  77.                          int newColumns)
  78. {
  79.     pageData *somThis = pageGetData(somSelf);
  80.     pageMethodDebug("page", "pgSetNumberOfColumns");
  81.     _ncolumns = newColumns;
  82. }
  83.  
  84. /* ************************************************************ */
  85. SOM_Scope void SOMLINK pgSetPageNumber(page * somSelf,
  86.                     TPWord * newPageWord)
  87. {
  88.     pageData *somThis = pageGetData(somSelf);
  89.     pageMethodDebug("page", "pgSetPageNumber");
  90.     _pageWord = newPageWord;
  91. }
  92.  
  93. /* ************************************************************ */
  94. SOM_Scope columnBlock *SOMLINK pgGetColumnBlock(page * somSelf)
  95. {
  96.     pageData *somThis = pageGetData(somSelf);
  97.     pageMethodDebug("page", "pgGetColumnBlock");
  98.  
  99.     if (!_columns) {
  100.     _columns = columnBlockNew();
  101.     _cbInit(_columns, _ncolumns, _height, _width);
  102.     }
  103.     return _columns;
  104. }
  105.  
  106. /* ************************************************************ */
  107. SOM_Scope textLine *SOMLINK pgGetHeaderBlock(page * somSelf)
  108. {
  109.     pageData *somThis = pageGetData(somSelf);
  110.     pageMethodDebug("page", "pgGetHeaderBlock");
  111.  
  112.     if (!_header) {
  113.     _header = textLineNew();
  114.     _tlInit(_header, MAX_WORDS_IN_HEADER);
  115.     }
  116.     return _header;
  117. }
  118.  
  119. /* ************************************************************ */
  120. SOM_Scope textLine *SOMLINK pgGetFooterBlock(page * somSelf)
  121. {
  122.     pageData *somThis = pageGetData(somSelf);
  123.     pageMethodDebug("page", "pgGetFooterBlock");
  124.     if (!_footer) {
  125.     _footer = textLineNew();
  126.     _tlInit(_footer, MAX_WORDS_IN_FOOTER);
  127.     }
  128.     return _footer;
  129. }
  130.  
  131. /* ************************************************************ */
  132. SOM_Scope void SOMLINK somInit(page * somSelf)
  133. {
  134.     pageData *somThis = pageGetData(somSelf);
  135.     pageMethodDebug("page", "somInit");
  136.  
  137.     parent_somInit(somSelf);
  138. }
  139.  
  140. /* ************************************************************ */
  141. SOM_Scope void SOMLINK somUninit(page * somSelf)
  142. {
  143.     pageData *somThis = pageGetData(somSelf);
  144.     pageMethodDebug("page", "somUninit");
  145.  
  146.     parent_somUninit(somSelf);
  147. }
  148.  
  149. /* ************************************************************ */
  150. SOM_Scope void SOMLINK somDumpSelfInt(page * somSelf,
  151.                        int level)
  152. {
  153.     pageData *somThis = pageGetData(somSelf);
  154.     pageMethodDebug("page", "somDumpSelfInt");
  155.  
  156.     parent_somDumpSelfInt(somSelf, level);
  157. }
  158.