/usr/include/vdk2/vdk/vdkutils.h is in libvdk2-dev 2.4.0-5.5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | /*
* ===========================
* VDK Visual Development Kit
* Version 0.4
* October 1998
* ===========================
*
* Copyright (C) 1998, Mario Motta
* Developed by Mario Motta <mmotta@guest.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-130
*/
#ifndef VDKUTILS_H
#define VDKUTILS_H
#include <gdk/gdk.h>
/*
VDKRgb
*/
/*!
\class VDKRgb
\brief Provides a simple RGB color structure
*/
class VDKRgb
{
public:
int red,green,blue;
/*!
Constructor
\param r red component (0-256)
\param g green component
\param b blue component
*/
VDKRgb(int r = 0, int g = 0, int b = 0): red(r),green(g),blue(b)
{
}
/*!
Destructor
*/
~VDKRgb()
{
}
/*!
Constructor
\param name names are those provided
in rgb X database (normally on /usr/lib/X11/rgb.txt )
*/
VDKRgb(char* name)
{
red = green = blue = -1;
GdkColor color;
if(gdk_color_parse(name, &color))
{
red = color.red >> 8;
green = color.green >> 8;
blue = color.blue >> 8;
}
}
/*!
Returns true if a valid color was loaded
*/
bool IsValid() const { return red != -1 && green != -1 && blue != -1 ; }
/*!
Equality operator
*/
bool operator==(VDKRgb& c) const
{
return ( (red == c.red) && (green == c.green) && (blue == c.blue) );
}
};
/*
------------
point class
------------
*/
/*!
\class VDKPoint
\brief Provides a simple point object
*/
class VDKPoint {
public:
/*!
x,y coordinates
*/
int x,y;
public:
// Constructors
/*!
Constructor, make a point with 0,0 coordinates
*/
VDKPoint(): x(0),y(0)
{
}
/*!
Constructor
\param _x x coordinate
\param _y y coordinate
*/
VDKPoint(int _x, int _y)
{
x = _x; y = _y;
}
/*!
Destructor
*/
virtual
~VDKPoint()
{
}
/*!
Equality operator
*/
int
operator ==(VDKPoint& p) const{ return (x == p.x ) && (y == p.y); }
/*!
Disequality operator
*/
int
operator !=(VDKPoint& p) const{ return ! (*this == p) ; }
/*!
Returns an offset point
\param dx x offset
\param dy y offset
*/
VDKPoint
OffsetBy(int dx, int dy) const { return VDKPoint(x+dx, y+dy); }
/*!
Return simmetric point in plane
*/
VDKPoint
operator -() const{ return VDKPoint(-x, -y); }
/*!
Modify this with an offset
\param dx x offset
\param dy y offset
*/
VDKPoint&
Offset(int dx, int dy);
int
X() const { return x; }
int
Y() const { return y; }
};
/*
----------
rect class
----------
*/
/*!
\class VDKRect
\brief Provides a simple rectangle object
*/
class VDKRect
{
public:
/*!
Corners coordinates
*/
int left,top,right,bottom;
/*!
width and height
*/
int w,h;
public:
/*!
Constructor makes a null rect
*/
VDKRect()
{
left = top = right = bottom = w = h = 0;
}
/*!
Constructor
\param x left-upper corner x
\param left-upper corner y
\param _w width
\param _h height
*/
VDKRect(int x, int y, int _w, int _h):w(_w),h(_h)
{
left = x; top = y; right = x+_w; bottom = y+_h;
}
/*!
Copy initializer
*/
VDKRect(VDKRect& r):w(r.w),h(r.h)
{
left = r.left; right = r.right; top = r.top; bottom = r.bottom;
}
/*!
Destructor
*/
~VDKRect()
{
}
/*!
Returns rect origin
*/
VDKPoint
Origin() const { return VDKPoint(left,top); }
/*!
Returns rect width
*/
int
W() const { return w; }
/*!
Returns rect height
*/
int
H() const { return h; }
/*!
Returns 1 if this contains a point
\param point a point reference
*/
int
Contains(const VDKPoint& point) const
{
return point.X() >= left && point.X() < right
&& point.Y() >= top && point.Y() < bottom;
}
/*!
Returns 1 if this intersect a rect
\param rect a rect reference
*/
int
Contains( const VDKRect& r) const {
return r.left >= left && r.right <= right
&& r.top >= top && r.bottom <= bottom;
}
};
/*!
\class VDKNotCopyAble
\brief Hierarchy root class
All vdk gui and gui related objects (with few exceptions)
belong to this. This object can't be copied or assigned,
any copy/assign operation is flagged as an error since
copy-initializer and assignement operator are private methods.
Most of them are constructed on the heap with new operator
and a great part can be handled with garbage collection.
*/
class VDKNotCopyAble
{
private:
VDKNotCopyAble(VDKNotCopyAble const&);
VDKNotCopyAble& operator=(VDKNotCopyAble const&);
protected:
VDKNotCopyAble(){}
~VDKNotCopyAble(){}
};
#endif
|