Code

Mnemonics in fill and stroke dialog and menu
[inkscape.git] / src / 2geom / point-l.h
1 #ifndef SEEN_Geom_POINT_L_H
2 #define SEEN_Geom_POINT_L_H
4 #include <stdexcept>
5 #include <2geom/point.h>
7 namespace Geom {
9 typedef long ICoord;
11 class IPoint {
12     ICoord _pt[2];
14   public:
15     IPoint() { }
17     IPoint(ICoord x, ICoord y) {
18         _pt[X] = x;
19         _pt[Y] = y;
20     }
22     IPoint(NRPointL const &p) {
23         _pt[X] = p.x;
24         _pt[Y] = p.y;
25     }
27     IPoint(IPoint const &p) {
28         for (unsigned i = 0; i < 2; ++i) {
29             _pt[i] = p._pt[i];
30         }
31     }
33     IPoint &operator=(IPoint const &p) {
34         for (unsigned i = 0; i < 2; ++i) {
35             _pt[i] = p._pt[i];
36         }
37         return *this;
38     }
40     operator Point() {
41         return Point(_pt[X], _pt[Y]);
42     }
44     ICoord operator[](unsigned i) const throw(std::out_of_range) {
45         if ( i > Y ) throw std::out_of_range("index out of range");
46         return _pt[i];
47     }
49     ICoord &operator[](unsigned i) throw(std::out_of_range) {
50         if ( i > Y ) throw std::out_of_range("index out of range");
51         return _pt[i];
52     }
54     ICoord operator[](Dim2 d) const throw() { return _pt[d]; }
55     ICoord &operator[](Dim2 d) throw() { return _pt[d]; }
57     IPoint &operator+=(IPoint const &o) {
58         for ( unsigned i = 0 ; i < 2 ; ++i ) {
59             _pt[i] += o._pt[i];
60         }
61         return *this;
62     }
63   
64     IPoint &operator-=(IPoint const &o) {
65         for ( unsigned i = 0 ; i < 2 ; ++i ) {
66             _pt[i] -= o._pt[i];
67         }
68         return *this;
69     }
70 };
73 }  // namespace Geom
75 #endif /* !SEEN_Geom_POINT_L_H */
77 /*
78   Local Variables:
79   mode:c++
80   c-file-style:"stroustrup"
81   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
82   indent-tabs-mode:nil
83   fill-column:99
84   End:
85 */
86 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :