home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20cpp.zip / tvision / views.h < prev   
C/C++ Source or Header  |  1998-01-19  |  26KB  |  1,012 lines

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