home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 2.ddi / TVINC.ZIP / VIEWS.H < prev   
Encoding:
C/C++ Source or Header  |  1992-06-10  |  25.6 KB  |  979 lines

  1. /* ------------------------------------------------------------------------*/
  2. /*                                                                         */
  3. /*   VIEWS.H                                                               */
  4. /*                                                                         */
  5. /*   Copyright (c) Borland International 1991                              */
  6. /*   All Rights Reserved.                                                  */
  7. /*                                                                         */
  8. /*   defines the classes TView, TFrame, TScrollBar, TScroller,             */
  9. /*   TListViewer, TGroup, and TWindow                                      */
  10. /*                                                                         */
  11. /* ------------------------------------------------------------------------*/
  12.  
  13. #pragma option -Vo-
  14. #if defined( __BCOPT__ )
  15. #pragma option -po-
  16. #endif
  17.  
  18. #if !defined( __COMMAND_CODES )
  19. #define __COMMAND_CODES
  20.  
  21. const ushort
  22.  
  23. //  Standard command codes
  24.  
  25.     cmValid         = 0,
  26.     cmQuit          = 1,
  27.     cmError         = 2,
  28.     cmMenu          = 3,
  29.     cmClose         = 4,
  30.     cmZoom          = 5,
  31.     cmResize        = 6,
  32.     cmNext          = 7,
  33.     cmPrev          = 8,
  34.     cmHelp          = 9,
  35.  
  36. //  TDialog standard commands
  37.  
  38.     cmOK            = 10,
  39.     cmCancel        = 11,
  40.     cmYes           = 12,
  41.     cmNo            = 13,
  42.     cmDefault       = 14,
  43.  
  44. //  TView State masks 
  45.  
  46.     sfVisible       = 0x001,
  47.     sfCursorVis     = 0x002,
  48.     sfCursorIns     = 0x004,
  49.     sfShadow        = 0x008,
  50.     sfActive        = 0x010,
  51.     sfSelected      = 0x020,
  52.     sfFocused       = 0x040,
  53.     sfDragging      = 0x080,
  54.     sfDisabled      = 0x100,
  55.     sfModal         = 0x200,
  56.     sfDefault       = 0x400,
  57.     sfExposed       = 0x800,
  58.  
  59. // TView Option masks 
  60.  
  61.     ofSelectable    = 0x001,
  62.     ofTopSelect     = 0x002,
  63.     ofFirstClick    = 0x004,
  64.     ofFramed        = 0x008,
  65.     ofPreProcess    = 0x010,
  66.     ofPostProcess   = 0x020,
  67.     ofBuffered      = 0x040,
  68.     ofTileable      = 0x080,
  69.     ofCenterX       = 0x100,
  70.     ofCenterY       = 0x200,
  71.     ofCentered      = 0x300,
  72.  
  73. // TView GrowMode masks 
  74.  
  75.     gfGrowLoX       = 0x01,
  76.     gfGrowLoY       = 0x02,
  77.     gfGrowHiX       = 0x04,
  78.     gfGrowHiY       = 0x08,
  79.     gfGrowAll       = 0x0f,
  80.     gfGrowRel       = 0x10,
  81.  
  82. // TView DragMode masks 
  83.  
  84.     dmDragMove      = 0x01,
  85.     dmDragGrow      = 0x02,
  86.     dmLimitLoX      = 0x10,
  87.     dmLimitLoY      = 0x20,
  88.     dmLimitHiX      = 0x40,
  89.     dmLimitHiY      = 0x80,
  90.     dmLimitAll      = dmLimitLoX | dmLimitLoY | dmLimitHiX | dmLimitHiY,
  91.  
  92. // TView Help context codes
  93.  
  94.     hcNoContext     = 0,
  95.     hcDragging      = 1,
  96.  
  97. // TScrollBar part codes 
  98.  
  99.     sbLeftArrow     = 0,
  100.     sbRightArrow    = 1,
  101.     sbPageLeft      = 2,
  102.     sbPageRight     = 3,
  103.     sbUpArrow       = 4,
  104.     sbDownArrow     = 5,
  105.     sbPageUp        = 6,
  106.     sbPageDown      = 7,
  107.     sbIndicator     = 8,
  108.  
  109. // TScrollBar options for TWindow.StandardScrollBar 
  110.  
  111.     sbHorizontal    = 0x000,
  112.     sbVertical      = 0x001,
  113.     sbHandleKeyboard = 0x002,
  114.  
  115. // TWindow Flags masks
  116.  
  117.     wfMove          = 0x01,
  118.     wfGrow          = 0x02,
  119.     wfClose         = 0x04,
  120.     wfZoom          = 0x08,
  121.  
  122. //  TView inhibit flags
  123.  
  124.     noMenuBar       = 0x0001,
  125.     noDeskTop       = 0x0002,
  126.     noStatusLine    = 0x0004,
  127.     noBackground    = 0x0008,
  128.     noFrame         = 0x0010,
  129.     noViewer        = 0x0020,
  130.     noHistory       = 0x0040,
  131.  
  132. // TWindow number constants
  133.  
  134.     wnNoNumber      = 0,
  135.  
  136. // TWindow palette entries 
  137.  
  138.     wpBlueWindow    = 0,
  139.     wpCyanWindow    = 1,
  140.     wpGrayWindow    = 2,
  141.  
  142. //  Application command codes
  143.  
  144.     cmCut           = 20,
  145.     cmCopy          = 21,
  146.     cmPaste         = 22,
  147.     cmUndo          = 23,
  148.     cmClear         = 24,
  149.     cmTile          = 25,
  150.     cmCascade       = 26,
  151.  
  152. // Standard messages 
  153.  
  154.     cmReceivedFocus     = 50,
  155.     cmReleasedFocus     = 51,
  156.     cmCommandSetChanged = 52,
  157.  
  158. // TScrollBar messages 
  159.  
  160.     cmScrollBarChanged  = 53,
  161.     cmScrollBarClicked  = 54,
  162.  
  163. // TWindow select messages 
  164.  
  165.     cmSelectWindowNum   = 55,
  166.  
  167. //  TListViewer messages
  168.  
  169.     cmListItemSelected  = 56,
  170.  
  171. //  Event masks
  172.  
  173.     positionalEvents    = evMouse,
  174.     focusedEvents       = evKeyboard | evCommand;
  175.  
  176. #endif  // __COMMAND_CODES
  177.  
  178. #if defined( Uses_TCommandSet ) && !defined( __TCommandSet )
  179. #define __TCommandSet
  180.  
  181. class TCommandSet
  182. {
  183.  
  184. public:
  185.  
  186.     TCommandSet();
  187.     TCommandSet( const TCommandSet& );
  188.  
  189.     Boolean has( int cmd );
  190.  
  191.     void disableCmd( int cmd );
  192.     void enableCmd( int cmd );
  193.     void operator += ( int cmd );
  194.     void operator -= ( int cmd );
  195.  
  196.     void disableCmd( const TCommandSet& );
  197.     void enableCmd( const TCommandSet& );
  198.     void operator += ( const TCommandSet& );
  199.     void operator -= ( const TCommandSet& );
  200.  
  201.     Boolean TCommandSet::isEmpty();
  202.  
  203.     TCommandSet& operator &= ( const TCommandSet& );
  204.     TCommandSet& operator |= ( const TCommandSet& );
  205.  
  206.     friend TCommandSet operator & ( const TCommandSet&, const TCommandSet& );
  207.     friend TCommandSet operator | ( const TCommandSet&, const TCommandSet& );
  208.  
  209.     friend int operator == ( const TCommandSet& tc1, const TCommandSet& tc2 );
  210.     friend int operator != ( const TCommandSet& tc1, const TCommandSet& tc2 );
  211.  
  212. private:
  213.  
  214.     int loc( int );
  215.     int mask( int );
  216.  
  217.     static int near masks[8];
  218.  
  219.     uchar cmds[32];
  220.  
  221. };
  222.  
  223. inline void TCommandSet::operator += ( int cmd )
  224. {
  225.     enableCmd( cmd );
  226. }
  227.  
  228. inline void TCommandSet::operator -= ( int cmd )
  229. {
  230.     disableCmd( cmd );
  231. }
  232.  
  233. inline void TCommandSet::operator += ( const TCommandSet& tc )
  234. {
  235.     enableCmd( tc );
  236. }
  237.  
  238. inline void TCommandSet::operator -= ( const TCommandSet& tc )
  239. {
  240.     disableCmd( tc );
  241. }
  242.  
  243. inline int operator != ( const TCommandSet& tc1, const TCommandSet& tc2 )
  244. {
  245.     return !operator == ( tc1, tc2 );
  246. }
  247.  
  248. inline int TCommandSet::loc( int cmd )
  249. {
  250.     return cmd / 8;
  251. }
  252.  
  253. inline int TCommandSet::mask( int cmd )
  254. {
  255.     return masks[ cmd & 0x07 ];
  256. }
  257.  
  258. #endif  // Uses_TCommandSet
  259.  
  260. #if defined( Uses_TPalette ) && !defined( __TPalette )
  261. #define __TPalette
  262.  
  263. class TPalette
  264. {
  265.  
  266. public:
  267.  
  268.     TPalette( const char *, ushort );
  269.     TPalette( const TPalette& );
  270.     ~TPalette();
  271.  
  272.     TPalette& operator = ( const TPalette& );
  273.  
  274.     char& operator[]( int ) const;
  275.  
  276.     char *data;
  277.  
  278. };
  279.  
  280. #endif  // Uses_TPalette
  281.  
  282. #if defined( Uses_TView ) && !defined( __TView )
  283. #define __TView
  284.  
  285. struct write_args
  286. {
  287.     void far *self;
  288.     void far *target;
  289.     void far *buf;
  290.     ushort offset;
  291. };
  292.  
  293. class far TRect;
  294. class far TEvent;
  295. class far TGroup;
  296.  
  297. class TView : public TObject, public TStreamable
  298. {
  299.  
  300. public:
  301.  
  302.     friend void genRefs();
  303.  
  304.     enum phaseType { phFocused, phPreProcess, phPostProcess };
  305.     enum selectMode{ normalSelect, enterSelect, leaveSelect };
  306.  
  307.     TView( const TRect& bounds );
  308.     ~TView();
  309.  
  310.     virtual void sizeLimits( TPoint& min, TPoint& max );
  311.     TRect getBounds();
  312.     TRect getExtent();
  313.     TRect getClipRect();
  314.     Boolean mouseInView( TPoint mouse );
  315.     Boolean containsMouse( TEvent& event );
  316.  
  317.     void locate( TRect& bounds );
  318.     virtual void dragView( TEvent& event, uchar mode,   //  temporary fix
  319.       TRect& limits, TPoint minSize, TPoint maxSize ); //  for Miller's stuff
  320.     virtual void calcBounds( TRect& bounds, TPoint delta );
  321.     virtual void changeBounds( const TRect& bounds );
  322.     void growTo( short x, short y );
  323.     void moveTo( short x, short y );
  324.     void setBounds( const TRect& bounds );
  325.  
  326.     virtual ushort getHelpCtx();
  327.  
  328.     virtual Boolean valid( ushort command );
  329.  
  330.     void hide();
  331.     void show();
  332.     virtual void draw();
  333.     void drawView();
  334.     Boolean exposed();
  335.     void hideCursor();
  336.     void drawHide( TView *lastView );
  337.     void drawShow( TView *lastView );
  338.     void drawUnderRect( TRect& r, TView *lastView );
  339.     void drawUnderView( Boolean doShadow, TView *lastView );
  340.  
  341.     virtual ushort dataSize();
  342.     virtual void getData( void *rec );
  343.     virtual void setData( void *rec );
  344.  
  345.     void blockCursor();
  346.     void normalCursor();
  347.     virtual void resetCursor();
  348.     void setCursor( short x, short y );
  349.     void showCursor();
  350.     void drawCursor();
  351.  
  352.     void clearEvent( TEvent& event );
  353.     Boolean eventAvail();
  354.     virtual void getEvent( TEvent& event );
  355.     virtual void handleEvent( TEvent& event );
  356.     virtual void putEvent( TEvent& event );
  357.  
  358.     static Boolean commandEnabled( ushort command );
  359.     static void disableCommands( TCommandSet& commands );
  360.     static void enableCommands( TCommandSet& commands );
  361.     static void disableCommand( ushort command );
  362.     static void enableCommand( ushort command );
  363.     static void getCommands( TCommandSet& commands );
  364.     static void setCommands( TCommandSet& commands );
  365.  
  366.     virtual void endModal( ushort command );
  367.     virtual ushort execute();
  368.  
  369.     ushort getColor( ushort color );
  370.     virtual TPalette& getPalette() const;
  371.     uchar mapColor( uchar );
  372.  
  373.     Boolean getState( ushort aState );
  374.     void select();
  375.     virtual void setState( ushort aState, Boolean enable );
  376.  
  377.     void keyEvent( TEvent& event );
  378.     Boolean mouseEvent( TEvent& event, ushort mask );
  379.  
  380.  
  381.     TPoint makeGlobal( TPoint source );
  382.     TPoint makeLocal( TPoint source );
  383.  
  384.     TView *nextView();
  385.     TView *prevView();
  386.     TView *prev();
  387.     TView *next;
  388.  
  389.     void makeFirst();
  390.     void putInFrontOf( TView *Target );
  391.     TView *TopView();
  392.  
  393.     void writeBuf(  short x, short y, short w, short h, const void far *b );
  394.     void writeBuf(  short x, short y, short w, short h, const TDrawBuffer& b );
  395.     void writeChar( short x, short y, char c, uchar color, short count );
  396.     void writeLine( short x, short y, short w, short h, const TDrawBuffer& b );
  397.     void writeLine( short x, short y, short w, short h, const void far *b );
  398.     void writeStr( short x, short y, const char *str, uchar color );
  399.  
  400.     TPoint size;
  401.     ushort options;
  402.     ushort eventMask;
  403.     ushort state;
  404.     TPoint origin;
  405.     TPoint cursor;
  406.     uchar growMode;
  407.     uchar dragMode;
  408.     ushort helpCtx;
  409.     static Boolean near commandSetChanged;
  410.     static TCommandSet near curCommandSet;
  411.     TGroup *owner;
  412.  
  413.     static Boolean near showMarkers;
  414.     static uchar near errorAttr;
  415.  
  416.     virtual void shutDown();
  417.  
  418. private:
  419.  
  420.     void moveGrow( TPoint p,
  421.                    TPoint s,
  422.                    TRect& limits,
  423.                    TPoint minSize,
  424.                    TPoint maxSize,
  425.                    uchar mode
  426.                  );
  427.     void change( uchar, TPoint delta, TPoint& p, TPoint& s );
  428.     static void writeView( write_args );
  429.  
  430.     virtual const char *streamableName() const
  431.         { return name; }
  432.  
  433. protected:
  434.  
  435.     TView( StreamableInit );
  436.  
  437. public:
  438.  
  439.     static const char * const near name;
  440.     static TStreamable *build();
  441.  
  442. protected:
  443.  
  444.     virtual void write( opstream& );
  445.     virtual void *read( ipstream& );
  446.  
  447. };
  448.  
  449. inline ipstream& operator >> ( ipstream& is, TView& cl )
  450.     { return is >> (TStreamable&)cl; }
  451. inline ipstream& operator >> ( ipstream& is, TView*& cl )
  452.     { return is >> (void *&)cl; }
  453.  
  454. inline opstream& operator << ( opstream& os, TView& cl )
  455.     { return os << (TStreamable&)cl; }
  456. inline opstream& operator << ( opstream& os, TView* cl )
  457.     { return os << (TStreamable *)cl; }
  458.  
  459. inline void TView::writeBuf( short x, short y, short w, short h,
  460.                              const TDrawBuffer& b )
  461. {
  462.     writeBuf( x, y, w, h, b.data );
  463. }
  464.  
  465. inline void TView::writeLine( short x, short y, short w, short h,
  466.                               const TDrawBuffer& b )
  467. {
  468.     writeLine( x, y, w, h, b.data );
  469. }
  470.  
  471. #endif  // Uses_TView
  472.  
  473. /* ---------------------------------------------------------------------- */
  474. /*      class TFrame                                                      */
  475. /*                                                                        */
  476. /*      Palette layout                                                    */
  477. /*        1 = Passive frame                                               */
  478. /*        2 = Passive title                                               */
  479. /*        3 = Active frame                                                */
  480. /*        4 = Active title                                                */
  481. /*        5 = Icons                                                       */
  482. /* ---------------------------------------------------------------------- */
  483.  
  484. #if defined( Uses_TFrame ) && !defined( __TFrame )
  485. #define __TFrame
  486.  
  487. class far TRect;
  488. class far TEvent;
  489. class far TDrawBuffer;
  490.  
  491. class TFrame : public TView
  492. {
  493.  
  494. public:
  495.  
  496.     TFrame( const TRect& bounds );
  497.  
  498.     virtual void draw();
  499.     virtual TPalette& getPalette() const;
  500.     virtual void handleEvent( TEvent& event );
  501.     virtual void setState( ushort aState, Boolean enable );
  502.  
  503. private:
  504.  
  505.     void frameLine( TDrawBuffer& frameBuf, short y, short n, uchar color );
  506.     void dragWindow( TEvent& event, uchar dragMode );
  507.  
  508.     friend class TDisplay;
  509.     static const char near initFrame[19];
  510.     static char near frameChars[33];
  511.     static const char * near closeIcon;
  512.     static const char * near zoomIcon;
  513.     static const char * near unZoomIcon;
  514.     static const char * near dragIcon;
  515.  
  516.     virtual const char *streamableName() const
  517.         { return name; }
  518.  
  519. protected:
  520.  
  521.     TFrame( StreamableInit );
  522.  
  523. public:
  524.  
  525.     static const char * const near name;
  526.     static TStreamable *build();
  527.  
  528. };
  529.  
  530. inline ipstream& operator >> ( ipstream& is, TFrame& cl )
  531.     { return is >> (TStreamable&)cl; }
  532. inline ipstream& operator >> ( ipstream& is, TFrame*& cl )
  533.     { return is >> (void *&)cl; }
  534.  
  535. inline opstream& operator << ( opstream& os, TFrame& cl )
  536.     { return os << (TStreamable&)cl; }
  537. inline opstream& operator << ( opstream& os, TFrame* cl )
  538.     { return os << (TStreamable *)cl; }
  539.  
  540. #endif  // Uses_TFrame
  541.  
  542. /* ---------------------------------------------------------------------- */
  543. /*      class TScrollBar                                                  */
  544. /*                                                                        */
  545. /*      Palette layout                                                    */
  546. /*        1 = Page areas                                                  */
  547. /*        2 = Arrows                                                      */
  548. /*        3 = Indicator                                                   */
  549. /* ---------------------------------------------------------------------- */
  550.  
  551. #if defined( Uses_TScrollBar ) && !defined( __TScrollBar )
  552. #define __TScrollBar
  553.  
  554. class far TRect;
  555. class far TEvent;
  556.  
  557. typedef char TScrollChars[5];
  558.  
  559. class TScrollBar : public TView
  560. {
  561.  
  562. public:
  563.  
  564.     TScrollBar( const TRect& bounds );
  565.  
  566.     virtual void draw();
  567.     virtual TPalette& getPalette() const;
  568.     virtual void handleEvent( TEvent& event );
  569.     virtual void scrollDraw();
  570.     virtual short scrollStep( short part );
  571.     void setParams( short aValue, short aMin, short aMax, 
  572.                     short aPgStep, short aArStep );
  573.     void setRange( short aMin, short aMax );
  574.     void setStep( short aPgStep, short aArStep );
  575.     void setValue( short aValue );
  576.  
  577.     void drawPos( short pos );
  578.     short getPos();
  579.     short getSize();
  580.  
  581.     short value;
  582.  
  583.     TScrollChars chars;
  584.     short minVal;
  585.     short maxVal;
  586.     short pgStep;
  587.     short arStep;
  588.  
  589. private:
  590.  
  591.     short getPartCode(void);
  592.  
  593.     static TScrollChars near vChars;
  594.     static TScrollChars near hChars;
  595.  
  596.     virtual const char *streamableName() const
  597.         { return name; }
  598.  
  599. protected:
  600.  
  601.     TScrollBar( StreamableInit );
  602.     virtual void write( opstream& );
  603.     virtual void *read( ipstream& );
  604.  
  605. public:
  606.  
  607.     static const char * const near name;
  608.     static TStreamable *build();
  609.  
  610. };
  611.  
  612. inline ipstream& operator >> ( ipstream& is, TScrollBar& cl )
  613.     { return is >> (TStreamable&)cl; }
  614. inline ipstream& operator >> ( ipstream& is, TScrollBar*& cl )
  615.     { return is >> (void *&)cl; }
  616.  
  617. inline opstream& operator << ( opstream& os, TScrollBar& cl )
  618.     { return os << (TStreamable&)cl; }
  619. inline opstream& operator << ( opstream& os, TScrollBar* cl )
  620.     { return os << (TStreamable *)cl; }
  621.  
  622. #endif  // Uses_TScrollBar
  623.  
  624. /* ---------------------------------------------------------------------- */
  625. /*      class TScroller                                                   */
  626. /*                                                                        */
  627. /*      Palette layout                                                    */
  628. /*      1 = Normal text                                                   */
  629. /*      2 = Selected text                                                 */
  630. /* ---------------------------------------------------------------------- */
  631.  
  632. #if defined( Uses_TScroller ) && !defined( __TScroller )
  633. #define __TScroller
  634.  
  635. class far TRect;
  636. class far TScrollBar;
  637. class far TEvent;
  638.  
  639. class TScroller : public TView
  640. {
  641.  
  642. public:
  643.  
  644.     TScroller( const TRect& bounds,
  645.                TScrollBar *aHScrollBar,
  646.                TScrollBar *aVScrollBar
  647.              );
  648.  
  649.     virtual void changeBounds( const TRect& bounds );
  650.     virtual TPalette& getPalette() const;
  651.     virtual void handleEvent( TEvent& event );
  652.     virtual void scrollDraw();
  653.     void scrollTo( short x, short y );
  654.     void setLimit( short x, short y );
  655.     virtual void setState( ushort aState, Boolean enable );
  656.     void checkDraw();
  657.     virtual void shutDown();
  658.  
  659. protected:
  660.  
  661.     uchar drawLock;
  662.     Boolean drawFlag;
  663.     TScrollBar *hScrollBar;
  664.     TScrollBar *vScrollBar;
  665.     TPoint delta;
  666.     TPoint limit;
  667.  
  668. private:
  669.  
  670.     void showSBar( TScrollBar *sBar );
  671.  
  672.     virtual const char *streamableName() const
  673.         { return name; }
  674.  
  675. protected:
  676.  
  677.     TScroller( StreamableInit );
  678.     virtual void write( opstream& );
  679.     virtual void *read( ipstream& );
  680.  
  681. public:
  682.  
  683.     static const char * const near name;
  684.     static TStreamable *build();
  685.  
  686. };
  687.  
  688. inline ipstream& operator >> ( ipstream& is, TScroller& cl )
  689.     { return is >> (TStreamable&)cl; }
  690. inline ipstream& operator >> ( ipstream& is, TScroller*& cl )
  691.     { return is >> (void *&)cl; }
  692.  
  693. inline opstream& operator << ( opstream& os, TScroller& cl )
  694.     { return os << (TStreamable&)cl; }
  695. inline opstream& operator << ( opstream& os, TScroller* cl )
  696.     { return os << (TStreamable *)cl; }
  697.  
  698. #endif  // Uses_TScroller
  699.  
  700. #if defined( Uses_TListViewer ) && !defined( __TListViewer )
  701. #define __TListViewer
  702.  
  703. class far TRect;
  704. class far TScrollBar;
  705. class far TEvent;
  706.  
  707. class TListViewer : public TView
  708. {
  709.  
  710. public:
  711.  
  712.     TListViewer( const TRect& bounds,
  713.                  ushort aNumCols,
  714.                  TScrollBar *aHScrollBar,
  715.                  TScrollBar *aVScrollBar
  716.                );
  717.  
  718.     virtual void changeBounds( const TRect& bounds );
  719.     virtual void draw();
  720.     virtual void focusItem( short item );
  721.     virtual TPalette& getPalette() const;
  722.     virtual void getText( char *dest, short item, short maxLen );
  723.     virtual Boolean isSelected( short item );
  724.     virtual void handleEvent( TEvent& event );
  725.     virtual void selectItem( short item );
  726.     void setRange( short aRange );
  727.     virtual void setState( ushort aState, Boolean enable );
  728.  
  729.     virtual void focusItemNum( short item );
  730.     virtual void shutDown();
  731.  
  732.     TScrollBar *hScrollBar;
  733.     TScrollBar *vScrollBar;
  734.     short numCols;
  735.     short topItem;
  736.     short focused;
  737.     short range;
  738.  
  739. private:
  740.  
  741.     virtual const char *streamableName() const
  742.         { return name; }
  743.  
  744. protected:
  745.  
  746.     TListViewer( StreamableInit );
  747.     virtual void write( opstream& );
  748.     virtual void *read( ipstream& );
  749.  
  750. public:
  751.  
  752.     static const char * const near name;
  753.     static TStreamable *build();
  754.  
  755. };
  756.  
  757. inline ipstream& operator >> ( ipstream& is, TListViewer& cl )
  758.     { return is >> (TStreamable&)cl; }
  759. inline ipstream& operator >> ( ipstream& is, TListViewer*& cl )
  760.     { return is >> (void *&)cl; }
  761.  
  762. inline opstream& operator << ( opstream& os, TListViewer& cl )
  763.     { return os << (TStreamable&)cl; }
  764. inline opstream& operator << ( opstream& os, TListViewer* cl )
  765.     { return os << (TStreamable *)cl; }
  766.  
  767. #endif  // Uses_TListViewer
  768.  
  769. #if defined( Uses_TGroup ) && !defined( __TGroup )
  770. #define __TGroup
  771.  
  772. class far TView;
  773.  
  774. class TGroup : public TView
  775. {
  776.  
  777. public:
  778.  
  779.     friend void genRefs();
  780.  
  781.     TGroup( const TRect& bounds );
  782.     ~TGroup();
  783.  
  784.     virtual void shutDown();
  785.  
  786.     ushort execView( TView *p );
  787.     virtual ushort execute();
  788.  
  789.     void insertView( TView *p, TView *Target );
  790.     void remove( TView *p );
  791.     void removeView( TView *p );
  792.     void resetCurrent();
  793.     void setCurrent( TView *p, selectMode mode );
  794.     void selectNext( Boolean forwards );
  795.     TView *firstThat( Boolean (*func)( TView *, void * ), void *args );
  796.     void forEach( void (*func)( TView *, void * ), void *args );
  797.     void insert( TView *p );
  798.     void insertBefore( TView *p, TView *Target );
  799.     TView *current;
  800.     TView *at( short index );
  801.     TView *firstMatch( ushort aState, ushort aOptions );
  802.     short indexOf( TView *p );
  803.     Boolean matches( TView *p );
  804.     TView *first();
  805.  
  806.     virtual void setState( ushort aState, Boolean enable );
  807.  
  808.     virtual void handleEvent( TEvent& event );
  809.  
  810.     void drawSubViews( TView *p, TView *bottom );
  811.  
  812.     virtual void changeBounds( const TRect& bounds );
  813.  
  814.     virtual ushort dataSize();
  815.     virtual void getData( void *rec );
  816.     virtual void setData( void *rec );
  817.  
  818.     virtual void draw();
  819.     void redraw();
  820.     void lock();
  821.     void unlock();
  822.     virtual void resetCursor();
  823.  
  824.     virtual void endModal( ushort command );
  825.  
  826.     virtual void eventError( TEvent& event );
  827.  
  828.     virtual ushort getHelpCtx();
  829.  
  830.     virtual Boolean valid( ushort command );
  831.  
  832.     void freeBuffer();
  833.     void getBuffer();
  834.  
  835.     TView *last;
  836.  
  837.     TRect clip;
  838.     phaseType phase;
  839.  
  840.     ushort far *buffer;
  841.     uchar lockFlag;
  842.     ushort endState;
  843.  
  844. private:
  845.  
  846.     Boolean invalid( TView *p, ushort command );
  847.     void focusView( TView *p, Boolean enable );
  848.     void selectView( TView *p, Boolean enable );
  849.  
  850.     virtual const char *streamableName() const
  851.         { return name; }
  852.  
  853. protected:
  854.  
  855.     TGroup( StreamableInit );
  856.     virtual void write( opstream& );
  857.     virtual void *read( ipstream& );
  858.  
  859. public:
  860.  
  861.     static const char * const near name;
  862.     static TStreamable *build();
  863.  
  864. };
  865.  
  866. inline ipstream& operator >> ( ipstream& is, TGroup& cl )
  867.     { return is >> (TStreamable&)cl; }
  868. inline ipstream& operator >> ( ipstream& is, TGroup*& cl )
  869.     { return is >> (void *&)cl; }
  870.  
  871. inline opstream& operator << ( opstream& os, TGroup& cl )
  872.     { return os << (TStreamable&)cl; }
  873. inline opstream& operator << ( opstream& os, TGroup* cl )
  874.     { return os << (TStreamable *)cl; }
  875.  
  876. #endif  // Uses_TGroup
  877.  
  878. #if defined( Uses_TWindow ) && !defined( __TWindow )
  879. #define __TWindow
  880.  
  881. class far TFrame;
  882. class far TRect;
  883. class far TPoint;
  884. class far TEvent;
  885. class far TFrame;
  886. class far TScrollBar;
  887.  
  888. class TWindowInit
  889. {
  890.  
  891. public:
  892.  
  893.     TWindowInit( TFrame *(*cFrame)( TRect ) );
  894.  
  895. protected:
  896.  
  897.     TFrame *(*createFrame)( TRect );
  898.  
  899. };
  900.  
  901. /* ---------------------------------------------------------------------- */
  902. /*      class TWindow                                                     */
  903. /*                                                                        */
  904. /*      Palette layout                                                    */
  905. /*        1 = Frame passive                                               */
  906. /*        2 = Frame active                                                */
  907. /*        3 = Frame icon                                                  */
  908. /*        4 = ScrollBar page area                                         */
  909. /*        5 = ScrollBar controls                                          */
  910. /*        6 = Scroller normal text                                        */
  911. /*        7 = Scroller selected text                                      */
  912. /*        8 = Reserved                                                    */
  913. /* ---------------------------------------------------------------------- */
  914.  
  915. class TWindow: public TGroup, public virtual TWindowInit
  916. {
  917.  
  918. public:
  919.  
  920.     TWindow( const TRect& bounds,
  921.              const char *aTitle,
  922.              short aNumber
  923.            );
  924.     ~TWindow();
  925.  
  926.     virtual void close();
  927.     virtual TPalette& getPalette() const;
  928.     virtual const char *getTitle( short maxSize );
  929.     virtual void handleEvent( TEvent& event );
  930.     static TFrame *initFrame( TRect );
  931.     virtual void setState( ushort aState, Boolean enable );
  932.     virtual void sizeLimits( TPoint& min, TPoint& max );
  933.     TScrollBar *standardScrollBar( ushort aOptions );
  934.     virtual void zoom();
  935.     virtual void shutDown();
  936.  
  937.     uchar flags;
  938.     TRect zoomRect;
  939.     short number;
  940.     short palette;
  941.     TFrame *frame;
  942.     const char *title;
  943.  
  944. private:
  945.  
  946.     virtual const char *streamableName() const
  947.         { return name; }            
  948.  
  949. protected:
  950.  
  951.     TWindow( StreamableInit );
  952.     virtual void write( opstream& );
  953.     virtual void *read( ipstream& );
  954.  
  955. public:
  956.  
  957.     static const char * const near name;
  958.     static TStreamable *build();
  959.  
  960. };
  961.  
  962. inline ipstream& operator >> ( ipstream& is, TWindow& cl )
  963.     { return is >> (TStreamable&)cl; }
  964. inline ipstream& operator >> ( ipstream& is, TWindow*& cl )
  965.     { return is >> (void *&)cl; }
  966.  
  967. inline opstream& operator << ( opstream& os, TWindow& cl )
  968.     { return os << (TStreamable&)cl; }
  969. inline opstream& operator << ( opstream& os, TWindow* cl )
  970.     { return os << (TStreamable *)cl; }
  971.  
  972. #endif  // Uses_TWindow
  973.  
  974. #pragma option -Vo.
  975. #if defined( __BCOPT__ )
  976. #pragma option -po.
  977. #endif
  978.  
  979.