home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20cpp.zip / tvision / app.h next >
C/C++ Source or Header  |  1998-03-29  |  11KB  |  352 lines

  1. /*
  2.  * app.h
  3.  *
  4.  * Turbo Vision - Version 2.0
  5.  *
  6.  * Copyright (c) 1994 by Borland International
  7.  * All Rights Reserved.
  8.  *
  9.  * Modified by Sergio Sigala <ssigala@globalnet.it>
  10.  */
  11.  
  12. #if defined( Uses_TBackground ) && !defined( __TBackground )
  13. #define __TBackground
  14.  
  15. class TRect;
  16.  
  17. class TBackground : public TView
  18. {
  19.  
  20. public:
  21.  
  22.     TBackground( const TRect& bounds, char aPattern );
  23.     virtual void draw();
  24.     virtual TPalette& getPalette() const;
  25.  
  26. protected:
  27.  
  28.     char pattern;
  29.  
  30. private:
  31.  
  32.     virtual const char *streamableName() const
  33.         { return name; }
  34.  
  35. protected:
  36.  
  37.     TBackground( StreamableInit );
  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, TBackground& cl )
  49.     { return is >> (TStreamable&)cl; }
  50. inline ipstream& operator >> ( ipstream& is, TBackground*& cl )
  51.     { return is >> (void *&)cl; }
  52.  
  53. inline opstream& operator << ( opstream& os, TBackground& cl )
  54.     { return os << (TStreamable&)cl; }
  55. inline opstream& operator << ( opstream& os, TBackground* cl )
  56.     { return os << (TStreamable *)cl; }
  57.  
  58. #endif  // Uses_TBackground
  59.  
  60.  
  61. #if defined( Uses_TDeskTop )  && !defined( __TDeskTop )
  62. #define __TDeskTop
  63.  
  64. class TBackground;
  65. class TRect;
  66. class TEvent;
  67.  
  68. class TDeskInit
  69. {
  70.  
  71. public:
  72.  
  73.     TDeskInit( TBackground *(*cBackground)( TRect ) );
  74.  
  75. protected:
  76.  
  77.     TBackground *(*createBackground)( TRect );
  78.  
  79. };
  80.  
  81. class TDeskTop : public TGroup, public virtual TDeskInit
  82. {
  83.  
  84. public:
  85.  
  86.     TDeskTop( const TRect& );
  87.  
  88.     void cascade( const TRect& );
  89.     virtual void handleEvent( TEvent& );
  90.     static TBackground *initBackground( TRect );
  91.     void tile( const TRect& );
  92.     virtual void tileError();
  93.     virtual void shutDown();
  94.     static /*const*/ char defaultBkgrnd;
  95.  
  96. protected:
  97.  
  98.     TBackground *background;
  99.     Boolean tileColumnsFirst;
  100.  
  101. private:
  102.  
  103. //    static const char defaultBkgrnd;
  104.  
  105.     virtual const char *streamableName() const
  106.         { return name; }
  107.  
  108. protected:
  109.  
  110.     TDeskTop( StreamableInit );
  111.  
  112. public:
  113.  
  114.     static const char * const name;
  115.     static TStreamable *build();
  116.  
  117. };
  118.  
  119. inline ipstream& operator >> ( ipstream& is, TDeskTop& cl )
  120.     { return is >> (TStreamable&)(TGroup&)cl; }
  121. inline ipstream& operator >> ( ipstream& is, TDeskTop*& cl )
  122.     { return is >> (void *&)cl; }
  123.  
  124. inline opstream& operator << ( opstream& os, TDeskTop& cl )
  125.     { return os << (TStreamable&)(TGroup&)cl; }
  126. inline opstream& operator << ( opstream& os, TDeskTop* cl )
  127.     { return os << (TStreamable *)(TGroup *)cl; }
  128.  
  129. #endif
  130.  
  131. // Turbo Vision 2.0 Color Palettes
  132.  
  133. #ifndef __UNPATCHED
  134. #define cpAppColor \
  135.        "\x71\x70\x78\x74\x20\x28\x24\x17\x1F\x1A\x31\x31\x1E\x71\x1F" \
  136.     "\x37\x3F\x3A\x13\x13\x3E\x21\x3F\x70\x7F\x7A\x13\x13\x70\x7F\x7E" \
  137.     "\x70\x7F\x7A\x13\x13\x70\x70\x7F\x7E\x20\x2B\x2F\x78\x2E\x70\x30" \
  138.     "\x3F\x3E\x1F\x2F\x1A\x20\x72\x31\x31\x30\x2F\x3E\x31\x13\x38\x00" \
  139.     "\x17\x1F\x1A\x71\x71\x1E\x17\x1F\x1E\x20\x2B\x2F\x78\x2E\x10\x30" \
  140.     "\x3F\x3E\x70\x2F\x7A\x20\x12\x31\x31\x30\x2F\x3E\x31\x13\x38\x00" \
  141.     "\x37\x3F\x3A\x13\x13\x3E\x30\x3F\x3E\x20\x2B\x2F\x78\x2E\x30\x70" \
  142.     "\x7F\x7E\x1F\x2F\x1A\x20\x32\x31\x71\x70\x2F\x7E\x71\x13\x78\x00" \
  143.     "\x37\x3F\x3A\x13\x13\x30\x3E\x1E"    // help colors
  144. #else
  145. #define cpAppColor \
  146.        "\x71\x70\x78\x74\x20\x28\x24\x17\x1F\x1A\x31\x31\x1E\x71\x1F" \
  147.     "\x37\x3F\x3A\x13\x13\x3E\x21\x3F\x70\x7F\x7A\x13\x13\x70\x7F\x7E" \
  148.     "\x70\x7F\x7A\x13\x13\x70\x70\x7F\x7E\x20\x2B\x2F\x78\x2E\x70\x30" \
  149.     "\x3F\x3E\x1F\x2F\x1A\x20\x72\x31\x31\x30\x2F\x3E\x31\x13\x38\x00" \
  150.     "\x17\x1F\x1A\x71\x71\x1E\x17\x1F\x1E\x20\x2B\x2F\x78\x2E\x10\x30" \
  151.     "\x3F\x3E\x70\x2F\x7A\x20\x12\x31\x31\x30\x2F\x3E\x31\x13\x38\x00" \
  152.     "\x37\x3F\x3A\x13\x13\x3E\x30\x3F\x3E\x20\x2B\x2F\x78\x2E\x30\x70" \
  153.     "\x7F\x7E\x1F\x2F\x1A\x20\x32\x31\x71\x70\x2F\x7E\x71\x13\x38\x00" \
  154.     "\x37\x3F\x3A\x13\x13\x30\x3E\x1E"    // help colors
  155. #endif
  156.  
  157. #ifndef __UNPATCHED
  158. #define cpAppBlackWhite \
  159.        "\x70\x70\x78\x7F\x07\x07\x0F\x07\x0F\x07\x70\x70\x07\x70\x0F" \
  160.     "\x07\x0F\x07\x70\x70\x07\x70\x0F\x70\x7F\x7F\x70\x07\x70\x07\x0F" \
  161.     "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  162.     "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x08\x00" \
  163.     "\x07\x0F\x0F\x07\x70\x07\x07\x0F\x0F\x70\x78\x7F\x08\x7F\x08\x70" \
  164.     "\x7F\x7F\x7F\x0F\x70\x70\x07\x70\x70\x70\x07\x7F\x70\x07\x78\x00" \
  165.     "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  166.     "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x08\x00" \
  167.     "\x07\x0F\x07\x70\x70\x07\x0F\x70"    // help colors
  168. #else
  169. #define cpAppBlackWhite \
  170.        "\x70\x70\x78\x7F\x07\x07\x0F\x07\x0F\x07\x70\x70\x07\x70\x0F" \
  171.     "\x07\x0F\x07\x70\x70\x07\x70\x0F\x70\x7F\x7F\x70\x07\x70\x07\x0F" \
  172.     "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  173.     "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x78\x00" \
  174.     "\x07\x0F\x0F\x07\x70\x07\x07\x0F\x0F\x70\x78\x7F\x08\x7F\x08\x70" \
  175.     "\x7F\x7F\x7F\x0F\x70\x70\x07\x70\x70\x70\x07\x7F\x70\x07\x78\x00" \
  176.     "\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F\x0F\x78\x0F\x78\x07" \
  177.     "\x0F\x0F\x0F\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x78\x00" \
  178.     "\x07\x0F\x07\x70\x70\x07\x0F\x70"    // help colors
  179. #endif
  180.  
  181. #ifndef __UNPATCHED
  182. #define cpAppMonochrome \
  183.        "\x70\x07\x07\x0F\x70\x70\x70\x07\x0F\x07\x70\x70\x07\x70\x00" \
  184.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x70\x70\x07\x07\x70\x07\x00" \
  185.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  186.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x70\x00" \
  187.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  188.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x01\x00" \
  189.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  190.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x01\x00" \
  191.     "\x07\x0F\x07\x70\x70\x07\x0F\x70"    // help colors
  192. #else
  193. #define cpAppMonochrome \
  194.        "\x70\x07\x07\x0F\x70\x70\x70\x07\x0F\x07\x70\x70\x07\x70\x00" \
  195.     "\x07\x0F\x07\x70\x70\x07\x70\x00\x70\x70\x70\x07\x07\x70\x07\x00" \
  196.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  197.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x70\x00" \
  198.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  199.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x70\x00" \
  200.     "\x70\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07\x0F\x70\x0F\x70\x07" \
  201.     "\x0F\x0F\x07\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x70\x00" \
  202.     "\x07\x0F\x07\x70\x70\x07\x0F\x70"    // help colors
  203. #endif
  204.  
  205. #if defined( Uses_TProgram ) && !defined( __TProgram )
  206. #define __TProgram
  207.  
  208. // Standard application help contexts
  209.  
  210. // Note: range $FF00 - $FFFF of help contexts are reserved by Borland
  211.  
  212. const unsigned short hcNew          = 0xFF01;
  213. const unsigned short hcOpen         = 0xFF02;
  214. const unsigned short hcSave         = 0xFF03;
  215. const unsigned short hcSaveAs       = 0xFF04;
  216. const unsigned short hcSaveAll      = 0xFF05;
  217. const unsigned short hcChangeDir    = 0xFF06;
  218. const unsigned short hcDosShell     = 0xFF07;
  219. const unsigned short hcExit         = 0xFF08;
  220.  
  221. const unsigned short hcUndo         = 0xFF10;
  222. const unsigned short hcCut          = 0xFF11;
  223. const unsigned short hcCopy         = 0xFF12;
  224. const unsigned short hcPaste        = 0xFF13;
  225. const unsigned short hcClear        = 0xFF14;
  226.  
  227. const unsigned short hcTile         = 0xFF20;
  228. const unsigned short hcCascade      = 0xFF21;
  229. const unsigned short hcCloseAll     = 0xFF22;
  230. const unsigned short hcResize       = 0xFF23;
  231. const unsigned short hcZoom         = 0xFF24;
  232. const unsigned short hcNext         = 0xFF25;
  233. const unsigned short hcPrev         = 0xFF26;
  234. const unsigned short hcClose        = 0xFF27;
  235.  
  236.  
  237. class TStatusLine;
  238. class TMenuBar;
  239. class TDeskTop;
  240. class TEvent;
  241. class TView;
  242.  
  243. class TProgInit
  244. {
  245.  
  246. public:
  247.  
  248.     TProgInit( TStatusLine *(*cStatusLine)( TRect ),
  249.                TMenuBar *(*cMenuBar)( TRect ),
  250.                TDeskTop *(*cDeskTop )( TRect )
  251.              );
  252.  
  253. protected:
  254.  
  255.     TStatusLine *(*createStatusLine)( TRect );
  256.     TMenuBar *(*createMenuBar)( TRect );
  257.     TDeskTop *(*createDeskTop)( TRect );
  258.  
  259. };
  260.  
  261. /* ---------------------------------------------------------------------- */
  262. /*      class TProgram                                                    */
  263. /*                                                                        */
  264. /*      Palette layout                                                    */
  265. /*          1 = TBackground                                               */
  266. /*       2- 7 = TMenuView and TStatusLine                                 */
  267. /*       8-15 = TWindow(Blue)                                             */
  268. /*      16-23 = TWindow(Cyan)                                             */
  269. /*      24-31 = TWindow(Gray)                                             */
  270. /*      32-63 = TDialog                                                   */
  271. /* ---------------------------------------------------------------------- */
  272.  
  273. const
  274.  
  275. //  TApplication palette entries
  276.  
  277.     apColor      = 0,
  278.     apBlackWhite = 1,
  279.     apMonochrome = 2;
  280.  
  281. class TDialog;
  282. class TWindow;
  283.  
  284. class TProgram : public TGroup, public virtual TProgInit
  285. {
  286.  
  287. public:
  288.  
  289.     TProgram();
  290.     virtual ~TProgram();
  291.  
  292.     virtual Boolean canMoveFocus();
  293.     virtual ushort executeDialog(TDialog*, void*data = 0);
  294.     virtual void getEvent(TEvent& event);
  295.     virtual TPalette& getPalette() const;
  296.     virtual void handleEvent(TEvent& event);
  297.     virtual void idle();
  298.     virtual void initScreen();
  299.     virtual void outOfMemory();
  300.     virtual void putEvent( TEvent& event );
  301.     virtual void run();
  302.     virtual TWindow* insertWindow(TWindow*);
  303.     void setScreenMode( ushort mode );
  304.     TView *validView( TView *p );
  305.     virtual void shutDown();
  306.  
  307.     virtual void suspend() {}
  308.     virtual void resume() {}
  309.  
  310.     static TStatusLine *initStatusLine( TRect );
  311.     static TMenuBar *initMenuBar( TRect );
  312.     static TDeskTop *initDeskTop( TRect );
  313.  
  314.     static TProgram * application;
  315.     static TStatusLine * statusLine;
  316.     static TMenuBar * menuBar;
  317.     static TDeskTop * deskTop;
  318.     static int appPalette;
  319.  
  320. protected:
  321.  
  322.     static TEvent pending;
  323.  
  324. private:
  325.  
  326.     static const char * exitText;
  327.  
  328. };
  329.  
  330. #endif
  331.  
  332. #if defined( Uses_TApplication ) && !defined( __TApplication )
  333. #define __TApplication
  334.  
  335. //class TApplication : public TProgram
  336. class TApplication : public TScreen, public TProgram
  337. {
  338.  
  339. protected:
  340.  
  341.     TApplication();
  342.     virtual ~TApplication();
  343.  
  344. public:
  345.     virtual void suspend();
  346.     virtual void resume();
  347.     void getEvent(TEvent& event) { TProgram::getEvent(event); };
  348.  
  349. };
  350.  
  351. #endif
  352.