home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / streams / stream / funkview.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-30  |  3.4 KB  |  132 lines

  1. //========================================================================
  2. //  The following example routines have been provided by the Technical
  3. //  Support staff at Borland International.  They are provided as a
  4. //  courtesy and not as part of a Borland product, and as such, are
  5. //  provided without the assurance of technical support or any specific
  6. //  guarantees.
  7. //========================================================================
  8. //
  9. // funkview.h:  The class definition for TMyApp.
  10. //
  11.  
  12. //
  13. // class FunkyView
  14. //      View that simply displays some text on the screen in a random color.
  15. //
  16. // Member functions:
  17. //      FunkyView - Constructor
  18. //      ~FunkyView - Destructor
  19. //      draw - Display the text
  20. //
  21. //    for stream support:
  22. //      FunkyView - stream constructor
  23. //      streamableName
  24. //      build
  25. //      read
  26. //      write
  27. //
  28.  
  29. class FunkyView : public TView
  30. {
  31.  
  32. public:
  33.  
  34.     FunkyView( TRect& r, char *word );
  35.     ~FunkyView() { delete text; }
  36.     virtual void draw();
  37.  
  38. private:
  39.  
  40.     char *text;
  41.  
  42. // Stream support is from here on down.
  43.  
  44.     virtual const char *streamableName() const
  45.         { return name; }
  46.  
  47. protected:
  48.  
  49.     virtual void write( opstream& op );
  50.     virtual void *read( ipstream& ip );
  51.  
  52. public:
  53.  
  54.     FunkyView( StreamableInit ) : TView( streamableInit ) { }
  55.     static TStreamable *build();
  56.  
  57.     static const char * const name;
  58.  
  59. };
  60.  
  61. inline ipstream& operator >> ( ipstream& is, FunkyView& cl )
  62.     { return is >> (TStreamable&) cl; }
  63. inline ipstream& operator >> ( ipstream& is, FunkyView*& cl )
  64.     { return is >> (void *&) cl; }
  65.  
  66. inline opstream& operator << ( opstream& os, FunkyView& cl )
  67.     { return os << (TStreamable&) cl; }
  68. inline opstream& operator << ( opstream& os, FunkyView* cl )
  69.     { return os << (TStreamable *) cl; }
  70.  
  71.  
  72. //
  73. // classFunkyWindow -
  74. //   provides encapsulation for FunkyView, as well as the ability to move
  75. //   the view around the screen and remove it from the desktop with little
  76. //   coding (since TWindow's automatically calls cmClose)
  77. //
  78. // Member functions:
  79. //      FunkyWindow - Constructor
  80. //      sizeLimits - so we can have a smaller than regulation TWindow.
  81. //
  82. //    for stream support:
  83. //      FunkyWindow - stream constructor
  84. //      streamableName
  85. //      build
  86. //      read
  87. //      write
  88. //
  89.  
  90. #define FUNK_WIDTH  31
  91. #define FUNK_HEIGHT  7
  92.  
  93.  
  94. #pragma argsused
  95.  
  96. class FunkyWindow : public TWindow
  97. {
  98.  
  99. public:
  100.  
  101.     FunkyWindow( TRect& r, char *words);
  102.  
  103. // Stream support is from here on down.
  104.  
  105.     virtual const char *streamableName() const
  106.         { return name; }
  107.  
  108. protected:
  109.  
  110. //    virtual void write( opstream& op );       // These will be inherited.
  111. //    virtual void *read( ipstream& ip );
  112.  
  113. public:
  114.  
  115.     FunkyWindow( StreamableInit ) : TWindow( streamableInit ),
  116.                                     TWindowInit( streamableInit ) { }
  117.     static TStreamable *build();
  118.  
  119.     static const char * const name;
  120.  
  121. };
  122.  
  123. inline ipstream& operator >> ( ipstream& is, FunkyWindow& cl )
  124.     { return is >> (TStreamable&) cl; }
  125. inline ipstream& operator >> ( ipstream& is, FunkyWindow*& cl )
  126.     { return is >> (void *&) cl; }
  127.  
  128. inline opstream& operator << ( opstream& os, FunkyWindow& cl )
  129.     { return os << (TStreamable&) cl; }
  130. inline opstream& operator << ( opstream& os, FunkyWindow* cl )
  131.     { return os << (TStreamable *) cl; }
  132.