home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 2.ddi / TVINC.ZIP / APP.H next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  7.0 KB  |  269 lines

  1. /* ------------------------------------------------------------------------*/
  2. /*                                                                         */
  3. /*   APP.H                                                                 */
  4. /*                                                                         */
  5. /*   Copyright (c) Borland International 1991                              */
  6. /*   All Rights Reserved.                                                  */
  7. /*                                                                         */
  8. /*   defines the classes TBackground, TDeskTop, TProgram, and TApplication */
  9. /*                                                                         */
  10. /* ------------------------------------------------------------------------*/
  11.  
  12. #pragma option -Vo-
  13. #if defined( __BCOPT__ )
  14. #pragma option -po-
  15. #endif
  16.  
  17. #if defined( Uses_TBackground ) && !defined( __TBackground )
  18. #define __TBackground
  19.     
  20. class far TRect;
  21.  
  22. class TBackground : public TView
  23. {
  24.  
  25. public:
  26.  
  27.     TBackground( const TRect& bounds, char aPattern );
  28.     virtual void draw();
  29.     virtual TPalette& getPalette() const;
  30.  
  31. protected:
  32.  
  33.     char pattern;
  34.  
  35. private:
  36.  
  37.     virtual const char *streamableName() const
  38.         { return name; }
  39.  
  40. protected:
  41.  
  42.     TBackground( StreamableInit );
  43.     virtual void write( opstream& );
  44.     virtual void *read( ipstream& );
  45.  
  46. public:
  47.  
  48.     static const char * const near name;
  49.     static TStreamable *build();
  50.  
  51. };
  52.  
  53. inline ipstream& operator >> ( ipstream& is, TBackground& cl )
  54.     { return is >> (TStreamable&)cl; }
  55. inline ipstream& operator >> ( ipstream& is, TBackground*& cl )
  56.     { return is >> (void *&)cl; }
  57.  
  58. inline opstream& operator << ( opstream& os, TBackground& cl )
  59.     { return os << (TStreamable&)cl; }
  60. inline opstream& operator << ( opstream& os, TBackground* cl )
  61.     { return os << (TStreamable *)cl; }
  62.  
  63. #endif  // Uses_TBackground
  64.  
  65.  
  66. #if defined( Uses_TDeskTop )  && !defined( __TDeskTop )
  67. #define __TDeskTop
  68.  
  69. class far TBackground;
  70. class far TRect;
  71. class far TEvent;
  72.  
  73. class TDeskInit
  74. {
  75.  
  76. public:
  77.  
  78.     TDeskInit( TBackground *(*cBackground)( TRect ) );
  79.  
  80. protected:
  81.  
  82.     TBackground *(*createBackground)( TRect );
  83.  
  84. };
  85.  
  86. class TDeskTop : public TGroup, public virtual TDeskInit
  87. {
  88.  
  89. public:
  90.  
  91.     TDeskTop( const TRect& );
  92.  
  93.     void cascade( const TRect& );
  94.     virtual void handleEvent( TEvent& );
  95.     static TBackground *initBackground( TRect );
  96.     void tile( const TRect& );
  97.     virtual void tileError();
  98.     virtual void shutDown();
  99.  
  100. protected:
  101.  
  102.     TBackground *background;
  103.  
  104. private:
  105.  
  106.     static const char near defaultBkgrnd;
  107.     
  108.     virtual const char *streamableName() const
  109.         { return name; }
  110.  
  111. protected:
  112.  
  113.     TDeskTop( StreamableInit );
  114.  
  115. public:
  116.  
  117.     static const char * const near name;
  118.     static TStreamable *build();
  119.  
  120. };
  121.  
  122. inline ipstream& operator >> ( ipstream& is, TDeskTop& cl )
  123.     { return is >> (TStreamable&)(TGroup&)cl; }
  124. inline ipstream& operator >> ( ipstream& is, TDeskTop*& cl )
  125.     { return is >> (void *&)cl; }
  126.  
  127. inline opstream& operator << ( opstream& os, TDeskTop& cl )
  128.     { return os << (TStreamable&)(TGroup&)cl; }
  129. inline opstream& operator << ( opstream& os, TDeskTop* cl )
  130.     { return os << (TStreamable *)(TGroup *)cl; }
  131.  
  132. #endif
  133.  
  134.  
  135. #if defined( Uses_TProgram ) && !defined( __TProgram )
  136. #define __TProgram
  137.  
  138. #define cpColor \
  139.     "\x71\x70\x78\x74\x20\x28\x24\x17\x1F\x1A\x31\x31\x1E\x71\x00" \
  140.     "\x37\x3F\x3A\x13\x13\x3E\x21\x00\x70\x7F\x7A\x13\x13\x70\x7F\x00" \
  141.     "\x70\x7F\x7A\x13\x13\x70\x70\x7F\x7E\x20\x2B\x2F\x78\x2E\x70\x30" \
  142.     "\x3F\x3E\x1F\x2F\x1A\x20\x72\x31\x31\x30\x2F\x3E\x31\x13\x00\x00"
  143.  
  144. #define cpBlackWhite \
  145.     "\x70\x70\x78\x7F\x07\x07\x0F\x07\x0F\x07\x70\x70\x07\x70\x00" \
  146.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x7F\x7F\x70\x07\x70\x07\x00" \
  147.     "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  148.     "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x00\x00"
  149.  
  150. #define cpMonochrome \
  151.     "\x70\x07\x07\x0F\x70\x70\x70\x07\x0F\x07\x70\x70\x07\x70\x00" \
  152.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x70\x70\x07\x07\x70\x07\x00" \
  153.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  154.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x00\x00"
  155.  
  156.  
  157. class far TStatusLine;
  158. class far TMenuBar;
  159. class far TDeskTop;
  160. class far TEvent;
  161. class far TView;
  162.  
  163. class TProgInit
  164. {
  165.  
  166. public:
  167.  
  168.     TProgInit( TStatusLine *(*cStatusLine)( TRect ),
  169.                TMenuBar *(*cMenuBar)( TRect ),
  170.                TDeskTop *(*cDeskTop )( TRect )
  171.              );
  172.  
  173. protected:
  174.  
  175.     TStatusLine *(*createStatusLine)( TRect );
  176.     TMenuBar *(*createMenuBar)( TRect );
  177.     TDeskTop *(*createDeskTop)( TRect );
  178.  
  179. };
  180.  
  181. /* ---------------------------------------------------------------------- */
  182. /*      class TProgram                                                    */
  183. /*                                                                        */
  184. /*      Palette layout                                                    */
  185. /*          1 = TBackground                                               */
  186. /*       2- 7 = TMenuView and TStatusLine                                 */
  187. /*       8-15 = TWindow(Blue)                                             */
  188. /*      16-23 = TWindow(Cyan)                                             */
  189. /*      24-31 = TWindow(Gray)                                             */
  190. /*      32-63 = TDialog                                                   */
  191. /* ---------------------------------------------------------------------- */
  192.  
  193. const
  194.  
  195. //  TApplication palette entries
  196.  
  197.     apColor      = 0,
  198.     apBlackWhite = 1,
  199.     apMonochrome = 2;
  200.  
  201. class TProgram : public TGroup, public virtual TProgInit
  202. {
  203.  
  204. public:
  205.  
  206.     TProgram();
  207.     virtual ~TProgram();
  208.  
  209.     virtual void getEvent(TEvent& event);
  210.     virtual TPalette& getPalette() const;
  211.     virtual void handleEvent(TEvent& event);
  212.     virtual void idle();
  213.     virtual void initScreen();
  214.     virtual void outOfMemory();
  215.     virtual void putEvent( TEvent& event );
  216.     virtual void run();
  217.     void setScreenMode( ushort mode );
  218.     TView *validView( TView *p );
  219.     virtual void shutDown();
  220.  
  221.     virtual void suspend() {}
  222.     virtual void resume() {}
  223.  
  224.     static TStatusLine *initStatusLine( TRect );
  225.     static TMenuBar *initMenuBar( TRect );
  226.     static TDeskTop *initDeskTop( TRect );
  227.  
  228.     static TProgram * near application;
  229.     static TStatusLine * near statusLine;
  230.     static TMenuBar * near menuBar;
  231.     static TDeskTop * near deskTop;
  232.     static int near appPalette;
  233.  
  234. protected:
  235.  
  236.     static TEvent near pending;
  237.  
  238. private:
  239.  
  240.     static const char * near exitText;
  241.  
  242. };
  243.  
  244. #endif
  245.  
  246. #if defined( Uses_TApplication ) && !defined( __TApplication )
  247. #define __TApplication
  248.  
  249. class TApplication : public TProgram
  250. {
  251.  
  252. protected:
  253.  
  254.     TApplication();
  255.     virtual ~TApplication();
  256.  
  257.     virtual void suspend();
  258.     virtual void resume();
  259.  
  260. };
  261.  
  262. #endif
  263.  
  264. #pragma option -Vo.
  265. #if defined( __BCOPT__ )
  266. #pragma option -po.
  267. #endif
  268.  
  269.