home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / i / iv26_w_3.zip / EXAMPLES / IDRAW / SLPICT.H < prev    next >
C/C++ Source or Header  |  1980-01-05  |  5KB  |  163 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. // $Header: slpict.h,v 1.10 89/10/09 14:49:37 linton Exp $
  24. // declares class PictSelection.
  25.  
  26. #ifndef slpict_h
  27. #define slpict_h
  28.  
  29. #include "selection.h"
  30.  
  31. // Declare imported types.
  32.  
  33. class IFont;
  34. class IFontList;
  35.  
  36. // A PictSelection contains other Selections.
  37.  
  38. class PictSelection : public Selection {
  39. public:
  40.  
  41.     PictSelection(Graphic* = nil);
  42.     PictSelection(FILE*, State*);
  43.  
  44.     Graphic* Copy();
  45.     boolean HasChildren();
  46.     void Propagate();
  47.  
  48.     boolean Valid();
  49.     boolean WritePicture(FILE*, State*, boolean);
  50.  
  51.     Selection* GetCurrent();
  52.     Selection* First();
  53.     Selection* Last();
  54.     Selection* Next();
  55.     Selection* Prev();
  56.  
  57.     Selection* FirstSelectionContaining(PointObj&);
  58.     Selection* LastSelectionContaining(PointObj&);
  59.     int SelectionsContaining(PointObj&, Selection**&);
  60.  
  61.     Selection* FirstSelectionIntersecting(BoxObj&);
  62.     Selection* LastSelectionIntersecting(BoxObj&);
  63.     int SelectionsIntersecting(BoxObj&, Selection**&);
  64.  
  65.     Selection* FirstSelectionWithin(BoxObj&);
  66.     Selection* LastSelectionWithin(BoxObj&);
  67.     int SelectionsWithin(BoxObj&, Selection**&);
  68.  
  69. protected:
  70.  
  71.     PictSelection(istream&, State*);
  72.     void ReadChildren(istream&, State*);
  73.  
  74.     void WritePicture(ostream&, State*, boolean);
  75.     void WriteComments(ostream&);
  76.     void WritePrologue(ostream&);
  77.     void WriteDrawing(ostream&);
  78.     void WriteData(ostream&);
  79.     void WriteTrailer(ostream&);
  80.     void ScaleToPostscriptCoords();
  81.     void ScaleToScreenCoords();
  82.     void CollectFonts(IFontList*);
  83.     void Merge(IFont*, IFontList*);
  84.  
  85.     boolean valid;        // true if creation of PictSelection succeeded
  86.  
  87. };
  88.  
  89. // Define inline access functions to get members' values.
  90.  
  91. inline boolean PictSelection::Valid () {
  92.     return valid;
  93. }
  94.  
  95. // Cast these functions to return Selections instead of Graphics.
  96.  
  97. inline Selection* PictSelection::GetCurrent() {
  98.     return (Selection*) Picture::GetCurrent();
  99. }
  100.  
  101. inline Selection* PictSelection::First() {
  102.     return (Selection*) Picture::First();
  103. }
  104.  
  105. inline Selection* PictSelection::Last() {
  106.     return (Selection*) Picture::Last();
  107. }
  108.  
  109. inline Selection* PictSelection::Next() {
  110.     return (Selection*) Picture::Next();
  111. }
  112.  
  113. inline Selection* PictSelection::Prev() {
  114.     return (Selection*) Picture::Prev();
  115. }
  116.  
  117. inline Selection* PictSelection::FirstSelectionContaining(PointObj& p) {
  118.     return (Selection*) Picture::FirstGraphicContaining(p);
  119. }
  120.  
  121. inline Selection* PictSelection::LastSelectionContaining(PointObj& p) {
  122.     return (Selection*) Picture::LastGraphicContaining(p);
  123. }
  124.  
  125. inline int PictSelection::SelectionsContaining(PointObj& p, Selection**& ss) {
  126.     Graphic** gg = nil;
  127.     int num = Picture::GraphicsContaining(p, gg);
  128.     ss = (Selection**) gg;
  129.     return num;
  130. }
  131.  
  132. inline Selection* PictSelection::FirstSelectionIntersecting(BoxObj& b) {
  133.     return (Selection*) Picture::FirstGraphicIntersecting(b);
  134. }
  135.  
  136. inline Selection* PictSelection::LastSelectionIntersecting(BoxObj& b) {
  137.     return (Selection*) Picture::LastGraphicIntersecting(b);
  138. }
  139.  
  140. inline int PictSelection::SelectionsIntersecting(BoxObj& b, Selection**& ss) {
  141.     Graphic** gg = nil;
  142.     int num = Picture::GraphicsIntersecting(b, gg);
  143.     ss = (Selection**) gg;
  144.     return num;
  145. }
  146.  
  147. inline Selection* PictSelection::FirstSelectionWithin(BoxObj& b) {
  148.     return (Selection*) Picture::FirstGraphicWithin(b);
  149. }
  150.  
  151. inline Selection* PictSelection::LastSelectionWithin(BoxObj& b) {
  152.     return (Selection*) Picture::LastGraphicWithin(b);
  153. }
  154.  
  155. inline int PictSelection::SelectionsWithin(BoxObj& b, Selection**& ss) {
  156.     Graphic** gg = nil;
  157.     int num = Picture::GraphicsWithin(b, gg);
  158.     ss = (Selection**) gg;
  159.     return num;
  160. }
  161.  
  162. #endif
  163.