home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 2.ddi / TVDEMOS.ZIP / PUZZLE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.5 KB  |  97 lines

  1. /*---------------------------------------------------------*/
  2. /*                                                         */
  3. /*   Turbo Vision 1.0                                      */
  4. /*   Copyright (c) 1991 by Borland International           */
  5. /*                                                         */
  6. /*   Puzzle.h : Header file for puzzle.cpp                 */
  7. /*---------------------------------------------------------*/
  8.  
  9. #if !defined( __PUZZLE_H )
  10. #define __PUZZLE_H
  11.  
  12. class TPuzzleView : public TView
  13. {
  14.  
  15. public:
  16.  
  17.     TPuzzleView(TRect& r);
  18.     TPuzzleView( StreamableInit ) : TView(streamableInit) { };
  19.     virtual TPalette& getPalette() const;
  20.     virtual void handleEvent(TEvent& event);
  21.     virtual void draw();
  22.     void moveKey(int key);
  23.     void moveTile(TPoint point);
  24.     void scramble();
  25.     void winCheck();
  26.  
  27. private:
  28.  
  29.     char board[6][6];
  30.     int moves;
  31.     char solved;
  32.  
  33.     virtual const char *streamableName() const
  34.         { return name; }
  35.  
  36. protected:
  37.  
  38.     virtual void write( opstream& );
  39.     virtual void *read( ipstream& );
  40.  
  41. public:
  42.  
  43.     static const char * const name;
  44.     static TStreamable *build();
  45.  
  46. };
  47.  
  48. inline ipstream& operator >> ( ipstream& is, TPuzzleView& cl )
  49.     { return is >> (TStreamable&) cl; }
  50. inline ipstream& operator >> ( ipstream& is, TPuzzleView*& cl )
  51.     { return is >> (void *&) cl; }
  52.  
  53. inline opstream& operator << ( opstream& os, TPuzzleView& cl )
  54.     { return os << (TStreamable&) cl; }
  55. inline opstream& operator << ( opstream& os, TPuzzleView* cl )
  56.     { return os << (TStreamable *) cl; }
  57.  
  58.  
  59. class TPuzzleWindow : public TWindow
  60. {
  61.  
  62. public:
  63.  
  64.     TPuzzleWindow();
  65.     TPuzzleWindow( StreamableInit ) :
  66.         TWindow(streamableInit), TWindowInit(&TPuzzleWindow::initFrame) { };
  67.  
  68. private:
  69.  
  70.     virtual const char *streamableName() const
  71.         { return name; }
  72.  
  73. protected:
  74.  
  75.     virtual void write( opstream& );
  76.     virtual void *read( ipstream& );
  77.  
  78. public:
  79.  
  80.     static const char * const name;
  81.     static TStreamable *build();
  82.  
  83. };
  84.  
  85. inline ipstream& operator >> ( ipstream& is, TPuzzleWindow& cl )
  86.     { return is >> (TStreamable&) cl; }
  87. inline ipstream& operator >> ( ipstream& is, TPuzzleWindow*& cl )
  88.     { return is >> (void *&) cl; }
  89.  
  90. inline opstream& operator << ( opstream& os, TPuzzleWindow& cl )
  91.     { return os << (TStreamable&) cl; }
  92. inline opstream& operator << ( opstream& os, TPuzzleWindow* cl )
  93.     { return os << (TStreamable *) cl; }
  94.  
  95.  
  96. #endif      // __PUZZLE_H
  97.