00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#ifndef VDKUTILS_H
00028
#define VDKUTILS_H
00029
#include <gdk/gdk.h>
00030
00031
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
00088
00089
00094 class VDKPoint {
00095
public:
00099 int x,
y;
00100
public:
00101
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
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