home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / program / gempp15b.zoo / include / gemw.h < prev    next >
C/C++ Source or Header  |  1993-04-25  |  5KB  |  190 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  GEMwindow
  4. //
  5. //  A GEMwindow is a standard GEM window, which acts just like that as
  6. //  a base class.  Its contents is undefined, and redraw requests have
  7. //  no effect - derived classes should implement this.  It does, however,
  8. //  handle the requirement of clipping the redraw area - a standard
  9. //  requirement of GEM windows.
  10. //
  11. //  This file is Copyright 1992,1993 by Warwick W. Allison.
  12. //  This file is part of the gem++ library.
  13. //  You are free to copy and modify these sources, provided you acknowledge
  14. //  the origin by retaining this notice, and adhere to the conditions
  15. //  described in the file COPYING.LIB.
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18.  
  19. #ifndef GEMw_h
  20. #define GEMw_h
  21.  
  22. #include <gemfb.h>
  23. #include <grect.h>
  24. #include <gemfast.h>
  25. #include <bool.h>
  26.  
  27. class GEMactivity;
  28. class GEMevent;
  29.  
  30. class GEMwindow
  31. {
  32. public:
  33.     GEMwindow(GEMactivity& in, int Parts);
  34.     GEMwindow(GEMactivity& in, int Parts, const GRect&);
  35.     GEMwindow(GEMactivity& in, int Parts, const GRect& actWorkArea, const GRect& maxWorkArea);
  36.     GEMwindow(const GEMwindow&);
  37.  
  38.     virtual ~GEMwindow();
  39.  
  40.     // some GEM like open and close functions
  41.     virtual bool Create();
  42.     virtual void Open();
  43.     virtual void Close();
  44.     virtual void Delete();
  45.  
  46.     // Accessory windows are closed "automatically".  Groan.  An accessory
  47.     // should call this method for all windows on an AC_CLOSE message.
  48.     virtual void BecomeDeleted();
  49.  
  50.     // discriminators and inquiring functions
  51.     virtual bool  IsOpen() const;
  52.     bool  IsCreated() const        { return created;        }
  53.     GRect BorderRect() const    { return Work2Win(Pos);    }
  54.     GRect WorkRect() const        { return Pos;            }
  55.  
  56.     // routines performing actions
  57.     virtual void Top(const GEMevent&);
  58.     virtual void Move(int X, int Y);
  59.     virtual void Resize( int w, int h );    // it's the border size
  60.     virtual GEMfeedback Click(const GEMevent&);
  61.  
  62.     // Top attempted by clicking at (x,y) - returns TRUE if actually topped.
  63.     // (rather than simply using the click)
  64.  
  65.  
  66.     void RedrawOverlaps(const GRect&); // Calls Redraw
  67.  
  68.     int Handle() const { return handle; }
  69.  
  70.     void Align(int x, int y, int xmult=8, int ymult=1);
  71.     // Movement will align such that (x,y) is a multiple of (xmult,ymult).
  72.  
  73.     virtual GEMfeedback UserClosed()
  74.             { Close(); return ContinueInteraction;    }
  75.     virtual void UserFulled();
  76.     virtual void UserResized( int w,int h );
  77.     virtual void UserMoved( int x, int y )
  78.         {    Move( x,y );    }
  79.     
  80.     // methods for the vertical slider
  81.     virtual GEMfeedback VSlidered( int newPos );
  82.     virtual GEMfeedback LineUp();
  83.     virtual GEMfeedback LineDown();
  84.     virtual GEMfeedback PageUp();
  85.     virtual GEMfeedback PageDown();
  86.     
  87.     // methods for the horizontal slider
  88.     virtual GEMfeedback HSlidered( int newPos );
  89.     virtual GEMfeedback ColumnLeft();
  90.     virtual GEMfeedback ColumnRight();
  91.     virtual GEMfeedback PageLeft();
  92.     virtual GEMfeedback PageRight();
  93.  
  94.     // Info-line
  95.     char *InfoText() const    { return info;    }
  96.     void SetInfoText( const char * );
  97.  
  98.     // Name (title)
  99.     void SetName( const char * );
  100.     const char *Name() const { return name;    }
  101.  
  102.     // Slider
  103.     virtual void Flush();
  104.     // the Set* members flush their changes !
  105.     void SetVisibleLines( int noOfLines );
  106.     void SetTotalLines( int noOfLines );
  107.     void SetTopLine( int noOfLine );
  108.     // the Set* members flush their changes !
  109.     void SetVisibleColumns( int noOfColumns );
  110.     void SetTotalColumns( int noOfColumns );
  111.     void SetLeftColumn( int noOfColumn );
  112.     // since this value may change after Resize()
  113.     int VisibleLines() { return visibleLines; }
  114.     // since this value may change after Resize()
  115.     int VisibleColumns() { return visibleColumns; }
  116.  
  117.     int TopLine() { return actualTopLine; }
  118.     int LeftColumn() { return actualLeftColumn; }
  119.     int LineHeight() { return lineHeight; }
  120.     int ColumnWidth() { return columnWidth; }
  121.     void LineHeight(int i) { lineHeight=i; }
  122.     void ColumnWidth(int i) { columnWidth=i; }
  123.  
  124. protected:
  125.     int    parts;
  126.     bool initialized;
  127.     // characteristic rectangles, representing the work area
  128.     GRect Pos, Max; // Current and Full sizes
  129.  
  130.     // convert functions using the 'parts' member
  131.     GRect Win2Work( const GRect& outer ) const;
  132.     GRect Work2Win( const GRect& work ) const;
  133.  
  134.     virtual void Redraw(const GRect&);
  135.  
  136.     void SetBorderRect( const GRect& );
  137.     virtual void SetWorkRect( const GRect& );
  138.  
  139.     // ratio of the units ( document / pixel ),
  140.     // used to handle Resize() requests
  141.     //Rational    vUnitRatio;
  142.             // I'd like to implement windows with automatic
  143.             // processing of WinWithSizer::UserResized() and
  144.             // WinWithFuller::UserFulled() requests, i.e., the
  145.             // slider size will change because the number of
  146.             // visible lines may change.
  147.  
  148.     void VCalculateGEMvalues();
  149.     void VCalculateValues();
  150.     virtual bool VAlignSlider();
  151.     void VFlushSlider();
  152.     void HCalculateGEMvalues();
  153.     void HCalculateValues();
  154.     virtual bool HAlignSlider();
  155.     void HFlushSlider();
  156.  
  157. private:
  158.     char *info;
  159.     GRect    storer;            // stores last actual size and pos. 
  160.     char *name;
  161.     int handle;
  162.         
  163.     bool opened, created;
  164.     GEMactivity* act;
  165.     int xoff,yoff,xalign,yalign;
  166.  
  167.     // parameters representing the real GEM slider
  168.     int    vSize,
  169.         vPosition;
  170.     int    hSize,
  171.         hPosition;
  172.  
  173.     // pixel size of document units
  174.     int lineHeight,columnWidth;
  175.  
  176.     // representation of the slider in document units
  177.     int    visibleLines,
  178.         totalLines,
  179.         actualTopLine;
  180.     // representation of the slider in document units
  181.     int    visibleColumns,
  182.         totalColumns,
  183.         actualLeftColumn;
  184.  
  185.     void InActivity(GEMactivity& in);
  186. };
  187.  
  188.  
  189. #endif
  190.