Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

vdkutils.h

00001 /*
00002  * ===========================
00003  * VDK Visual Development Kit
00004  * Version 0.4
00005  * October 1998
00006  * ===========================
00007  *
00008  * Copyright (C) 1998, Mario Motta
00009  * Developed by Mario Motta <mmotta@guest.net>
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Library General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Library General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Library General Public
00022  * License along with this library; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00024  * 02111-130
00025  */ 
00026 
00027 #ifndef VDKUTILS_H
00028 #define VDKUTILS_H
00029 #include <gdk/gdk.h>
00030 /*
00031 VDKRgb
00032 */
00037 class VDKRgb
00038 {
00039  public:
00040   int red,green,blue;
00047   VDKRgb(int r = 0, int g = 0, int b = 0): red(r),green(g),blue(b) 
00048     {
00049     }
00053   ~VDKRgb() 
00054     {
00055     }
00061   VDKRgb(char* name) 
00062     {
00063       red = green = blue = -1;
00064       GdkColor color;
00065       if(gdk_color_parse(name, &color))
00066         {
00067         red = color.red >> 8;
00068         green = color.green >> 8;
00069         blue = color.blue >> 8;
00070         }
00071     }
00075   bool IsValid() const { return red != -1 && green != -1 && blue != -1 ; }
00079   bool operator==(VDKRgb& c) const
00080   {
00081     return ( (red == c.red) && (green == c.green) && (blue == c.blue) );
00082   }
00083 };
00084 
00085 /*
00086    ------------
00087    point class
00088    ------------
00089 */
00094 class  VDKPoint {
00095  public:
00099   int x,y;
00100  public:
00101   // Constructors
00105   VDKPoint(): x(0),y(0)
00106     {
00107     }
00113   VDKPoint(int _x, int _y) 
00114     {  
00115       x = _x; y = _y; 
00116     }
00120   virtual
00121     ~VDKPoint() 
00122     {
00123     }
00124 
00128   int
00129     operator ==(VDKPoint& p) const{  return (x == p.x ) && (y == p.y);  }
00133   int
00134     operator !=(VDKPoint& p) const{  return ! (*this == p) ;  }
00140   VDKPoint
00141     OffsetBy(int dx, int dy) const {  return VDKPoint(x+dx, y+dy);  }
00145   VDKPoint
00146     operator -() const{  return VDKPoint(-x, -y);  }
00152   VDKPoint&
00153     Offset(int dx, int dy);
00154 
00155   int
00156     X() const {  return x;  }
00157   int
00158     Y() const {  return y;  }
00159 };
00160 
00161 /*
00162    ----------
00163    rect class
00164    ----------
00165 */
00170 class VDKRect
00171 {
00172 
00173  public:
00177   int left,top,right,bottom;
00181   int w,h;
00182  public:
00183 
00184 
00188   VDKRect() 
00189     {  
00190     left = top = right = bottom = w = h = 0;  
00191     }
00199   VDKRect(int x, int y, int _w, int _h):w(_w),h(_h)
00200     {
00201       left = x; top = y; right = x+_w; bottom = y+_h;
00202     }
00206   VDKRect(VDKRect& r):w(r.w),h(r.h)
00207     {
00208       left = r.left; right = r.right; top = r.top; bottom = r.bottom;
00209     }
00213   ~VDKRect()
00214     {
00215     }
00219   VDKPoint
00220     Origin() const {  return VDKPoint(left,top);  }
00224   int
00225     W() const {  return w;  }
00229   int
00230     H() const {  return h;  }
00235   int
00236     Contains(const VDKPoint& point) const
00237     {
00238       return point.X() >= left && point.X() < right
00239         && point.Y() >= top && point.Y() < bottom;
00240     }
00245   int
00246     Contains( const VDKRect& r) const {
00247     return r.left >= left && r.right <= right
00248       && r.top >= top && r.bottom <= bottom;
00249   }
00250 };
00251 
00263 class VDKNotCopyAble
00264 {
00265  private:
00266      VDKNotCopyAble(VDKNotCopyAble const&);
00267      VDKNotCopyAble& operator=(VDKNotCopyAble const&);
00268  protected:
00269      VDKNotCopyAble(){}
00270      ~VDKNotCopyAble(){}
00271 };
00272 
00273 #endif
00274 
00275 
00276 
00277 
00278 
00279 
00280 

Generated on Sat May 4 21:58:35 2002 for vdk 2.0.1 by doxygen1.2.15