home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / som / somk / c / tp / textline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-24  |  4.1 KB  |  153 lines

  1.  
  2. /*
  3.  *  This file was generated by the SOM Compiler.
  4.  *  Generated using:
  5.  *     SOM incremental update: 10.9
  6.  */
  7.  
  8.  
  9. #ifndef lint
  10. static char *sccsid = "%Z% %I% %W% %G% %U% [%H% %T%] (c)IBM Corp. 1992";
  11. #endif
  12.  
  13. /*
  14.  * This class is adapted from the book
  15.  *   Class Construction in C and C++, Object Oriented Fundamentals
  16.  *   by Roger Sessions, Copyright (c) 1992 Prentice Hall.
  17.  * Reprinted with permission.
  18.  */
  19.  
  20. #define textLine_Class_Source
  21. #if defined(_WIN32)
  22. #include "statcls.h"
  23. #endif
  24. #include "textline.ih"
  25. #include "helper.h"
  26. #include "tpword.h"
  27.  
  28. /* ************************************************************ */
  29. /*
  30.  *  Initialize a new text line with the number of characters
  31.  *  it can contain.
  32.  */
  33.  
  34. SOM_Scope void  SOMLINK tlInit(textLine *somSelf,
  35.         long newSize)
  36. {
  37.     textLineData *somThis = textLineGetData(somSelf);
  38.     textLineMethodDebug("textLine", "tlInit");
  39.     _totalChars = 0;
  40.     _maxSize = newSize;
  41. }
  42.  
  43. /* ************************************************************ */
  44. /*
  45.  *  Returns the number of characters in a textLine.
  46.  */
  47.  
  48. SOM_Scope long  SOMLINK tlCharsInLine(textLine *somSelf)
  49. {
  50.     textLineData *somThis = textLineGetData(somSelf);
  51.     textLineMethodDebug("textLine", "tlCharsInLine");
  52.     return _totalChars;
  53.  
  54. }
  55.  
  56. /* ************************************************************ */
  57. /*
  58.  *  Returns the number of characters that can still be placed
  59.  *  in the textLine.
  60.  */
  61.  
  62. SOM_Scope long  SOMLINK tlCharsLeft(textLine *somSelf)
  63. {
  64.     textLineData *somThis = textLineGetData(somSelf);
  65.     textLineMethodDebug("textLine", "tlCharsLeft");
  66.     return _maxSize - _totalChars;
  67. }
  68.  
  69. /* ************************************************************ */
  70. SOM_Scope baseType *SOMLINK llAddTail(textLine * somSelf,
  71.                        baseType * newElement)
  72. {
  73.     textLineData *somThis = textLineGetData(somSelf);
  74.     TPWord *myWord = (TPWord *) newElement;
  75.     int newTotal;
  76.     textLineMethodDebug("textLine", "llAddTail");
  77.  
  78.     newTotal = _totalChars + __get_length(newElement);
  79.     if (newTotal <= _maxSize) {
  80.     _totalChars = newTotal;
  81.     return (parent_llAddTail(somSelf, newElement));
  82.     }
  83.     else
  84.     return newElement;
  85. }
  86.  
  87. /* ************************************************************ */
  88. SOM_Scope baseType *SOMLINK llAddHead(textLine * somSelf,
  89.                        baseType * newElement)
  90. {
  91.     textLineData *somThis = textLineGetData(somSelf);
  92.     TPWord *myWord = (TPWord *) newElement;
  93.     int newTotal;
  94.     textLineMethodDebug("textLine", "llAddHead");
  95.  
  96.     newTotal = _totalChars + __get_length(newElement);
  97.     if (newTotal <= _maxSize) {
  98.     _totalChars = newTotal;
  99.     return (parent_llAddHead(somSelf, newElement));
  100.     }
  101.     else
  102.     return newElement;
  103. }
  104.  
  105. /* ************************************************************ */
  106. SOM_Scope baseType *SOMLINK llReplace(textLine * somSelf,
  107.                        baseType * newElement)
  108. {
  109.     textLineData *somThis = textLineGetData(somSelf);
  110.     textLineMethodDebug("textLine", "llReplace");
  111.     shouldHaveOverridden(somSelf, "llReplace");
  112.     newElement;
  113.     return (baseType *) NULL;
  114. }
  115.  
  116. /* ************************************************************ */
  117. SOM_Scope void SOMLINK somInit(textLine * somSelf)
  118. {
  119.     textLineData *somThis = textLineGetData(somSelf);
  120.     textLineMethodDebug("textLine", "somInit");
  121.     parent_somInit(somSelf);
  122.     _maxSize = 0;
  123.     _totalChars = 0;
  124. }
  125.  
  126. /* ************************************************************ */
  127. SOM_Scope void SOMLINK somUninit(textLine * somSelf)
  128. {
  129.     textLineData *somThis = textLineGetData(somSelf);
  130.     textLineMethodDebug("textLine", "somUninit");
  131.  
  132.     parent_somUninit(somSelf);
  133. }
  134.  
  135. /* ************************************************************ */
  136.  
  137. /*
  138.  * SOM_Scope void SOMLINK somDumpSelfInt(textLine * somSelf,
  139.  *                        int level)
  140.  */
  141.  
  142. /*
  143.  * The prototype for somDumpSelfInt was replaced by the following prototype:
  144.  */
  145. SOM_Scope void  SOMLINK somDumpSelfInt(textLine *somSelf,
  146.         long level)
  147. {
  148.     textLineData *somThis = textLineGetData(somSelf);
  149.     textLineMethodDebug("textLine", "somDumpSelfInt");
  150.  
  151.     parent_somDumpSelfInt(somSelf, level);
  152. }
  153.