home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / bcpp / file18 / texplode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  6.2 KB  |  192 lines

  1. // Program : TEXPLODE.H
  2. // Author  : Eric Woodruff,  CIS ID: 72134,1150
  3. // Updated : Wed 08/25/93 09:42:58
  4. // Note    : Copyright 1993, Eric Woodruff, All rights reserved
  5. // Compiler: Borland C++ 3.1
  6. //
  7. // This header file defines a TWindow derived class and a TDialog derived
  8. // class that can explode on opening or showing and implode on closing
  9. // or hiding.
  10. //
  11. // If you use these classes in your own programs, please send $10 to:
  12. //
  13. // Eric Woodruff
  14. // 16719 Lakeside Drive
  15. // Medical Lake WA 99022
  16. //
  17. // Feel free to distribute these files to anyone, but please distribute them
  18. // in UNMODIFIED form.  If you find any bugs or make any interesting changes,
  19. // please let me know so that I can maintain these classes and distribute
  20. // the updates.
  21. //
  22. // I can be reached on CompuServe at 72134,1150 if you have any
  23. // questions or comments.  Thanks for trying these classes out!
  24. //
  25.  
  26. #if !defined(__TEXPLODE_H)
  27. #define __TEXPLODE_H
  28.  
  29. // Found in TGROUP.CPP and required by the changeBounds() functions.
  30. extern void doCalcChange(TView *p, void *d);
  31.  
  32. // Direction types.
  33. enum Direction { expImploding = -1, expNeither, expExploding };
  34.  
  35. #if defined(Uses_TExplodeWindow) && !defined(__TExplodeWindow)
  36. #define __TExplodeWindow
  37.  
  38. class far TRect;
  39. class far TWindow;
  40.  
  41. class TExplodeWindow : public TWindow
  42. {
  43. private:
  44.     Boolean   WillExplode, WillImplode;     // Flags to signal the need
  45.     Direction Is_Exploding_Imploding;       // to explode or implode.
  46.     short     msDelay;                      // Milliseconds between draws.
  47.  
  48.     void Explode(void);     // Explode the window upon opening/showing.
  49.     void Implode(void);     // Implode the window upon closing/hiding.
  50.     void ExpImpDraw(void);  // Specialized explode/implode draw.
  51.  
  52. public:
  53.     TExplodeWindow(const TRect &r, const char *aTitle, short aNumber) :
  54.         TWindow(r, aTitle, aNumber), TWindowInit(&TExplodeWindow::initFrame)
  55.     {
  56.         // Default to exploding window.
  57.         msDelay = 20;           // Default to 20ms delay.
  58.         WillExplode = True;
  59.         WillImplode = False;
  60.         Is_Exploding_Imploding = expNeither;
  61.     }
  62.  
  63.     virtual void setState(ushort aState, Boolean enable);
  64.     virtual void changeBounds(const TRect &bounds);
  65.     virtual void sizeLimits(TPoint &min, TPoint &max);
  66.     virtual void draw(void);
  67.     virtual void close(void);
  68.  
  69.     // Turn it back into a normal window.
  70.     inline void MakeItNormal(void)
  71.         {  WillExplode = WillImplode = False; }
  72.  
  73.     // Tell the window to explode on opening and implode on closing.
  74.     // Also used to change the explode/implode delay.
  75.     inline void MakeItExplode(short ms)
  76.         {   WillExplode = True;  msDelay = ms; }
  77.  
  78.     // Get the current explode/implode delay factor.
  79.     inline short GetDelay(void)
  80.         {  return msDelay; }
  81.  
  82. // This stuff will make it streamable.
  83. private:
  84.     virtual const char *streamableName() const
  85.         { return name; }
  86.  
  87. protected:
  88.     TExplodeWindow(StreamableInit) : TWindow(streamableInit),
  89.         TWindowInit(streamableInit) {}
  90.  
  91. public:
  92.     static const char * const near name;
  93.     static TStreamable *build();
  94.  
  95. protected:
  96.     virtual void write(opstream &);
  97.     virtual void *read(ipstream &);
  98. };
  99.  
  100. inline ipstream& operator >> ( ipstream& is, TExplodeWindow& cl )
  101.     { return is >> (TStreamable&)cl; }
  102. inline ipstream& operator >> ( ipstream& is, TExplodeWindow*& cl )
  103.     { return is >> (void *&)cl; }
  104.  
  105. inline opstream& operator << ( opstream& os, TExplodeWindow& cl )
  106.     { return os << (TStreamable&)cl; }
  107. inline opstream& operator << ( opstream& os, TExplodeWindow* cl )
  108.     { return os << (TStreamable *)cl; }
  109.  
  110. #endif      // TExplodeWindow
  111.  
  112. #if defined(Uses_TExplodeDialog) && !defined(__TExplodeDialog)
  113. #define __TExplodeDialog
  114.  
  115. class far TRect;
  116. class far TDialog;
  117. class far TWindow;
  118. class far TWindowInit;
  119.  
  120. class TExplodeDialog : public TDialog
  121. {
  122. private:
  123.     Boolean   WillExplode, WillImplode;     // Flags to signal the need
  124.     Direction Is_Exploding_Imploding;       // to explode or implode.
  125.     short     msDelay;                      // Milliseconds between draws.
  126.  
  127.     void Explode(void);     // Explode the window upon opening/showing.
  128.     void Implode(void);     // Implode the window upon closing/hiding.
  129.     void ExpImpDraw(void);  // Specialized explode/implode draw.
  130.  
  131. public:
  132.     TExplodeDialog(const TRect &r, const char *aTitle) :
  133.         TDialog(r, aTitle), TWindowInit(&TExplodeDialog::initFrame)
  134.     {
  135.         // Default to exploding dialog box.
  136.         msDelay = 20;           // Default to 20ms delay.
  137.         WillExplode = True;
  138.         WillImplode = False;
  139.         Is_Exploding_Imploding = expNeither;
  140.     }
  141.  
  142.     virtual void setState(ushort aState, Boolean enable);
  143.     virtual void changeBounds(const TRect &bounds);
  144.     virtual void sizeLimits(TPoint &min, TPoint &max);
  145.     virtual void draw(void);
  146.     virtual void close(void);
  147.  
  148.     // Turn it back into a normal window.
  149.     inline void MakeItNormal(void)
  150.         {  WillExplode = WillImplode = False; }
  151.  
  152.     // Tell the window to explode on opening and implode on closing.
  153.     // Also used to change the explode/implode delay.
  154.     inline void MakeItExplode(short ms)
  155.         {   WillExplode = True;  msDelay = ms; }
  156.  
  157.     // Get the current explode/implode delay factor.
  158.     inline short GetDelay(void)
  159.         {  return msDelay; }
  160.  
  161. // This stuff will make it streamable.
  162. private:
  163.     virtual const char *streamableName() const
  164.         { return name; }
  165.  
  166. protected:
  167.     TExplodeDialog(StreamableInit) : TDialog(streamableInit),
  168.         TWindowInit(&TExplodeDialog::initFrame) {}
  169.  
  170. public:
  171.     static const char * const near name;
  172.     static TStreamable *build();
  173.  
  174. protected:
  175.     virtual void write(opstream &);
  176.     virtual void *read(ipstream &);
  177. };
  178.  
  179. inline ipstream& operator >> ( ipstream& is, TExplodeDialog& cl )
  180.     { return is >> (TStreamable&)cl; }
  181. inline ipstream& operator >> ( ipstream& is, TExplodeDialog*& cl )
  182.     { return is >> (void *&)cl; }
  183.  
  184. inline opstream& operator << ( opstream& os, TExplodeDialog& cl )
  185.     { return os << (TStreamable&)cl; }
  186. inline opstream& operator << ( opstream& os, TExplodeDialog* cl )
  187.     { return os << (TStreamable *)cl; }
  188.  
  189. #endif      // TExplodeDialog
  190.  
  191. #endif      // __TEXPLODE_H
  192.