Remove .gitignore do nothing is ignored.
[synfig.git] / ETL / trunk / ETL / _pen.h
index 83bda67..096570a 100644 (file)
@@ -1,7 +1,7 @@
 /*! ========================================================================
 ** Extended Template Library
 ** Pen Template Class Implementation
-** $Id: _pen.h,v 1.1.1.1 2005/01/04 01:31:48 darco Exp $
+** $Id$
 **
 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
 **
@@ -24,8 +24,8 @@
 
 /* === S T A R T =========================================================== */
 
-#ifndef __ETL_PEN_H
-#define __ETL_PEN_H
+#ifndef __ETL__PEN_H
+#define __ETL__PEN_H
 
 /* === H E A D E R S ======================================================= */
 
@@ -60,10 +60,10 @@ public:
        reference operator[](int i)const { assert(data_); return *(pointer)( (char*)data_+pitch_*i ); }
        reference operator*()const { assert(data_); return *data_; }
        pointer operator->() const { assert(data_); return &(operator*()); }
-       
+
        void inc() { assert(data_); data_ = (pointer)((char*)data_ + pitch_); }
        void inc(int n) { assert(data_); data_ = (pointer)((char*)data_ + n*pitch_); }
-       
+
        void dec() { assert(data_); data_ = (pointer)((char*)data_ - pitch_); }
        void dec(int n) { assert(data_); data_ = (pointer)((char*)data_ - n*pitch_); }
 
@@ -151,10 +151,10 @@ private:
        {
                data_ = (pointer)((char*)data_ + nbytes);
        }
-       
+
        void subptr(int nbytes)
        {
-               data_ = (pointer)((char*)data_ + nbytes);
+               data_ = (pointer)((char*)data_ - nbytes);
        }
 
 public:
@@ -181,12 +181,12 @@ public:
 
        generic_pen():data_(NULL) { }
 
-       self_type& move(int a, int b) 
-       { 
-               assert(data_); 
+       self_type& move(int a, int b)
+       {
+               assert(data_);
                x_ += a, y_ += b;
-               addptr(b*pitch_ + a*sizeof(value_type)); 
-               return *this; 
+               addptr(b*pitch_ + a*sizeof(value_type));
+               return *this;
        }
        self_type& move_to(int x, int y) { assert(data_); return move(x - x_,y - y_);}
        void set_value(const value_type &v) { value_=v; }
@@ -214,55 +214,55 @@ public:
 
        const_reference get_value_clip_at(int x, int y)const { assert(data_); if(clipped(x,y))return value_type(); return ((pointer)(((char*)data_)+y*pitch_))[x]; }
 
-       value_type get_value_clip()const { assert(data_); if(clipped())return value_type(); return *data_; }
+       const value_type get_value_clip()const { assert(data_); if(clipped())return value_type(); return *data_; }
 
-       value_type get_pen_value()const { return value_; }
+       const value_type get_pen_value()const { return value_; }
 
        void put_hline(int l,const value_type &v)
        {for(;l>0;l--,inc_x())put_value(v);}
-       
+
        void put_hline(int l) {put_hline(l,value_);}
 
        void put_hline_clip(int l, const value_type &v)
        {l=std::min(l,w_-x_);for(;l>0;l--,inc_x())put_value_clip(v);}
-       
+
        void put_hline_clip(int l) {put_hline_clip(l,value_);}
-               
+
        //the put_block functions do not modify the pen
        void put_block(int h, int w, const value_type &v)
        {
                self_type row(*this);
                for(;h>0;h--,row.inc_y())
-               { 
+               {
                        self_type col(row);
                        col.put_hline(w,v);
                }
        }
-       
+
        void put_block(int h, int w) { put_block(h,w,value_); }
 
        void put_block_clip(int h, int w, const value_type &v)
        {
                self_type row(*this);
-               
+
                //clip start position
-               if(row.x_ < 0) { w+=row.x_; row.inc_x(-row.x_); }               
+               if(row.x_ < 0) { w+=row.x_; row.inc_x(-row.x_); }
                if(row.y_ < 0) { h+=row.y_; row.inc_y(-row.y_); }
-               
+
                //clip width and height of copy rect
                h = std::min(h,h_-y_);
                w = std::min(w,w_-x_);
-               
+
                //copy rect
                for(;h>0;h--,row.inc_y())
-               { 
+               {
                        self_type col(row);
                        col.put_hline(w,v);     //already clipped
                }
        }
-       
+
        void put_block_clip(int h, int w) { put_block(h,w,value_); }
-       
+
 
        iterator_x operator[](int i)const { assert(data_); return (pointer)(((char*)data_)+i*pitch_); }
 
@@ -294,15 +294,15 @@ public:
                assert(data_);
                self_type ret(*this);
                ret.move(rhs.x,rhs.y);
-               return ret;             
+               return ret;
        }
-       
+
        difference_type diff_begin()const {return difference_type(-x_,-y_);}
        difference_type diff_end()const {return difference_type(w_-x_,h_-y_);}
-       
+
        self_type get_start()const      {return *this + diff_begin(); }
        self_type get_end()const        {return *this + diff_end(); }
-       
+
        int get_width()const {return w_;}
        int get_height()const {return h_;}
 
@@ -343,7 +343,7 @@ public:
        using PEN_::h_;
        using PEN_::x_;
        using PEN_::y_;
-       
+
        alpha_pen(const alpha_type &a = 1, const affine_func_type &func = affine_func_type()):alpha_(a),affine_func_(func) { }
        alpha_pen(const PEN_ &x, const alpha_type &a=1, const affine_func_type &func=affine_func_type())
                :PEN_(x),alpha_(a),affine_func_(func) { }
@@ -363,13 +363,13 @@ public:
        void put_value_clip()const { put_value_clip(get_pen_value()); }
        void put_value_clip_alpha(alpha_type a)const { put_value_clip(get_pen_value(),a); }
        void put_hline_clip(int l, const alpha_type &a = 1){l=std::min(l,w_-x_);for(;l>0;l--,inc_x())put_value_clip_alpha(a);}
-       
+
        //the put_block functions do not modify the pen
        void put_block(int h, int w, const alpha_type &a = 1)
        {
                self_type row(*this);
                for(;h>0;h--,row.inc_y())
-               { 
+               {
                        self_type col(row);
                        col.put_hline(w,a);
                }
@@ -378,18 +378,18 @@ public:
        void put_block_clip(int h, int w, const alpha_type &a = 1)
        {
                self_type row(*this);
-               
+
                //clip start position
                if(row.x_ < 0) { w+=row.x_; row.inc_x(-row.x_); }
                if(row.y_ < 0) { h+=row.y_; row.inc_y(-row.y_); }
-               
+
                //clip width and height of copy rect
                h = std::min(h,h_-y_);
                w = std::min(w,w_-x_);
-               
+
                //copy rect
                for(;h>0;h--,row.inc_y())
-               { 
+               {
                        self_type col(row);
                        col.put_hline(w,a);     //already clipped
                }