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