Rapicorn - Experimental UI Toolkit - Source Code 10.08.1
region.hh
Go to the documentation of this file.
00001 /* Rapicorn
00002  * Copyright (C) 2006 Tim Janik
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * A copy of the GNU Lesser General Public License should ship along
00015  * with this library; if not, see http://www.gnu.org/copyleft/.
00016  */
00017 #ifndef __RAPICORN_REGION_HH__
00018 #define __RAPICORN_REGION_HH__
00019 
00020 #include <ui/primitives.hh>
00021 
00022 namespace Rapicorn {
00023 
00031 class Region {
00032   union {
00033     struct CRegion { int64 idummy[4]; void *pdummy; };
00034     CRegion          cstruct_mem;               // ensure C structure size and alignment
00035     char             chars[sizeof (CRegion)];   // char may_alias any type
00036   }                  m_region;                  // RAPICORN_MAY_ALIAS; ICE: GCC#30894
00037   inline void*       region_mem   ();
00038   inline const void* region_mem   () const;
00039 public: /* rectangles are represented at 64bit integer precision */
00040   typedef enum { OUTSIDE = 0, INSIDE = 1, PARTIAL } ContainedType;
00041   explicit      Region            ();
00042   /*Con*/       Region            (const Region         &src);
00043   /*Con*/       Region            (const Rect           &src);
00044   /*Con*/       Region            (const Point          &rect_p1,
00045                                    const Point          &rect_p2);
00046   Region&       operator=         (const Region         &src);
00047   void          clear             ();
00048   bool          empty             () const;
00049   bool          equal             (const Region &other) const;
00050   int           cmp               (const Region &other) const;
00051   void          swap              (Region               &other);
00052   Rect          extents           () const;
00053   bool          contains          (const Point          &point) const;
00054   bool          contains          (double                x,
00055                                    double                y) const       { return contains (Point (x, y)); }
00056   ContainedType contains          (const Rect           &rect) const;
00057   ContainedType contains          (const Region         &other) const;
00058   void          list_rects        (std::vector<Rect>    &rects) const;
00059   uint          count_rects       () const;
00060   void          add               (const Rect           &rect);
00061   void          add               (const Region         &other);
00062   void          subtract          (const Region         &subtrahend);
00063   void          intersect         (const Region         &other);
00064   void          exor              (const Region         &other);
00065   void          affine            (const Affine         &aff);
00066   double        epsilon           () const;
00067   String        string            ();
00068   /*Des*/      ~Region            ();
00069 };
00070 
00071 bool operator== (const Region &r1,
00072                  const Region &r2);
00073 bool operator!= (const Region &r1,
00074                  const Region &r2);
00075 bool operator<  (const Region &r1,
00076                  const Region &r2);
00077 
00078 } // Rapicorn
00079 
00080 #endif  /* __RAPICORN_REGION_HH__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines