diff --git a/assdraw/_common.hpp b/assdraw/_common.hpp
index 93c17f23559b2376fec4baa155e1357f6d107e99..89b2f918768ce6b66091b0593914929100067051 100644
--- a/assdraw/_common.hpp
+++ b/assdraw/_common.hpp
@@ -2,11 +2,11 @@
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-    #pragma hdrstop
+#pragma hdrstop
 #endif
 
 #ifndef WX_PRECOMP
-    #include "wx/wx.h"
+#include "wx/wx.h"
 #endif
 
 #define TITLE wxT("ASSDraw3")
diff --git a/assdraw/agg_bcspline.cpp b/assdraw/agg_bcspline.cpp
index d6973c04a9325a29df172e3e8f6f1c9a684dfd69..f559c328a6beebfe22d5f25f0ca367fa03bfa53a 100644
--- a/assdraw/agg_bcspline.cpp
+++ b/assdraw/agg_bcspline.cpp
@@ -24,266 +24,245 @@
 
 #include "agg_bcspline.h"
 
-namespace agg
+namespace agg {
+//------------------------------------------------------------------------
+bcspline::bcspline() :
+    m_max(0),
+    m_num(0),
+    m_x(0),
+    m_y(0),
+    m_last_idx(-1)
 {
-    //------------------------------------------------------------------------
-    bcspline::bcspline() :
-        m_max(0),
-        m_num(0),
-        m_x(0),
-        m_y(0),
-        m_last_idx(-1)
-    {
-    }
+}
 
-    //------------------------------------------------------------------------
-    bcspline::bcspline(int num) :
-        m_max(0),
-        m_num(0),
-        m_x(0),
-        m_y(0),
-        m_last_idx(-1)
-    {
-        init(num);
-    }
+//------------------------------------------------------------------------
+bcspline::bcspline(int num) :
+    m_max(0),
+    m_num(0),
+    m_x(0),
+    m_y(0),
+    m_last_idx(-1)
+{
+    init(num);
+}
 
-    //------------------------------------------------------------------------
-    bcspline::bcspline(int num, const double* x, const double* y) :
-        m_max(0),
-        m_num(0),
-        m_x(0),
-        m_y(0),
-        m_last_idx(-1)
-    {
-        init(num, x, y);
-    }
+//------------------------------------------------------------------------
+bcspline::bcspline(int num, const double *x, const double *y) :
+    m_max(0),
+    m_num(0),
+    m_x(0),
+    m_y(0),
+    m_last_idx(-1)
+{
+    init(num, x, y);
+}
 
 
-    //------------------------------------------------------------------------
-    void bcspline::init(int max)
-    {
-        if(max > 2 && max > m_max)
-        {
-            m_am.resize(max * 3);
-            m_max = max;
-            m_x   = &m_am[m_max];
-            m_y   = &m_am[m_max * 2];
-        }
-        m_num = 0;
-        m_last_idx = -1;
+//------------------------------------------------------------------------
+void bcspline::init(int max)
+{
+    if (max > 2 && max > m_max) {
+        m_am.resize(max * 3);
+        m_max = max;
+        m_x   = &m_am[m_max];
+        m_y   = &m_am[m_max * 2];
     }
+    m_num = 0;
+    m_last_idx = -1;
+}
 
 
-    //------------------------------------------------------------------------
-    void bcspline::add_point(double x, double y)
-    {
-        if(m_num < m_max)
-        {
-            m_x[m_num] = x;
-            m_y[m_num] = y;
-            ++m_num;
-        }
+//------------------------------------------------------------------------
+void bcspline::add_point(double x, double y)
+{
+    if (m_num < m_max) {
+        m_x[m_num] = x;
+        m_y[m_num] = y;
+        ++m_num;
     }
+}
 
 
-    //------------------------------------------------------------------------
-    void bcspline::prepare()
-    {
-        if(m_num > 2)
-        {
-            int i, k, n1;
-            double* temp;
-            double* r;
-            double* s;
-            double h, p, d, f, e;
-
-            for(k = 0; k < m_num; k++)
-            {
-                m_am[k] = 0.0;
-            }
+//------------------------------------------------------------------------
+void bcspline::prepare()
+{
+    if (m_num > 2) {
+        int i, k, n1;
+        double *temp;
+        double *r;
+        double *s;
+        double h, p, d, f, e;
+
+        for (k = 0; k < m_num; k++) {
+            m_am[k] = 0.0;
+        }
 
-            n1 = 3 * m_num;
+        n1 = 3 * m_num;
 
-            pod_array<double> al(n1);
-            temp = &al[0];
+        pod_array<double> al(n1);
+        temp = &al[0];
 
-            for(k = 0; k < n1; k++)
-            {
-                temp[k] = 0.0;
-            }
+        for (k = 0; k < n1; k++) {
+            temp[k] = 0.0;
+        }
 
-            r = temp + m_num;
-            s = temp + m_num * 2;
-
-            n1 = m_num - 1;
-            d = m_x[1] - m_x[0];
-            e = (m_y[1] - m_y[0]) / d;
-
-            for(k = 1; k < n1; k++)
-            {
-                h     = d;
-                d     = m_x[k + 1] - m_x[k];
-                f     = e;
-                e     = (m_y[k + 1] - m_y[k]) / d;
-                al[k] = d / (d + h);
-                r[k]  = 1.0 - al[k];
-                s[k]  = 6.0 * (e - f) / (h + d);
-            }
+        r = temp + m_num;
+        s = temp + m_num * 2;
+
+        n1 = m_num - 1;
+        d = m_x[1] - m_x[0];
+        e = (m_y[1] - m_y[0]) / d;
+
+        for (k = 1; k < n1; k++) {
+            h     = d;
+            d     = m_x[k + 1] - m_x[k];
+            f     = e;
+            e     = (m_y[k + 1] - m_y[k]) / d;
+            al[k] = d / (d + h);
+            r[k]  = 1.0 - al[k];
+            s[k]  = 6.0 * (e - f) / (h + d);
+        }
 
-            for(k = 1; k < n1; k++)
-            {
-                p = 1.0 / (r[k] * al[k - 1] + 2.0);
-                al[k] *= -p;
-                s[k] = (s[k] - r[k] * s[k - 1]) * p;
-            }
+        for (k = 1; k < n1; k++) {
+            p = 1.0 / (r[k] * al[k - 1] + 2.0);
+            al[k] *= -p;
+            s[k] = (s[k] - r[k] * s[k - 1]) * p;
+        }
 
-            m_am[n1]     = 0.0;
-            al[n1 - 1]   = s[n1 - 1];
-            m_am[n1 - 1] = al[n1 - 1];
+        m_am[n1]     = 0.0;
+        al[n1 - 1]   = s[n1 - 1];
+        m_am[n1 - 1] = al[n1 - 1];
 
-            for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
-            {
-                al[k]   = al[k] * al[k + 1] + s[k];
-                m_am[k] = al[k];
-            }
+        for (k = n1 - 2, i = 0; i < m_num - 2; i++, k--) {
+            al[k]   = al[k] * al[k + 1] + s[k];
+            m_am[k] = al[k];
         }
-        m_last_idx = -1;
     }
+    m_last_idx = -1;
+}
 
 
 
-    //------------------------------------------------------------------------
-    void bcspline::init(int num, const double* x, const double* y)
-    {
-        if(num > 2)
-        {
-            init(num);
-            int i;
-            for(i = 0; i < num; i++)
-            {
-                add_point(*x++, *y++);
-            }
-            prepare();
+//------------------------------------------------------------------------
+void bcspline::init(int num, const double *x, const double *y)
+{
+    if (num > 2) {
+        init(num);
+        int i;
+        for (i = 0; i < num; i++) {
+            add_point(*x++, *y++);
         }
-        m_last_idx = -1;
+        prepare();
     }
+    m_last_idx = -1;
+}
 
 
-    //------------------------------------------------------------------------
-    void bcspline::bsearch(int n, const double *x, double x0, int *i)
-    {
-        int j = n - 1;
-        int k;
+//------------------------------------------------------------------------
+void bcspline::bsearch(int n, const double *x, double x0, int *i)
+{
+    int j = n - 1;
+    int k;
 
-        for(*i = 0; (j - *i) > 1; )
-        {
-            if(x0 < x[k = (*i + j) >> 1]) j = k;
-            else                         *i = k;
-        }
+    for (*i = 0; (j - *i) > 1; ) {
+        if (x0 < x[k = (*i + j) >> 1]) j = k;
+        else                         *i = k;
     }
+}
 
 
 
-    //------------------------------------------------------------------------
-    double bcspline::interpolation(double x, int i) const
-    {
-        int j = i + 1;
-        double d = m_x[i] - m_x[j];
-        double h = x - m_x[j];
-        double r = m_x[i] - x;
-        double p = d * d / 6.0;
-        return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d +
-               ((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d;
-    }
+//------------------------------------------------------------------------
+double bcspline::interpolation(double x, int i) const
+{
+    int j = i + 1;
+    double d = m_x[i] - m_x[j];
+    double h = x - m_x[j];
+    double r = m_x[i] - x;
+    double p = d * d / 6.0;
+    return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d +
+           ((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d;
+}
 
 
-    //------------------------------------------------------------------------
-    double bcspline::extrapolation_left(double x) const
-    {
-        double d = m_x[1] - m_x[0];
-        return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
-               (x - m_x[0]) +
-               m_y[0];
-    }
+//------------------------------------------------------------------------
+double bcspline::extrapolation_left(double x) const
+{
+    double d = m_x[1] - m_x[0];
+    return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
+           (x - m_x[0]) +
+           m_y[0];
+}
 
-    //------------------------------------------------------------------------
-    double bcspline::extrapolation_right(double x) const
-    {
-        double d = m_x[m_num - 1] - m_x[m_num - 2];
-        return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
-               (x - m_x[m_num - 1]) +
-               m_y[m_num - 1];
-    }
+//------------------------------------------------------------------------
+double bcspline::extrapolation_right(double x) const
+{
+    double d = m_x[m_num - 1] - m_x[m_num - 2];
+    return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
+           (x - m_x[m_num - 1]) +
+           m_y[m_num - 1];
+}
 
-    //------------------------------------------------------------------------
-    double bcspline::get(double x) const
-    {
-        if(m_num > 2)
-        {
-            int i;
+//------------------------------------------------------------------------
+double bcspline::get(double x) const
+{
+    if (m_num > 2) {
+        int i;
 
-            // Extrapolation on the left
-            if(x < m_x[0]) return extrapolation_left(x);
+        // Extrapolation on the left
+        if (x < m_x[0]) return extrapolation_left(x);
 
-            // Extrapolation on the right
-            if(x >= m_x[m_num - 1]) return extrapolation_right(x);
+        // Extrapolation on the right
+        if (x >= m_x[m_num - 1]) return extrapolation_right(x);
 
-            // Interpolation
-            bsearch(m_num, m_x, x, &i);
-            return interpolation(x, i);
-        }
-        return 0.0;
+        // Interpolation
+        bsearch(m_num, m_x, x, &i);
+        return interpolation(x, i);
     }
+    return 0.0;
+}
 
 
-    //------------------------------------------------------------------------
-    double bcspline::get_stateful(double x) const
-    {
-        if(m_num > 2)
-        {
-            // Extrapolation on the left
-            if(x < m_x[0]) return extrapolation_left(x);
-
-            // Extrapolation on the right
-            if(x >= m_x[m_num - 1]) return extrapolation_right(x);
-
-            if(m_last_idx >= 0)
-            {
-                // Check if x is not in current range
-                if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1])
-                {
-                    // Check if x between next points (most probably)
-                    if(m_last_idx < m_num - 2 &&
-                       x >= m_x[m_last_idx + 1] &&
-                       x <= m_x[m_last_idx + 2])
-                    {
-                        ++m_last_idx;
-                    }
-                    else
-                    if(m_last_idx > 0 &&
-                       x >= m_x[m_last_idx - 1] &&
-                       x <= m_x[m_last_idx])
-                    {
-                        // x is between pevious points
-                        --m_last_idx;
-                    }
-                    else
-                    {
-                        // Else perform full search
-                        bsearch(m_num, m_x, x, &m_last_idx);
-                    }
+//------------------------------------------------------------------------
+double bcspline::get_stateful(double x) const
+{
+    if (m_num > 2) {
+        // Extrapolation on the left
+        if (x < m_x[0]) return extrapolation_left(x);
+
+        // Extrapolation on the right
+        if (x >= m_x[m_num - 1]) return extrapolation_right(x);
+
+        if (m_last_idx >= 0) {
+            // Check if x is not in current range
+            if (x < m_x[m_last_idx] || x > m_x[m_last_idx + 1]) {
+                // Check if x between next points (most probably)
+                if (m_last_idx < m_num - 2 &&
+                    x >= m_x[m_last_idx + 1] &&
+                    x <= m_x[m_last_idx + 2]) {
+                    ++m_last_idx;
+                }
+                else if (m_last_idx > 0 &&
+                         x >= m_x[m_last_idx - 1] &&
+                         x <= m_x[m_last_idx]) {
+                    // x is between pevious points
+                    --m_last_idx;
+                }
+                else {
+                    // Else perform full search
+                    bsearch(m_num, m_x, x, &m_last_idx);
                 }
-                return interpolation(x, m_last_idx);
-            }
-            else
-            {
-                // Interpolation
-                bsearch(m_num, m_x, x, &m_last_idx);
-                return interpolation(x, m_last_idx);
             }
+            return interpolation(x, m_last_idx);
+        }
+        else {
+            // Interpolation
+            bsearch(m_num, m_x, x, &m_last_idx);
+            return interpolation(x, m_last_idx);
         }
-        return 0.0;
     }
+    return 0.0;
+}
 
 }
 
diff --git a/assdraw/agg_bcspline.h b/assdraw/agg_bcspline.h
index 05d2364978ffdc8f920cfa0fd01fb5c975dee97b..e5f049b97902d3b00ef6776bb01190182f5c545d 100644
--- a/assdraw/agg_bcspline.h
+++ b/assdraw/agg_bcspline.h
@@ -5,20 +5,20 @@
 // Contact: mcseem@antigrain.com
 //          mcseemagg@yahoo.com
 //          http://antigrain.com
-// 
+//
 // AGG is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
 // as published by the Free Software Foundation; either version 2
 // of the License, or (at your option) any later version.
-// 
+//
 // AGG 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 General Public License for more details.
-// 
+//
 // You should have received a copy of the GNU General Public License
 // along with AGG; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 // MA 02110-1301, USA.
 //----------------------------------------------------------------------------
 
@@ -27,53 +27,51 @@
 
 #include "agg_array.h"
 
-namespace agg
-{
-    //----------------------------------------------------------------bcspline
-    // A very simple class of Bi-cubic Spline interpolation.
-    // First call init(num, x[], y[]) where num - number of source points, 
-    // x, y - arrays of X and Y values respectively. Here Y must be a function 
-    // of X. It means that all the X-coordinates must be arranged in the ascending
-    // order. 
-    // Then call get(x) that calculates a value Y for the respective X. 
-    // The class supports extrapolation, i.e. you can call get(x) where x is
-    // outside the given with init() X-range. Extrapolation is a simple linear 
-    // function.
-    //
-    //  See Implementation agg_bcspline.cpp
-    //------------------------------------------------------------------------
-    class bcspline 
-    {
-    public:
-        bcspline();
-        bcspline(int num);
-        bcspline(int num, const double* x, const double* y);
+namespace agg {
+//----------------------------------------------------------------bcspline
+// A very simple class of Bi-cubic Spline interpolation.
+// First call init(num, x[], y[]) where num - number of source points,
+// x, y - arrays of X and Y values respectively. Here Y must be a function
+// of X. It means that all the X-coordinates must be arranged in the ascending
+// order.
+// Then call get(x) that calculates a value Y for the respective X.
+// The class supports extrapolation, i.e. you can call get(x) where x is
+// outside the given with init() X-range. Extrapolation is a simple linear
+// function.
+//
+//  See Implementation agg_bcspline.cpp
+//------------------------------------------------------------------------
+class bcspline {
+public:
+    bcspline();
+    bcspline(int num);
+    bcspline(int num, const double *x, const double *y);
 
-        void   init(int num);
-        void   add_point(double x, double y);
-        void   prepare();
+    void   init(int num);
+    void   add_point(double x, double y);
+    void   prepare();
 
-        void   init(int num, const double* x, const double* y);
+    void   init(int num, const double *x, const double *y);
 
-        double get(double x) const;
-        double get_stateful(double x) const;
-    
-    private:
-        bcspline(const bcspline&);
-        const bcspline& operator = (const bcspline&);
+    double get(double x) const;
+    double get_stateful(double x) const;
 
-        static void bsearch(int n, const double *x, double x0, int *i);
-        double extrapolation_left(double x) const;
-        double extrapolation_right(double x) const;
-        double interpolation(double x, int i) const;
+private:
+    bcspline(const bcspline &);
+    const bcspline &operator = (const bcspline &);
 
-        int               m_max;
-        int               m_num;
-        double*           m_x;
-        double*           m_y;
-        pod_array<double> m_am;
-        mutable int       m_last_idx;
-    };
+    static void bsearch(int n, const double *x, double x0, int *i);
+    double extrapolation_left(double x) const;
+    double extrapolation_right(double x) const;
+    double interpolation(double x, int i) const;
+
+    int               m_max;
+    int               m_num;
+    double           *m_x;
+    double           *m_y;
+    pod_array<double> m_am;
+    mutable int       m_last_idx;
+};
 
 
 }
diff --git a/assdraw/agg_conv_bcspline.h b/assdraw/agg_conv_bcspline.h
index 3d40b9619193291dda4ebeff3ae26aa076a5bb48..6a4cac602c64af8a587c6edad2fed174efa229b9 100644
--- a/assdraw/agg_conv_bcspline.h
+++ b/assdraw/agg_conv_bcspline.h
@@ -5,20 +5,20 @@
 // Contact: mcseem@antigrain.com
 //          mcseemagg@yahoo.com
 //          http://antigrain.com
-// 
+//
 // AGG is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
 // as published by the Free Software Foundation; either version 2
 // of the License, or (at your option) any later version.
-// 
+//
 // AGG 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 General Public License for more details.
-// 
+//
 // You should have received a copy of the GNU General Public License
 // along with AGG; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 // MA 02110-1301, USA.
 //----------------------------------------------------------------------------
 
@@ -30,26 +30,24 @@
 #include "agg_conv_adaptor_vcgen.h"
 
 
-namespace agg
-{
+namespace agg {
 
-    //---------------------------------------------------------conv_bcspline
-    template<class VertexSource> 
-    struct conv_bcspline : public conv_adaptor_vcgen<VertexSource, vcgen_bcspline>
-    {
-        typedef conv_adaptor_vcgen<VertexSource, vcgen_bcspline> base_type;
+//---------------------------------------------------------conv_bcspline
+template<class VertexSource>
+struct conv_bcspline : public conv_adaptor_vcgen<VertexSource, vcgen_bcspline> {
+    typedef conv_adaptor_vcgen<VertexSource, vcgen_bcspline> base_type;
 
-        conv_bcspline(VertexSource& vs) : 
-            conv_adaptor_vcgen<VertexSource, vcgen_bcspline>(vs) {}
+    conv_bcspline(VertexSource &vs) :
+        conv_adaptor_vcgen<VertexSource, vcgen_bcspline>(vs) {}
 
-        void   interpolation_step(double v) { base_type::generator().interpolation_step(v); }
-        double interpolation_step() const { return base_type::generator().interpolation_step(); }
+    void   interpolation_step(double v) { base_type::generator().interpolation_step(v); }
+    double interpolation_step() const { return base_type::generator().interpolation_step(); }
 
-    private:
-        conv_bcspline(const conv_bcspline<VertexSource>&);
-        const conv_bcspline<VertexSource>& 
-            operator = (const conv_bcspline<VertexSource>&);
-    };
+private:
+    conv_bcspline(const conv_bcspline<VertexSource> &);
+    const conv_bcspline<VertexSource> &
+    operator = (const conv_bcspline<VertexSource> &);
+};
 
 }
 
diff --git a/assdraw/agg_vcgen_bcspline.cpp b/assdraw/agg_vcgen_bcspline.cpp
index 5796b1277105c7c0efd679bf5aaae5e641c7294a..7ae1ba3562eb13aa12fe76976d7c0f144c526f8b 100644
--- a/assdraw/agg_vcgen_bcspline.cpp
+++ b/assdraw/agg_vcgen_bcspline.cpp
@@ -24,179 +24,162 @@
 
 #include "agg_vcgen_bcspline.h"
 
-namespace agg
+namespace agg {
+
+//------------------------------------------------------------------------
+vcgen_bcspline::vcgen_bcspline() :
+    m_src_vertices(),
+    m_spline_x(),
+    m_spline_y(),
+    m_interpolation_step(1.0 / 50.0),
+    m_closed(0),
+    m_status(initial),
+    m_src_vertex(0)
 {
-
-    //------------------------------------------------------------------------
-    vcgen_bcspline::vcgen_bcspline() :
-        m_src_vertices(),
-        m_spline_x(),
-        m_spline_y(),
-        m_interpolation_step(1.0/50.0),
-        m_closed(0),
-        m_status(initial),
-        m_src_vertex(0)
-    {
-    }
+}
 
 
-    //------------------------------------------------------------------------
-    void vcgen_bcspline::remove_all()
-    {
-        m_src_vertices.remove_all();
-        m_closed = 0;
-        m_status = initial;
-        m_src_vertex = 0;
-    }
+//------------------------------------------------------------------------
+void vcgen_bcspline::remove_all()
+{
+    m_src_vertices.remove_all();
+    m_closed = 0;
+    m_status = initial;
+    m_src_vertex = 0;
+}
 
 
-    //------------------------------------------------------------------------
-    void vcgen_bcspline::add_vertex(double x, double y, unsigned cmd)
-    {
-        m_status = initial;
-        if(is_move_to(cmd))
-        {
-            m_src_vertices.modify_last(point_d(x, y));
+//------------------------------------------------------------------------
+void vcgen_bcspline::add_vertex(double x, double y, unsigned cmd)
+{
+    m_status = initial;
+    if (is_move_to(cmd)) {
+        m_src_vertices.modify_last(point_d(x, y));
+    }
+    else {
+        if (is_vertex(cmd)) {
+            m_src_vertices.add(point_d(x, y));
         }
-        else
-        {
-            if(is_vertex(cmd))
-            {
-                m_src_vertices.add(point_d(x, y));
-            }
-            else
-            {
-                m_closed = get_close_flag(cmd);
-            }
+        else {
+            m_closed = get_close_flag(cmd);
         }
     }
+}
 
 
-    //------------------------------------------------------------------------
-    void vcgen_bcspline::rewind(unsigned)
-    {
+//------------------------------------------------------------------------
+void vcgen_bcspline::rewind(unsigned)
+{
+    m_cur_abscissa = 0.0;
+    m_max_abscissa = 0.0;
+    m_src_vertex = 0;
+    if (m_status == initial && m_src_vertices.size() > 2) {
+        if (m_closed) {
+            m_spline_x.init(m_src_vertices.size() + 8);
+            m_spline_y.init(m_src_vertices.size() + 8);
+            m_spline_x.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).x);
+            m_spline_y.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).y);
+            m_spline_x.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].x);
+            m_spline_y.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].y);
+            m_spline_x.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].x);
+            m_spline_y.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].y);
+            m_spline_x.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].x);
+            m_spline_y.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].y);
+        }
+        else {
+            m_spline_x.init(m_src_vertices.size());
+            m_spline_y.init(m_src_vertices.size());
+        }
+        unsigned i;
+        for (i = 0; i < m_src_vertices.size(); i++) {
+            double x = m_closed ? i + 4 : i;
+            m_spline_x.add_point(x, m_src_vertices[i].x);
+            m_spline_y.add_point(x, m_src_vertices[i].y);
+        }
         m_cur_abscissa = 0.0;
-        m_max_abscissa = 0.0;
-        m_src_vertex = 0;
-        if(m_status == initial && m_src_vertices.size() > 2)
-        {
-            if(m_closed)
-            {
-                m_spline_x.init(m_src_vertices.size() + 8);
-                m_spline_y.init(m_src_vertices.size() + 8);
-                m_spline_x.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).x);
-                m_spline_y.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).y);
-                m_spline_x.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].x);
-                m_spline_y.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].y);
-                m_spline_x.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].x);
-                m_spline_y.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].y);
-                m_spline_x.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].x);
-                m_spline_y.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].y);
-            }
-            else
-            {
-                m_spline_x.init(m_src_vertices.size());
-                m_spline_y.init(m_src_vertices.size());
-            }
-            unsigned i;
-            for(i = 0; i < m_src_vertices.size(); i++)
-            {
-                double x = m_closed ? i + 4 : i;
-                m_spline_x.add_point(x, m_src_vertices[i].x);
-                m_spline_y.add_point(x, m_src_vertices[i].y);
-            }
-            m_cur_abscissa = 0.0;
-            m_max_abscissa = m_src_vertices.size() - 1;
-            if(m_closed)
-            {
-                m_cur_abscissa = 4.0;
-                m_max_abscissa += 5.0;
-                m_spline_x.add_point(m_src_vertices.size() + 4, m_src_vertices[0].x);
-                m_spline_y.add_point(m_src_vertices.size() + 4, m_src_vertices[0].y);
-                m_spline_x.add_point(m_src_vertices.size() + 5, m_src_vertices[1].x);
-                m_spline_y.add_point(m_src_vertices.size() + 5, m_src_vertices[1].y);
-                m_spline_x.add_point(m_src_vertices.size() + 6, m_src_vertices[2].x);
-                m_spline_y.add_point(m_src_vertices.size() + 6, m_src_vertices[2].y);
-                m_spline_x.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).x);
-                m_spline_y.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).y);
-            }
-            m_spline_x.prepare();
-            m_spline_y.prepare();
+        m_max_abscissa = m_src_vertices.size() - 1;
+        if (m_closed) {
+            m_cur_abscissa = 4.0;
+            m_max_abscissa += 5.0;
+            m_spline_x.add_point(m_src_vertices.size() + 4, m_src_vertices[0].x);
+            m_spline_y.add_point(m_src_vertices.size() + 4, m_src_vertices[0].y);
+            m_spline_x.add_point(m_src_vertices.size() + 5, m_src_vertices[1].x);
+            m_spline_y.add_point(m_src_vertices.size() + 5, m_src_vertices[1].y);
+            m_spline_x.add_point(m_src_vertices.size() + 6, m_src_vertices[2].x);
+            m_spline_y.add_point(m_src_vertices.size() + 6, m_src_vertices[2].y);
+            m_spline_x.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).x);
+            m_spline_y.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).y);
         }
-        m_status = ready;
+        m_spline_x.prepare();
+        m_spline_y.prepare();
     }
+    m_status = ready;
+}
 
 
 
 
 
 
-    //------------------------------------------------------------------------
-    unsigned vcgen_bcspline::vertex(double* x, double* y)
-    {
-        unsigned cmd = path_cmd_line_to;
-        while(!is_stop(cmd))
-        {
-            switch(m_status)
-            {
-            case initial:
-                rewind(0);
+//------------------------------------------------------------------------
+unsigned vcgen_bcspline::vertex(double *x, double *y)
+{
+    unsigned cmd = path_cmd_line_to;
+    while (!is_stop(cmd)) {
+        switch (m_status) {
+        case initial:
+            rewind(0);
+
+        case ready:
+            if (m_src_vertices.size() < 2) {
+                cmd = path_cmd_stop;
+                break;
+            }
 
-            case ready:
-                if(m_src_vertices.size() < 2)
-                {
-                    cmd = path_cmd_stop;
-                    break;
-                }
+            if (m_src_vertices.size() == 2) {
+                *x = m_src_vertices[m_src_vertex].x;
+                *y = m_src_vertices[m_src_vertex].y;
+                m_src_vertex++;
+                if (m_src_vertex == 1) return path_cmd_move_to;
+                if (m_src_vertex == 2) return path_cmd_line_to;
+                cmd = path_cmd_stop;
+                break;
+            }
 
-                if(m_src_vertices.size() == 2)
-                {
-                    *x = m_src_vertices[m_src_vertex].x;
-                    *y = m_src_vertices[m_src_vertex].y;
-                    m_src_vertex++;
-                    if(m_src_vertex == 1) return path_cmd_move_to;
-                    if(m_src_vertex == 2) return path_cmd_line_to;
-                    cmd = path_cmd_stop;
+            cmd = path_cmd_move_to;
+            m_status = polygon;
+            m_src_vertex = 0;
+
+        case polygon:
+            if (m_cur_abscissa >= m_max_abscissa) {
+                if (m_closed) {
+                    m_status = end_poly;
                     break;
                 }
-
-                cmd = path_cmd_move_to;
-                m_status = polygon;
-                m_src_vertex = 0;
-
-            case polygon:
-                if(m_cur_abscissa >= m_max_abscissa)
-                {
-                    if(m_closed)
-                    {
-                        m_status = end_poly;
-                        break;
-                    }
-                    else
-                    {
-                        *x = m_src_vertices[m_src_vertices.size() - 1].x;
-                        *y = m_src_vertices[m_src_vertices.size() - 1].y;
-                        m_status = end_poly;
-                        return path_cmd_line_to;
-                    }
+                else {
+                    *x = m_src_vertices[m_src_vertices.size() - 1].x;
+                    *y = m_src_vertices[m_src_vertices.size() - 1].y;
+                    m_status = end_poly;
+                    return path_cmd_line_to;
                 }
+            }
 
-                *x = m_spline_x.get(m_cur_abscissa);
-                *y = m_spline_y.get(m_cur_abscissa);
-                m_src_vertex++;
-                m_cur_abscissa += m_interpolation_step;
-                return (m_src_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
+            *x = m_spline_x.get(m_cur_abscissa);
+            *y = m_spline_y.get(m_cur_abscissa);
+            m_src_vertex++;
+            m_cur_abscissa += m_interpolation_step;
+            return (m_src_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
 
-            case end_poly:
-                m_status = stop;
-                return path_cmd_end_poly | m_closed;
+        case end_poly:
+            m_status = stop;
+            return path_cmd_end_poly | m_closed;
 
-            case stop:
-                return path_cmd_stop;
-            }
+        case stop:
+            return path_cmd_stop;
         }
-        return cmd;
     }
+    return cmd;
+}
 
 
 }
diff --git a/assdraw/agg_vcgen_bcspline.h b/assdraw/agg_vcgen_bcspline.h
index 6f92d994201171311b56a723f59bbfe811ffb960..e9f68577b41a8c6baff9c8e79d2baf43b9ebf7ba 100644
--- a/assdraw/agg_vcgen_bcspline.h
+++ b/assdraw/agg_vcgen_bcspline.h
@@ -5,20 +5,20 @@
 // Contact: mcseem@antigrain.com
 //          mcseemagg@yahoo.com
 //          http://antigrain.com
-// 
+//
 // AGG is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
 // as published by the Free Software Foundation; either version 2
 // of the License, or (at your option) any later version.
-// 
+//
 // AGG 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 General Public License for more details.
-// 
+//
 // You should have received a copy of the GNU General Public License
 // along with AGG; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 // MA 02110-1301, USA.
 //----------------------------------------------------------------------------
 
@@ -30,52 +30,49 @@
 #include "agg_bcspline.h"
 
 
-namespace agg
-{
-
-    //==========================================================vcgen_bcspline
-    class vcgen_bcspline
-    {
-        enum status_e
-        {
-            initial,
-            ready,
-            polygon,
-            end_poly,
-            stop
-        };
-
-    public:
-        typedef pod_bvector<point_d, 6> vertex_storage;
-
-        vcgen_bcspline();
-
-        void interpolation_step(double v) { m_interpolation_step = v; }
-        double interpolation_step() const { return m_interpolation_step; }
-
-        // Vertex Generator Interface
-        void remove_all();
-        void add_vertex(double x, double y, unsigned cmd);
-
-        // Vertex Source Interface
-        void     rewind(unsigned path_id);
-        unsigned vertex(double* x, double* y);
-
-    private:
-        vcgen_bcspline(const vcgen_bcspline&);
-        const vcgen_bcspline& operator = (const vcgen_bcspline&);
-
-        vertex_storage m_src_vertices;
-        bcspline        m_spline_x;
-        bcspline        m_spline_y;
-        double         m_interpolation_step;
-        unsigned       m_closed;
-        status_e       m_status;
-        unsigned       m_src_vertex;
-        double         m_cur_abscissa;
-        double         m_max_abscissa;
+namespace agg {
+
+//==========================================================vcgen_bcspline
+class vcgen_bcspline {
+    enum status_e {
+        initial,
+        ready,
+        polygon,
+        end_poly,
+        stop
     };
 
+public:
+    typedef pod_bvector<point_d, 6> vertex_storage;
+
+    vcgen_bcspline();
+
+    void interpolation_step(double v) { m_interpolation_step = v; }
+    double interpolation_step() const { return m_interpolation_step; }
+
+    // Vertex Generator Interface
+    void remove_all();
+    void add_vertex(double x, double y, unsigned cmd);
+
+    // Vertex Source Interface
+    void     rewind(unsigned path_id);
+    unsigned vertex(double *x, double *y);
+
+private:
+    vcgen_bcspline(const vcgen_bcspline &);
+    const vcgen_bcspline &operator = (const vcgen_bcspline &);
+
+    vertex_storage m_src_vertices;
+    bcspline        m_spline_x;
+    bcspline        m_spline_y;
+    double         m_interpolation_step;
+    unsigned       m_closed;
+    status_e       m_status;
+    unsigned       m_src_vertex;
+    double         m_cur_abscissa;
+    double         m_max_abscissa;
+};
+
 }
 
 
diff --git a/assdraw/agghelper.hpp b/assdraw/agghelper.hpp
index de0ce66fccccd7c019d6a67ae540063bdf551a38..4a2a9904fb836c0246a3101c16f461dd4e8caac3 100644
--- a/assdraw/agghelper.hpp
+++ b/assdraw/agghelper.hpp
@@ -2,19 +2,17 @@
 
 #include "agg_path_storage.h"
 
-class agghelper
-{
+class agghelper {
 public:
-	
-	static agg::path_storage RectanglePath(double left, double right, double top, double bottom)
-	{
-		agg::path_storage path;
-		path.move_to(left,top);
-		path.line_to(right,top);
-		path.line_to(right,bottom);
-		path.line_to(left,bottom);
-		path.line_to(left,top);
-		return path;
-	}
-	
+
+    static agg::path_storage RectanglePath(double left, double right, double top, double bottom) {
+        agg::path_storage path;
+        path.move_to(left, top);
+        path.line_to(right, top);
+        path.line_to(right, bottom);
+        path.line_to(left, bottom);
+        path.line_to(left, top);
+        return path;
+    }
+
 };
diff --git a/assdraw/assdraw.cpp b/assdraw/assdraw.cpp
index 1c9696083a8cbb7f995ae05c79885c0fe01f6eb6..b80966e5d86c275b7196c4ed659d9972fe69f184 100644
--- a/assdraw/assdraw.cpp
+++ b/assdraw/assdraw.cpp
@@ -93,7 +93,7 @@ BEGIN_EVENT_TABLE(ASSDrawFrame, wxFrame)
     EVT_MENU_RANGE(MODE_ARR, MODE_NUT_BILINEAR, ASSDrawFrame::OnChoose_Mode)
     EVT_MENU_RANGE(MENU_REPOS_TOPLEFT, MENU_REPOS_BOTRIGHT, ASSDrawFrame::OnChoose_Recenter)
     EVT_MENU_RANGE(MENU_REPOS_BGTOPLEFT, MENU_REPOS_BGBOTRIGHT, ASSDrawFrame::OnChoose_RecenterToBG)
-	EVT_CLOSE(ASSDrawFrame::OnClose)
+    EVT_CLOSE(ASSDrawFrame::OnClose)
 END_EVENT_TABLE()
 
 // ----------------------------------------------------------------------------
@@ -103,10 +103,10 @@ END_EVENT_TABLE()
 // 'Main program' equivalent: the program execution _T("starts") here
 bool ASSDrawApp::OnInit()
 {
-	SetAppName(TITLE);
+    SetAppName(TITLE);
     // create the main application window
-    ASSDrawFrame * assdrawframe = new ASSDrawFrame( this, TITLE, wxDefaultPosition, wxSize(640, 480) );
-	SetTopWindow(assdrawframe);
+    ASSDrawFrame *assdrawframe = new ASSDrawFrame( this, TITLE, wxDefaultPosition, wxSize(640, 480) );
+    SetTopWindow(assdrawframe);
     return TRUE;
 }
 
@@ -118,132 +118,131 @@ bool ASSDrawApp::OnInit()
 
 // constructor
 
-ASSDrawFrame::ASSDrawFrame( wxApp *app, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
-       : wxFrame(NULL, wxID_ANY, title, pos, size, style)
+ASSDrawFrame::ASSDrawFrame( wxApp *app, const wxString &title, const wxPoint &pos, const wxSize &size, long style)
+    : wxFrame(NULL, wxID_ANY, title, pos, size, style)
 {
-	m_app = app;
+    m_app = app;
     m_mgr.SetManagedWindow(this);
 #ifndef __UNIX__
     m_mgr.SetFlags(m_mgr.GetFlags() | wxAUI_MGR_ALLOW_ACTIVE_PANE);
 #else
-	m_mgr.SetFlags(wxAUI_MGR_ALLOW_FLOATING | wxAUI_MGR_ALLOW_ACTIVE_PANE | wxAUI_MGR_RECTANGLE_HINT);
+    m_mgr.SetFlags(wxAUI_MGR_ALLOW_FLOATING | wxAUI_MGR_ALLOW_ACTIVE_PANE | wxAUI_MGR_RECTANGLE_HINT);
 #endif
 
     // set the frame icon
     SetIcon(wxICON(appico));
 
-   	// Create status bar for the frame
+    // Create status bar for the frame
     CreateStatusBar(3);
     int statwidths[] = { 64, -1, 64 };
     GetStatusBar()->SetStatusWidths(3, statwidths);
     SetStatusBarPane(1);
 
-	InitializeDefaultSettings();
+    InitializeDefaultSettings();
 
-	// load config
-	configfile = wxFileName(wxStandardPaths::Get().GetUserDataDir(), _T("ASSDraw3.cfg")).GetFullPath();
+    // load config
+    configfile = wxFileName(wxStandardPaths::Get().GetUserDataDir(), _T("ASSDraw3.cfg")).GetFullPath();
 
-	bool firsttime = !::wxFileExists(configfile);
-	if (firsttime) {
-		wxFileName::Mkdir(wxStandardPaths::Get().GetUserDataDir(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
-		wxFileOutputStream(configfile).Close();
-	}
-	wxFileInputStream cfgf(configfile);
-	config = new wxFileConfig(cfgf);
+    bool firsttime = !::wxFileExists(configfile);
+    if (firsttime) {
+        wxFileName::Mkdir(wxStandardPaths::Get().GetUserDataDir(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
+        wxFileOutputStream(configfile).Close();
+    }
+    wxFileInputStream cfgf(configfile);
+    config = new wxFileConfig(cfgf);
 
-	// nullify transformdlg
-	transformdlg = NULL;
+    // nullify transformdlg
+    transformdlg = NULL;
 
-	Maximize(true);
-	Show(true); // to get the right client size, must call Show() first
+    Maximize(true);
+    Show(true); // to get the right client size, must call Show() first
 
-	// config
-	LoadSettings();
+    // config
+    LoadSettings();
 
-	// THE CANVAS
-    m_canvas = new ASSDrawCanvas( this , this );
+    // THE CANVAS
+    m_canvas = new ASSDrawCanvas( this, this );
 
-	// shapes library
-	shapelib = new ASSDrawShapeLibrary(this, this);
+    // shapes library
+    shapelib = new ASSDrawShapeLibrary(this, this);
 
-	// source text ctrl
-	srctxtctrl = new ASSDrawSrcTxtCtrl(this, this);
+    // source text ctrl
+    srctxtctrl = new ASSDrawSrcTxtCtrl(this, this);
 
-	// settings
-	settingsdlg = new ASSDrawSettingsDialog(this, this);
-	settingsdlg->Init();
+    // settings
+    settingsdlg = new ASSDrawSettingsDialog(this, this);
+    settingsdlg->Init();
 
-	SetMenus();
-	SetToolBars();
-	SetPanes();
+    SetMenus();
+    SetToolBars();
+    SetPanes();
 
-	// config
+    // config
 
-	config->SetPath(_T("info"));
-	wxString version;
-	config->Read(_T("version"), &version);
-	config->SetPath(_T(".."));
+    config->SetPath(_T("info"));
+    wxString version;
+    config->Read(_T("version"), &version);
+    config->SetPath(_T(".."));
 
-	default_perspective = m_mgr.SavePerspective(); // back up default perspective
-	config->SetPath(_T("perspective"));
-	wxString perspective;
-	if (config->Read(_T("perspective"), &perspective) && version == VERSION) m_mgr.LoadPerspective(perspective, false);
-	config->SetPath(_T(".."));
+    default_perspective = m_mgr.SavePerspective(); // back up default perspective
+    config->SetPath(_T("perspective"));
+    wxString perspective;
+    if (config->Read(_T("perspective"), &perspective) && version == VERSION) m_mgr.LoadPerspective(perspective, false);
+    config->SetPath(_T(".."));
 
-	config->SetPath(_T("library"));
-	int n = 0;
-	config->Read(_T("n"), &n);
-	for (int i = 0; i < n; i++)
-	{
-		wxString libcmds;
-		config->Read(wxString::Format(_T("%d"),i), &libcmds);
-		shapelib->AddShapePreview(libcmds);
-	}
-	config->SetPath(_T(".."));
+    config->SetPath(_T("library"));
+    int n = 0;
+    config->Read(_T("n"), &n);
+    for (int i = 0; i < n; i++) {
+        wxString libcmds;
+        config->Read(wxString::Format(_T("%d"), i), &libcmds);
+        shapelib->AddShapePreview(libcmds);
+    }
+    config->SetPath(_T(".."));
 
     m_mgr.Update();
-	m_canvas->SetFocus();
-	m_canvas->Show();
+    m_canvas->SetFocus();
+    m_canvas->Show();
 
-	wxSize clientsize = m_canvas->GetClientSize();
-	m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(clientsize.x / 2, clientsize.y / 2));
-	m_canvas->MoveCanvasOriginTo(clientsize.x / 2, clientsize.y / 2);
-	UpdateASSCommandStringToSrcTxtCtrl(m_canvas->GenerateASS());
+    wxSize clientsize = m_canvas->GetClientSize();
+    m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(clientsize.x / 2, clientsize.y / 2));
+    m_canvas->MoveCanvasOriginTo(clientsize.x / 2, clientsize.y / 2);
+    UpdateASSCommandStringToSrcTxtCtrl(m_canvas->GenerateASS());
 
-	UpdateFrameUI();
-	ApplySettings();
+    UpdateFrameUI();
+    ApplySettings();
 
-	if (firsttime)
-		_About();
-	else if (!behaviors.nosplashscreen)
-		_About(3);
+    if (firsttime)
+        _About();
+    else if (!behaviors.nosplashscreen)
+        _About(3);
 
-	helpcontroller.SetParentWindow(this);
-	helpcontroller.Initialize(wxFileName(::wxGetCwd(), _T("ASSDraw3.chm")).GetFullPath());
+    helpcontroller.SetParentWindow(this);
+    helpcontroller.Initialize(wxFileName(::wxGetCwd(), _T("ASSDraw3.chm")).GetFullPath());
 }
 
 void ASSDrawFrame::SetToolBars()
 {
-    drawtbar = new wxToolBar(this, wxID_ANY, __DPDS__ , wxTB_FLAT | wxTB_TEXT | wxTB_NODIVIDER | wxTB_HORIZONTAL);
-	drawtbar->AddTool(TB_CLEAR, _T("Clear"), wxBITMAP(new_), wxNullBitmap, wxITEM_NORMAL, _T(""), TIPS_CLEAR);
+    drawtbar = new wxToolBar(this, wxID_ANY, __DPDS__, wxTB_FLAT | wxTB_TEXT | wxTB_NODIVIDER | wxTB_HORIZONTAL);
+    drawtbar->AddTool(TB_CLEAR, _T("Clear"), wxBITMAP(new_), wxNullBitmap, wxITEM_NORMAL, _T(""), TIPS_CLEAR);
     //tbar->AddTool(TB_EDITSRC, _T("Source"), wxBITMAP(src_), wxNullBitmap, wxITEM_NORMAL, _T(""), TIPS_EDITSRC);
     drawtbar->AddCheckTool(TB_PREVIEW, _T("Preview"), wxBITMAP(preview_), wxNullBitmap, _T(""), TIPS_PREVIEW);
     //drawtbar->AddTool(TB_TRANSFORM, _T("Transform"), wxBITMAP(rot_), wxNullBitmap, wxITEM_NORMAL, _T(""), TIPS_TRANSFORM);
-	zoomslider = new wxSlider(drawtbar, TB_ZOOMSLIDER, 1000, 100, 5000, __DPDS__ );
-	//zoomslider->SetSize(280, zoomslider->GetSize().y);
-	zoomslider->Connect(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
-	zoomslider->Connect(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
-	zoomslider->Connect(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
-	zoomslider->Connect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
-	zoomslider->Connect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
-	zoomslider->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
-	drawtbar->AddControl(zoomslider);
+    zoomslider = new wxSlider(drawtbar, TB_ZOOMSLIDER, 1000, 100, 5000, __DPDS__ );
+    //zoomslider->SetSize(280, zoomslider->GetSize().y);
+    zoomslider->Connect(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
+    zoomslider->Connect(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
+    zoomslider->Connect(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
+    zoomslider->Connect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
+    zoomslider->Connect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
+    zoomslider->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(ASSDrawFrame::OnZoomSliderChanged), NULL, this);
+    drawtbar->AddControl(zoomslider);
     drawtbar->Realize();
 
     m_mgr.AddPane(drawtbar, wxAuiPaneInfo().Name(_T("drawtbar")).Caption(TBNAME_DRAW).
                   ToolbarPane().Top().Position(0).Dockable(true).LeftDockable(false).RightDockable(false));
 
-    modetbar = new wxToolBar(this, wxID_ANY, __DPDS__ , wxTB_FLAT | wxTB_TEXT | wxTB_NODIVIDER | wxTB_HORIZONTAL);
+    modetbar = new wxToolBar(this, wxID_ANY, __DPDS__, wxTB_FLAT | wxTB_TEXT | wxTB_NODIVIDER | wxTB_HORIZONTAL);
     modetbar->AddRadioTool(MODE_ARR, _T("Drag"), wxBITMAP(arr_), wxNullBitmap, _T(""), TIPS_ARR);
     modetbar->AddRadioTool(MODE_M, _T("Move"), wxBITMAP(m_), wxNullBitmap, _T(""), TIPS_M);
     //modetbar->AddRadioTool(MODE_N, _T("Move*"), wxBITMAP(n_), wxNullBitmap, _T(""), TIPS_N);
@@ -261,8 +260,8 @@ void ASSDrawFrame::SetToolBars()
     m_mgr.AddPane(modetbar, wxAuiPaneInfo().Name(_T("modetbar")).Caption(TBNAME_MODE).
                   ToolbarPane().Top().Position(1).Dockable(true).LeftDockable(false).RightDockable(false));
 
-    bgimgtbar = new wxToolBar(this, wxID_ANY, __DPDS__ , wxTB_FLAT | wxTB_TEXT | wxTB_NODIVIDER | wxTB_HORIZONTAL);
-	bgimgtbar->SetToolBitmapSize(wxSize(24,15));
+    bgimgtbar = new wxToolBar(this, wxID_ANY, __DPDS__, wxTB_FLAT | wxTB_TEXT | wxTB_NODIVIDER | wxTB_HORIZONTAL);
+    bgimgtbar->SetToolBitmapSize(wxSize(24, 15));
     bgimgtbar->AddCheckTool(DRAG_DWG, _T("Pan drawing"), wxBITMAP(pan_shp), wxNullBitmap, _T(""), TIPS_DWG);
     bgimgtbar->AddCheckTool(DRAG_BGIMG, _T("Pan background"), wxBITMAP(pan_bg), wxNullBitmap, _T(""), TIPS_BGIMG);
     //bgimgtbar->AddRadioTool(DRAG_BOTH, _T("Pan both"), wxBITMAP(pan_both), wxNullBitmap, _T(""), TIPS_BOTH);
@@ -275,467 +274,448 @@ void ASSDrawFrame::SetToolBars()
 
 void ASSDrawFrame::SetMenus()
 {
-	drawMenu = new wxMenu;
-	drawMenu->Append(MENU_CLEAR, _T("&Clear\tCtrl+N"), TIPS_CLEAR);
-	//drawMenu->Append(MENU_EDITSRC, _T("&Source"), TIPS_EDITSRC);
-	drawMenu->Append(MENU_PREVIEW, _T("&Preview\tCtrl+P"), TIPS_PREVIEW, wxITEM_CHECK);
-	drawMenu->Append(MENU_TRANSFORM, _T("&Transform"), TIPS_TRANSFORM);
-	drawMenu->Append(MENU_PASTE, _T("&Paste\tCtrl+V"), TIPS_PASTE);
-	drawMenu->AppendSeparator();
-	drawMenu->Append(MENU_UNDO, _T("&Undo\tCtrl+Z"), TIPS_UNDO);
-	drawMenu->Append(MENU_REDO, _T("&Redo\tCtrl+Y"), TIPS_REDO);
-	drawMenu->Enable(MENU_UNDO, false);
-	drawMenu->Enable(MENU_REDO, false);
-
-	modeMenu = new wxMenu;
-	modeMenu->Append(MODE_ARR, _T("D&rag\tF1"), TIPS_ARR, wxITEM_RADIO);
-	modeMenu->Append(MODE_M, _T("Draw &M\tF2"), TIPS_M, wxITEM_RADIO);
-	modeMenu->Append(MODE_L, _T("Draw &L\tF3"), TIPS_L, wxITEM_RADIO);
-	modeMenu->Append(MODE_B, _T("Draw &B\tF4"), TIPS_B, wxITEM_RADIO);
-	modeMenu->Append(MODE_DEL, _T("&Delete\tF5"), TIPS_DEL, wxITEM_RADIO);
-	modeMenu->Append(MODE_SCALEROTATE, _T("&Scale/Rotate\tF6"), TIPS_NUTB, wxITEM_RADIO);
-	modeMenu->Append(MODE_NUT_BILINEAR, _T("&Bilinear transformation\tF7"), TIPS_SCALEROTATE, wxITEM_RADIO);
-
-	bgimgMenu = new wxMenu;
-	bgimgMenu->Append(DRAG_DWG, _T("Pan/Zoom &Drawing\tShift+F1"), TIPS_DWG, wxITEM_CHECK);
-	bgimgMenu->Append(DRAG_BGIMG, _T("Pan/Zoom Back&ground\tShift+F2"), TIPS_BGIMG, wxITEM_CHECK);
-	bgimgMenu->AppendSeparator();
-	bgimgMenu->Append(MENU_BGIMG_ALPHA, _T("Set background image opacity"), _T(""));
-	wxMenu* reposbgMenu = new wxMenu;
-	reposbgMenu->Append( MENU_REPOS_BGTOPLEFT, _T("Top left\tCtrl+Shift+7") );
-	reposbgMenu->Append( MENU_REPOS_BGTOPRIGHT, _T("Top right\tCtrl+Shift+9") );
-	reposbgMenu->Append( MENU_REPOS_BGCENTER, _T("&Center\tCtrl+Shift+5") );
-	reposbgMenu->Append( MENU_REPOS_BGBOTLEFT, _T("Bottom left\tCtrl+Shift+1") );
-	reposbgMenu->Append( MENU_REPOS_BGBOTRIGHT, _T("Bottom right\tCtrl+Shift+3") );
-	bgimgMenu->Append(MENU_BGIMG_RECENTER, _T("Reposition [&0, 0]"), reposbgMenu);
-	bgimgMenu->Append(MENU_BGIMG_REMOVE, _T("Remove background\tShift+Del"), _T(""));
-
-	wxMenu* reposMenu = new wxMenu;
-	reposMenu->Append( MENU_REPOS_TOPLEFT, _T("Top left\tCtrl+7") );
-	reposMenu->Append( MENU_REPOS_TOPRIGHT, _T("Top right\tCtrl+9") );
-	reposMenu->Append( MENU_REPOS_CENTER, _T("&Center\tCtrl+5") );
-	reposMenu->Append( MENU_REPOS_BOTLEFT, _T("Bottom left\tCtrl+1") );
-	reposMenu->Append( MENU_REPOS_BOTRIGHT, _T("Bottom right\tCtrl+3") );
-
-	tbarMenu = new wxMenu;
-	tbarMenu->AppendCheckItem(MENU_TB_DRAW, TBNAME_DRAW);
-	tbarMenu->AppendCheckItem(MENU_TB_MODE, TBNAME_MODE);
-	tbarMenu->AppendCheckItem(MENU_TB_BGIMG, TBNAME_BGIMG);
-	tbarMenu->AppendSeparator();
-	tbarMenu->Append(MENU_TB_ALL, _T("Show all"));
-	tbarMenu->Append(MENU_TB_NONE, _T("Hide all"));
-	tbarMenu->Append(MENU_TB_DOCK, _T("Dock all"));
-	tbarMenu->Append(MENU_TB_UNDOCK, _T("Undock all"));
-
-	viewMenu = new wxMenu;
-	viewMenu->Append(MENU_LIBRARY, _T("&Library"), TIPS_LIBRARY, wxITEM_CHECK);
-	if (settingsdlg)
-		viewMenu->Append(MENU_SETTINGS, _T("&Settings"), _T(""), wxITEM_CHECK);
-	viewMenu->Append(MENU_TBAR, _T("&Toolbars"), tbarMenu);
-	viewMenu->Append(MENU_RECENTER, _T("Reposition [&0, 0]"), reposMenu);
-	viewMenu->AppendSeparator();
-	viewMenu->Append(MENU_RESETPERSPECTIVE, _T("&Reset workspace"));
-
-	wxMenu* helpMenu = new wxMenu;
-	helpMenu->Append(MENU_HELP, _T("&Manual"));
-	helpMenu->Append(wxID_ABOUT, _T("&About"));
-
-	wxMenuBar *menuBar = new wxMenuBar();
-	menuBar->Append(drawMenu, _T("&Canvas"));
-	menuBar->Append(modeMenu, _T("&Mode"));
-	menuBar->Append(bgimgMenu, _T("&Background"));
-	menuBar->Append(viewMenu, _T("&Workspace"));
-	menuBar->Append(helpMenu, _T("&Help"));
-
-
-	SetMenuBar(menuBar);
+    drawMenu = new wxMenu;
+    drawMenu->Append(MENU_CLEAR, _T("&Clear\tCtrl+N"), TIPS_CLEAR);
+    //drawMenu->Append(MENU_EDITSRC, _T("&Source"), TIPS_EDITSRC);
+    drawMenu->Append(MENU_PREVIEW, _T("&Preview\tCtrl+P"), TIPS_PREVIEW, wxITEM_CHECK);
+    drawMenu->Append(MENU_TRANSFORM, _T("&Transform"), TIPS_TRANSFORM);
+    drawMenu->Append(MENU_PASTE, _T("&Paste\tCtrl+V"), TIPS_PASTE);
+    drawMenu->AppendSeparator();
+    drawMenu->Append(MENU_UNDO, _T("&Undo\tCtrl+Z"), TIPS_UNDO);
+    drawMenu->Append(MENU_REDO, _T("&Redo\tCtrl+Y"), TIPS_REDO);
+    drawMenu->Enable(MENU_UNDO, false);
+    drawMenu->Enable(MENU_REDO, false);
+
+    modeMenu = new wxMenu;
+    modeMenu->Append(MODE_ARR, _T("D&rag\tF1"), TIPS_ARR, wxITEM_RADIO);
+    modeMenu->Append(MODE_M, _T("Draw &M\tF2"), TIPS_M, wxITEM_RADIO);
+    modeMenu->Append(MODE_L, _T("Draw &L\tF3"), TIPS_L, wxITEM_RADIO);
+    modeMenu->Append(MODE_B, _T("Draw &B\tF4"), TIPS_B, wxITEM_RADIO);
+    modeMenu->Append(MODE_DEL, _T("&Delete\tF5"), TIPS_DEL, wxITEM_RADIO);
+    modeMenu->Append(MODE_SCALEROTATE, _T("&Scale/Rotate\tF6"), TIPS_NUTB, wxITEM_RADIO);
+    modeMenu->Append(MODE_NUT_BILINEAR, _T("&Bilinear transformation\tF7"), TIPS_SCALEROTATE, wxITEM_RADIO);
+
+    bgimgMenu = new wxMenu;
+    bgimgMenu->Append(DRAG_DWG, _T("Pan/Zoom &Drawing\tShift+F1"), TIPS_DWG, wxITEM_CHECK);
+    bgimgMenu->Append(DRAG_BGIMG, _T("Pan/Zoom Back&ground\tShift+F2"), TIPS_BGIMG, wxITEM_CHECK);
+    bgimgMenu->AppendSeparator();
+    bgimgMenu->Append(MENU_BGIMG_ALPHA, _T("Set background image opacity"), _T(""));
+    wxMenu *reposbgMenu = new wxMenu;
+    reposbgMenu->Append( MENU_REPOS_BGTOPLEFT, _T("Top left\tCtrl+Shift+7") );
+    reposbgMenu->Append( MENU_REPOS_BGTOPRIGHT, _T("Top right\tCtrl+Shift+9") );
+    reposbgMenu->Append( MENU_REPOS_BGCENTER, _T("&Center\tCtrl+Shift+5") );
+    reposbgMenu->Append( MENU_REPOS_BGBOTLEFT, _T("Bottom left\tCtrl+Shift+1") );
+    reposbgMenu->Append( MENU_REPOS_BGBOTRIGHT, _T("Bottom right\tCtrl+Shift+3") );
+    bgimgMenu->Append(MENU_BGIMG_RECENTER, _T("Reposition [&0, 0]"), reposbgMenu);
+    bgimgMenu->Append(MENU_BGIMG_REMOVE, _T("Remove background\tShift+Del"), _T(""));
+
+    wxMenu *reposMenu = new wxMenu;
+    reposMenu->Append( MENU_REPOS_TOPLEFT, _T("Top left\tCtrl+7") );
+    reposMenu->Append( MENU_REPOS_TOPRIGHT, _T("Top right\tCtrl+9") );
+    reposMenu->Append( MENU_REPOS_CENTER, _T("&Center\tCtrl+5") );
+    reposMenu->Append( MENU_REPOS_BOTLEFT, _T("Bottom left\tCtrl+1") );
+    reposMenu->Append( MENU_REPOS_BOTRIGHT, _T("Bottom right\tCtrl+3") );
+
+    tbarMenu = new wxMenu;
+    tbarMenu->AppendCheckItem(MENU_TB_DRAW, TBNAME_DRAW);
+    tbarMenu->AppendCheckItem(MENU_TB_MODE, TBNAME_MODE);
+    tbarMenu->AppendCheckItem(MENU_TB_BGIMG, TBNAME_BGIMG);
+    tbarMenu->AppendSeparator();
+    tbarMenu->Append(MENU_TB_ALL, _T("Show all"));
+    tbarMenu->Append(MENU_TB_NONE, _T("Hide all"));
+    tbarMenu->Append(MENU_TB_DOCK, _T("Dock all"));
+    tbarMenu->Append(MENU_TB_UNDOCK, _T("Undock all"));
+
+    viewMenu = new wxMenu;
+    viewMenu->Append(MENU_LIBRARY, _T("&Library"), TIPS_LIBRARY, wxITEM_CHECK);
+    if (settingsdlg)
+        viewMenu->Append(MENU_SETTINGS, _T("&Settings"), _T(""), wxITEM_CHECK);
+    viewMenu->Append(MENU_TBAR, _T("&Toolbars"), tbarMenu);
+    viewMenu->Append(MENU_RECENTER, _T("Reposition [&0, 0]"), reposMenu);
+    viewMenu->AppendSeparator();
+    viewMenu->Append(MENU_RESETPERSPECTIVE, _T("&Reset workspace"));
+
+    wxMenu *helpMenu = new wxMenu;
+    helpMenu->Append(MENU_HELP, _T("&Manual"));
+    helpMenu->Append(wxID_ABOUT, _T("&About"));
+
+    wxMenuBar *menuBar = new wxMenuBar();
+    menuBar->Append(drawMenu, _T("&Canvas"));
+    menuBar->Append(modeMenu, _T("&Mode"));
+    menuBar->Append(bgimgMenu, _T("&Background"));
+    menuBar->Append(viewMenu, _T("&Workspace"));
+    menuBar->Append(helpMenu, _T("&Help"));
+
+
+    SetMenuBar(menuBar);
 }
 
 void ASSDrawFrame::SetPanes()
 {
-	m_mgr.AddPane(shapelib, wxAuiPaneInfo().Name(_T("library")).Caption(_T("Shapes Library")).
+    m_mgr.AddPane(shapelib, wxAuiPaneInfo().Name(_T("library")).Caption(_T("Shapes Library")).
                   Right().Layer(2).Position(0).CloseButton(true).BestSize(wxSize(120, 480)).MinSize(wxSize(100, 200)));
 
-	m_mgr.AddPane(m_canvas, wxAuiPaneInfo().Name(_T("canvas")).CenterPane());
+    m_mgr.AddPane(m_canvas, wxAuiPaneInfo().Name(_T("canvas")).CenterPane());
 
-	m_mgr.AddPane(srctxtctrl, wxAuiPaneInfo().Name(_T("commands")).Caption(_T("Drawing commands")).
+    m_mgr.AddPane(srctxtctrl, wxAuiPaneInfo().Name(_T("commands")).Caption(_T("Drawing commands")).
                   Bottom().Layer(1).CloseButton(false).BestSize(wxSize(320, 48)));
 
-	if (settingsdlg)
-		m_mgr.AddPane(settingsdlg, wxAuiPaneInfo().Name(_T("settings")).Caption(_T("Settings")).
-                  Right().Layer(3).Position(0).CloseButton(true).BestSize(wxSize(240, 480)).MinSize(wxSize(200, 200)).Show(false));
+    if (settingsdlg)
+        m_mgr.AddPane(settingsdlg, wxAuiPaneInfo().Name(_T("settings")).Caption(_T("Settings")).
+                      Right().Layer(3).Position(0).CloseButton(true).BestSize(wxSize(240, 480)).MinSize(wxSize(200, 200)).Show(false));
 }
 
 ASSDrawFrame::~ASSDrawFrame()
 {
-	config->SetPath(_T("info"));
-	config->Write(_T("assdraw3.exe"), wxStandardPaths::Get().GetExecutablePath());
-	config->Write(_T("version"), VERSION);
-	config->SetPath(_T(".."));
-
-	SaveSettings();
-
-	config->SetPath(_T("perspective"));
-	config->Write(_T("perspective"), m_mgr.SavePerspective());
-	config->SetPath(_T(".."));
-
-	config->DeleteGroup(_T("library"));
-	config->SetPath(_T("library"));
-	typedef std::vector< ASSDrawShapePreview *> PrevVec;
-	PrevVec shapes = shapelib->GetShapePreviews();
-	int n = shapes.size();
-	config->Write(_T("n"), n);
-	for (int i = 0; i < n; i++)
-		config->Write(wxString::Format(_T("%d"),i), shapes[i]->GenerateASS());
-	config->SetPath(_T(".."));
-
-	wxFileOutputStream cfgf(configfile);
-	config->Save(cfgf);
-	delete config;
-
-	if (settingsdlg) settingsdlg->Destroy(); // we need this since wxPropertyGrid must be Clear()ed before deleting
-
-	m_mgr.UnInit();
+    config->SetPath(_T("info"));
+    config->Write(_T("assdraw3.exe"), wxStandardPaths::Get().GetExecutablePath());
+    config->Write(_T("version"), VERSION);
+    config->SetPath(_T(".."));
+
+    SaveSettings();
+
+    config->SetPath(_T("perspective"));
+    config->Write(_T("perspective"), m_mgr.SavePerspective());
+    config->SetPath(_T(".."));
+
+    config->DeleteGroup(_T("library"));
+    config->SetPath(_T("library"));
+    typedef std::vector< ASSDrawShapePreview *> PrevVec;
+    PrevVec shapes = shapelib->GetShapePreviews();
+    int n = shapes.size();
+    config->Write(_T("n"), n);
+    for (int i = 0; i < n; i++)
+        config->Write(wxString::Format(_T("%d"), i), shapes[i]->GenerateASS());
+    config->SetPath(_T(".."));
+
+    wxFileOutputStream cfgf(configfile);
+    config->Save(cfgf);
+    delete config;
+
+    if (settingsdlg) settingsdlg->Destroy(); // we need this since wxPropertyGrid must be Clear()ed before deleting
+
+    m_mgr.UnInit();
 }
 
 void ASSDrawFrame::_Clear()
 {
-	wxMessageDialog msgb(this, _T("Clear the canvas and create a new drawing?"),
-                  _T("Confirmation"), wxOK | wxCANCEL | wxICON_QUESTION );
-	if (msgb.ShowModal() == wxID_OK)
-	{
-		m_canvas->RefreshUndocmds();
-		m_canvas->AddUndo(_T("Clear canvas"));
-		m_canvas->ResetEngine(true);
-	    wxSize siz = m_canvas->GetClientSize();
-		m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(siz.x / 2, siz.y / 2));
-		m_canvas->MoveCanvasOriginTo(siz.x / 2, siz.y / 2);
-		UpdateUndoRedoMenu();
-		m_canvas->RefreshDisplay();
-	}
+    wxMessageDialog msgb(this, _T("Clear the canvas and create a new drawing?"),
+                         _T("Confirmation"), wxOK | wxCANCEL | wxICON_QUESTION );
+    if (msgb.ShowModal() == wxID_OK) {
+        m_canvas->RefreshUndocmds();
+        m_canvas->AddUndo(_T("Clear canvas"));
+        m_canvas->ResetEngine(true);
+        wxSize siz = m_canvas->GetClientSize();
+        m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(siz.x / 2, siz.y / 2));
+        m_canvas->MoveCanvasOriginTo(siz.x / 2, siz.y / 2);
+        UpdateUndoRedoMenu();
+        m_canvas->RefreshDisplay();
+    }
 }
 
 void ASSDrawFrame::_Preview()
 {
-	m_canvas->SetPreviewMode( !m_canvas->IsPreviewMode() );
-	UpdateFrameUI();
-	m_canvas->RefreshDisplay();
+    m_canvas->SetPreviewMode( !m_canvas->IsPreviewMode() );
+    UpdateFrameUI();
+    m_canvas->RefreshDisplay();
 }
 
 void ASSDrawFrame::_ToggleLibrary()
 {
-	m_mgr.GetPane(shapelib).Show(!m_mgr.GetPane(shapelib).IsShown());
-	m_mgr.Update();
-	UpdateFrameUI();
+    m_mgr.GetPane(shapelib).Show(!m_mgr.GetPane(shapelib).IsShown());
+    m_mgr.Update();
+    UpdateFrameUI();
 }
 
 void ASSDrawFrame::_ToggleSettings()
 {
-	if (settingsdlg == NULL) return;
-	m_mgr.GetPane(settingsdlg).Show(!m_mgr.GetPane(settingsdlg).IsShown());
-	m_mgr.Update();
-	UpdateFrameUI();
+    if (settingsdlg == NULL) return;
+    m_mgr.GetPane(settingsdlg).Show(!m_mgr.GetPane(settingsdlg).IsShown());
+    m_mgr.Update();
+    UpdateFrameUI();
 }
 
 void ASSDrawFrame::_ResetPerspective()
 {
-	m_mgr.LoadPerspective(default_perspective, false);
-	UpdateFrameUI();
-	m_mgr.Update();
-	DRAGMODE bck = m_canvas->GetDragMode();
-	if (m_canvas->HasBackgroundImage()) m_canvas->SetDragMode(DRAGMODE(true, true));
-	wxSize clientsize = m_canvas->GetClientSize();
-	m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(clientsize.x / 2, clientsize.y / 2));
-	m_canvas->MoveCanvasOriginTo(clientsize.x / 2, clientsize.y / 2);
-	m_canvas->SetDragMode(bck);
-	UpdateFrameUI();
+    m_mgr.LoadPerspective(default_perspective, false);
+    UpdateFrameUI();
+    m_mgr.Update();
+    DRAGMODE bck = m_canvas->GetDragMode();
+    if (m_canvas->HasBackgroundImage()) m_canvas->SetDragMode(DRAGMODE(true, true));
+    wxSize clientsize = m_canvas->GetClientSize();
+    m_canvas->ChangeZoomLevelTo(DEFAULT_SCALE, wxPoint(clientsize.x / 2, clientsize.y / 2));
+    m_canvas->MoveCanvasOriginTo(clientsize.x / 2, clientsize.y / 2);
+    m_canvas->SetDragMode(bck);
+    UpdateFrameUI();
 }
 
 void ASSDrawFrame::_Transform()
 {
-	if (transformdlg == NULL)
-		transformdlg = new ASSDrawTransformDlg( this );
-
-	if (transformdlg->ShowModal() == wxID_OK)
-	{
-		m_canvas->Transform(
-			transformdlg->xformvals.f1,
-			transformdlg->xformvals.f2,
-			transformdlg->xformvals.f3,
-			transformdlg->xformvals.f4,
-			transformdlg->xformvals.f5,
-			transformdlg->xformvals.f6,
-			transformdlg->xformvals.f7,
-			transformdlg->xformvals.f8 );
-		m_canvas->AddUndo(_T("Transform"));
-		m_canvas->RefreshDisplay();
-		UpdateUndoRedoMenu();
-	}
+    if (transformdlg == NULL)
+        transformdlg = new ASSDrawTransformDlg( this );
+
+    if (transformdlg->ShowModal() == wxID_OK) {
+        m_canvas->Transform(
+            transformdlg->xformvals.f1,
+            transformdlg->xformvals.f2,
+            transformdlg->xformvals.f3,
+            transformdlg->xformvals.f4,
+            transformdlg->xformvals.f5,
+            transformdlg->xformvals.f6,
+            transformdlg->xformvals.f7,
+            transformdlg->xformvals.f8 );
+        m_canvas->AddUndo(_T("Transform"));
+        m_canvas->RefreshDisplay();
+        UpdateUndoRedoMenu();
+    }
 }
 
 void ASSDrawFrame::_Paste()
 {
-	if (wxTheClipboard->Open())
-	{
-		if (wxTheClipboard->IsSupported( wxDF_BITMAP ))
-		{
-			wxBitmapDataObject data;
-			wxTheClipboard->GetData( data );
-			m_canvas->SetBackgroundImage( data.GetBitmap().ConvertToImage() );
-			//m_canvas->AskUserForBackgroundAlpha();
-		}
-		else if (wxTheClipboard->IsSupported( wxDF_TEXT ))
-		{
-			wxTextDataObject data;
-			wxTheClipboard->GetData( data );
-			UpdateASSCommandStringToSrcTxtCtrl( data.GetText() );
-		}
-		wxTheClipboard->Close();
-	}
+    if (wxTheClipboard->Open()) {
+        if (wxTheClipboard->IsSupported( wxDF_BITMAP )) {
+            wxBitmapDataObject data;
+            wxTheClipboard->GetData( data );
+            m_canvas->SetBackgroundImage( data.GetBitmap().ConvertToImage() );
+            //m_canvas->AskUserForBackgroundAlpha();
+        }
+        else if (wxTheClipboard->IsSupported( wxDF_TEXT )) {
+            wxTextDataObject data;
+            wxTheClipboard->GetData( data );
+            UpdateASSCommandStringToSrcTxtCtrl( data.GetText() );
+        }
+        wxTheClipboard->Close();
+    }
 }
 
-void ASSDrawFrame::OnChoose_Recenter(wxCommandEvent& event)
+void ASSDrawFrame::OnChoose_Recenter(wxCommandEvent &event)
 {
-	int x = 0, y = 0;
-	wxSize f = m_canvas->GetClientSize();
-
-	switch (event.GetId())
-	{
-	case MENU_REPOS_TOPLEFT: x = 0, y = 0; break;
-	case MENU_REPOS_TOPRIGHT: x = f.x, y = 0; break;
-	case MENU_REPOS_CENTER: x = f.x / 2, y = f.y / 2; break;
-	case MENU_REPOS_BOTLEFT: x = 0, y = f.y; break;
-	case MENU_REPOS_BOTRIGHT: x = f.x, y = f.y; break;
-	}
-
-	m_canvas->MoveCanvasOriginTo(x, y);
-	m_canvas->RefreshDisplay();
+    int x = 0, y = 0;
+    wxSize f = m_canvas->GetClientSize();
+
+    switch (event.GetId()) {
+    case MENU_REPOS_TOPLEFT: x = 0, y = 0; break;
+    case MENU_REPOS_TOPRIGHT: x = f.x, y = 0; break;
+    case MENU_REPOS_CENTER: x = f.x / 2, y = f.y / 2; break;
+    case MENU_REPOS_BOTLEFT: x = 0, y = f.y; break;
+    case MENU_REPOS_BOTRIGHT: x = f.x, y = f.y; break;
+    }
+
+    m_canvas->MoveCanvasOriginTo(x, y);
+    m_canvas->RefreshDisplay();
 }
 
-void ASSDrawFrame::OnChoose_RecenterToBG(wxCommandEvent& event)
+void ASSDrawFrame::OnChoose_RecenterToBG(wxCommandEvent &event)
 {
-	unsigned w, h;
-	wxRealPoint disp;
-	double scale;
-	if (m_canvas->GetBackgroundInfo(w, h, disp, scale))
-	{
-		int x = 0, y = 0;
-		int lx = (int)disp.x, ty = (int)disp.y;
-		int rx = lx + (int)(w * scale);
-		int by = ty + (int)(h * scale);
-
-		switch (event.GetId())
-		{
-		case MENU_REPOS_BGTOPLEFT: x = lx, y = ty; break;
-		case MENU_REPOS_BGTOPRIGHT: x = rx, y = ty; break;
-		case MENU_REPOS_BGCENTER: x = (rx + lx) / 2, y = (by + ty) / 2; break;
-		case MENU_REPOS_BGBOTLEFT: x = lx, y = by; break;
-		case MENU_REPOS_BGBOTRIGHT: x = rx, y = by; break;
-		}
-
-		m_canvas->MoveCanvasDrawing(x - m_canvas->GetOriginX(), y - m_canvas->GetOriginY());
-		m_canvas->RefreshDisplay();
-	}
+    unsigned w, h;
+    wxRealPoint disp;
+    double scale;
+    if (m_canvas->GetBackgroundInfo(w, h, disp, scale)) {
+        int x = 0, y = 0;
+        int lx = (int)disp.x, ty = (int)disp.y;
+        int rx = lx + (int)(w * scale);
+        int by = ty + (int)(h * scale);
+
+        switch (event.GetId()) {
+        case MENU_REPOS_BGTOPLEFT: x = lx, y = ty; break;
+        case MENU_REPOS_BGTOPRIGHT: x = rx, y = ty; break;
+        case MENU_REPOS_BGCENTER: x = (rx + lx) / 2, y = (by + ty) / 2; break;
+        case MENU_REPOS_BGBOTLEFT: x = lx, y = by; break;
+        case MENU_REPOS_BGBOTRIGHT: x = rx, y = by; break;
+        }
+
+        m_canvas->MoveCanvasDrawing(x - m_canvas->GetOriginX(), y - m_canvas->GetOriginY());
+        m_canvas->RefreshDisplay();
+    }
 }
 
 void ASSDrawFrame::_Help()
 {
-	helpcontroller.DisplayContents();
+    helpcontroller.DisplayContents();
 }
 
 void ASSDrawFrame::_About(unsigned timeout)
 {
-	ASSDrawAboutDlg *aboutdlg = new ASSDrawAboutDlg( this, timeout );
-	aboutdlg->ShowModal();
-	aboutdlg->Destroy();
+    ASSDrawAboutDlg *aboutdlg = new ASSDrawAboutDlg( this, timeout );
+    aboutdlg->ShowModal();
+    aboutdlg->Destroy();
 }
 
-void ASSDrawFrame::OnChoose_Mode(wxCommandEvent& event)
+void ASSDrawFrame::OnChoose_Mode(wxCommandEvent &event)
 {
-	m_canvas->SetDrawMode( (MODE) event.GetId() );
-	UpdateFrameUI();
+    m_canvas->SetDrawMode( (MODE) event.GetId() );
+    UpdateFrameUI();
 }
 
-void ASSDrawFrame::OnChoose_DragMode(wxCommandEvent& event)
+void ASSDrawFrame::OnChoose_DragMode(wxCommandEvent &event)
 {
-	DRAGMODE dm = m_canvas->GetDragMode();
-	switch (event.GetId())
-	{
-		case DRAG_DWG: dm.drawing = !dm.drawing; break;
-		case DRAG_BGIMG: dm.bgimg = !dm.bgimg; break;
-	}
-	m_canvas->SetDragMode( dm );
-	UpdateFrameUI();
+    DRAGMODE dm = m_canvas->GetDragMode();
+    switch (event.GetId()) {
+    case DRAG_DWG: dm.drawing = !dm.drawing; break;
+    case DRAG_BGIMG: dm.bgimg = !dm.bgimg; break;
+    }
+    m_canvas->SetDragMode( dm );
+    UpdateFrameUI();
 }
 
 void ASSDrawFrame::OnZoomSliderChanged(wxScrollEvent &event)
 {
-	double zoom = (double) event.GetPosition() / 100.0;
-	m_canvas->ChangeZoomLevelTo(zoom, wxPoint((int) m_canvas->GetOriginX(), (int) m_canvas->GetOriginY()));
+    double zoom = (double) event.GetPosition() / 100.0;
+    m_canvas->ChangeZoomLevelTo(zoom, wxPoint((int) m_canvas->GetOriginX(), (int) m_canvas->GetOriginY()));
 }
 
-void ASSDrawFrame::OnToolRClick(wxCommandEvent& event)
+void ASSDrawFrame::OnToolRClick(wxCommandEvent &event)
 {
-	int id = event.GetId();
-	if (drawtbar->FindById(id) != NULL
-		|| modetbar->FindById(id) != NULL
-		|| bgimgtbar->FindById(id) != NULL)
-	{
-		PopupMenu(tbarMenu);
-	}
+    int id = event.GetId();
+    if (drawtbar->FindById(id) != NULL
+        || modetbar->FindById(id) != NULL
+        || bgimgtbar->FindById(id) != NULL) {
+        PopupMenu(tbarMenu);
+    }
 }
 
-void ASSDrawFrame::OnChoose_TBarRClickMenu(wxCommandEvent& event)
+void ASSDrawFrame::OnChoose_TBarRClickMenu(wxCommandEvent &event)
 {
-	int id = event.GetId();
-	wxToolBar* tbar[3] = { drawtbar, modetbar, bgimgtbar };
-	bool tb[3] = { false, false, false };
-	bool show[2] = { false, true };
-	bool dock[2] = { false, true };
-	switch (id)
-	{
-	case MENU_TB_ALL:
-		tb[0] = true, tb[1] = true, tb[2] = true;
-		show[0] = true, show[1] = true;
-		break;
-	case MENU_TB_NONE:
-		tb[0] = true, tb[1] = true, tb[2] = true;
-		show[0] = true, show[1] = false;
-		break;
-	case MENU_TB_DOCK:
-		tb[0] = true, tb[1] = true, tb[2] = true;
-		dock[0] = true, dock[1] = true;
-		break;
-	case MENU_TB_UNDOCK:
-		tb[0] = true, tb[1] = true, tb[2] = true;
-		dock[0] = true, dock[1] = false;
-		break;
-	case MENU_TB_DRAW:
-		tb[0] = true;
-		show[0] = true, show[1] = !m_mgr.GetPane(tbar[0]).IsShown();
-		break;
-	case MENU_TB_MODE:
-		tb[1] = true;
-		show[0] = true, show[1] = !m_mgr.GetPane(tbar[1]).IsShown();
-		break;
-	case MENU_TB_BGIMG:
-		tb[2] = true;
-		show[0] = true, show[1] = !m_mgr.GetPane(tbar[2]).IsShown();
-		break;
-	}
-	for (int i = 0; i < 3; i++)
-	{
-		if (tb[i])
-		{
-			if (show[0])
-				m_mgr.GetPane(tbar[i]).Show(show[1]);
-			if (dock[0])
-				if (dock[1])
-					m_mgr.GetPane(tbar[i]).Dock();
-				else
-					m_mgr.GetPane(tbar[i]).Float();
-		}
-	}
-	m_mgr.Update();
-	UpdateFrameUI();
+    int id = event.GetId();
+    wxToolBar *tbar[3] = { drawtbar, modetbar, bgimgtbar };
+    bool tb[3] = { false, false, false };
+    bool show[2] = { false, true };
+    bool dock[2] = { false, true };
+    switch (id) {
+    case MENU_TB_ALL:
+        tb[0] = true, tb[1] = true, tb[2] = true;
+        show[0] = true, show[1] = true;
+        break;
+    case MENU_TB_NONE:
+        tb[0] = true, tb[1] = true, tb[2] = true;
+        show[0] = true, show[1] = false;
+        break;
+    case MENU_TB_DOCK:
+        tb[0] = true, tb[1] = true, tb[2] = true;
+        dock[0] = true, dock[1] = true;
+        break;
+    case MENU_TB_UNDOCK:
+        tb[0] = true, tb[1] = true, tb[2] = true;
+        dock[0] = true, dock[1] = false;
+        break;
+    case MENU_TB_DRAW:
+        tb[0] = true;
+        show[0] = true, show[1] = !m_mgr.GetPane(tbar[0]).IsShown();
+        break;
+    case MENU_TB_MODE:
+        tb[1] = true;
+        show[0] = true, show[1] = !m_mgr.GetPane(tbar[1]).IsShown();
+        break;
+    case MENU_TB_BGIMG:
+        tb[2] = true;
+        show[0] = true, show[1] = !m_mgr.GetPane(tbar[2]).IsShown();
+        break;
+    }
+    for (int i = 0; i < 3; i++) {
+        if (tb[i]) {
+            if (show[0])
+                m_mgr.GetPane(tbar[i]).Show(show[1]);
+            if (dock[0])
+                if (dock[1])
+                    m_mgr.GetPane(tbar[i]).Dock();
+                else
+                    m_mgr.GetPane(tbar[i]).Float();
+        }
+    }
+    m_mgr.Update();
+    UpdateFrameUI();
 }
 
 void ASSDrawFrame::UpdateASSCommandStringFromSrcTxtCtrl(wxString cmds)
 {
-	m_canvas->ParseASS(cmds, true);
-	m_canvas->RefreshDisplay();
+    m_canvas->ParseASS(cmds, true);
+    m_canvas->RefreshDisplay();
 }
 
 void ASSDrawFrame::UpdateASSCommandStringToSrcTxtCtrl(wxString cmd)
 {
-	if (behaviors.capitalizecmds)
-		cmd.UpperCase();
-	else
-		cmd.LowerCase();
-	srctxtctrl->ChangeValue(cmd);
-	//srctxtctrl->AppendText(cmd);
+    if (behaviors.capitalizecmds)
+        cmd.UpperCase();
+    else
+        cmd.LowerCase();
+    srctxtctrl->ChangeValue(cmd);
+    //srctxtctrl->AppendText(cmd);
 }
 
 void ASSDrawFrame::UndoOrRedo(bool isundo)
 {
-	if (isundo)
-		m_canvas->Undo();
-	else
-		m_canvas->Redo();
-	UpdateUndoRedoMenu();
-	UpdateFrameUI();
+    if (isundo)
+        m_canvas->Undo();
+    else
+        m_canvas->Redo();
+    UpdateUndoRedoMenu();
+    UpdateFrameUI();
 }
 
 void ASSDrawFrame::UpdateUndoRedoMenu()
 {
-	wxString nextUndo = m_canvas->GetTopUndo();
-	if (nextUndo.IsSameAs(_T("")))
-	{
-		drawMenu->SetLabel(MENU_UNDO, _T("Undo\tCtrl+Z"));
-		drawMenu->Enable(MENU_UNDO, false);
-	}
-	else
-	{
-		drawMenu->SetLabel(MENU_UNDO, wxString::Format(_T("Undo: %s\tCtrl+Z"), nextUndo.c_str()));
-		drawMenu->Enable(MENU_UNDO, true);
-	}
-	wxString nextRedo = m_canvas->GetTopRedo();
-	if (nextRedo.IsSameAs(_T("")))
-	{
-		drawMenu->SetLabel(MENU_REDO, _T("Redo\tCtrl+Y"));
-		drawMenu->Enable(MENU_REDO, false);
-	}
-	else
-	{
-		drawMenu->SetLabel(MENU_REDO, wxString::Format(_T("Redo: %s\tCtrl+Y"), nextRedo.c_str()));
-		drawMenu->Enable(MENU_REDO, true);
-	}
+    wxString nextUndo = m_canvas->GetTopUndo();
+    if (nextUndo.IsSameAs(_T(""))) {
+        drawMenu->SetLabel(MENU_UNDO, _T("Undo\tCtrl+Z"));
+        drawMenu->Enable(MENU_UNDO, false);
+    }
+    else {
+        drawMenu->SetLabel(MENU_UNDO, wxString::Format(_T("Undo: %s\tCtrl+Z"), nextUndo.c_str()));
+        drawMenu->Enable(MENU_UNDO, true);
+    }
+    wxString nextRedo = m_canvas->GetTopRedo();
+    if (nextRedo.IsSameAs(_T(""))) {
+        drawMenu->SetLabel(MENU_REDO, _T("Redo\tCtrl+Y"));
+        drawMenu->Enable(MENU_REDO, false);
+    }
+    else {
+        drawMenu->SetLabel(MENU_REDO, wxString::Format(_T("Redo: %s\tCtrl+Y"), nextRedo.c_str()));
+        drawMenu->Enable(MENU_REDO, true);
+    }
 }
 
 void ASSDrawFrame::UpdateFrameUI(unsigned level)
 {
-	bool hasbg = m_canvas->HasBackgroundImage();
-	int zoom = (int) ((m_canvas->GetScale() * 100.0)+0.5);
-	switch (level)
-	{
-	case 0: // all
-		drawtbar->ToggleTool(TB_PREVIEW, m_canvas->IsPreviewMode());
-		modetbar->ToggleTool(m_canvas->GetDrawMode(), true);
-		drawMenu->Check(MENU_PREVIEW, m_canvas->IsPreviewMode());
-		modeMenu->Check(m_canvas->GetDrawMode(), true);
-	case 2: // bgimg & toolbars
-		bgimgtbar->ToggleTool(DRAG_DWG, m_canvas->GetDragMode().drawing);
-		bgimgtbar->ToggleTool(DRAG_BGIMG, m_canvas->GetDragMode().bgimg);
-		bgimgtbar->EnableTool(DRAG_BGIMG, hasbg);
-		m_mgr.Update();
-		viewMenu->Check(MENU_LIBRARY, m_mgr.GetPane(shapelib).IsShown());
-		if (settingsdlg)
-			viewMenu->Check(MENU_SETTINGS, m_mgr.GetPane(settingsdlg).IsShown());
-		bgimgMenu->Check(DRAG_DWG, m_canvas->GetDragMode().drawing);
-		bgimgMenu->Check(DRAG_BGIMG, m_canvas->GetDragMode().bgimg);
-		bgimgMenu->Enable(DRAG_BGIMG, hasbg);
-		bgimgMenu->Enable(MENU_BGIMG_ALPHA, hasbg);
-		bgimgMenu->Enable(MENU_BGIMG_RECENTER, hasbg);
-		bgimgMenu->Enable(MENU_BGIMG_REMOVE, hasbg);
-		tbarMenu->Check(MENU_TB_DRAW, m_mgr.GetPane(drawtbar).IsShown());
-		tbarMenu->Check(MENU_TB_MODE, m_mgr.GetPane(modetbar).IsShown());
-		tbarMenu->Check(MENU_TB_BGIMG, m_mgr.GetPane(bgimgtbar).IsShown());
-	case 3:	// zoom slider
-		zoomslider->SetValue(zoom);
-		SetStatusText( wxString::Format(_T("%d%%"), zoom), 2 );
-		zoomslider->Enable(m_canvas->GetDragMode().drawing && m_canvas->CanZoom());
-	}
+    bool hasbg = m_canvas->HasBackgroundImage();
+    int zoom = (int) ((m_canvas->GetScale() * 100.0) + 0.5);
+    switch (level) {
+    case 0: // all
+        drawtbar->ToggleTool(TB_PREVIEW, m_canvas->IsPreviewMode());
+        modetbar->ToggleTool(m_canvas->GetDrawMode(), true);
+        drawMenu->Check(MENU_PREVIEW, m_canvas->IsPreviewMode());
+        modeMenu->Check(m_canvas->GetDrawMode(), true);
+    case 2: // bgimg & toolbars
+        bgimgtbar->ToggleTool(DRAG_DWG, m_canvas->GetDragMode().drawing);
+        bgimgtbar->ToggleTool(DRAG_BGIMG, m_canvas->GetDragMode().bgimg);
+        bgimgtbar->EnableTool(DRAG_BGIMG, hasbg);
+        m_mgr.Update();
+        viewMenu->Check(MENU_LIBRARY, m_mgr.GetPane(shapelib).IsShown());
+        if (settingsdlg)
+            viewMenu->Check(MENU_SETTINGS, m_mgr.GetPane(settingsdlg).IsShown());
+        bgimgMenu->Check(DRAG_DWG, m_canvas->GetDragMode().drawing);
+        bgimgMenu->Check(DRAG_BGIMG, m_canvas->GetDragMode().bgimg);
+        bgimgMenu->Enable(DRAG_BGIMG, hasbg);
+        bgimgMenu->Enable(MENU_BGIMG_ALPHA, hasbg);
+        bgimgMenu->Enable(MENU_BGIMG_RECENTER, hasbg);
+        bgimgMenu->Enable(MENU_BGIMG_REMOVE, hasbg);
+        tbarMenu->Check(MENU_TB_DRAW, m_mgr.GetPane(drawtbar).IsShown());
+        tbarMenu->Check(MENU_TB_MODE, m_mgr.GetPane(modetbar).IsShown());
+        tbarMenu->Check(MENU_TB_BGIMG, m_mgr.GetPane(bgimgtbar).IsShown());
+    case 3:	// zoom slider
+        zoomslider->SetValue(zoom);
+        SetStatusText( wxString::Format(_T("%d%%"), zoom), 2 );
+        zoomslider->Enable(m_canvas->GetDragMode().drawing && m_canvas->CanZoom());
+    }
 }
 
 void ASSDrawFrame::OnClose(wxCloseEvent &event)
 {
-	if (event.CanVeto() && behaviors.confirmquit)
-	{
-		if (wxMessageDialog(this, _T("Do you want to close ASSDraw3 now?"), _T("Confirmation"), wxOK | wxCANCEL).ShowModal() == wxID_OK)
-			Destroy();
-		else
-			event.Veto();
-	}
-	else
-		Destroy();
+    if (event.CanVeto() && behaviors.confirmquit) {
+        if (wxMessageDialog(this, _T("Do you want to close ASSDraw3 now?"), _T("Confirmation"), wxOK | wxCANCEL).ShowModal() == wxID_OK)
+            Destroy();
+        else
+            event.Veto();
+    }
+    else
+        Destroy();
 }
diff --git a/assdraw/assdraw.hpp b/assdraw/assdraw.hpp
index 1ebd4dc4f2a97683ca99572a5b3b48b4d96e8fb1..678559a0148b673ed48315f332e03fd51035fc9b 100644
--- a/assdraw/assdraw.hpp
+++ b/assdraw/assdraw.hpp
@@ -58,86 +58,84 @@ class ASSDrawApp;
 class ASSDrawFrame;
 class ASSDrawCanvas;
 
-class ASSDrawApp : public wxApp 
-{ 
-public:      
+class ASSDrawApp : public wxApp {
+public:
     bool OnInit();
 };
 
-class ASSDrawFrame : public wxFrame
-{
+class ASSDrawFrame : public wxFrame {
 public:
     // constructor
-    ASSDrawFrame(wxApp *app, const wxString& title, const wxPoint& pos, const wxSize& size = wxDefaultSize,
-            long style = wxDEFAULT_FRAME_STYLE);
+    ASSDrawFrame(wxApp *app, const wxString &title, const wxPoint &pos, const wxSize &size = wxDefaultSize,
+                 long style = wxDEFAULT_FRAME_STYLE);
     virtual ~ASSDrawFrame();
 
     // event handlers (these functions should _not_ be virtual)
-	// OnSelect_* for single items, OnChoose_* for many-choose-one items
-	void OnSelect_Clear(wxCommandEvent& WXUNUSED(event)) { _Clear(); }
-	void OnSelect_Preview(wxCommandEvent& WXUNUSED(event)) { _Preview(); }
-	void OnSelect_Transform(wxCommandEvent& WXUNUSED(event)) { _Transform(); }
-	void OnSelect_Library(wxCommandEvent& WXUNUSED(event)) { _ToggleLibrary(); }
-	void OnSelect_Settings(wxCommandEvent& WXUNUSED(event)) { _ToggleSettings(); }
-	void OnSelect_ResetPerspective(wxCommandEvent& WXUNUSED(event)) { _ResetPerspective(); }
-	void OnSelect_Help(wxCommandEvent& WXUNUSED(event)) { _Help(); }
-	void OnSelect_About(wxCommandEvent& WXUNUSED(event)) { _About(); }
-	void OnSelect_Undo(wxCommandEvent& WXUNUSED(event)) { UndoOrRedo( true ); }
-	void OnSelect_Redo(wxCommandEvent& WXUNUSED(event)) { UndoOrRedo( false ); }
-	void OnSelect_Paste(wxCommandEvent& WXUNUSED(event)) { _Paste(); }
-	void OnSelect_RemoveBG(wxCommandEvent& WXUNUSED(event)) { m_canvas->RemoveBackgroundImage(); }
-	void OnSelect_AlphaBG(wxCommandEvent& WXUNUSED(event)) { m_canvas->AskUserForBackgroundAlpha(); }
-	void OnChoose_Recenter(wxCommandEvent& event);
-	void OnChoose_RecenterToBG(wxCommandEvent& event);
-	void OnChoose_Mode(wxCommandEvent& event);
-	void OnChoose_DragMode(wxCommandEvent& event);
-	void OnZoomSliderChanged(wxScrollEvent &event);
-	void OnToolRClick(wxCommandEvent& event);
-	void OnChoose_TBarRClickMenu(wxCommandEvent& event);
-	void OnSettingsChanged(wxCommandEvent& event);
-	void OnClose(wxCloseEvent &event);
-
-	void UpdateASSCommandStringToSrcTxtCtrl(wxString cmds);
-	void UpdateASSCommandStringFromSrcTxtCtrl(wxString cmds);
-
-	void UndoOrRedo(bool isundo);
-	void UpdateUndoRedoMenu();
+    // OnSelect_* for single items, OnChoose_* for many-choose-one items
+    void OnSelect_Clear(wxCommandEvent &WXUNUSED(event)) { _Clear(); }
+    void OnSelect_Preview(wxCommandEvent &WXUNUSED(event)) { _Preview(); }
+    void OnSelect_Transform(wxCommandEvent &WXUNUSED(event)) { _Transform(); }
+    void OnSelect_Library(wxCommandEvent &WXUNUSED(event)) { _ToggleLibrary(); }
+    void OnSelect_Settings(wxCommandEvent &WXUNUSED(event)) { _ToggleSettings(); }
+    void OnSelect_ResetPerspective(wxCommandEvent &WXUNUSED(event)) { _ResetPerspective(); }
+    void OnSelect_Help(wxCommandEvent &WXUNUSED(event)) { _Help(); }
+    void OnSelect_About(wxCommandEvent &WXUNUSED(event)) { _About(); }
+    void OnSelect_Undo(wxCommandEvent &WXUNUSED(event)) { UndoOrRedo( true ); }
+    void OnSelect_Redo(wxCommandEvent &WXUNUSED(event)) { UndoOrRedo( false ); }
+    void OnSelect_Paste(wxCommandEvent &WXUNUSED(event)) { _Paste(); }
+    void OnSelect_RemoveBG(wxCommandEvent &WXUNUSED(event)) { m_canvas->RemoveBackgroundImage(); }
+    void OnSelect_AlphaBG(wxCommandEvent &WXUNUSED(event)) { m_canvas->AskUserForBackgroundAlpha(); }
+    void OnChoose_Recenter(wxCommandEvent &event);
+    void OnChoose_RecenterToBG(wxCommandEvent &event);
+    void OnChoose_Mode(wxCommandEvent &event);
+    void OnChoose_DragMode(wxCommandEvent &event);
+    void OnZoomSliderChanged(wxScrollEvent &event);
+    void OnToolRClick(wxCommandEvent &event);
+    void OnChoose_TBarRClickMenu(wxCommandEvent &event);
+    void OnSettingsChanged(wxCommandEvent &event);
+    void OnClose(wxCloseEvent &event);
+
+    void UpdateASSCommandStringToSrcTxtCtrl(wxString cmds);
+    void UpdateASSCommandStringFromSrcTxtCtrl(wxString cmds);
+
+    void UndoOrRedo(bool isundo);
+    void UpdateUndoRedoMenu();
 
     void _Clear();
     void _Preview();
     void _Transform();
-	void _ToggleLibrary();
-	void _ToggleSettings();
+    void _ToggleLibrary();
+    void _ToggleSettings();
     void _Help();
     void _About(unsigned timeout = 0);
     void _Paste();
     void _ResetPerspective();
 
-	void UpdateFrameUI(unsigned level = 0);
+    void UpdateFrameUI(unsigned level = 0);
 
     // the canvas
     wxApp *m_app;
-    ASSDrawCanvas* m_canvas;
-	wxAuiManager m_mgr;
-	wxString default_perspective;
-	ASSDrawSrcTxtCtrl* srctxtctrl;
-
-	// config
-	wxString configfile;
-	wxFileConfig *config;
-	
+    ASSDrawCanvas *m_canvas;
+    wxAuiManager m_mgr;
+    wxString default_perspective;
+    ASSDrawSrcTxtCtrl *srctxtctrl;
+
+    // config
+    wxString configfile;
+    wxFileConfig *config;
+
     // toolbars
     wxToolBar *drawtbar, *modetbar, *bgimgtbar;
-	
-	// zoom slider
-	wxSlider* zoomslider;
-	
-	//library
-	ASSDrawShapeLibrary *shapelib;
-	typedef std::vector< ASSDrawEngine* > DrawEngineVec;
-	DrawEngineVec libshapes;
-	
-	// menus
+
+    // zoom slider
+    wxSlider *zoomslider;
+
+    //library
+    ASSDrawShapeLibrary *shapelib;
+    typedef std::vector< ASSDrawEngine * > DrawEngineVec;
+    DrawEngineVec libshapes;
+
+    // menus
 #if wxUSE_MENUS
     wxMenu *drawMenu;
     wxMenu *modeMenu;
@@ -146,64 +144,60 @@ public:
     wxMenu *tbarMenu;
 #endif
 
-	// dialogs
-	ASSDrawTransformDlg* transformdlg;	
-	ASSDrawSettingsDialog* settingsdlg;
-	
-	// colors
-	struct
-	{
-		wxColour canvas_bg;
-		wxColour canvas_shape_normal;
-		wxColour canvas_shape_preview;
-		wxColour canvas_shape_outline;
-		wxColour canvas_shape_guideline;
-		wxColour canvas_shape_mainpoint;
-		wxColour canvas_shape_controlpoint;
-		wxColour canvas_shape_selectpoint;
-		wxColour library_shape;
-		wxColour library_libarea;
-		wxColour origin, ruler_h, ruler_v;
-	} colors;
-
-	struct
-	{
-		long canvas_shape_normal;
-		long canvas_shape_preview;
-		long canvas_shape_outline;
-		long canvas_shape_guideline;
-		long canvas_shape_mainpoint;
-		long canvas_shape_controlpoint;
-		long canvas_shape_selectpoint;
-	} alphas;
-
-	struct
-	{
-		long origincross;
-	} sizes;
-	
-	struct
-	{
-		bool capitalizecmds;
-		bool autoaskimgopac;
-		bool parse_spc;
-		bool nosplashscreen;
-		bool confirmquit;
-	} behaviors;
-	
-	void LoadSettings();
-	void SaveSettings();
-	void InitializeDefaultSettings();
-	void ApplySettings();
-	static void wxColourToAggRGBA(wxColour &colour, agg::rgba &rgba);
-	static void wxColourSetAlpha(wxColour &colour, long alpha);
+    // dialogs
+    ASSDrawTransformDlg *transformdlg;
+    ASSDrawSettingsDialog *settingsdlg;
+
+    // colors
+    struct {
+        wxColour canvas_bg;
+        wxColour canvas_shape_normal;
+        wxColour canvas_shape_preview;
+        wxColour canvas_shape_outline;
+        wxColour canvas_shape_guideline;
+        wxColour canvas_shape_mainpoint;
+        wxColour canvas_shape_controlpoint;
+        wxColour canvas_shape_selectpoint;
+        wxColour library_shape;
+        wxColour library_libarea;
+        wxColour origin, ruler_h, ruler_v;
+    } colors;
+
+    struct {
+        long canvas_shape_normal;
+        long canvas_shape_preview;
+        long canvas_shape_outline;
+        long canvas_shape_guideline;
+        long canvas_shape_mainpoint;
+        long canvas_shape_controlpoint;
+        long canvas_shape_selectpoint;
+    } alphas;
+
+    struct {
+        long origincross;
+    } sizes;
+
+    struct {
+        bool capitalizecmds;
+        bool autoaskimgopac;
+        bool parse_spc;
+        bool nosplashscreen;
+        bool confirmquit;
+    } behaviors;
+
+    void LoadSettings();
+    void SaveSettings();
+    void InitializeDefaultSettings();
+    void ApplySettings();
+    static void wxColourToAggRGBA(wxColour &colour, agg::rgba &rgba);
+    static void wxColourSetAlpha(wxColour &colour, long alpha);
 
 protected:
-	virtual void SetToolBars();
-	virtual void SetMenus();
-	virtual void SetPanes();
-	DECLARE_EVENT_TABLE()
-	
-	wxHelpController helpcontroller;
+    virtual void SetToolBars();
+    virtual void SetMenus();
+    virtual void SetPanes();
+    DECLARE_EVENT_TABLE()
+
+    wxHelpController helpcontroller;
 
 };
diff --git a/assdraw/assdraw_settings.cpp b/assdraw/assdraw_settings.cpp
index d774f55c1e31da3d6123bb1c4c1ad270786ece52..948ebcc2bb294a207b2bb60df7dce4d20d56cbda 100644
--- a/assdraw/assdraw_settings.cpp
+++ b/assdraw/assdraw_settings.cpp
@@ -30,161 +30,161 @@
 
 void ASSDrawFrame::InitializeDefaultSettings()
 {
-	colors.canvas_bg = wxColour(0xFF, 0xFF, 0xFF);
-	colors.canvas_shape_normal = wxColour(0x0, 0x0, 0xFF, 0x99);
-	colors.canvas_shape_preview = wxColour(0x0, 0x0, 0xFF);
-	colors.canvas_shape_outline = wxColour(0x0, 0x0, 0x0);
-	colors.canvas_shape_guideline = wxColour(0x66, 0x66, 0x66);
-	colors.canvas_shape_mainpoint = wxColour(0xFF, 0x0, 0x0, 0xCC);
-	colors.canvas_shape_controlpoint = wxColour(0x0, 0xFF, 0x0, 0xCC);
-	colors.canvas_shape_selectpoint = wxColour(0x0, 0x0, 0xCC);
-	colors.library_shape = wxColour(0x0, 0x66, 0x99);
-	colors.library_libarea = wxColour(0xFF, 0xFF, 0x99);
-	colors.origin = wxColour(0xFF, 0x0, 0x0);
-	colors.ruler_h = wxColour(0x0, 0x0, 0x66);
-	colors.ruler_v = wxColour(0x66, 0x0, 0x0);
-
-	alphas.canvas_shape_normal = 128;
-	alphas.canvas_shape_preview = 255;
-	alphas.canvas_shape_outline = 255;
-	alphas.canvas_shape_guideline = 255;
-	alphas.canvas_shape_mainpoint = 128;
-	alphas.canvas_shape_controlpoint = 128;
-	alphas.canvas_shape_selectpoint = 255;
-
-	sizes.origincross = 2;
-
-	behaviors.capitalizecmds = false;
-	behaviors.autoaskimgopac = true;
-	behaviors.parse_spc = false;
-	behaviors.nosplashscreen = false;
-	behaviors.confirmquit = true;
+    colors.canvas_bg = wxColour(0xFF, 0xFF, 0xFF);
+    colors.canvas_shape_normal = wxColour(0x0, 0x0, 0xFF, 0x99);
+    colors.canvas_shape_preview = wxColour(0x0, 0x0, 0xFF);
+    colors.canvas_shape_outline = wxColour(0x0, 0x0, 0x0);
+    colors.canvas_shape_guideline = wxColour(0x66, 0x66, 0x66);
+    colors.canvas_shape_mainpoint = wxColour(0xFF, 0x0, 0x0, 0xCC);
+    colors.canvas_shape_controlpoint = wxColour(0x0, 0xFF, 0x0, 0xCC);
+    colors.canvas_shape_selectpoint = wxColour(0x0, 0x0, 0xCC);
+    colors.library_shape = wxColour(0x0, 0x66, 0x99);
+    colors.library_libarea = wxColour(0xFF, 0xFF, 0x99);
+    colors.origin = wxColour(0xFF, 0x0, 0x0);
+    colors.ruler_h = wxColour(0x0, 0x0, 0x66);
+    colors.ruler_v = wxColour(0x66, 0x0, 0x0);
+
+    alphas.canvas_shape_normal = 128;
+    alphas.canvas_shape_preview = 255;
+    alphas.canvas_shape_outline = 255;
+    alphas.canvas_shape_guideline = 255;
+    alphas.canvas_shape_mainpoint = 128;
+    alphas.canvas_shape_controlpoint = 128;
+    alphas.canvas_shape_selectpoint = 255;
+
+    sizes.origincross = 2;
+
+    behaviors.capitalizecmds = false;
+    behaviors.autoaskimgopac = true;
+    behaviors.parse_spc = false;
+    behaviors.nosplashscreen = false;
+    behaviors.confirmquit = true;
 }
 
 void ASSDrawFrame::ApplySettings()
 {
-	wxColourSetAlpha(colors.canvas_shape_normal, alphas.canvas_shape_normal);
-	wxColourSetAlpha(colors.canvas_shape_preview, alphas.canvas_shape_preview);
-	wxColourSetAlpha(colors.canvas_shape_outline, alphas.canvas_shape_outline);
-	wxColourSetAlpha(colors.canvas_shape_guideline, alphas.canvas_shape_guideline);
-	wxColourSetAlpha(colors.canvas_shape_mainpoint, alphas.canvas_shape_mainpoint);
-	wxColourSetAlpha(colors.canvas_shape_controlpoint, alphas.canvas_shape_controlpoint);
-	wxColourSetAlpha(colors.canvas_shape_selectpoint, alphas.canvas_shape_selectpoint);
-
-	wxColourToAggRGBA(colors.canvas_shape_normal, m_canvas->rgba_shape_normal);
-	wxColourToAggRGBA(colors.canvas_shape_preview, m_canvas->rgba_shape);
-	wxColourToAggRGBA(colors.canvas_shape_outline, m_canvas->rgba_outline);
-	wxColourToAggRGBA(colors.canvas_shape_guideline, m_canvas->rgba_guideline);
-	wxColourToAggRGBA(colors.canvas_shape_mainpoint, m_canvas->rgba_mainpoint);
-	wxColourToAggRGBA(colors.canvas_shape_controlpoint, m_canvas->rgba_controlpoint);
-	wxColourToAggRGBA(colors.canvas_shape_selectpoint, m_canvas->rgba_selectpoint);
-	wxColourToAggRGBA(colors.origin, m_canvas->rgba_origin);
-	wxColourToAggRGBA(colors.ruler_h, m_canvas->rgba_ruler_h);
-	wxColourToAggRGBA(colors.ruler_v, m_canvas->rgba_ruler_v);
-
-	m_canvas->color_bg.r = colors.canvas_bg.Red();
-	m_canvas->color_bg.g = colors.canvas_bg.Green();
-	m_canvas->color_bg.b = colors.canvas_bg.Blue();
-	m_canvas->color_bg.a = colors.canvas_bg.Alpha();
-	m_canvas->PrepareBackgroundBitmap(-1.0);
-	m_canvas->Refresh();
-
-	shapelib->libarea->SetBackgroundColour(colors.library_libarea);
-	typedef std::vector< ASSDrawShapePreview *> PrevVec;
-	PrevVec shapes = shapelib->GetShapePreviews();
-	int n = shapes.size();
-	for (int i = 0; i < n; i++)
-		wxColourToAggRGBA(colors.library_shape, shapes[i]->rgba_shape);
-	shapelib->libarea->Refresh();
-
-	m_canvas->SetDrawCmdSet(behaviors.parse_spc? _T("m n l b s p c _"):_T("m n l b _"));
-
-	UpdateASSCommandStringToSrcTxtCtrl(m_canvas->GenerateASS());
+    wxColourSetAlpha(colors.canvas_shape_normal, alphas.canvas_shape_normal);
+    wxColourSetAlpha(colors.canvas_shape_preview, alphas.canvas_shape_preview);
+    wxColourSetAlpha(colors.canvas_shape_outline, alphas.canvas_shape_outline);
+    wxColourSetAlpha(colors.canvas_shape_guideline, alphas.canvas_shape_guideline);
+    wxColourSetAlpha(colors.canvas_shape_mainpoint, alphas.canvas_shape_mainpoint);
+    wxColourSetAlpha(colors.canvas_shape_controlpoint, alphas.canvas_shape_controlpoint);
+    wxColourSetAlpha(colors.canvas_shape_selectpoint, alphas.canvas_shape_selectpoint);
+
+    wxColourToAggRGBA(colors.canvas_shape_normal, m_canvas->rgba_shape_normal);
+    wxColourToAggRGBA(colors.canvas_shape_preview, m_canvas->rgba_shape);
+    wxColourToAggRGBA(colors.canvas_shape_outline, m_canvas->rgba_outline);
+    wxColourToAggRGBA(colors.canvas_shape_guideline, m_canvas->rgba_guideline);
+    wxColourToAggRGBA(colors.canvas_shape_mainpoint, m_canvas->rgba_mainpoint);
+    wxColourToAggRGBA(colors.canvas_shape_controlpoint, m_canvas->rgba_controlpoint);
+    wxColourToAggRGBA(colors.canvas_shape_selectpoint, m_canvas->rgba_selectpoint);
+    wxColourToAggRGBA(colors.origin, m_canvas->rgba_origin);
+    wxColourToAggRGBA(colors.ruler_h, m_canvas->rgba_ruler_h);
+    wxColourToAggRGBA(colors.ruler_v, m_canvas->rgba_ruler_v);
+
+    m_canvas->color_bg.r = colors.canvas_bg.Red();
+    m_canvas->color_bg.g = colors.canvas_bg.Green();
+    m_canvas->color_bg.b = colors.canvas_bg.Blue();
+    m_canvas->color_bg.a = colors.canvas_bg.Alpha();
+    m_canvas->PrepareBackgroundBitmap(-1.0);
+    m_canvas->Refresh();
+
+    shapelib->libarea->SetBackgroundColour(colors.library_libarea);
+    typedef std::vector< ASSDrawShapePreview *> PrevVec;
+    PrevVec shapes = shapelib->GetShapePreviews();
+    int n = shapes.size();
+    for (int i = 0; i < n; i++)
+        wxColourToAggRGBA(colors.library_shape, shapes[i]->rgba_shape);
+    shapelib->libarea->Refresh();
+
+    m_canvas->SetDrawCmdSet(behaviors.parse_spc ? _T("m n l b s p c _") : _T("m n l b _"));
+
+    UpdateASSCommandStringToSrcTxtCtrl(m_canvas->GenerateASS());
 }
 
 void ASSDrawFrame::wxColourToAggRGBA(wxColour &colour, agg::rgba &rgba)
 {
-	rgba.r = (double) colour.Red() / 255.0;
-	rgba.g = (double) colour.Green() / 255.0;
-	rgba.b = (double) colour.Blue() / 255.0;
-	rgba.a = (double) colour.Alpha() / 255.0;
+    rgba.r = (double) colour.Red() / 255.0;
+    rgba.g = (double) colour.Green() / 255.0;
+    rgba.b = (double) colour.Blue() / 255.0;
+    rgba.a = (double) colour.Alpha() / 255.0;
 }
 
 void ASSDrawFrame::wxColourSetAlpha(wxColour &colour, long alpha)
 {
-	colour.Set(colour.Red(), colour.Green(), colour.Blue(), alpha);
+    colour.Set(colour.Red(), colour.Green(), colour.Blue(), alpha);
 }
 
-void ASSDrawFrame::OnSettingsChanged(wxCommandEvent& event)
+void ASSDrawFrame::OnSettingsChanged(wxCommandEvent &event)
 {
-	ApplySettings();
+    ApplySettings();
 }
 
 void ASSDrawFrame::LoadSettings()
 {
-	#define CFGREADCOLOR(color) if (config->Read(wxString(#color,wxConvUTF8), &tmpstr)) color.Set(tmpstr);
-	#define CFGREAD(var) config->Read(wxString(#var,wxConvUTF8), &var);
-	config->SetPath(_T("settings"));
-	wxString tmpstr;
-	CFGREADCOLOR(colors.canvas_bg)
-	CFGREADCOLOR(colors.canvas_shape_normal)
-	CFGREADCOLOR(colors.canvas_shape_preview)
-	CFGREADCOLOR(colors.canvas_shape_controlpoint)
-	CFGREADCOLOR(colors.canvas_shape_guideline)
-	CFGREADCOLOR(colors.canvas_shape_mainpoint)
-	CFGREADCOLOR(colors.canvas_shape_outline)
-	CFGREADCOLOR(colors.canvas_shape_selectpoint)
-	CFGREADCOLOR(colors.library_libarea)
-	CFGREADCOLOR(colors.library_shape)
-	CFGREADCOLOR(colors.origin)
-	CFGREADCOLOR(colors.ruler_h)
-	CFGREADCOLOR(colors.ruler_v)
-	CFGREAD(alphas.canvas_shape_normal)
-	CFGREAD(alphas.canvas_shape_preview)
-	CFGREAD(alphas.canvas_shape_controlpoint)
-	CFGREAD(alphas.canvas_shape_guideline)
-	CFGREAD(alphas.canvas_shape_mainpoint)
-	CFGREAD(alphas.canvas_shape_outline)
-	CFGREAD(alphas.canvas_shape_selectpoint)
-	CFGREAD(sizes.origincross)
-	CFGREAD(behaviors.autoaskimgopac)
-	CFGREAD(behaviors.capitalizecmds)
-	CFGREAD(behaviors.parse_spc)
-	CFGREAD(behaviors.nosplashscreen)
-	CFGREAD(behaviors.confirmquit)
-	config->SetPath(_T(".."));
+#define CFGREADCOLOR(color) if (config->Read(wxString(#color,wxConvUTF8), &tmpstr)) color.Set(tmpstr);
+#define CFGREAD(var) config->Read(wxString(#var,wxConvUTF8), &var);
+    config->SetPath(_T("settings"));
+    wxString tmpstr;
+    CFGREADCOLOR(colors.canvas_bg)
+    CFGREADCOLOR(colors.canvas_shape_normal)
+    CFGREADCOLOR(colors.canvas_shape_preview)
+    CFGREADCOLOR(colors.canvas_shape_controlpoint)
+    CFGREADCOLOR(colors.canvas_shape_guideline)
+    CFGREADCOLOR(colors.canvas_shape_mainpoint)
+    CFGREADCOLOR(colors.canvas_shape_outline)
+    CFGREADCOLOR(colors.canvas_shape_selectpoint)
+    CFGREADCOLOR(colors.library_libarea)
+    CFGREADCOLOR(colors.library_shape)
+    CFGREADCOLOR(colors.origin)
+    CFGREADCOLOR(colors.ruler_h)
+    CFGREADCOLOR(colors.ruler_v)
+    CFGREAD(alphas.canvas_shape_normal)
+    CFGREAD(alphas.canvas_shape_preview)
+    CFGREAD(alphas.canvas_shape_controlpoint)
+    CFGREAD(alphas.canvas_shape_guideline)
+    CFGREAD(alphas.canvas_shape_mainpoint)
+    CFGREAD(alphas.canvas_shape_outline)
+    CFGREAD(alphas.canvas_shape_selectpoint)
+    CFGREAD(sizes.origincross)
+    CFGREAD(behaviors.autoaskimgopac)
+    CFGREAD(behaviors.capitalizecmds)
+    CFGREAD(behaviors.parse_spc)
+    CFGREAD(behaviors.nosplashscreen)
+    CFGREAD(behaviors.confirmquit)
+    config->SetPath(_T(".."));
 }
 
 void ASSDrawFrame::SaveSettings()
 {
-	#define CFGWRITE(var) config->Write(wxString(#var,wxConvUTF8), var);
-	#define CFGWRITECOLOR(color) config->Write(wxString(#color,wxConvUTF8), color.GetAsString(wxC2S_CSS_SYNTAX));
-	config->SetPath(_T("settings"));
-	CFGWRITECOLOR(colors.canvas_bg)
-	CFGWRITECOLOR(colors.canvas_shape_normal)
-	CFGWRITECOLOR(colors.canvas_shape_preview)
-	CFGWRITECOLOR(colors.canvas_shape_controlpoint)
-	CFGWRITECOLOR(colors.canvas_shape_guideline)
-	CFGWRITECOLOR(colors.canvas_shape_mainpoint)
-	CFGWRITECOLOR(colors.canvas_shape_outline)
-	CFGWRITECOLOR(colors.canvas_shape_selectpoint)
-	CFGWRITECOLOR(colors.library_libarea)
-	CFGWRITECOLOR(colors.library_shape)
-	CFGWRITECOLOR(colors.origin)
-	CFGWRITECOLOR(colors.ruler_h)
-	CFGWRITECOLOR(colors.ruler_v)
-	CFGWRITE(alphas.canvas_shape_normal)
-	CFGWRITE(alphas.canvas_shape_preview)
-	CFGWRITE(alphas.canvas_shape_controlpoint)
-	CFGWRITE(alphas.canvas_shape_guideline)
-	CFGWRITE(alphas.canvas_shape_mainpoint)
-	CFGWRITE(alphas.canvas_shape_outline)
-	CFGWRITE(alphas.canvas_shape_selectpoint)
-	CFGWRITE(sizes.origincross)
-	CFGWRITE(behaviors.autoaskimgopac)
-	CFGWRITE(behaviors.capitalizecmds)
-	CFGWRITE(behaviors.parse_spc)
-	CFGWRITE(behaviors.nosplashscreen)
-	CFGWRITE(behaviors.confirmquit)
-	config->SetPath(_T(".."));
+#define CFGWRITE(var) config->Write(wxString(#var,wxConvUTF8), var);
+#define CFGWRITECOLOR(color) config->Write(wxString(#color,wxConvUTF8), color.GetAsString(wxC2S_CSS_SYNTAX));
+    config->SetPath(_T("settings"));
+    CFGWRITECOLOR(colors.canvas_bg)
+    CFGWRITECOLOR(colors.canvas_shape_normal)
+    CFGWRITECOLOR(colors.canvas_shape_preview)
+    CFGWRITECOLOR(colors.canvas_shape_controlpoint)
+    CFGWRITECOLOR(colors.canvas_shape_guideline)
+    CFGWRITECOLOR(colors.canvas_shape_mainpoint)
+    CFGWRITECOLOR(colors.canvas_shape_outline)
+    CFGWRITECOLOR(colors.canvas_shape_selectpoint)
+    CFGWRITECOLOR(colors.library_libarea)
+    CFGWRITECOLOR(colors.library_shape)
+    CFGWRITECOLOR(colors.origin)
+    CFGWRITECOLOR(colors.ruler_h)
+    CFGWRITECOLOR(colors.ruler_v)
+    CFGWRITE(alphas.canvas_shape_normal)
+    CFGWRITE(alphas.canvas_shape_preview)
+    CFGWRITE(alphas.canvas_shape_controlpoint)
+    CFGWRITE(alphas.canvas_shape_guideline)
+    CFGWRITE(alphas.canvas_shape_mainpoint)
+    CFGWRITE(alphas.canvas_shape_outline)
+    CFGWRITE(alphas.canvas_shape_selectpoint)
+    CFGWRITE(sizes.origincross)
+    CFGWRITE(behaviors.autoaskimgopac)
+    CFGWRITE(behaviors.capitalizecmds)
+    CFGWRITE(behaviors.parse_spc)
+    CFGWRITE(behaviors.nosplashscreen)
+    CFGWRITE(behaviors.confirmquit)
+    config->SetPath(_T(".."));
 }
diff --git a/assdraw/canvas.cpp b/assdraw/canvas.cpp
index a077c1ef526a42af6069d94e9182030fe600b11a..56f6fe6155e58f3a52f758dd51b475e825f428d7 100644
--- a/assdraw/canvas.cpp
+++ b/assdraw/canvas.cpp
@@ -57,21 +57,21 @@ BEGIN_EVENT_TABLE(ASSDrawCanvas, ASSDrawEngine)
     EVT_RIGHT_UP(ASSDrawCanvas::OnMouseRightUp)
     EVT_RIGHT_DOWN(ASSDrawCanvas::OnMouseRightDown)
     EVT_RIGHT_DCLICK(ASSDrawCanvas::OnMouseRightDClick)
-	EVT_MOUSEWHEEL(ASSDrawCanvas::OnMouseWheel)
+    EVT_MOUSEWHEEL(ASSDrawCanvas::OnMouseWheel)
     EVT_KEY_DOWN(ASSDrawCanvas::CustomOnKeyDown)
     EVT_KEY_UP(ASSDrawCanvas::CustomOnKeyUp)
-	EVT_MENU(MENU_DRC_LNTOBEZ, ASSDrawCanvas::OnSelect_ConvertLineToBezier)
-	EVT_MENU(MENU_DRC_BEZTOLN, ASSDrawCanvas::OnSelect_ConvertBezierToLine)
-	EVT_MENU(MENU_DRC_C1CONTBEZ, ASSDrawCanvas::OnSelect_C1ContinuityBezier)
-	EVT_MENU(MENU_DRC_MOVE00, ASSDrawCanvas::OnSelect_Move00Here)
-	EVT_MOUSE_CAPTURE_LOST(ASSDrawCanvas::CustomOnMouseCaptureLost)
+    EVT_MENU(MENU_DRC_LNTOBEZ, ASSDrawCanvas::OnSelect_ConvertLineToBezier)
+    EVT_MENU(MENU_DRC_BEZTOLN, ASSDrawCanvas::OnSelect_ConvertBezierToLine)
+    EVT_MENU(MENU_DRC_C1CONTBEZ, ASSDrawCanvas::OnSelect_C1ContinuityBezier)
+    EVT_MENU(MENU_DRC_MOVE00, ASSDrawCanvas::OnSelect_Move00Here)
+    EVT_MOUSE_CAPTURE_LOST(ASSDrawCanvas::CustomOnMouseCaptureLost)
 END_EVENT_TABLE()
 
 ASSDrawCanvas::ASSDrawCanvas(wxWindow *parent, ASSDrawFrame *frame, int extraflags)
- : ASSDrawEngine( parent, extraflags )
+    : ASSDrawEngine( parent, extraflags )
 {
-	m_frame = frame;
-	preview_mode = false;
+    m_frame = frame;
+    preview_mode = false;
     lastDrag_left = NULL;
     lastDrag_right = NULL;
     dragAnchor_left = NULL;
@@ -82,1640 +82,1533 @@ ASSDrawCanvas::ASSDrawCanvas(wxWindow *parent, ASSDrawFrame *frame, int extrafla
     draw_mode = MODE_ARR;
 
     dragOrigin = false;
-	hilite_cmd = NULL;
-	hilite_point = NULL;
-	capturemouse_left = false;
-	capturemouse_right = false;
-	bgimg.bgbmp = NULL;
-	bgimg.bgimg = NULL;
-	bgimg.alpha = 0.5;
-	rectbound2upd = -1, rectbound2upd2 = -1;
-
-	rgba_shape_normal = agg::rgba(0,0,1,0.5);
-	rgba_outline = agg::rgba(0,0,0);
-	rgba_guideline = agg::rgba(0.5,0.5,0.5);
-	rgba_mainpoint = agg::rgba(1,0,0,0.75);
-	rgba_controlpoint = agg::rgba(0,1,0,0.75);
-	rgba_selectpoint = agg::rgba(0,0,1,0.75);
-	rgba_origin = agg::rgba(0,0,0);
-	rgba_ruler_h = agg::rgba(0,0,1);
-	rgba_ruler_v = agg::rgba(1,0,0);
-
-	wxFlexGridSizer* sizer = new wxFlexGridSizer(1, 1, 0);
+    hilite_cmd = NULL;
+    hilite_point = NULL;
+    capturemouse_left = false;
+    capturemouse_right = false;
+    bgimg.bgbmp = NULL;
+    bgimg.bgimg = NULL;
+    bgimg.alpha = 0.5;
+    rectbound2upd = -1, rectbound2upd2 = -1;
+
+    rgba_shape_normal = agg::rgba(0, 0, 1, 0.5);
+    rgba_outline = agg::rgba(0, 0, 0);
+    rgba_guideline = agg::rgba(0.5, 0.5, 0.5);
+    rgba_mainpoint = agg::rgba(1, 0, 0, 0.75);
+    rgba_controlpoint = agg::rgba(0, 1, 0, 0.75);
+    rgba_selectpoint = agg::rgba(0, 0, 1, 0.75);
+    rgba_origin = agg::rgba(0, 0, 0);
+    rgba_ruler_h = agg::rgba(0, 0, 1);
+    rgba_ruler_v = agg::rgba(1, 0, 0);
+
+    wxFlexGridSizer *sizer = new wxFlexGridSizer(1, 1, 0);
     sizer->AddGrowableRow(0);
     sizer->AddGrowableCol(0);
-    sizer->Add( this, 0, wxGROW|wxGROW, 5);
+    sizer->Add( this, 0, wxGROW | wxGROW, 5);
     parent->SetSizer(sizer);
 
-	// for background image loading
-	::wxInitAllImageHandlers();
-	bgimg.bgbmp = NULL;
-	bgimg.bgimg = NULL;
-	// drag image background file
-	SetDropTarget(new ASSDrawFileDropTarget(this));
+    // for background image loading
+    ::wxInitAllImageHandlers();
+    bgimg.bgbmp = NULL;
+    bgimg.bgimg = NULL;
+    // drag image background file
+    SetDropTarget(new ASSDrawFileDropTarget(this));
 
-	hasStatusBar = m_frame->GetStatusBar() != NULL;
+    hasStatusBar = m_frame->GetStatusBar() != NULL;
 
-	// cursor = crosshair
-	SetCursor( *wxCROSS_CURSOR );
+    // cursor = crosshair
+    SetCursor( *wxCROSS_CURSOR );
 
-	bgimg.alpha_dlg = new wxDialog(this, wxID_ANY, wxString(_T("Background image opacity")));
-	bgimg.alpha_slider = new wxSlider(bgimg.alpha_dlg, TB_BGALPHA_SLIDER, 50, 0, 100, __DPDS__ , wxSL_LABELS);
-	bgimg.alpha_slider->SetSize(280, bgimg.alpha_slider->GetSize().y);
-	bgimg.alpha_dlg->Fit();
-	bgimg.alpha_dlg->Show(false);
-	bgimg.alpha_slider->Connect(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
-	bgimg.alpha_slider->Connect(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
-	bgimg.alpha_slider->Connect(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
-	bgimg.alpha_slider->Connect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
-	bgimg.alpha_slider->Connect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
-	bgimg.alpha_slider->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
+    bgimg.alpha_dlg = new wxDialog(this, wxID_ANY, wxString(_T("Background image opacity")));
+    bgimg.alpha_slider = new wxSlider(bgimg.alpha_dlg, TB_BGALPHA_SLIDER, 50, 0, 100, __DPDS__, wxSL_LABELS);
+    bgimg.alpha_slider->SetSize(280, bgimg.alpha_slider->GetSize().y);
+    bgimg.alpha_dlg->Fit();
+    bgimg.alpha_dlg->Show(false);
+    bgimg.alpha_slider->Connect(wxEVT_SCROLL_LINEUP, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
+    bgimg.alpha_slider->Connect(wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
+    bgimg.alpha_slider->Connect(wxEVT_SCROLL_PAGEUP, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
+    bgimg.alpha_slider->Connect(wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
+    bgimg.alpha_slider->Connect(wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
+    bgimg.alpha_slider->Connect(wxEVT_SCROLL_CHANGED, wxScrollEventHandler(ASSDrawCanvas::OnAlphaSliderChanged), NULL, this);
 
-	RefreshUndocmds();
+    RefreshUndocmds();
 
 }
 
 // Destructor
 ASSDrawCanvas::~ASSDrawCanvas()
 {
-	ASSDrawEngine::ResetEngine(false);
-	if (pointsys) delete pointsys;
-	if (bgimg.bgbmp) delete bgimg.bgbmp;
-	if (bgimg.bgimg) delete bgimg.bgimg;
+    ASSDrawEngine::ResetEngine(false);
+    if (pointsys) delete pointsys;
+    if (bgimg.bgbmp) delete bgimg.bgbmp;
+    if (bgimg.bgimg) delete bgimg.bgimg;
 }
 
 void ASSDrawCanvas::ParseASS(wxString str, bool addundo)
 {
-	if (addundo)
-		AddUndo(_T("Modify drawing commands"));
+    if (addundo)
+        AddUndo(_T("Modify drawing commands"));
 
-	ASSDrawEngine::ParseASS(str);
+    ASSDrawEngine::ParseASS(str);
 
-	RefreshUndocmds();
+    RefreshUndocmds();
 }
 
 void ASSDrawCanvas::ResetEngine(bool addM)
 {
-	ClearPointsSelection();
-	SetHighlighted(NULL, NULL);
-	SetPreviewMode(false);
-	SetDrawMode(MODE_ARR);
-	ASSDrawEngine::ResetEngine(addM);
-	RefreshUndocmds();
+    ClearPointsSelection();
+    SetHighlighted(NULL, NULL);
+    SetPreviewMode(false);
+    SetDrawMode(MODE_ARR);
+    ASSDrawEngine::ResetEngine(addM);
+    RefreshUndocmds();
 }
 
 void ASSDrawCanvas::SetPreviewMode(bool mode)
 {
-	preview_mode = mode;
-	if (preview_mode)
-	{
-		if (mousedownAt_point != NULL)
-		{
-			mousedownAt_point->cmd_main->Init();
-			mousedownAt_point = NULL;
-		}
+    preview_mode = mode;
+    if (preview_mode) {
+        if (mousedownAt_point != NULL) {
+            mousedownAt_point->cmd_main->Init();
+            mousedownAt_point = NULL;
+        }
 
-		if (pointedAt_point != NULL)
-			pointedAt_point = NULL;
+        if (pointedAt_point != NULL)
+            pointedAt_point = NULL;
 
-		SetHighlighted( NULL, NULL );
+        SetHighlighted( NULL, NULL );
 
-		RefreshDisplay();
-	}
+        RefreshDisplay();
+    }
 }
 
 // (Re)draw canvas
 void ASSDrawCanvas::RefreshDisplay()
 {
-	ASSDrawEngine::RefreshDisplay();
-	wxString asscmds = GenerateASS();
-	if (oldasscmds != asscmds)
-	{
-		m_frame->UpdateASSCommandStringToSrcTxtCtrl(asscmds);
-		oldasscmds = asscmds;
-	}
+    ASSDrawEngine::RefreshDisplay();
+    wxString asscmds = GenerateASS();
+    if (oldasscmds != asscmds) {
+        m_frame->UpdateASSCommandStringToSrcTxtCtrl(asscmds);
+        oldasscmds = asscmds;
+    }
 }
 
 void ASSDrawCanvas::SetDrawMode( MODE mode )
 {
-	draw_mode = mode;
-
-	if (!selected_points.empty())
-		ClearPointsSelection();
-
-	RefreshDisplay();
-
-	if (IsTransformMode())
-	{
-		isshapetransformable = cmds.size() > 1;
-
-		if (isshapetransformable)
-		{
-
-			// backup cmds
-			backupcmds.free_all();
-			for (DrawCmdList::iterator iterate = cmds.begin(); iterate != cmds.end(); iterate++)
-			{
-				DrawCmd* cmd = (*iterate);
-				for (PointList::iterator iterate2 = cmd->controlpoints.begin(); iterate2 != cmd->controlpoints.end(); iterate2++)
-				{
-					wxPoint pp = (*iterate2)->ToWxPoint();
-					backupcmds.move_to(pp.x, pp.y);
-				}
-				wxPoint pp = (*iterate)->m_point->ToWxPoint();
-				backupcmds.move_to(pp.x, pp.y);
-			}
-
-			// calculate bounding rectangle
-			agg::trans_affine mtx;
-			trans_path *rm, *rb;
-			agg::conv_curve<trans_path> *rc;
-			ConstructPathsAndCurves(mtx, rm, rb, rc);
-			rasterizer.reset();
-			rasterizer.add_path(*rc);
-			delete rm;
-			delete rb;
-			delete rc;
-		    int minx = rasterizer.min_x(), miny = rasterizer.min_y();
-		    int maxx = rasterizer.max_x(), maxy = rasterizer.max_y();
-
-		    rectbound[0] = wxRealPoint(minx, miny);
-		    rectbound[1] = wxRealPoint(maxx, miny);
-		    rectbound[2] = wxRealPoint(maxx, maxy);
-		    rectbound[3] = wxRealPoint(minx, maxy);
-		    for (int i = 0; i < 4; i++)
-		    	rectbound2[i] = rectbound[i];
-
-		    rectbound2upd = -1;
-		    rectbound2upd2 = -1;
-
-		    backupowner = NONE;
-		    InitiateDraggingIfTransformMode();
-
-		    if (maxx - minx < 5 || maxy - miny < 5)
-		    	isshapetransformable = false;
-		}
-	}
-
-	RefreshUndocmds();
-	m_frame->UpdateFrameUI();
+    draw_mode = mode;
+
+    if (!selected_points.empty())
+        ClearPointsSelection();
+
+    RefreshDisplay();
+
+    if (IsTransformMode()) {
+        isshapetransformable = cmds.size() > 1;
+
+        if (isshapetransformable) {
+
+            // backup cmds
+            backupcmds.free_all();
+            for (DrawCmdList::iterator iterate = cmds.begin(); iterate != cmds.end(); iterate++) {
+                DrawCmd *cmd = (*iterate);
+                for (PointList::iterator iterate2 = cmd->controlpoints.begin(); iterate2 != cmd->controlpoints.end(); iterate2++) {
+                    wxPoint pp = (*iterate2)->ToWxPoint();
+                    backupcmds.move_to(pp.x, pp.y);
+                }
+                wxPoint pp = (*iterate)->m_point->ToWxPoint();
+                backupcmds.move_to(pp.x, pp.y);
+            }
+
+            // calculate bounding rectangle
+            agg::trans_affine mtx;
+            trans_path *rm, *rb;
+            agg::conv_curve<trans_path> *rc;
+            ConstructPathsAndCurves(mtx, rm, rb, rc);
+            rasterizer.reset();
+            rasterizer.add_path(*rc);
+            delete rm;
+            delete rb;
+            delete rc;
+            int minx = rasterizer.min_x(), miny = rasterizer.min_y();
+            int maxx = rasterizer.max_x(), maxy = rasterizer.max_y();
+
+            rectbound[0] = wxRealPoint(minx, miny);
+            rectbound[1] = wxRealPoint(maxx, miny);
+            rectbound[2] = wxRealPoint(maxx, maxy);
+            rectbound[3] = wxRealPoint(minx, maxy);
+            for (int i = 0; i < 4; i++)
+                rectbound2[i] = rectbound[i];
+
+            rectbound2upd = -1;
+            rectbound2upd2 = -1;
+
+            backupowner = NONE;
+            InitiateDraggingIfTransformMode();
+
+            if (maxx - minx < 5 || maxy - miny < 5)
+                isshapetransformable = false;
+        }
+    }
+
+    RefreshUndocmds();
+    m_frame->UpdateFrameUI();
 
 }
 
 void ASSDrawCanvas::SetDragMode( DRAGMODE mode )
 {
-	drag_mode = mode;
+    drag_mode = mode;
 }
 
 bool ASSDrawCanvas::IsTransformMode()
 {
-	return draw_mode == MODE_NUT_BILINEAR || draw_mode == MODE_SCALEROTATE;
+    return draw_mode == MODE_NUT_BILINEAR || draw_mode == MODE_SCALEROTATE;
 }
 
 bool ASSDrawCanvas::CanZoom()
 {
-	return !IsTransformMode() || !drag_mode.drawing;
+    return !IsTransformMode() || !drag_mode.drawing;
 }
 
 bool ASSDrawCanvas::CanMove()
 {
-	return !IsTransformMode() || dragAnchor_left == NULL;
+    return !IsTransformMode() || dragAnchor_left == NULL;
 }
 
 // Do the dragging
 void ASSDrawCanvas::OnMouseMove(wxMouseEvent &event)
 {
-	mouse_point = event.GetPosition();
-	int xx, yy, wx, wy;
-	xx = mouse_point.x; yy = mouse_point.y;
-	pointsys->FromWxPoint ( mouse_point, wx, wy );
-	if (event.Dragging())
-	{
-		if (IsTransformMode() && isshapetransformable && backupowner == LEFT)
-		{
-			// update bounding polygon
-			if (rectbound2upd > -1)
-			{
-				if (!dragAnchor_left) dragAnchor_left = new wxPoint(mouse_point);
-				wxPoint diff = mouse_point - *dragAnchor_left;
-				wxRealPoint rdiff(diff.x, diff.y);
-				switch(draw_mode)
-				{
-				case MODE_NUT_BILINEAR:
-					if (rectbound2upd2 == -1) //only one vertex dragged
-						rectbound2[rectbound2upd].x = xx, rectbound2[rectbound2upd].y = yy;
-					else
-					{
-						rectbound2[rectbound2upd].x += diff.x, rectbound2[rectbound2upd].y += diff.y;
-						rectbound2[rectbound2upd2].x += diff.x, rectbound2[rectbound2upd2].y += diff.y;
-					}
-					undodesc = _T("Bilinear transform");
-					*dragAnchor_left = mouse_point;
-					break;
-				case MODE_SCALEROTATE:
-					if (rectbound2upd2 == -1) //only one vertex dragged
-					{
-						int adjacent[2] = { (rectbound2upd + 3) % 4, (rectbound2upd + 1) % 4 };
-						int opposite = (rectbound2upd + 2) % 4;
-						wxRealPoint newpoint = backup[rectbound2upd] + rdiff;
-						double nx, ny;
-						for (int i = 0; i < 2; i++)
-						{
-							bool isect = agg::calc_intersection(
-								backup[opposite].x, backup[opposite].y,
-								backup[adjacent[i]].x, backup[adjacent[i]].y,
-								newpoint.x, newpoint.y,
-								backup[adjacent[i]].x + diff.x, backup[adjacent[i]].y + diff.y,
-								&nx, &ny);
-							if (isect && !(fabs(nx - backup[opposite].x) < 10 && fabs(ny - backup[opposite].y) < 10))
-								rectbound2[adjacent[i]] = wxRealPoint(nx, ny);
-						}
-						GetThe4thPoint(backup[opposite].x, backup[opposite].y,
-							rectbound2[adjacent[0]].x, rectbound2[adjacent[0]].y,
-							rectbound2[adjacent[1]].x, rectbound2[adjacent[1]].y,
-							&rectbound2[rectbound2upd].x, &rectbound2[rectbound2upd].y);
-						if (event.ShiftDown()) // shift down = maintain aspect ratio (damn so complicated)
-						{
-							// first create the guide points, which are basically backup points reoriented based on mouse position
-							wxRealPoint guide[4];
-							guide[opposite] = backup[opposite];
-							guide[adjacent[0]] = backup[adjacent[0]];
-							guide[adjacent[1]] = backup[adjacent[1]];
-							for (int i = 0; i < 2; i++)
-							{
-								if ((rectbound2[adjacent[i]].x < guide[opposite].x && guide[opposite].x < guide[adjacent[i]].x)
-									|| (rectbound2[adjacent[i]].x > guide[opposite].x && guide[opposite].x > guide[adjacent[i]].x)
-									|| (rectbound2[adjacent[i]].y < guide[opposite].y && guide[opposite].y < guide[adjacent[i]].y)
-									|| (rectbound2[adjacent[i]].y > guide[opposite].y && guide[opposite].y > guide[adjacent[i]].y))
-								{
-									guide[adjacent[i]] = guide[opposite] - (guide[adjacent[i]] - guide[opposite]);
-								}
-							}
-							guide[rectbound2upd] = guide[adjacent[0]] + (guide[adjacent[1]] - guide[opposite]);
-							// now we determine which rescaled sides have larger enlargement/shrinkage ratio ..
-							double ix[2], iy[2], dx[2], dy[2];
-							for (int i = 0; i < 2; i++)
-							{
-								agg::calc_intersection(guide[opposite].x, guide[opposite].y, guide[rectbound2upd].x, guide[rectbound2upd].y,
-									rectbound2[rectbound2upd].x, rectbound2[rectbound2upd].y,
-									rectbound2[adjacent[i]].x, rectbound2[adjacent[i]].y, &ix[i], &iy[i]);
-								dx[i] = ix[i] - guide[opposite].x;
-								dy[i] = iy[i] - guide[opposite].y;
-							}
-							// .. and modify the other sides to follow the ratio
-							for (int i = 0; i < 2; i++)
-							{
-								int j = (i + 1) % 2;
-								if (fabs(dx[i]) > fabs(dx[j]) || fabs(dy[i]) > fabs(dy[j]))
-								{
-									rectbound2[rectbound2upd].x = ix[i];
-									rectbound2[rectbound2upd].y = iy[i];
-									GetThe4thPoint(rectbound2[adjacent[i]].x, rectbound2[adjacent[i]].y,
-										guide[opposite].x, guide[opposite].y, ix[i], iy[i],
-										&rectbound2[adjacent[j]].x, &rectbound2[adjacent[j]].y);
-								}
-							}
-						}
-					}
-					else // an edge dragged (i.e. move 2 vertices in sync)
-					{
-						// it is guaranteed that rectbound2upd and rectbound2upd2 are in clockwise direction
-						// from the way they are detected in OnMouseLeftDown()
-						int toupd[2] = { rectbound2upd, rectbound2upd2 };
-						int adjacent[2] = { (rectbound2upd2 + 2) % 4, (rectbound2upd2 + 1) % 4 };
-						wxRealPoint vertexone = backup[toupd[0]] + rdiff, vertextwo = backup[toupd[1]] + rdiff;
-						double nx, ny;
-						for (int i = 0; i < 2; i++)
-						{
-							agg::calc_intersection(
-								rectbound2[adjacent[i]].x, rectbound2[adjacent[i]].y,
-								backup[toupd[i]].x, backup[toupd[i]].y,
-								vertexone.x, vertexone.y,
-								vertextwo.x, vertextwo.y,
-								&nx, &ny);
-							if (!(fabs(nx - backup[adjacent[i]].x) < 10 && fabs(ny - backup[adjacent[i]].y) < 10))
-								rectbound2[toupd[i]].x = (int) nx, rectbound2[toupd[i]].y = (int) ny;
-						}
-					}
-					UpdateTranformModeRectCenter();
-					undodesc = _T("Scale");
-					break;
-				}
-
-				// update points
-				UpdateNonUniformTransformation();
-				RefreshDisplay();
-			}
-		}
-		else if (draw_mode != MODE_DEL)
-		{
-
-			// point left-dragged
-			if (mousedownAt_point != NULL && mousedownAt_point->isselected)
-			{
-				if (!mousedownAt_point->IsAt( wx, wy ))
-				{
-					if (draw_mode == MODE_ARR) {
-						int movex = wx - mousedownAt_point->x(), movey = wy - mousedownAt_point->y();
-						PointSet::iterator iter = selected_points.begin();
-						for (; iter != selected_points.end(); iter++)
-							(*iter)->setXY( (*iter)->x() + movex, (*iter)->y() + movey );
-					}
-					else
-						mousedownAt_point->setXY( wx, wy );
-
-					EnforceC1Continuity (mousedownAt_point->cmd_main, mousedownAt_point);
-
-					RefreshDisplay();
-					if (undodesc == _T(""))
-					{
-						if (mousedownAt_point->type == MP)
-							undodesc = _T("Drag point");
-						else
-							undodesc = _T("Drag control point");
-					}
-				}
-			}
-			// origin left-dragged
-			else if (dragOrigin)
-			{
-				if (wx != 0 || wy != 0)
-				{
-					wxPoint wxp = pointsys->ToWxPoint ( wx, wy );
-					MovePoints(-wx, -wy);
-					pointsys->originx = wxp.x;
-					pointsys->originy = wxp.y;
-					RefreshDisplay();
-					undodesc = _T("Move origin");
-				}
-			}
-			else if (dragAnchor_left != NULL)
-			{
-				// handle left-dragging here
-				if (lastDrag_left && dragAnchor_left != lastDrag_left)
-			       delete lastDrag_left;
-				lastDrag_left = new wxPoint(xx, yy);
-				int ax = dragAnchor_left->x, ay = dragAnchor_left->y;
-				int sx = lastDrag_left->x, sy = lastDrag_left->y;
-				int lx, rx, ty, by;
-				if (ax > sx) lx = sx, rx = ax;
-				else lx = ax, rx = sx;
-				if (ay > sy) ty = sy, by = ay;
-				else ty = ay, by = sy;
-				SelectPointsWithin( lx, rx, ty, by, GetSelectMode(event) );
-				RefreshDisplay();
-			}
-		}
-
-		// right-dragged
-		if (dragAnchor_right != NULL)
-		{
-			if (draw_mode == MODE_SCALEROTATE)
-			{
-				if (backupowner == RIGHT)
-				{
-					double cx = rectcenter.x, cy = rectcenter.y; // center x,y
-					double diameter = sqrt(pow(rectbound2[0].x - rectbound2[2].x, 2) + pow(rectbound2[0].y - rectbound2[2].y, 2));
-					double radius = diameter / 2;
-					double old_dx = dragAnchor_right->x - cx, old_dy = dragAnchor_right->y - cy;
-					double new_dx = mouse_point.x - cx, new_dy = mouse_point.y - cy;
-					double old_angle = atan2(old_dy, old_dx);
-					double new_angle = atan2(new_dy, new_dx);
-					double delta = new_angle - old_angle;
-					for (int i = 0; i < 4; i++)
-					{
-						old_dx = backup[i].x - cx, old_dy = backup[i].y - cy;
-						old_angle = atan2(old_dy, old_dx);
-						new_angle = old_angle + delta;
-						new_dx = radius * cos(new_angle), new_dy = radius * sin(new_angle);
-						rectbound2[i].x = (int)(new_dx + cx), rectbound2[i].y = (int)(new_dy + cy);
-					}
-					UpdateNonUniformTransformation();
-					RefreshDisplay();
-					undodesc = _T("Rotate");
-				}
-			}
-			else if (CanMove())
-			{
-				MoveCanvas(xx - dragAnchor_right->x, yy - dragAnchor_right->y);
-				dragAnchor_right->x = xx;
-				dragAnchor_right->y = yy;
-				RefreshDisplay();
-			}
-		}
-	}
-	else if (!preview_mode)// not dragging and not preview mode
-    {
-		if (IsTransformMode())
-		{
-			int oldrectbound = rectbound2upd;
-			rectbound2upd = -1;
-			rectbound2upd2 = -1;
-			for (int i = 0; i < 4; i++)
-			{
-				if (abs((int)rectbound2[i].x - mouse_point.x) <= pointsys->scale
-					&& abs((int)rectbound2[i].y - mouse_point.y) <= pointsys->scale)
-						rectbound2upd = i;
-			}
-			for (int i = 0; rectbound2upd == -1 && i < 4; i++)
-			{
-				int j = (i+1) % 4;
-				wxRealPoint &pi = rectbound2[i], &pj = rectbound2[j];
-				double dy = fabs(pj.y - pi.y);
-				double dy3 = dy / 3;
-				double dx = fabs(pj.x - pi.x);
-				double dx3 = dx / 3;
-				double ix, iy;
-				bool intersect = false;
-				if (dy > dx)
-				{
-					intersect = agg::calc_intersection(
-						pi.x, pi.y, pj.x, pj.y,
-	                    mouse_point.x - pointsys->scale, mouse_point.y,
-						mouse_point.x + pointsys->scale, mouse_point.y, &ix, &iy);
-					intersect &= fabs(mouse_point.x - ix) <= pointsys->scale;
-					intersect &= (pj.y > pi.y?
-						pj.y - dy3 > iy && iy > pi.y + dy3:
-						pj.y + dy3 < iy && iy < pi.y - dy3);
-				}
-				else
-				{
-					intersect = agg::calc_intersection(
-						pi.x, pi.y, pj.x, pj.y,
-	                    mouse_point.x, mouse_point.y - pointsys->scale,
-						mouse_point.x, mouse_point.y + pointsys->scale, &ix, &iy);
-					intersect &= fabs(mouse_point.y - iy) <= pointsys->scale;
-					intersect &= (pj.x > pi.x?
-						pj.x - dx3 > ix && ix > pi.x + dx3:
-						pj.x + dx3 < ix && ix < pi.x - dx3);
-				}
-				if (intersect)
-				{
-					rectbound2upd = i;
-					rectbound2upd2 = j;
-				}
-			}
-			if (rectbound2upd != -1 || oldrectbound != -1)
-				RefreshDisplay();
-		}
-		else
-		{
-	         /* figure out if the mouse is pointing at a point of a command
-	            we need not do this for dragging since this same block has set
-	            the related variables before the user starts to hold the button
-	            (well, before you can drag something you have to move the pointer
-	            over that thing first, right?) and we don't want to mess with those
-	            when it's dragging
-	         */
-
-			// check if mouse points on any control point first
-			Point* last_pointedAt_point = pointedAt_point;
-			ControlAt( wx, wy, pointedAt_point );
-
-			// then check if mouse points on any m_points
-			// override any control point set to pointedAt_point above
-			DrawCmd* p = PointAt( wx, wy );
-			if (p != NULL)
-			{
-				pointedAt_point = p->m_point;
-			}
-
-			if (pointedAt_point != last_pointedAt_point)
-			{
-				if (pointedAt_point != NULL)
-					SetHighlighted( pointedAt_point->cmd_main, pointedAt_point );
-				else
-					SetHighlighted( NULL, NULL );
-				RefreshDisplay();
-			}
-		}
-	} // not dragging and preview mode = ignore all mouse movements
-
-	// we are not done yet?
+    mouse_point = event.GetPosition();
+    int xx, yy, wx, wy;
+    xx = mouse_point.x; yy = mouse_point.y;
+    pointsys->FromWxPoint ( mouse_point, wx, wy );
+    if (event.Dragging()) {
+        if (IsTransformMode() && isshapetransformable && backupowner == LEFT) {
+            // update bounding polygon
+            if (rectbound2upd > -1) {
+                if (!dragAnchor_left) dragAnchor_left = new wxPoint(mouse_point);
+                wxPoint diff = mouse_point - *dragAnchor_left;
+                wxRealPoint rdiff(diff.x, diff.y);
+                switch (draw_mode) {
+                case MODE_NUT_BILINEAR:
+                    if (rectbound2upd2 == -1) //only one vertex dragged
+                        rectbound2[rectbound2upd].x = xx, rectbound2[rectbound2upd].y = yy;
+                    else {
+                        rectbound2[rectbound2upd].x += diff.x, rectbound2[rectbound2upd].y += diff.y;
+                        rectbound2[rectbound2upd2].x += diff.x, rectbound2[rectbound2upd2].y += diff.y;
+                    }
+                    undodesc = _T("Bilinear transform");
+                    *dragAnchor_left = mouse_point;
+                    break;
+                case MODE_SCALEROTATE:
+                    if (rectbound2upd2 == -1) { //only one vertex dragged
+                        int adjacent[2] = { (rectbound2upd + 3) % 4, (rectbound2upd + 1) % 4 };
+                        int opposite = (rectbound2upd + 2) % 4;
+                        wxRealPoint newpoint = backup[rectbound2upd] + rdiff;
+                        double nx, ny;
+                        for (int i = 0; i < 2; i++) {
+                            bool isect = agg::calc_intersection(
+                                             backup[opposite].x, backup[opposite].y,
+                                             backup[adjacent[i]].x, backup[adjacent[i]].y,
+                                             newpoint.x, newpoint.y,
+                                             backup[adjacent[i]].x + diff.x, backup[adjacent[i]].y + diff.y,
+                                             &nx, &ny);
+                            if (isect && !(fabs(nx - backup[opposite].x) < 10 && fabs(ny - backup[opposite].y) < 10))
+                                rectbound2[adjacent[i]] = wxRealPoint(nx, ny);
+                        }
+                        GetThe4thPoint(backup[opposite].x, backup[opposite].y,
+                                       rectbound2[adjacent[0]].x, rectbound2[adjacent[0]].y,
+                                       rectbound2[adjacent[1]].x, rectbound2[adjacent[1]].y,
+                                       &rectbound2[rectbound2upd].x, &rectbound2[rectbound2upd].y);
+                        if (event.ShiftDown()) { // shift down = maintain aspect ratio (damn so complicated)
+                            // first create the guide points, which are basically backup points reoriented based on mouse position
+                            wxRealPoint guide[4];
+                            guide[opposite] = backup[opposite];
+                            guide[adjacent[0]] = backup[adjacent[0]];
+                            guide[adjacent[1]] = backup[adjacent[1]];
+                            for (int i = 0; i < 2; i++) {
+                                if ((rectbound2[adjacent[i]].x < guide[opposite].x && guide[opposite].x < guide[adjacent[i]].x)
+                                    || (rectbound2[adjacent[i]].x > guide[opposite].x && guide[opposite].x > guide[adjacent[i]].x)
+                                    || (rectbound2[adjacent[i]].y < guide[opposite].y && guide[opposite].y < guide[adjacent[i]].y)
+                                    || (rectbound2[adjacent[i]].y > guide[opposite].y && guide[opposite].y > guide[adjacent[i]].y)) {
+                                    guide[adjacent[i]] = guide[opposite] - (guide[adjacent[i]] - guide[opposite]);
+                                }
+                            }
+                            guide[rectbound2upd] = guide[adjacent[0]] + (guide[adjacent[1]] - guide[opposite]);
+                            // now we determine which rescaled sides have larger enlargement/shrinkage ratio ..
+                            double ix[2], iy[2], dx[2], dy[2];
+                            for (int i = 0; i < 2; i++) {
+                                agg::calc_intersection(guide[opposite].x, guide[opposite].y, guide[rectbound2upd].x, guide[rectbound2upd].y,
+                                                       rectbound2[rectbound2upd].x, rectbound2[rectbound2upd].y,
+                                                       rectbound2[adjacent[i]].x, rectbound2[adjacent[i]].y, &ix[i], &iy[i]);
+                                dx[i] = ix[i] - guide[opposite].x;
+                                dy[i] = iy[i] - guide[opposite].y;
+                            }
+                            // .. and modify the other sides to follow the ratio
+                            for (int i = 0; i < 2; i++) {
+                                int j = (i + 1) % 2;
+                                if (fabs(dx[i]) > fabs(dx[j]) || fabs(dy[i]) > fabs(dy[j])) {
+                                    rectbound2[rectbound2upd].x = ix[i];
+                                    rectbound2[rectbound2upd].y = iy[i];
+                                    GetThe4thPoint(rectbound2[adjacent[i]].x, rectbound2[adjacent[i]].y,
+                                                   guide[opposite].x, guide[opposite].y, ix[i], iy[i],
+                                                   &rectbound2[adjacent[j]].x, &rectbound2[adjacent[j]].y);
+                                }
+                            }
+                        }
+                    }
+                    else { // an edge dragged (i.e. move 2 vertices in sync)
+                        // it is guaranteed that rectbound2upd and rectbound2upd2 are in clockwise direction
+                        // from the way they are detected in OnMouseLeftDown()
+                        int toupd[2] = { rectbound2upd, rectbound2upd2 };
+                        int adjacent[2] = { (rectbound2upd2 + 2) % 4, (rectbound2upd2 + 1) % 4 };
+                        wxRealPoint vertexone = backup[toupd[0]] + rdiff, vertextwo = backup[toupd[1]] + rdiff;
+                        double nx, ny;
+                        for (int i = 0; i < 2; i++) {
+                            agg::calc_intersection(
+                                rectbound2[adjacent[i]].x, rectbound2[adjacent[i]].y,
+                                backup[toupd[i]].x, backup[toupd[i]].y,
+                                vertexone.x, vertexone.y,
+                                vertextwo.x, vertextwo.y,
+                                &nx, &ny);
+                            if (!(fabs(nx - backup[adjacent[i]].x) < 10 && fabs(ny - backup[adjacent[i]].y) < 10))
+                                rectbound2[toupd[i]].x = (int) nx, rectbound2[toupd[i]].y = (int) ny;
+                        }
+                    }
+                    UpdateTranformModeRectCenter();
+                    undodesc = _T("Scale");
+                    break;
+                }
+
+                // update points
+                UpdateNonUniformTransformation();
+                RefreshDisplay();
+            }
+        }
+        else if (draw_mode != MODE_DEL) {
+
+            // point left-dragged
+            if (mousedownAt_point != NULL && mousedownAt_point->isselected) {
+                if (!mousedownAt_point->IsAt( wx, wy )) {
+                    if (draw_mode == MODE_ARR) {
+                        int movex = wx - mousedownAt_point->x(), movey = wy - mousedownAt_point->y();
+                        PointSet::iterator iter = selected_points.begin();
+                        for (; iter != selected_points.end(); iter++)
+                            (*iter)->setXY( (*iter)->x() + movex, (*iter)->y() + movey );
+                    }
+                    else
+                        mousedownAt_point->setXY( wx, wy );
+
+                    EnforceC1Continuity (mousedownAt_point->cmd_main, mousedownAt_point);
+
+                    RefreshDisplay();
+                    if (undodesc == _T("")) {
+                        if (mousedownAt_point->type == MP)
+                            undodesc = _T("Drag point");
+                        else
+                            undodesc = _T("Drag control point");
+                    }
+                }
+            }
+            // origin left-dragged
+            else if (dragOrigin) {
+                if (wx != 0 || wy != 0) {
+                    wxPoint wxp = pointsys->ToWxPoint ( wx, wy );
+                    MovePoints(-wx, -wy);
+                    pointsys->originx = wxp.x;
+                    pointsys->originy = wxp.y;
+                    RefreshDisplay();
+                    undodesc = _T("Move origin");
+                }
+            }
+            else if (dragAnchor_left != NULL) {
+                // handle left-dragging here
+                if (lastDrag_left && dragAnchor_left != lastDrag_left)
+                    delete lastDrag_left;
+                lastDrag_left = new wxPoint(xx, yy);
+                int ax = dragAnchor_left->x, ay = dragAnchor_left->y;
+                int sx = lastDrag_left->x, sy = lastDrag_left->y;
+                int lx, rx, ty, by;
+                if (ax > sx) lx = sx, rx = ax;
+                else lx = ax, rx = sx;
+                if (ay > sy) ty = sy, by = ay;
+                else ty = ay, by = sy;
+                SelectPointsWithin( lx, rx, ty, by, GetSelectMode(event) );
+                RefreshDisplay();
+            }
+        }
+
+        // right-dragged
+        if (dragAnchor_right != NULL) {
+            if (draw_mode == MODE_SCALEROTATE) {
+                if (backupowner == RIGHT) {
+                    double cx = rectcenter.x, cy = rectcenter.y; // center x,y
+                    double diameter = sqrt(pow(rectbound2[0].x - rectbound2[2].x, 2) + pow(rectbound2[0].y - rectbound2[2].y, 2));
+                    double radius = diameter / 2;
+                    double old_dx = dragAnchor_right->x - cx, old_dy = dragAnchor_right->y - cy;
+                    double new_dx = mouse_point.x - cx, new_dy = mouse_point.y - cy;
+                    double old_angle = atan2(old_dy, old_dx);
+                    double new_angle = atan2(new_dy, new_dx);
+                    double delta = new_angle - old_angle;
+                    for (int i = 0; i < 4; i++) {
+                        old_dx = backup[i].x - cx, old_dy = backup[i].y - cy;
+                        old_angle = atan2(old_dy, old_dx);
+                        new_angle = old_angle + delta;
+                        new_dx = radius * cos(new_angle), new_dy = radius * sin(new_angle);
+                        rectbound2[i].x = (int)(new_dx + cx), rectbound2[i].y = (int)(new_dy + cy);
+                    }
+                    UpdateNonUniformTransformation();
+                    RefreshDisplay();
+                    undodesc = _T("Rotate");
+                }
+            }
+            else if (CanMove()) {
+                MoveCanvas(xx - dragAnchor_right->x, yy - dragAnchor_right->y);
+                dragAnchor_right->x = xx;
+                dragAnchor_right->y = yy;
+                RefreshDisplay();
+            }
+        }
+    }
+    else if (!preview_mode) { // not dragging and not preview mode
+        if (IsTransformMode()) {
+            int oldrectbound = rectbound2upd;
+            rectbound2upd = -1;
+            rectbound2upd2 = -1;
+            for (int i = 0; i < 4; i++) {
+                if (abs((int)rectbound2[i].x - mouse_point.x) <= pointsys->scale
+                    && abs((int)rectbound2[i].y - mouse_point.y) <= pointsys->scale)
+                    rectbound2upd = i;
+            }
+            for (int i = 0; rectbound2upd == -1 && i < 4; i++) {
+                int j = (i + 1) % 4;
+                wxRealPoint &pi = rectbound2[i], &pj = rectbound2[j];
+                double dy = fabs(pj.y - pi.y);
+                double dy3 = dy / 3;
+                double dx = fabs(pj.x - pi.x);
+                double dx3 = dx / 3;
+                double ix, iy;
+                bool intersect = false;
+                if (dy > dx) {
+                    intersect = agg::calc_intersection(
+                                    pi.x, pi.y, pj.x, pj.y,
+                                    mouse_point.x - pointsys->scale, mouse_point.y,
+                                    mouse_point.x + pointsys->scale, mouse_point.y, &ix, &iy);
+                    intersect &= fabs(mouse_point.x - ix) <= pointsys->scale;
+                    intersect &= (pj.y > pi.y ?
+                                  pj.y - dy3 > iy && iy > pi.y + dy3 :
+                                  pj.y + dy3 < iy && iy < pi.y - dy3);
+                }
+                else {
+                    intersect = agg::calc_intersection(
+                                    pi.x, pi.y, pj.x, pj.y,
+                                    mouse_point.x, mouse_point.y - pointsys->scale,
+                                    mouse_point.x, mouse_point.y + pointsys->scale, &ix, &iy);
+                    intersect &= fabs(mouse_point.y - iy) <= pointsys->scale;
+                    intersect &= (pj.x > pi.x ?
+                                  pj.x - dx3 > ix && ix > pi.x + dx3 :
+                                  pj.x + dx3 < ix && ix < pi.x - dx3);
+                }
+                if (intersect) {
+                    rectbound2upd = i;
+                    rectbound2upd2 = j;
+                }
+            }
+            if (rectbound2upd != -1 || oldrectbound != -1)
+                RefreshDisplay();
+        }
+        else {
+            /* figure out if the mouse is pointing at a point of a command
+               we need not do this for dragging since this same block has set
+               the related variables before the user starts to hold the button
+               (well, before you can drag something you have to move the pointer
+               over that thing first, right?) and we don't want to mess with those
+               when it's dragging
+            */
+
+            // check if mouse points on any control point first
+            Point *last_pointedAt_point = pointedAt_point;
+            ControlAt( wx, wy, pointedAt_point );
+
+            // then check if mouse points on any m_points
+            // override any control point set to pointedAt_point above
+            DrawCmd *p = PointAt( wx, wy );
+            if (p != NULL) {
+                pointedAt_point = p->m_point;
+            }
+
+            if (pointedAt_point != last_pointedAt_point) {
+                if (pointedAt_point != NULL)
+                    SetHighlighted( pointedAt_point->cmd_main, pointedAt_point );
+                else
+                    SetHighlighted( NULL, NULL );
+                RefreshDisplay();
+            }
+        }
+    } // not dragging and preview mode = ignore all mouse movements
+
+    // we are not done yet?
     // oh yeah, we need to set the status bar just for fun
-    if (hasStatusBar)
-	{
+    if (hasStatusBar) {
         m_frame->SetStatusText(
             wxString::Format( _T("%5d %5d"), (int)wx, (int)wy ), 0 );
         if (pointedAt_point == NULL ||
-             (newcommand != NULL && !newcommand->initialized) )
-           m_frame->SetStatusText( _T(""), 1 );
+            (newcommand != NULL && !newcommand->initialized) )
+            m_frame->SetStatusText( _T(""), 1 );
         else
-           m_frame->SetStatusText( _T(" ") + pointedAt_point->cmd_main->ToString().Upper(), 1 );
-	}
+            m_frame->SetStatusText( _T(" ") + pointedAt_point->cmd_main->ToString().Upper(), 1 );
+    }
 
 }
 
 // End drag points
-void ASSDrawCanvas::OnMouseLeftUp(wxMouseEvent& event)
+void ASSDrawCanvas::OnMouseLeftUp(wxMouseEvent &event)
 {
-	ProcessOnMouseLeftUp();
-	event.Skip( true );
+    ProcessOnMouseLeftUp();
+    event.Skip( true );
 }
 
 void ASSDrawCanvas::ProcessOnMouseLeftUp()
 {
-	if (!capturemouse_left) return;
-
-	// draw mode
-	if (newcommand != NULL)
-	{
-		newcommand->Init();
-		switch (newcommand->type)
-		{
-		case M:
-			undodesc = _T("Add a new M"); break;
-		case L:
-			undodesc = _T("Add a new L"); break;
-		case B:
-			undodesc = _T("Add a new B"); break;
-		}
-		newcommand = NULL;
-		// we need to manually refresh the GUI to draw the new control points
-		RefreshDisplay();
-	}
-	else if ( draw_mode == MODE_DEL // if it's delete mode
-				&& mousedownAt_point != NULL // and mouse down at a point
-				&& mousedownAt_point == pointedAt_point ) // and released at the same point
-	{
-		// first take care of mouse readings
-		pointedAt_point = NULL;
-		Point *lastmousedownAt_point = mousedownAt_point;
-		mousedownAt_point = NULL;
-
-		// try deleting
-		CMDTYPE t = lastmousedownAt_point->cmd_main->type;
-		if ( DeleteCommand( lastmousedownAt_point->cmd_main ) )
-		{
-			ClearPointsSelection();
-			SetHighlighted( NULL, NULL );
-			RefreshDisplay();
-			switch (t)
-			{
-			case M:
-				undodesc = _T("Delete a M"); break;
-			case L:
-				undodesc = _T("Delete a L"); break;
-			case B:
-				undodesc = _T("Delete a B"); break;
-			}
-		}
-		else
-		{
-			RefreshDisplay(); // redraw before showing the error box
-			wxMessageDialog msgb(m_frame,
-			_T("You must delete that command/point last"),
-			_T("Error"), wxOK | wxICON_EXCLAMATION );
-			msgb.ShowModal();
-		}
-	}
-	else if ( lastDrag_left && dragAnchor_left ) // point selection
-	{
-		if (lastDrag_left && dragAnchor_left != lastDrag_left)
-		    delete lastDrag_left;
-	    delete dragAnchor_left;
-		lastDrag_left = NULL;
-		dragAnchor_left = NULL;
-	}
-
-	if (dragOrigin)
-	{
-		dragOrigin = false;
-		RefreshDisplay(); // clear the crosshair
-	}
-
-	rectbound2upd = -1;
-	rectbound2upd2 = -1;
+    if (!capturemouse_left) return;
+
+    // draw mode
+    if (newcommand != NULL) {
+        newcommand->Init();
+        switch (newcommand->type) {
+        case M:
+            undodesc = _T("Add a new M"); break;
+        case L:
+            undodesc = _T("Add a new L"); break;
+        case B:
+            undodesc = _T("Add a new B"); break;
+        }
+        newcommand = NULL;
+        // we need to manually refresh the GUI to draw the new control points
+        RefreshDisplay();
+    }
+    else if ( draw_mode == MODE_DEL // if it's delete mode
+              && mousedownAt_point != NULL // and mouse down at a point
+              && mousedownAt_point == pointedAt_point ) { // and released at the same point
+        // first take care of mouse readings
+        pointedAt_point = NULL;
+        Point *lastmousedownAt_point = mousedownAt_point;
+        mousedownAt_point = NULL;
+
+        // try deleting
+        CMDTYPE t = lastmousedownAt_point->cmd_main->type;
+        if ( DeleteCommand( lastmousedownAt_point->cmd_main ) ) {
+            ClearPointsSelection();
+            SetHighlighted( NULL, NULL );
+            RefreshDisplay();
+            switch (t) {
+            case M:
+                undodesc = _T("Delete a M"); break;
+            case L:
+                undodesc = _T("Delete a L"); break;
+            case B:
+                undodesc = _T("Delete a B"); break;
+            }
+        }
+        else {
+            RefreshDisplay(); // redraw before showing the error box
+            wxMessageDialog msgb(m_frame,
+                                 _T("You must delete that command/point last"),
+                                 _T("Error"), wxOK | wxICON_EXCLAMATION );
+            msgb.ShowModal();
+        }
+    }
+    else if ( lastDrag_left && dragAnchor_left ) { // point selection
+        if (lastDrag_left && dragAnchor_left != lastDrag_left)
+            delete lastDrag_left;
+        delete dragAnchor_left;
+        lastDrag_left = NULL;
+        dragAnchor_left = NULL;
+    }
+
+    if (dragOrigin) {
+        dragOrigin = false;
+        RefreshDisplay(); // clear the crosshair
+    }
+
+    rectbound2upd = -1;
+    rectbound2upd2 = -1;
     backupowner = NONE;
 
-	if (!undodesc.IsSameAs(_T("")))
-	{
-		AddUndo( undodesc );
-		undodesc = _T("");
-		RefreshUndocmds();
-	}
+    if (!undodesc.IsSameAs(_T(""))) {
+        AddUndo( undodesc );
+        undodesc = _T("");
+        RefreshUndocmds();
+    }
 
-	mousedownAt_point = NULL;
+    mousedownAt_point = NULL;
 
-	if (HasCapture())
-		ReleaseMouse();
-	capturemouse_left = false;
+    if (HasCapture())
+        ReleaseMouse();
+    capturemouse_left = false;
 
-	RefreshDisplay();
+    RefreshDisplay();
 }
 
 // Set up to drag points, if any
-void ASSDrawCanvas::OnMouseLeftDown(wxMouseEvent& event)
+void ASSDrawCanvas::OnMouseLeftDown(wxMouseEvent &event)
 {
 
     // no drawing in preview mode
-	if (preview_mode)
-		return;
-
-	wxPoint q = event.GetPosition();
-
-	// wxPoint to Point
-	int px, py;
-	pointsys->FromWxPoint(q, px, py);
-
-	// create new cmd if in draw mode / or delete point if del tool selected
-	switch (draw_mode)
-	{
-	case MODE_M:
-		newcommand = NewCmd(M, px, py);
-		break;
-	case MODE_L:
-		newcommand = NewCmd(L, px, py);
-		break;
-	case MODE_B:
-		newcommand = NewCmd(B, px, py);
-		break;
-	}
-
-	// continue working on the new command (if any)
-	// only if it is not mouse down on any control point
-	if (newcommand != NULL)
-	{
-		if (pointedAt_point != NULL && pointedAt_point->type == CP)
-		{
-			// oops, user clicked on a control point so cancel new command
-			// and let him drag the control point
-			delete newcommand;
+    if (preview_mode)
+        return;
+
+    wxPoint q = event.GetPosition();
+
+    // wxPoint to Point
+    int px, py;
+    pointsys->FromWxPoint(q, px, py);
+
+    // create new cmd if in draw mode / or delete point if del tool selected
+    switch (draw_mode) {
+    case MODE_M:
+        newcommand = NewCmd(M, px, py);
+        break;
+    case MODE_L:
+        newcommand = NewCmd(L, px, py);
+        break;
+    case MODE_B:
+        newcommand = NewCmd(B, px, py);
+        break;
+    }
+
+    // continue working on the new command (if any)
+    // only if it is not mouse down on any control point
+    if (newcommand != NULL) {
+        if (pointedAt_point != NULL && pointedAt_point->type == CP) {
+            // oops, user clicked on a control point so cancel new command
+            // and let him drag the control point
+            delete newcommand;
             newcommand = NULL;
-		}
-		else
-		{
-			// first set to drag the new command no matter what
-			mousedownAt_point = newcommand->m_point;
-
-			// if user drags from existing point, insert the new command
-			// else append the new command
-			if (pointedAt_point != NULL)
-				InsertCmd( newcommand, pointedAt_point->cmd_main );
-			else
-			{
-				if (cmds.empty() && newcommand->type != M)
-					AppendCmd( M, px, py );
-				newcommand = AppendCmd( newcommand );
-			}
-
-			pointedAt_point = mousedownAt_point;
-
-			//highlight it
-			SetHighlighted( newcommand, newcommand->m_point );
-		}
-	}
-
-	// we already calculated pointedAt_point in OnMouseMove() so just use it
-	mousedownAt_point = pointedAt_point;
-	SELECTMODE smode = GetSelectMode(event);
-	if (mousedownAt_point && !mousedownAt_point->isselected)
-	{
-		if (smode == NEW)
-		{
-			ClearPointsSelection();
-			mousedownAt_point->isselected = true;
-			selected_points.insert(mousedownAt_point);
-		}
-		else
-		{
-			wxPoint wxp = mousedownAt_point->ToWxPoint();
-			SelectPointsWithin(wxp.x, wxp.x, wxp.y, wxp.y, smode);
-		}
-	}
-	else if (!mousedownAt_point && smode == NEW)
-		ClearPointsSelection();
-
-	if ( mousedownAt_point == NULL && px == 0 && py == 0 )
-		dragOrigin = true;
-
-	if ( mousedownAt_point == NULL && !dragOrigin )
-	{
-		dragAnchor_left = new wxPoint(q.x, q.y);
-		lastDrag_left = dragAnchor_left;
-	}
-
-	if (InitiateDraggingIfTransformMode())
-	    backupowner = LEFT;
-
-	CaptureMouse();
-	capturemouse_left = true;
-	RefreshDisplay();
-
-	event.Skip( true );
+        }
+        else {
+            // first set to drag the new command no matter what
+            mousedownAt_point = newcommand->m_point;
+
+            // if user drags from existing point, insert the new command
+            // else append the new command
+            if (pointedAt_point != NULL)
+                InsertCmd( newcommand, pointedAt_point->cmd_main );
+            else {
+                if (cmds.empty() && newcommand->type != M)
+                    AppendCmd( M, px, py );
+                newcommand = AppendCmd( newcommand );
+            }
+
+            pointedAt_point = mousedownAt_point;
+
+            //highlight it
+            SetHighlighted( newcommand, newcommand->m_point );
+        }
+    }
+
+    // we already calculated pointedAt_point in OnMouseMove() so just use it
+    mousedownAt_point = pointedAt_point;
+    SELECTMODE smode = GetSelectMode(event);
+    if (mousedownAt_point && !mousedownAt_point->isselected) {
+        if (smode == NEW) {
+            ClearPointsSelection();
+            mousedownAt_point->isselected = true;
+            selected_points.insert(mousedownAt_point);
+        }
+        else {
+            wxPoint wxp = mousedownAt_point->ToWxPoint();
+            SelectPointsWithin(wxp.x, wxp.x, wxp.y, wxp.y, smode);
+        }
+    }
+    else if (!mousedownAt_point && smode == NEW)
+        ClearPointsSelection();
+
+    if ( mousedownAt_point == NULL && px == 0 && py == 0 )
+        dragOrigin = true;
+
+    if ( mousedownAt_point == NULL && !dragOrigin ) {
+        dragAnchor_left = new wxPoint(q.x, q.y);
+        lastDrag_left = dragAnchor_left;
+    }
+
+    if (InitiateDraggingIfTransformMode())
+        backupowner = LEFT;
+
+    CaptureMouse();
+    capturemouse_left = true;
+    RefreshDisplay();
+
+    event.Skip( true );
 }
 
 // End drag the canvas
-void ASSDrawCanvas::OnMouseRightUp(wxMouseEvent& event)
+void ASSDrawCanvas::OnMouseRightUp(wxMouseEvent &event)
 {
-	ProcessOnMouseRightUp();
-	event.Skip( true );
+    ProcessOnMouseRightUp();
+    event.Skip( true );
 }
 
 void ASSDrawCanvas::ProcessOnMouseRightUp()
 {
-	if (!capturemouse_right) return;
+    if (!capturemouse_right) return;
 
     if (lastDrag_right && dragAnchor_right != lastDrag_right)
         delete lastDrag_right;
     if (dragAnchor_right)
         delete dragAnchor_right;
-	dragAnchor_right = NULL;
-	lastDrag_right = NULL;
+    dragAnchor_right = NULL;
+    lastDrag_right = NULL;
 
-	// don't crash the program
-	if (HasCapture())
-		ReleaseMouse();
-	capturemouse_right = false;
+    // don't crash the program
+    if (HasCapture())
+        ReleaseMouse();
+    capturemouse_right = false;
 
-	rectbound2upd = -1;
-	rectbound2upd2 = -1;
+    rectbound2upd = -1;
+    rectbound2upd2 = -1;
     backupowner = NONE;
 
-	if (!undodesc.IsSameAs(_T("")))
-	{
-		AddUndo( undodesc );
-		undodesc = _T("");
-		RefreshUndocmds();
-	}
+    if (!undodesc.IsSameAs(_T(""))) {
+        AddUndo( undodesc );
+        undodesc = _T("");
+        RefreshUndocmds();
+    }
 
-	RefreshDisplay();
-	SetFocus();
+    RefreshDisplay();
+    SetFocus();
 }
 
 // Set up to drag the canvas
 void ASSDrawCanvas::OnMouseRightDown(wxMouseEvent &event)
 {
-	wxPoint q = event.GetPosition();
-	dragAnchor_right = new wxPoint(q.x, q.y);
-	lastDrag_right = dragAnchor_right;
-	CaptureMouse();
-	capturemouse_right = true;
+    wxPoint q = event.GetPosition();
+    dragAnchor_right = new wxPoint(q.x, q.y);
+    lastDrag_right = dragAnchor_right;
+    CaptureMouse();
+    capturemouse_right = true;
 
-	if (InitiateDraggingIfTransformMode())
-	    backupowner = RIGHT;
+    if (InitiateDraggingIfTransformMode())
+        backupowner = RIGHT;
 
-	event.Skip( true );
+    event.Skip( true );
 }
 
 // Reset to point-and-drag mode
-void ASSDrawCanvas::OnMouseRightDClick(wxMouseEvent& event)
+void ASSDrawCanvas::OnMouseRightDClick(wxMouseEvent &event)
 {
-	wxMenu* menu = new wxMenu();
+    wxMenu *menu = new wxMenu();
 
-	if (pointedAt_point)
-	{
-		ProcessOnMouseLeftUp();
-		ProcessOnMouseRightUp();
-		dblclicked_point_right = pointedAt_point;
-		pointedAt_point = NULL;
-		wxMenuItem *cmdmenuitem = new wxMenuItem(menu, MENU_DUMMY, dblclicked_point_right->cmd_main->ToString());
+    if (pointedAt_point) {
+        ProcessOnMouseLeftUp();
+        ProcessOnMouseRightUp();
+        dblclicked_point_right = pointedAt_point;
+        pointedAt_point = NULL;
+        wxMenuItem *cmdmenuitem = new wxMenuItem(menu, MENU_DUMMY, dblclicked_point_right->cmd_main->ToString());
 #ifdef __WINDOWS__
-		wxFont f = cmdmenuitem->GetFont();
-		f.SetWeight(wxFONTWEIGHT_BOLD);
-		cmdmenuitem->SetFont(f);
+        wxFont f = cmdmenuitem->GetFont();
+        f.SetWeight(wxFONTWEIGHT_BOLD);
+        cmdmenuitem->SetFont(f);
 #endif
-		menu->Append(cmdmenuitem);
-		menu->Enable(MENU_DUMMY, false);
-		switch (dblclicked_point_right->cmd_main->type)
-		{
-			case L:
-				menu->Append(MENU_DRC_LNTOBEZ, _T("Convert to Bezier curve (B command)"));
-				break;
-			case B:
-				if (dblclicked_point_right->type != MP) break;
-				menu->AppendCheckItem(MENU_DRC_BEZTOLN, _T("Convert to line (L command)"));
-				if (dblclicked_point_right->cmd_next && dblclicked_point_right->cmd_next->type == B)
-				{
-					menu->AppendCheckItem(MENU_DRC_C1CONTBEZ, _T("Smooth connection"));
-					if (static_cast<DrawCmd_B*>(dblclicked_point_right->cmd_main)->C1Cont)
-						menu->Check(MENU_DRC_C1CONTBEZ, true);
-				}
-				break;
-		}
-
-	}
-	else
-	{
-		menu->Append(MENU_DRC_MOVE00, _T("Move [0,0] here"));
-		menu->AppendSeparator();
-		menu->AppendRadioItem(MODE_ARR, _T("Mode: D&rag"));
-		menu->AppendRadioItem(MODE_M, _T("Mode: Draw &M"));
-		menu->AppendRadioItem(MODE_L, _T("Mode: Draw &L"));
-		menu->AppendRadioItem(MODE_B, _T("Mode: Draw &B"));
-		menu->AppendRadioItem(MODE_DEL, _T("Mode: &Delete"));
-		menu->Check(GetDrawMode(), true);
-	}
-
-	if (menu->GetMenuItemCount() > 0) // only if there is menu item
-	{
-		SetHighlighted(NULL, NULL);
-		mousedownAt_point = NULL;
-		RefreshDisplay();
-		PopupMenu(menu);
-	}
-	delete menu;
-
-	event.Skip( true );
+        menu->Append(cmdmenuitem);
+        menu->Enable(MENU_DUMMY, false);
+        switch (dblclicked_point_right->cmd_main->type) {
+        case L:
+            menu->Append(MENU_DRC_LNTOBEZ, _T("Convert to Bezier curve (B command)"));
+            break;
+        case B:
+            if (dblclicked_point_right->type != MP) break;
+            menu->AppendCheckItem(MENU_DRC_BEZTOLN, _T("Convert to line (L command)"));
+            if (dblclicked_point_right->cmd_next && dblclicked_point_right->cmd_next->type == B) {
+                menu->AppendCheckItem(MENU_DRC_C1CONTBEZ, _T("Smooth connection"));
+                if (static_cast<DrawCmd_B *>(dblclicked_point_right->cmd_main)->C1Cont)
+                    menu->Check(MENU_DRC_C1CONTBEZ, true);
+            }
+            break;
+        }
+
+    }
+    else {
+        menu->Append(MENU_DRC_MOVE00, _T("Move [0,0] here"));
+        menu->AppendSeparator();
+        menu->AppendRadioItem(MODE_ARR, _T("Mode: D&rag"));
+        menu->AppendRadioItem(MODE_M, _T("Mode: Draw &M"));
+        menu->AppendRadioItem(MODE_L, _T("Mode: Draw &L"));
+        menu->AppendRadioItem(MODE_B, _T("Mode: Draw &B"));
+        menu->AppendRadioItem(MODE_DEL, _T("Mode: &Delete"));
+        menu->Check(GetDrawMode(), true);
+    }
+
+    if (menu->GetMenuItemCount() > 0) { // only if there is menu item
+        SetHighlighted(NULL, NULL);
+        mousedownAt_point = NULL;
+        RefreshDisplay();
+        PopupMenu(menu);
+    }
+    delete menu;
+
+    event.Skip( true );
 }
 
 bool ASSDrawCanvas::InitiateDraggingIfTransformMode()
 {
-	if (IsTransformMode() && isshapetransformable && backupowner == NONE)
-	{
-		for (int i = 0; i < 4; i++)
-			backup[i] = rectbound2[i];
-		UpdateTranformModeRectCenter();
-		return true;
-	}
-	else
-		return false;
+    if (IsTransformMode() && isshapetransformable && backupowner == NONE) {
+        for (int i = 0; i < 4; i++)
+            backup[i] = rectbound2[i];
+        UpdateTranformModeRectCenter();
+        return true;
+    }
+    else
+        return false;
 }
 
 void ASSDrawCanvas::UpdateTranformModeRectCenter()
 {
-	double cx, cy;
-	if (agg::calc_intersection(rectbound2[0].x, rectbound2[0].y, rectbound2[2].x, rectbound2[2].y,
-		rectbound2[1].x, rectbound2[1].y, rectbound2[3].x, rectbound2[3].y, &cx, &cy))
-	{
-		rectcenter = wxRealPoint(cx, cy);
-	}
+    double cx, cy;
+    if (agg::calc_intersection(rectbound2[0].x, rectbound2[0].y, rectbound2[2].x, rectbound2[2].y,
+                               rectbound2[1].x, rectbound2[1].y, rectbound2[3].x, rectbound2[3].y, &cx, &cy)) {
+        rectcenter = wxRealPoint(cx, cy);
+    }
 }
 
 bool ASSDrawCanvas::GetThe4thPoint(double ox, double oy, double a1x, double a1y, double a2x, double a2y, double *x, double *y)
 {
-	*x = a1x + a2x - ox;
-	*y = a1y + a2y - oy;
-	return true;
+    *x = a1x + a2x - ox;
+    *y = a1y + a2y - oy;
+    return true;
 }
 
 // Mousewheel
 void ASSDrawCanvas::OnMouseWheel(wxMouseEvent &event)
 {
-	double amount = event.GetWheelRotation() / event.GetWheelDelta();
-	if (event.ControlDown()) amount /= 10.0;
-	bgimg.new_center = wxRealPoint(mouse_point.x, mouse_point.y);
-	ChangeZoomLevel( amount, mouse_point );
+    double amount = event.GetWheelRotation() / event.GetWheelDelta();
+    if (event.ControlDown()) amount /= 10.0;
+    bgimg.new_center = wxRealPoint(mouse_point.x, mouse_point.y);
+    ChangeZoomLevel( amount, mouse_point );
 }
 
 void ASSDrawCanvas::ChangeZoomLevelTo( double zoom, wxPoint bgzoomctr )
 {
-	ChangeZoomLevel(zoom - pointsys->scale, bgzoomctr);
+    ChangeZoomLevel(zoom - pointsys->scale, bgzoomctr);
 }
 
 void ASSDrawCanvas::ChangeZoomLevel( double amount, wxPoint bgzoomctr )
 {
-	double old_scale = pointsys->scale;
-	if (CanZoom() && drag_mode.drawing)
-		ChangeDrawingZoomLevel( amount );
+    double old_scale = pointsys->scale;
+    if (CanZoom() && drag_mode.drawing)
+        ChangeDrawingZoomLevel( amount );
 
-	if (CanZoom() && drag_mode.bgimg)
-		if (drag_mode.drawing)
-		    ChangeBackgroundZoomLevel(bgimg.scale * pointsys->scale / old_scale, wxRealPoint(pointsys->originx, pointsys->originy));
-		else
-		    ChangeBackgroundZoomLevel(bgimg.scale + amount / 10.0,  wxRealPoint(bgzoomctr.x, bgzoomctr.y));
+    if (CanZoom() && drag_mode.bgimg)
+        if (drag_mode.drawing)
+            ChangeBackgroundZoomLevel(bgimg.scale * pointsys->scale / old_scale, wxRealPoint(pointsys->originx, pointsys->originy));
+        else
+            ChangeBackgroundZoomLevel(bgimg.scale + amount / 10.0,  wxRealPoint(bgzoomctr.x, bgzoomctr.y));
 
-	RefreshDisplay();
+    RefreshDisplay();
 }
 
 void ASSDrawCanvas::ChangeDrawingZoomLevel( double scrollamount )
 {
-	if (!CanZoom()) return;
+    if (!CanZoom()) return;
     double zoom = pointsys->scale + scrollamount;
-    if (zoom <= 50.0)
-	{
-		if (zoom < 1.0) zoom = 1.0;
-		pointsys->scale = zoom;
-	}
+    if (zoom <= 50.0) {
+        if (zoom < 1.0) zoom = 1.0;
+        pointsys->scale = zoom;
+    }
 
-	m_frame->UpdateFrameUI();
+    m_frame->UpdateFrameUI();
 }
 
 void ASSDrawCanvas::ChangeBackgroundZoomLevel(double zoom, wxRealPoint newcenter)
 {
-	bgimg.new_scale = zoom;
-	bgimg.new_center = newcenter;
-	if (bgimg.new_scale < 0.01) bgimg.new_scale = 0.01;
-	UpdateBackgroundImgScalePosition();
+    bgimg.new_scale = zoom;
+    bgimg.new_center = newcenter;
+    if (bgimg.new_scale < 0.01) bgimg.new_scale = 0.01;
+    UpdateBackgroundImgScalePosition();
 }
 
 void ASSDrawCanvas::MoveCanvasOriginTo(double originx, double originy)
 {
-	MoveCanvas(originx - pointsys->originx, originy - pointsys->originy);
+    MoveCanvas(originx - pointsys->originx, originy - pointsys->originy);
 }
 
 void ASSDrawCanvas::MoveCanvas(double xamount, double yamount)
 {
-	if (CanMove() && drag_mode.drawing)
-		MoveCanvasDrawing(xamount, yamount);
-	if (CanMove() && drag_mode.bgimg)
-		MoveCanvasBackground(xamount, yamount);
+    if (CanMove() && drag_mode.drawing)
+        MoveCanvasDrawing(xamount, yamount);
+    if (CanMove() && drag_mode.bgimg)
+        MoveCanvasBackground(xamount, yamount);
 }
 
 void ASSDrawCanvas::MoveCanvasDrawing(double xamount, double yamount)
 {
-	if (!CanMove()) return;
-	pointsys->originx += xamount;
-	pointsys->originy += yamount;
-	if (IsTransformMode())
-	{
-	    for (int i = 0; i < 4; i++)
-	    {
-	    	rectbound[i].x += (int) xamount;
-	    	rectbound[i].y += (int) yamount;
-	    	rectbound2[i].x += (int) xamount;
-	    	rectbound2[i].y += (int) yamount;
-		}
-		unsigned vertices = backupcmds.total_vertices();
-		double x, y;
-		for (int i = 0; i < vertices; i++)
-		{
-			backupcmds.vertex(i, &x, &y);
-	        backupcmds.modify_vertex(i, x + xamount, y + yamount);
-		}
-	}
+    if (!CanMove()) return;
+    pointsys->originx += xamount;
+    pointsys->originy += yamount;
+    if (IsTransformMode()) {
+        for (int i = 0; i < 4; i++) {
+            rectbound[i].x += (int) xamount;
+            rectbound[i].y += (int) yamount;
+            rectbound2[i].x += (int) xamount;
+            rectbound2[i].y += (int) yamount;
+        }
+        unsigned vertices = backupcmds.total_vertices();
+        double x, y;
+        for (int i = 0; i < vertices; i++) {
+            backupcmds.vertex(i, &x, &y);
+            backupcmds.modify_vertex(i, x + xamount, y + yamount);
+        }
+    }
 }
 
 void ASSDrawCanvas::MoveCanvasBackground(double xamount, double yamount)
 {
-	bgimg.new_disp.x += xamount;
-	bgimg.new_disp.y += yamount;
-	UpdateBackgroundImgScalePosition();
-}
-
-void ASSDrawCanvas::OnSelect_ConvertLineToBezier(wxCommandEvent&)
-{
-	if (!dblclicked_point_right) return;
-	AddUndo( _T("Convert Line to Bezier") );
-	DrawCmd_B *newB = new DrawCmd_B(dblclicked_point_right->x(), dblclicked_point_right->y(),
-		pointsys, dblclicked_point_right->cmd_main);
-	InsertCmd ( newB, dblclicked_point_right->cmd_main );
-	ClearPointsSelection();
-	SetHighlighted(NULL, NULL);
-	DeleteCommand(dblclicked_point_right->cmd_main);
-	pointedAt_point = newB->m_point;
-	newB->Init();
-	RefreshDisplay();
-	RefreshUndocmds();
-}
-
-void ASSDrawCanvas::OnSelect_ConvertBezierToLine(wxCommandEvent&)
-{
-	if (!dblclicked_point_right) return;
-	AddUndo( _T("Convert Bezier to Line") );
-	DrawCmd_L *newL = new DrawCmd_L(dblclicked_point_right->x(), dblclicked_point_right->y(), pointsys, dblclicked_point_right->cmd_main);
-	InsertCmd ( newL, dblclicked_point_right->cmd_main );
-	ClearPointsSelection();
-	SetHighlighted(NULL, NULL);
-	DeleteCommand(dblclicked_point_right->cmd_main);
-	pointedAt_point = newL->m_point;
-	newL->Init();
-	RefreshDisplay();
-	RefreshUndocmds();
-}
-
-void ASSDrawCanvas::OnSelect_C1ContinuityBezier(wxCommandEvent&)
-{
-	if (!dblclicked_point_right) return;
-	DrawCmd_B *cmdb = static_cast<DrawCmd_B*>(dblclicked_point_right->cmd_main);
-	AddUndo( cmdb->C1Cont? _T("Unset continuous"):_T("Set continuous") );
-	cmdb->C1Cont = !cmdb->C1Cont;
-	RefreshUndocmds();
-}
-
-void ASSDrawCanvas::OnSelect_Move00Here(wxCommandEvent&)
-{
-	AddUndo( _T("Move origin") );
-	int wx, wy;
-	pointsys->FromWxPoint(mouse_point, wx, wy);
-	wxPoint wxp = pointsys->ToWxPoint(wx, wy);
-	pointsys->originx = wxp.x;
-	pointsys->originy = wxp.y;
-	MovePoints(-wx, -wy);
-	RefreshDisplay();
-	RefreshUndocmds();
-}
-
-void ASSDrawCanvas::ConnectSubsequentCmds (DrawCmd* cmd1, DrawCmd* cmd2)
-{
-	ASSDrawEngine::ConnectSubsequentCmds(cmd1, cmd2);
-	if (cmd1 && cmd1->type == B)
-	{
-		DrawCmd_B *cmd1b = static_cast< DrawCmd_B* >(cmd1);
-		cmd1b->C1Cont = false;
-	}
-}
-
-void ASSDrawCanvas::EnforceC1Continuity (DrawCmd* cmd, Point* pnt)
-{
-	if (!cmd || !pnt) return;
-	if (cmd->type != B && cmd->type != S) return;
-	if (pnt->type == MP) return;
-	Point *theotherpoint, *mainpoint;
-	if (pnt->num == 1)
-	{
-		if (!cmd->prev || (cmd->prev->type != B && cmd->prev->type != S)) return;
-		DrawCmd_B *prevb = static_cast< DrawCmd_B* >(cmd->prev);
-		if (!prevb->C1Cont) return;
-		PointList::iterator it = prevb->controlpoints.end();
-		it--;
-		theotherpoint = *it;
-		mainpoint = prevb->m_point;
-	}
-	else if (pnt->num = cmd->controlpoints.size())
-	{
-		DrawCmd_B *thisb = static_cast< DrawCmd_B* >(cmd);
-		if (!thisb->C1Cont) return;
-		theotherpoint = *(cmd->m_point->cmd_next->controlpoints.begin());
-		mainpoint = thisb->m_point;
-	}
-	else
-		return;
-	theotherpoint->setXY( mainpoint->x() + mainpoint->x() - pnt->x(),
-		mainpoint->y() + mainpoint->y() - pnt->y() );
+    bgimg.new_disp.x += xamount;
+    bgimg.new_disp.y += yamount;
+    UpdateBackgroundImgScalePosition();
+}
+
+void ASSDrawCanvas::OnSelect_ConvertLineToBezier(wxCommandEvent &)
+{
+    if (!dblclicked_point_right) return;
+    AddUndo( _T("Convert Line to Bezier") );
+    DrawCmd_B *newB = new DrawCmd_B(dblclicked_point_right->x(), dblclicked_point_right->y(),
+                                    pointsys, dblclicked_point_right->cmd_main);
+    InsertCmd ( newB, dblclicked_point_right->cmd_main );
+    ClearPointsSelection();
+    SetHighlighted(NULL, NULL);
+    DeleteCommand(dblclicked_point_right->cmd_main);
+    pointedAt_point = newB->m_point;
+    newB->Init();
+    RefreshDisplay();
+    RefreshUndocmds();
+}
+
+void ASSDrawCanvas::OnSelect_ConvertBezierToLine(wxCommandEvent &)
+{
+    if (!dblclicked_point_right) return;
+    AddUndo( _T("Convert Bezier to Line") );
+    DrawCmd_L *newL = new DrawCmd_L(dblclicked_point_right->x(), dblclicked_point_right->y(), pointsys, dblclicked_point_right->cmd_main);
+    InsertCmd ( newL, dblclicked_point_right->cmd_main );
+    ClearPointsSelection();
+    SetHighlighted(NULL, NULL);
+    DeleteCommand(dblclicked_point_right->cmd_main);
+    pointedAt_point = newL->m_point;
+    newL->Init();
+    RefreshDisplay();
+    RefreshUndocmds();
+}
+
+void ASSDrawCanvas::OnSelect_C1ContinuityBezier(wxCommandEvent &)
+{
+    if (!dblclicked_point_right) return;
+    DrawCmd_B *cmdb = static_cast<DrawCmd_B *>(dblclicked_point_right->cmd_main);
+    AddUndo( cmdb->C1Cont ? _T("Unset continuous") : _T("Set continuous") );
+    cmdb->C1Cont = !cmdb->C1Cont;
+    RefreshUndocmds();
+}
+
+void ASSDrawCanvas::OnSelect_Move00Here(wxCommandEvent &)
+{
+    AddUndo( _T("Move origin") );
+    int wx, wy;
+    pointsys->FromWxPoint(mouse_point, wx, wy);
+    wxPoint wxp = pointsys->ToWxPoint(wx, wy);
+    pointsys->originx = wxp.x;
+    pointsys->originy = wxp.y;
+    MovePoints(-wx, -wy);
+    RefreshDisplay();
+    RefreshUndocmds();
+}
+
+void ASSDrawCanvas::ConnectSubsequentCmds (DrawCmd *cmd1, DrawCmd *cmd2)
+{
+    ASSDrawEngine::ConnectSubsequentCmds(cmd1, cmd2);
+    if (cmd1 && cmd1->type == B) {
+        DrawCmd_B *cmd1b = static_cast< DrawCmd_B * >(cmd1);
+        cmd1b->C1Cont = false;
+    }
+}
+
+void ASSDrawCanvas::EnforceC1Continuity (DrawCmd *cmd, Point *pnt)
+{
+    if (!cmd || !pnt) return;
+    if (cmd->type != B && cmd->type != S) return;
+    if (pnt->type == MP) return;
+    Point *theotherpoint, *mainpoint;
+    if (pnt->num == 1) {
+        if (!cmd->prev || (cmd->prev->type != B && cmd->prev->type != S)) return;
+        DrawCmd_B *prevb = static_cast< DrawCmd_B * >(cmd->prev);
+        if (!prevb->C1Cont) return;
+        PointList::iterator it = prevb->controlpoints.end();
+        it--;
+        theotherpoint = *it;
+        mainpoint = prevb->m_point;
+    }
+    else if (pnt->num = cmd->controlpoints.size()) {
+        DrawCmd_B *thisb = static_cast< DrawCmd_B * >(cmd);
+        if (!thisb->C1Cont) return;
+        theotherpoint = *(cmd->m_point->cmd_next->controlpoints.begin());
+        mainpoint = thisb->m_point;
+    }
+    else
+        return;
+    theotherpoint->setXY( mainpoint->x() + mainpoint->x() - pnt->x(),
+                          mainpoint->y() + mainpoint->y() - pnt->y() );
 }
 
 // Undo/Redo system
 void ASSDrawCanvas::AddUndo( wxString desc )
 {
-	PrepareUndoRedo(_undo, false, _T(""), desc);
-	undos.push_back( _undo );
-	// also empty redos
-	redos.clear();
-	m_frame->UpdateUndoRedoMenu();
+    PrepareUndoRedo(_undo, false, _T(""), desc);
+    undos.push_back( _undo );
+    // also empty redos
+    redos.clear();
+    m_frame->UpdateUndoRedoMenu();
 }
 
 bool ASSDrawCanvas::UndoOrRedo(bool isundo)
 {
-	std::list<UndoRedo>* main = (isundo? &undos:&redos);
-	std::list<UndoRedo>* sub = (isundo? &redos:&undos);
-
-	if (main->empty())
-		return false;
-
-	UndoRedo r = main->back();
-	// push into sub
-	UndoRedo nr(r);
-	PrepareUndoRedo(nr, true, GenerateASS(), r.desc);
-	sub->push_back( nr );
-	// parse
-	r.Export(this);
-	// delete that
-	std::list<UndoRedo>::iterator iter = main->end();
-	iter--;
-	main->erase(iter);
-
-	// reset some values before refreshing
-	mousedownAt_point = NULL;
-	pointedAt_point = NULL;
-	SetHighlighted ( NULL, NULL );
-	ClearPointsSelection();
-	RefreshDisplay();
-	RefreshUndocmds();
-	return true;
+    std::list<UndoRedo> *main = (isundo ? &undos : &redos);
+    std::list<UndoRedo> *sub = (isundo ? &redos : &undos);
+
+    if (main->empty())
+        return false;
+
+    UndoRedo r = main->back();
+    // push into sub
+    UndoRedo nr(r);
+    PrepareUndoRedo(nr, true, GenerateASS(), r.desc);
+    sub->push_back( nr );
+    // parse
+    r.Export(this);
+    // delete that
+    std::list<UndoRedo>::iterator iter = main->end();
+    iter--;
+    main->erase(iter);
+
+    // reset some values before refreshing
+    mousedownAt_point = NULL;
+    pointedAt_point = NULL;
+    SetHighlighted ( NULL, NULL );
+    ClearPointsSelection();
+    RefreshDisplay();
+    RefreshUndocmds();
+    return true;
 }
 
 bool ASSDrawCanvas::Undo()
 {
-	return UndoOrRedo( true );
+    return UndoOrRedo( true );
 }
 
 bool ASSDrawCanvas::Redo()
 {
-	return UndoOrRedo( false );
+    return UndoOrRedo( false );
 }
 
 wxString ASSDrawCanvas::GetTopUndo()
 {
-	if (undos.empty())
-		return _T("");
-	else
-		return undos.back().desc;
+    if (undos.empty())
+        return _T("");
+    else
+        return undos.back().desc;
 }
 
 wxString ASSDrawCanvas::GetTopRedo()
 {
-	if (redos.empty())
-		return _T("");
-	else
-		return redos.back().desc;
+    if (redos.empty())
+        return _T("");
+    else
+        return redos.back().desc;
 }
 
 void ASSDrawCanvas::RefreshUndocmds()
 {
-	_undo.Import(this, true, GenerateASS());
+    _undo.Import(this, true, GenerateASS());
 }
 
-void ASSDrawCanvas::PrepareUndoRedo(UndoRedo& ur, bool prestage, wxString cmds, wxString desc)
+void ASSDrawCanvas::PrepareUndoRedo(UndoRedo &ur, bool prestage, wxString cmds, wxString desc)
 {
-	ur.Import(this, prestage, cmds);
-	ur.desc = desc;
+    ur.Import(this, prestage, cmds);
+    ur.desc = desc;
 }
 
 // set command and point to highlight
-void ASSDrawCanvas::SetHighlighted ( DrawCmd* cmd, Point* point )
+void ASSDrawCanvas::SetHighlighted ( DrawCmd *cmd, Point *point )
 {
-     hilite_cmd = cmd;
-     hilite_point = point;
+    hilite_cmd = cmd;
+    hilite_point = point;
 }
 
 int ASSDrawCanvas::SelectPointsWithin( int lx, int rx, int ty, int by, SELECTMODE smode )
 {
 
-	DrawCmdList::iterator iterate = cmds.begin();
-	for (; iterate != cmds.end(); iterate++)
-	{
-		wxPoint wx = (*iterate)->m_point->ToWxPoint();
+    DrawCmdList::iterator iterate = cmds.begin();
+    for (; iterate != cmds.end(); iterate++) {
+        wxPoint wx = (*iterate)->m_point->ToWxPoint();
 
-		if (wx.x >= lx && wx.x <= rx && wx.y >= ty && wx.y <= by)
-			(*iterate)->m_point->isselected = (smode != DEL);
-		else
-	    	(*iterate)->m_point->isselected &= (smode != NEW);
+        if (wx.x >= lx && wx.x <= rx && wx.y >= ty && wx.y <= by)
+            (*iterate)->m_point->isselected = (smode != DEL);
+        else
+            (*iterate)->m_point->isselected &= (smode != NEW);
 
-		if ((*iterate)->m_point->isselected)
-	    	selected_points.insert((*iterate)->m_point);
-	    else
-			selected_points.erase((*iterate)->m_point);
+        if ((*iterate)->m_point->isselected)
+            selected_points.insert((*iterate)->m_point);
+        else
+            selected_points.erase((*iterate)->m_point);
+
+        PointList::iterator pnt_iterator = (*iterate)->controlpoints.begin();
+        PointList::iterator end = (*iterate)->controlpoints.end();
+        for (; pnt_iterator != end; pnt_iterator++) {
+            wxPoint wx = (*pnt_iterator)->ToWxPoint();
+
+            if (wx.x >= lx && wx.x <= rx && wx.y >= ty && wx.y <= by)
+                (*pnt_iterator)->isselected = (smode != DEL);
+            else
+                (*pnt_iterator)->isselected &= (smode != NEW);
+
+            if ((*pnt_iterator)->isselected)
+                selected_points.insert(*pnt_iterator);
+            else
+                selected_points.erase(*pnt_iterator);
+        }
+    }
 
-		PointList::iterator pnt_iterator = (*iterate)->controlpoints.begin();
-		PointList::iterator end = (*iterate)->controlpoints.end();
-		for (; pnt_iterator != end; pnt_iterator++)
-		{
-			wxPoint wx = (*pnt_iterator)->ToWxPoint();
+    return selected_points.size();
 
-			if (wx.x >= lx && wx.x <= rx && wx.y >= ty && wx.y <= by)
-	    		(*pnt_iterator)->isselected = (smode != DEL);
-		    else
-	    		(*pnt_iterator)->isselected &= (smode != NEW);
+}
 
-			if ((*pnt_iterator)->isselected)
-				selected_points.insert(*pnt_iterator);
-			else
-				selected_points.erase(*pnt_iterator);
-		}
-	}
+void ASSDrawCanvas::ClearPointsSelection()
+{
+    if (!selected_points.empty()) {
+        PointSet::iterator piter = selected_points.begin();
+        for (; piter != selected_points.end(); piter++) {
+            (*piter)->isselected = false;
+        }
+        selected_points.clear();
+    }
+}
 
-	return selected_points.size();
+SELECTMODE ASSDrawCanvas::GetSelectMode(wxMouseEvent &event)
+{
+    SELECTMODE smode = NEW;
+    bool CtrlDown = event.CmdDown();
+    bool AltDown = event.AltDown();
+    if (CtrlDown && !AltDown) smode = ADD;
+    else if (!CtrlDown && AltDown) smode = DEL;
+    return smode;
+}
+
+void ASSDrawCanvas::DoDraw( RendererBase &rbase, RendererPrimitives &rprim, RendererSolid &rsolid, agg::trans_affine &mtx )
+{
+    ASSDrawEngine::Draw_Clear( rbase );
+    int ww, hh; GetClientSize(&ww, &hh);
+
+    if (bgimg.bgbmp) {
+        rasterizer.reset();
+        interpolator_type interpolator(bgimg.img_mtx);
+        PixelFormat::AGGType ipixfmt(bgimg.ibuf);
+        span_gen_type spangen(ipixfmt, agg::rgba_pre(0, 0, 0), interpolator);
+        agg::conv_transform< agg::path_storage > bg_border(bgimg.bg_path, bgimg.path_mtx);
+        agg::conv_clip_polygon< agg::conv_transform< agg::path_storage >> bg_clip(bg_border);
+        bg_clip.clip_box(0, 0, ww, hh);
+        rasterizer.add_path(bg_clip);
+        agg::render_scanlines_aa(rasterizer, scanline, rbase, bgimg.spanalloc, spangen);
+    }
+
+    ASSDrawEngine::Draw_Draw( rbase, rprim, rsolid, mtx, preview_mode ? rgba_shape : rgba_shape_normal );
+
+    if (!preview_mode) {
+        // [0, 0]
+        rasterizer.reset();
+        agg::path_storage org_path;
+        org_path.move_to(0, m_frame->sizes.origincross);
+        org_path.line_to(0, -m_frame->sizes.origincross);
+        org_path.move_to(m_frame->sizes.origincross, 0);
+        org_path.line_to(-m_frame->sizes.origincross, 0);
+        agg::conv_transform< agg::path_storage > org_path_t(org_path, mtx);
+        agg::conv_curve< agg::conv_transform< agg::path_storage >> crosshair(org_path_t);
+        agg::conv_stroke< agg::conv_curve< agg::conv_transform< agg::path_storage >>> chstroke(crosshair);
+        rasterizer.add_path(chstroke);
+        rsolid.color(rgba_origin);
+        render_scanlines(rsolid, false);
+
+        if (IsTransformMode() && isshapetransformable) {
+            if (draw_mode == MODE_SCALEROTATE) {
+                // rotation centerpoint
+                rasterizer.reset();
+                double len = 10.0;
+                org_path.free_all();
+                org_path.move_to(rectcenter.x - len, rectcenter.y - len);
+                org_path.line_to(rectcenter.x + len, rectcenter.y + len);
+                org_path.move_to(rectcenter.x + len, rectcenter.y - len);
+                org_path.line_to(rectcenter.x - len, rectcenter.y + len);
+                agg::conv_stroke< agg::path_storage > cstroke(org_path);
+                rasterizer.add_path(cstroke);
+                agg::ellipse circ(rectcenter.x, rectcenter.y, len, len);
+                agg::conv_stroke< agg::ellipse > c(circ);
+                rasterizer.add_path(c);
+                rsolid.color(rgba_origin);
+                render_scanlines(rsolid, false);
+            }
+
+            rasterizer.reset();
+            agg::path_storage org_path;
+            org_path.move_to(rectbound2[0].x, rectbound2[0].y);
+            org_path.line_to(rectbound2[1].x, rectbound2[1].y);
+            org_path.line_to(rectbound2[2].x, rectbound2[2].y);
+            org_path.line_to(rectbound2[3].x, rectbound2[3].y);
+            org_path.line_to(rectbound2[0].x, rectbound2[0].y);
+            agg::conv_stroke<agg::path_storage> chstroke(org_path);
+            chstroke.width(1);
+            rsolid.color(rgba_origin);
+            rasterizer.add_path(chstroke);
+            if (rectbound2upd != -1) {
+                agg::ellipse circ(rectbound2[rectbound2upd].x, rectbound2[rectbound2upd].y,
+                                  pointsys->scale, pointsys->scale);
+                agg::conv_contour< agg::ellipse > c(circ);
+                rasterizer.add_path(c);
+            }
+            if (rectbound2upd2 != -1) {
+                agg::ellipse circ(rectbound2[rectbound2upd2].x, rectbound2[rectbound2upd2].y,
+                                  pointsys->scale, pointsys->scale);
+                agg::conv_contour< agg::ellipse > c(circ);
+                rasterizer.add_path(c);
+            }
+            render_scanlines(rsolid, false);
+        }
+        else {
+            // outlines
+            agg::conv_stroke< agg::conv_transform< agg::path_storage >> bguidestroke(*rb_path);
+            bguidestroke.width(1);
+            rsolid.color(rgba_guideline);
+            rasterizer.add_path(bguidestroke);
+            render_scanlines(rsolid);
+
+            agg::conv_stroke< agg::conv_curve< agg::conv_transform< agg::path_storage >>> stroke(*rm_curve);
+            stroke.width(1);
+            rsolid.color(rgba_outline);
+            rasterizer.add_path(stroke);
+            render_scanlines(rsolid);
+
+            double diameter = pointsys->scale;
+            double radius = diameter / 2.0;
+            // hilite
+            if (hilite_cmd && hilite_cmd->type != M) {
+                rasterizer.reset();
+                agg::path_storage h_path;
+                AddDrawCmdToAGGPathStorage(hilite_cmd, h_path, HILITE);
+                agg::conv_transform< agg::path_storage> h_path_trans(h_path, mtx);
+                agg::conv_curve< agg::conv_transform< agg::path_storage>> curve(h_path_trans);
+                agg::conv_dash< agg::conv_curve< agg::conv_transform< agg::path_storage >>> d(curve);
+                d.add_dash(10, 5);
+                agg::conv_stroke< agg::conv_dash< agg::conv_curve< agg::conv_transform< agg::path_storage >>>> stroke(d);
+                stroke.width(3);
+                rsolid.color(rgba_outline);
+                rasterizer.add_path(stroke);
+                render_scanlines(rsolid);
+            }
+
+            // m_point
+            rasterizer.reset();
+            DrawCmdList::iterator ci = cmds.begin();
+            while (ci != cmds.end()) {
+                double lx = (*ci)->m_point->x() * pointsys->scale + pointsys->originx - radius;
+                double ty = (*ci)->m_point->y() * pointsys->scale + pointsys->originy - radius;
+                agg::path_storage sqp = agghelper::RectanglePath(lx, lx + diameter, ty, ty + diameter);
+                agg::conv_contour< agg::path_storage > c(sqp);
+                rasterizer.add_path(c);
+                ci++;
+            }
+            render_scanlines_aa_solid(rbase, rgba_mainpoint);
+
+            // control_points
+            rasterizer.reset();
+            ci = cmds.begin();
+            while (ci != cmds.end()) {
+                PointList::iterator pi = (*ci)->controlpoints.begin();
+                while (pi != (*ci)->controlpoints.end()) {
+                    agg::ellipse circ((*pi)->x() * pointsys->scale + pointsys->originx,
+                                      (*pi)->y() * pointsys->scale + pointsys->originy, radius, radius);
+                    agg::conv_contour< agg::ellipse > c(circ);
+                    rasterizer.add_path(c);
+                    pi++;
+                }
+                ci++;
+            }
+            render_scanlines_aa_solid(rbase, rgba_controlpoint);
+
+            // selection
+            rasterizer.reset();
+            PointSet::iterator si = selected_points.begin();
+            while (si != selected_points.end()) {
+                agg::ellipse circ((*si)->x() * pointsys->scale + pointsys->originx,
+                                  (*si)->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3);
+                agg::conv_stroke< agg::ellipse > s(circ);
+                rasterizer.add_path(s);
+                si++;
+            }
+            render_scanlines_aa_solid(rbase, rgba_selectpoint);
+
+            // hover
+            if (hilite_point) {
+                rasterizer.reset();
+                agg::ellipse circ(hilite_point->x() * pointsys->scale + pointsys->originx,
+                                  hilite_point->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3);
+                agg::conv_stroke< agg::ellipse > s(circ);
+                s.width(2);
+                rasterizer.add_path(s);
+                render_scanlines_aa_solid(rbase, rgba_selectpoint);
+
+                rasterizer.reset();
+                agg::gsv_text t;
+                t.flip(true);
+                t.size(8.0);
+                wxPoint pxy = hilite_point->ToWxPoint(true);
+                t.start_point(pxy.x + 5, pxy.y - 5 );
+                t.text(wxString::Format(_T("%d,%d"), hilite_point->x(), hilite_point->y()).mb_str(wxConvUTF8));
+                agg::conv_stroke< agg::gsv_text > pt(t);
+                pt.line_cap(agg::round_cap);
+                pt.line_join(agg::round_join);
+                pt.width(1.5);
+                rasterizer.add_path(pt);
+                rsolid.color(agg::rgba(0, 0, 0));
+                render_scanlines(rsolid, false);
+
+                rasterizer.reset();
+                agg::path_storage sb_path;
+                sb_path.move_to(pxy.x, 0);
+                sb_path.line_to(pxy.x, hh);
+                sb_path.move_to(0, pxy.y);
+                sb_path.line_to(ww, pxy.y);
+                agg::conv_curve< agg::path_storage > curve(sb_path);
+                agg::conv_dash< agg::conv_curve< agg::path_storage >> d(curve);
+                d.add_dash(10, 5);
+                agg::conv_stroke< agg::conv_dash< agg::conv_curve< agg::path_storage >>> stroke(d);
+                stroke.width(1);
+                rsolid.color(agg::rgba(0, 0, 0, 0.5));
+                rasterizer.add_path(stroke);
+                render_scanlines(rsolid);
+            }
+
+            // selection box
+            if (lastDrag_left) {
+                double x1 = lastDrag_left->x, y1 = lastDrag_left->y;
+                double x2 = dragAnchor_left->x, y2 = dragAnchor_left->y;
+                double lx, rx, ty, by;
+                if (x1 < x2) lx = x1, rx = x2;
+                else lx = x2, rx = x1;
+                if (y1 < y2) ty = y1, by = y2;
+                else ty = y2, by = y1;
+                rasterizer.reset();
+                agg::path_storage sb_path = agghelper::RectanglePath(lx, rx, ty, by);
+                agg::conv_curve< agg::path_storage > curve(sb_path);
+                agg::conv_dash< agg::conv_curve< agg::path_storage >> d(curve);
+                d.add_dash(10, 5);
+                agg::conv_stroke< agg::conv_dash< agg::conv_curve< agg::path_storage >>> stroke(d);
+                stroke.width(1.0);
+                rsolid.color(agg::rgba(0, 0, 0, 0.5));
+                rasterizer.add_path(stroke);
+                render_scanlines(rsolid);
+            }
+        }
+    }
+
+    // ruler
+    int w, h;
+    GetClientSize( &w, &h );
+    double scale = pointsys->scale;
+    double coeff = 9 / scale + 1;
+    int numdist = (int) floor(coeff) * 5;
+    {
+        rsolid.color(rgba_ruler_h);
+        rasterizer.reset();
+        agg::path_storage rlr_path;
+        double start = pointsys->originx;
+        int t = - (int) floor(start / scale);
+        double s = (start + t * scale);
+        double collect = s;
+        int len;
+
+        for (; s <= w; s += scale) {
+            bool longtick = t % numdist == 0;
+            if (longtick) {
+                len = 10;
+                agg::gsv_text txt;
+                txt.flip(true);
+                txt.size(6.0);
+                txt.start_point(s, 20);
+                txt.text(wxString::Format(_T("%d"), t).mb_str(wxConvUTF8));
+                agg::conv_stroke< agg::gsv_text > pt(txt);
+                rasterizer.add_path(pt);
+            }
+            else
+                len = 5;
+            t++ ;
+            collect += scale;
+            if (collect > 5.0) {
+                collect = 0.0;
+                rlr_path.move_to(s, 0);
+                rlr_path.line_to(s, len);
+            }
+        }
+        agg::conv_stroke< agg::path_storage > rlr_stroke(rlr_path);
+        rlr_stroke.width(1);
+        rasterizer.add_path(rlr_stroke);
+        render_scanlines(rsolid, false);
+    }
+    {
+        rasterizer.reset();
+        rsolid.color(rgba_ruler_v);
+        agg::path_storage rlr_path;
+        double start = pointsys->originy;
+        int t = - (int) floor(start / scale);
+        double s = (start + t * scale);
+        double collect = 0;
+        int len;
+
+        for (; s <= h; s += scale) {
+            bool longtick = t % numdist == 0;
+            if (longtick) {
+                len = 10;
+                agg::gsv_text txt;
+                txt.flip(true);
+                txt.size(6.0);
+                txt.start_point(12, s);
+                txt.text(wxString::Format(_T("%d"), t).mb_str(wxConvUTF8));
+                agg::conv_stroke< agg::gsv_text > pt(txt);
+                rasterizer.add_path(pt);
+            }
+            else
+                len = 5;
+            t++ ;
+            collect += scale;
+            if (collect > 5.0) {
+                collect = 0.0;
+                rlr_path.move_to(0, s);
+                rlr_path.line_to(len, s);
+            }
+        }
+        agg::conv_stroke< agg::path_storage > rlr_stroke(rlr_path);
+        rlr_stroke.width(1);
+        rasterizer.add_path(rlr_stroke);
+        render_scanlines(rsolid, false);
+    }
 
 }
 
-void ASSDrawCanvas::ClearPointsSelection()
+void ASSDrawCanvas::ReceiveBackgroundImageFileDropEvent(const wxString &filename)
 {
-	if (!selected_points.empty())
-	{
-		PointSet::iterator piter = selected_points.begin();
-		for (; piter != selected_points.end(); piter++)
-		{
-			(*piter)->isselected = false;
-		}
-		selected_points.clear();
-	}
-}
-
-SELECTMODE ASSDrawCanvas::GetSelectMode(wxMouseEvent& event)
-{
-	SELECTMODE smode = NEW;
-	bool CtrlDown = event.CmdDown();
-	bool AltDown = event.AltDown();
-	if (CtrlDown && !AltDown) smode = ADD;
-	else if (!CtrlDown && AltDown) smode = DEL;
-	return smode;
-}
-
-void ASSDrawCanvas::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, RendererSolid& rsolid, agg::trans_affine& mtx )
-{
-	ASSDrawEngine::Draw_Clear( rbase );
-	int ww, hh; GetClientSize(&ww, &hh);
-
-	if (bgimg.bgbmp)
-	{
-		rasterizer.reset();
-	    interpolator_type interpolator(bgimg.img_mtx);
-	    PixelFormat::AGGType ipixfmt(bgimg.ibuf);
-		span_gen_type spangen(ipixfmt, agg::rgba_pre(0, 0, 0), interpolator);
-		agg::conv_transform< agg::path_storage > bg_border(bgimg.bg_path, bgimg.path_mtx);
-		agg::conv_clip_polygon< agg::conv_transform< agg::path_storage > > bg_clip(bg_border);
-		bg_clip.clip_box(0, 0, ww, hh);
-		rasterizer.add_path(bg_clip);
-		agg::render_scanlines_aa(rasterizer, scanline, rbase, bgimg.spanalloc, spangen);
-	}
-
-	ASSDrawEngine::Draw_Draw( rbase, rprim, rsolid, mtx, preview_mode? rgba_shape:rgba_shape_normal );
-
-	if (!preview_mode)
-	{
-		// [0, 0]
-		rasterizer.reset();
-		agg::path_storage org_path;
-		org_path.move_to(0, m_frame->sizes.origincross);
-		org_path.line_to(0, -m_frame->sizes.origincross);
-		org_path.move_to(m_frame->sizes.origincross, 0);
-		org_path.line_to(-m_frame->sizes.origincross, 0);
-		agg::conv_transform< agg::path_storage > org_path_t(org_path, mtx);
-	    agg::conv_curve< agg::conv_transform< agg::path_storage > > crosshair(org_path_t);
-		agg::conv_stroke< agg::conv_curve< agg::conv_transform< agg::path_storage > > > chstroke(crosshair);
-		rasterizer.add_path(chstroke);
-		rsolid.color(rgba_origin);
-		render_scanlines(rsolid, false);
-
-		if (IsTransformMode() && isshapetransformable)
-		{
-			if (draw_mode == MODE_SCALEROTATE)
-			{
-				// rotation centerpoint
-				rasterizer.reset();
-				double len = 10.0;
-				org_path.free_all();
-				org_path.move_to(rectcenter.x - len, rectcenter.y - len);
-				org_path.line_to(rectcenter.x + len, rectcenter.y + len);
-				org_path.move_to(rectcenter.x + len, rectcenter.y - len);
-				org_path.line_to(rectcenter.x - len, rectcenter.y + len);
-				agg::conv_stroke< agg::path_storage > cstroke(org_path);
-				rasterizer.add_path(cstroke);
-				agg::ellipse circ(rectcenter.x, rectcenter.y, len, len);
-				agg::conv_stroke< agg::ellipse > c(circ);
-				rasterizer.add_path(c);
-				rsolid.color(rgba_origin);
-				render_scanlines(rsolid, false);
-			}
-
-			rasterizer.reset();
-			agg::path_storage org_path;
-			org_path.move_to(rectbound2[0].x, rectbound2[0].y);
-			org_path.line_to(rectbound2[1].x, rectbound2[1].y);
-			org_path.line_to(rectbound2[2].x, rectbound2[2].y);
-			org_path.line_to(rectbound2[3].x, rectbound2[3].y);
-			org_path.line_to(rectbound2[0].x, rectbound2[0].y);
-			agg::conv_stroke<agg::path_storage> chstroke(org_path);
-			chstroke.width(1);
-			rsolid.color(rgba_origin);
-			rasterizer.add_path(chstroke);
-			if (rectbound2upd != -1)
-			{
-				agg::ellipse circ(rectbound2[rectbound2upd].x, rectbound2[rectbound2upd].y,
-					pointsys->scale, pointsys->scale);
-				agg::conv_contour< agg::ellipse > c(circ);
-				rasterizer.add_path(c);
-			}
-			if (rectbound2upd2 != -1)
-			{
-				agg::ellipse circ(rectbound2[rectbound2upd2].x, rectbound2[rectbound2upd2].y,
-					pointsys->scale, pointsys->scale);
-				agg::conv_contour< agg::ellipse > c(circ);
-				rasterizer.add_path(c);
-			}
-			render_scanlines(rsolid, false);
-		}
-		else
-		{
-			// outlines
-			agg::conv_stroke< agg::conv_transform< agg::path_storage > > bguidestroke(*rb_path);
-			bguidestroke.width(1);
-			rsolid.color(rgba_guideline);
-			rasterizer.add_path(bguidestroke);
-			render_scanlines(rsolid);
-
-			agg::conv_stroke< agg::conv_curve< agg::conv_transform< agg::path_storage > > > stroke(*rm_curve);
-			stroke.width(1);
-			rsolid.color(rgba_outline);
-			rasterizer.add_path(stroke);
-			render_scanlines(rsolid);
-
-			double diameter = pointsys->scale;
-			double radius = diameter / 2.0;
-			// hilite
-			if (hilite_cmd && hilite_cmd->type != M)
-			{
-				rasterizer.reset();
-				agg::path_storage h_path;
-				AddDrawCmdToAGGPathStorage(hilite_cmd, h_path, HILITE);
-				agg::conv_transform< agg::path_storage> h_path_trans(h_path, mtx);
-			    agg::conv_curve< agg::conv_transform< agg::path_storage> > curve(h_path_trans);
-				agg::conv_dash< agg::conv_curve< agg::conv_transform< agg::path_storage > > > d(curve);
-				d.add_dash(10,5);
-				agg::conv_stroke< agg::conv_dash< agg::conv_curve< agg::conv_transform< agg::path_storage > > > > stroke(d);
-				stroke.width(3);
-				rsolid.color(rgba_outline);
-				rasterizer.add_path(stroke);
-				render_scanlines(rsolid);
-			}
-
-			// m_point
-			rasterizer.reset();
-			DrawCmdList::iterator ci = cmds.begin();
-			while (ci != cmds.end())
-			{
-				double lx = (*ci)->m_point->x() * pointsys->scale + pointsys->originx - radius;
-				double ty = (*ci)->m_point->y() * pointsys->scale + pointsys->originy - radius;
-				agg::path_storage sqp = agghelper::RectanglePath(lx, lx + diameter, ty, ty + diameter);
-				agg::conv_contour< agg::path_storage > c(sqp);
-				rasterizer.add_path(c);
-				ci++;
-			}
-			render_scanlines_aa_solid(rbase, rgba_mainpoint);
-
-			// control_points
-			rasterizer.reset();
-			ci = cmds.begin();
-			while (ci != cmds.end())
-			{
-				PointList::iterator pi = (*ci)->controlpoints.begin();
-				while (pi != (*ci)->controlpoints.end())
-				{
-					agg::ellipse circ((*pi)->x() * pointsys->scale + pointsys->originx,
-						(*pi)->y() * pointsys->scale + pointsys->originy, radius, radius);
-					agg::conv_contour< agg::ellipse > c(circ);
-					rasterizer.add_path(c);
-					pi++;
-				}
-				ci++;
-			}
-			render_scanlines_aa_solid(rbase, rgba_controlpoint);
-
-			// selection
-			rasterizer.reset();
-			PointSet::iterator si = selected_points.begin();
-			while (si != selected_points.end())
-			{
-				agg::ellipse circ((*si)->x() * pointsys->scale + pointsys->originx,
-					(*si)->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3);
-				agg::conv_stroke< agg::ellipse > s(circ);
-				rasterizer.add_path(s);
-				si++;
-			}
-			render_scanlines_aa_solid(rbase, rgba_selectpoint);
-
-			// hover
-			if (hilite_point)
-			{
-				rasterizer.reset();
-				agg::ellipse circ(hilite_point->x() * pointsys->scale + pointsys->originx,
-					hilite_point->y() * pointsys->scale + pointsys->originy, radius + 3, radius + 3);
-				agg::conv_stroke< agg::ellipse > s(circ);
-				s.width(2);
-				rasterizer.add_path(s);
-				render_scanlines_aa_solid(rbase, rgba_selectpoint);
-
-				rasterizer.reset();
-				agg::gsv_text t;
-				t.flip(true);
-				t.size(8.0);
-				wxPoint pxy = hilite_point->ToWxPoint(true);
-				t.start_point(pxy.x + 5, pxy.y -5 );
-				t.text(wxString::Format(_T("%d,%d"), hilite_point->x(), hilite_point->y()).mb_str(wxConvUTF8));
-				agg::conv_stroke< agg::gsv_text > pt(t);
-				pt.line_cap(agg::round_cap);
-				pt.line_join(agg::round_join);
-				pt.width(1.5);
-				rasterizer.add_path(pt);
-				rsolid.color(agg::rgba(0,0,0));
-				render_scanlines(rsolid, false);
-
-				rasterizer.reset();
-				agg::path_storage sb_path;
-				sb_path.move_to(pxy.x, 0);
-				sb_path.line_to(pxy.x, hh);
-				sb_path.move_to(0, pxy.y);
-				sb_path.line_to(ww, pxy.y);
-			    agg::conv_curve< agg::path_storage > curve(sb_path);
-				agg::conv_dash< agg::conv_curve< agg::path_storage > > d(curve);
-				d.add_dash(10,5);
-				agg::conv_stroke< agg::conv_dash< agg::conv_curve< agg::path_storage > > > stroke(d);
-				stroke.width(1);
-				rsolid.color(agg::rgba(0,0,0,0.5));
-				rasterizer.add_path(stroke);
-				render_scanlines(rsolid);
-			}
-
-			// selection box
-			if (lastDrag_left)
-			{
-				double x1 = lastDrag_left->x, y1 = lastDrag_left->y;
-				double x2 = dragAnchor_left->x, y2 = dragAnchor_left->y;
-				double lx, rx, ty, by;
-				if (x1 < x2) lx = x1, rx = x2;
-				else lx = x2, rx = x1;
-				if (y1 < y2) ty = y1, by = y2;
-				else ty = y2, by = y1;
-				rasterizer.reset();
-				agg::path_storage sb_path = agghelper::RectanglePath(lx, rx, ty, by);
-			    agg::conv_curve< agg::path_storage > curve(sb_path);
-				agg::conv_dash< agg::conv_curve< agg::path_storage > > d(curve);
-				d.add_dash(10,5);
-				agg::conv_stroke< agg::conv_dash< agg::conv_curve< agg::path_storage > > > stroke(d);
-				stroke.width(1.0);
-				rsolid.color(agg::rgba(0,0,0,0.5));
-				rasterizer.add_path(stroke);
-				render_scanlines(rsolid);
-			}
-		}
-	}
-
-	// ruler
-	int w, h;
-	GetClientSize( &w, &h );
-	double scale = pointsys->scale;
-	double coeff = 9 / scale + 1;
-	int numdist = (int) floor(coeff) * 5;
-	{
-		rsolid.color(rgba_ruler_h);
-		rasterizer.reset();
-		agg::path_storage rlr_path;
-		double start = pointsys->originx;
-		int t = - (int) floor(start / scale);
-		double s = (start + t * scale);
-		double collect = s;
-		int len;
-
-		for (; s <= w; s += scale)
-		{
-			bool longtick = t % numdist == 0;
-			if (longtick)
-			{
-				len = 10;
-				agg::gsv_text txt;
-				txt.flip(true);
-				txt.size(6.0);
-				txt.start_point(s, 20);
-				txt.text(wxString::Format(_T("%d"), t).mb_str(wxConvUTF8));
-				agg::conv_stroke< agg::gsv_text > pt(txt);
-				rasterizer.add_path(pt);
-			}
-			else
-				len = 5;
-			t++ ;
-			collect += scale;
-			if (collect > 5.0)
-			{
-				collect = 0.0;
-				rlr_path.move_to(s, 0);
-				rlr_path.line_to(s, len);
-			}
-		}
-		agg::conv_stroke< agg::path_storage > rlr_stroke(rlr_path);
-		rlr_stroke.width(1);
-		rasterizer.add_path(rlr_stroke);
-		render_scanlines(rsolid, false);
-	}
-	{
-		rasterizer.reset();
-		rsolid.color(rgba_ruler_v);
-		agg::path_storage rlr_path;
-		double start = pointsys->originy;
-		int t = - (int) floor(start / scale);
-		double s = (start + t * scale);
-		double collect = 0;
-		int len;
-
-		for (; s <= h; s += scale)
-		{
-			bool longtick = t % numdist == 0;
-			if (longtick)
-			{
-				len = 10;
-				agg::gsv_text txt;
-				txt.flip(true);
-				txt.size(6.0);
-				txt.start_point(12, s);
-				txt.text(wxString::Format(_T("%d"), t).mb_str(wxConvUTF8));
-				agg::conv_stroke< agg::gsv_text > pt(txt);
-				rasterizer.add_path(pt);
-			}
-			else
-				len = 5;
-			t++ ;
-			collect += scale;
-			if (collect > 5.0)
-			{
-				collect = 0.0;
-				rlr_path.move_to(0, s);
-				rlr_path.line_to(len, s);
-			}
-		}
-		agg::conv_stroke< agg::path_storage > rlr_stroke(rlr_path);
-		rlr_stroke.width(1);
-		rasterizer.add_path(rlr_stroke);
-		render_scanlines(rsolid, false);
-	}
-
-}
-
-void ASSDrawCanvas::ReceiveBackgroundImageFileDropEvent(const wxString& filename)
-{
-	const wxChar *shortfname = wxFileName::FileName(filename).GetFullName().c_str();
-	m_frame->SetStatusText(wxString::Format(_T("Loading '%s' as canvas background ..."), shortfname), 1);
-	wxImage img;
-	img.LoadFile(filename);
-	if (img.IsOk())
-	{
-		SetBackgroundImage(img, filename);
-	}
-	m_frame->SetStatusText(_T("Canvas background loaded"), 1);
+    const wxChar *shortfname = wxFileName::FileName(filename).GetFullName().c_str();
+    m_frame->SetStatusText(wxString::Format(_T("Loading '%s' as canvas background ..."), shortfname), 1);
+    wxImage img;
+    img.LoadFile(filename);
+    if (img.IsOk()) {
+        SetBackgroundImage(img, filename);
+    }
+    m_frame->SetStatusText(_T("Canvas background loaded"), 1);
 }
 
 void ASSDrawCanvas::RemoveBackgroundImage()
 {
-	if (bgimg.bgimg) delete bgimg.bgimg;
-	bgimg.bgimg = NULL;
-	if (bgimg.bgbmp) delete bgimg.bgbmp;
-	bgimg.bgbmp = NULL;
-	bgimg.bgimgfile = _T("");
-	RefreshDisplay();
-	drag_mode = DRAGMODE();
-	bgimg.alpha_dlg->Show(false);
-	m_frame->UpdateFrameUI();
+    if (bgimg.bgimg) delete bgimg.bgimg;
+    bgimg.bgimg = NULL;
+    if (bgimg.bgbmp) delete bgimg.bgbmp;
+    bgimg.bgbmp = NULL;
+    bgimg.bgimgfile = _T("");
+    RefreshDisplay();
+    drag_mode = DRAGMODE();
+    bgimg.alpha_dlg->Show(false);
+    m_frame->UpdateFrameUI();
 }
 
-void ASSDrawCanvas::SetBackgroundImage(const wxImage& img, wxString fname, bool ask4alpha)
+void ASSDrawCanvas::SetBackgroundImage(const wxImage &img, wxString fname, bool ask4alpha)
 {
-	if (bgimg.bgimg) delete bgimg.bgimg;
-	bgimg.bgimg = new wxImage(img);
-	bgimg.bgimgfile = fname;
-	PrepareBackgroundBitmap(bgimg.alpha);
+    if (bgimg.bgimg) delete bgimg.bgimg;
+    bgimg.bgimg = new wxImage(img);
+    bgimg.bgimgfile = fname;
+    PrepareBackgroundBitmap(bgimg.alpha);
     UpdateBackgroundImgScalePosition(true);
-	RefreshDisplay();
-	m_frame->UpdateFrameUI();
-	if (ask4alpha && m_frame->behaviors.autoaskimgopac)
-		AskUserForBackgroundAlpha();
+    RefreshDisplay();
+    m_frame->UpdateFrameUI();
+    if (ask4alpha && m_frame->behaviors.autoaskimgopac)
+        AskUserForBackgroundAlpha();
 }
 
 void ASSDrawCanvas::AskUserForBackgroundAlpha()
 {
-	bgimg.alpha_slider->SetValue((int) (100 - bgimg.alpha * 100));
-	bgimg.alpha_dlg->Show();
-	SetFocus();
+    bgimg.alpha_slider->SetValue((int) (100 - bgimg.alpha * 100));
+    bgimg.alpha_dlg->Show();
+    SetFocus();
 }
 
 void ASSDrawCanvas::PrepareBackgroundBitmap(double alpha)
 {
-	if (alpha >= 0.0 && alpha <= 1.0) bgimg.alpha = alpha;
-	if (bgimg.bgimg == NULL) return;
-	if (bgimg.bgbmp) delete bgimg.bgbmp;
-	bgimg.bgbmp = new wxBitmap(*bgimg.bgimg);
+    if (alpha >= 0.0 && alpha <= 1.0) bgimg.alpha = alpha;
+    if (bgimg.bgimg == NULL) return;
+    if (bgimg.bgbmp) delete bgimg.bgbmp;
+    bgimg.bgbmp = new wxBitmap(*bgimg.bgimg);
     PixelData data(*bgimg.bgbmp);
-    wxAlphaPixelFormat::ChannelType* pd = (wxAlphaPixelFormat::ChannelType*) &data.GetPixels().Data();
+    wxAlphaPixelFormat::ChannelType *pd = (wxAlphaPixelFormat::ChannelType *) &data.GetPixels().Data();
     const int stride = data.GetRowStride();
     if (stride < 0)
         pd += (data.GetHeight() - 1) * stride;
     bgimg.ibuf.attach(pd, data.GetWidth(), data.GetHeight(), stride);
 
     // apply alpha
-	rasterizer.reset();
-	unsigned w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight();
-	bgimg.bg_path = agghelper::RectanglePath(0, w, 0, h);
+    rasterizer.reset();
+    unsigned w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight();
+    bgimg.bg_path = agghelper::RectanglePath(0, w, 0, h);
     agg::conv_contour< agg::path_storage > cont(bgimg.bg_path);
-	rasterizer.add_path(cont);
-	PixelFormat::AGGType pxt(bgimg.ibuf);
-	RendererBase rpxt(pxt);
-	agg::render_scanlines_aa_solid(rasterizer, scanline, rpxt, agg::rgba(color_bg.r / 255.0, color_bg.g / 255.0, color_bg.b / 255.0, bgimg.alpha));
+    rasterizer.add_path(cont);
+    PixelFormat::AGGType pxt(bgimg.ibuf);
+    RendererBase rpxt(pxt);
+    agg::render_scanlines_aa_solid(rasterizer, scanline, rpxt, agg::rgba(color_bg.r / 255.0, color_bg.g / 255.0, color_bg.b / 255.0, bgimg.alpha));
 }
 
 void ASSDrawCanvas::UpdateBackgroundImgScalePosition(bool firsttime)
 {
-	if (bgimg.bgbmp == NULL) return;
-	// transform the enclosing polygon
-	unsigned w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight();
-	bgimg.bg_path = agghelper::RectanglePath(0, w, 0, h);
+    if (bgimg.bgbmp == NULL) return;
+    // transform the enclosing polygon
+    unsigned w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight();
+    bgimg.bg_path = agghelper::RectanglePath(0, w, 0, h);
     // linear interpolation on image buffer
     wxRealPoint center, disp;
     double scale;
-    if (firsttime) // first time
-    {
-	    bgimg.img_mtx = agg::trans_affine();
-	    scale = 1.0;
-		center = wxRealPoint(0.0, 0.0);
-	    disp = wxRealPoint(0.0, 0.0);
-	    bgimg.path_mtx = bgimg.img_mtx;
-	}
-	else
-	{
-		wxRealPoint d_disp(bgimg.new_disp.x - bgimg.disp.x, bgimg.new_disp.y - bgimg.disp.y);
-		scale = bgimg.new_scale;
-		disp = bgimg.disp;
-		center = bgimg.new_center;
-		if (bgimg.scale == scale)
-		{
-		    bgimg.img_mtx.invert();
-		    bgimg.img_mtx *= agg::trans_affine_translation(d_disp.x, d_disp.y);
-			d_disp.x /= scale;
-			d_disp.y /= scale;
-		}
-		else
-		{
-			d_disp.x /= scale;
-			d_disp.y /= scale;
-		    bgimg.img_mtx = agg::trans_affine();
-			disp.x += (center.x - bgimg.center.x) * (1.0 - 1.0 / bgimg.scale);
-			disp.y += (center.y - bgimg.center.y) * (1.0 - 1.0 / bgimg.scale);
-		    bgimg.img_mtx *= agg::trans_affine_translation(-center.x + disp.x, -center.y + disp.y);
-		    bgimg.img_mtx *= agg::trans_affine_scaling(scale);
-		    bgimg.img_mtx *= agg::trans_affine_translation(center.x + d_disp.x, center.y + d_disp.y);
-		}
-	    bgimg.path_mtx = bgimg.img_mtx;
-	    bgimg.img_mtx.invert();
-	    disp.x += d_disp.x;
-	    disp.y += d_disp.y;
-	}
+    if (firsttime) { // first time
+        bgimg.img_mtx = agg::trans_affine();
+        scale = 1.0;
+        center = wxRealPoint(0.0, 0.0);
+        disp = wxRealPoint(0.0, 0.0);
+        bgimg.path_mtx = bgimg.img_mtx;
+    }
+    else {
+        wxRealPoint d_disp(bgimg.new_disp.x - bgimg.disp.x, bgimg.new_disp.y - bgimg.disp.y);
+        scale = bgimg.new_scale;
+        disp = bgimg.disp;
+        center = bgimg.new_center;
+        if (bgimg.scale == scale) {
+            bgimg.img_mtx.invert();
+            bgimg.img_mtx *= agg::trans_affine_translation(d_disp.x, d_disp.y);
+            d_disp.x /= scale;
+            d_disp.y /= scale;
+        }
+        else {
+            d_disp.x /= scale;
+            d_disp.y /= scale;
+            bgimg.img_mtx = agg::trans_affine();
+            disp.x += (center.x - bgimg.center.x) * (1.0 - 1.0 / bgimg.scale);
+            disp.y += (center.y - bgimg.center.y) * (1.0 - 1.0 / bgimg.scale);
+            bgimg.img_mtx *= agg::trans_affine_translation(-center.x + disp.x, -center.y + disp.y);
+            bgimg.img_mtx *= agg::trans_affine_scaling(scale);
+            bgimg.img_mtx *= agg::trans_affine_translation(center.x + d_disp.x, center.y + d_disp.y);
+        }
+        bgimg.path_mtx = bgimg.img_mtx;
+        bgimg.img_mtx.invert();
+        disp.x += d_disp.x;
+        disp.y += d_disp.y;
+    }
     //update
     bgimg.scale = scale;
     bgimg.center = center;
@@ -1725,273 +1618,249 @@ void ASSDrawCanvas::UpdateBackgroundImgScalePosition(bool firsttime)
     bgimg.new_disp = disp;
 }
 
-bool ASSDrawCanvas::GetBackgroundInfo(unsigned& w, unsigned& h, wxRealPoint& disp, double& scale)
+bool ASSDrawCanvas::GetBackgroundInfo(unsigned &w, unsigned &h, wxRealPoint &disp, double &scale)
 {
-	if (!HasBackgroundImage()) return false;
-	w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight();
-	double t, l;
-	agg::conv_transform<agg::path_storage, agg::trans_affine> trr(bgimg.bg_path, bgimg.path_mtx);
-	trr.rewind(0);
-	trr.vertex(&l, &t);
-	disp = wxRealPoint(l, t);
-	scale = bgimg.scale;
-	return true;
+    if (!HasBackgroundImage()) return false;
+    w = bgimg.bgbmp->GetWidth(), h = bgimg.bgbmp->GetHeight();
+    double t, l;
+    agg::conv_transform<agg::path_storage, agg::trans_affine> trr(bgimg.bg_path, bgimg.path_mtx);
+    trr.rewind(0);
+    trr.vertex(&l, &t);
+    disp = wxRealPoint(l, t);
+    scale = bgimg.scale;
+    return true;
 }
 
 void ASSDrawCanvas::UpdateNonUniformTransformation()
 {
-	double bound[8] = {
-		rectbound2[0].x, rectbound2[0].y,
-		rectbound2[1].x, rectbound2[1].y,
-		rectbound2[2].x, rectbound2[2].y,
-		rectbound2[3].x, rectbound2[3].y };
-	agg::path_storage trans;
-	unsigned vertices = backupcmds.total_vertices();
-
-	agg::trans_bilinear trans_b(rectbound[0].x, rectbound[0].y, rectbound[2].x, rectbound[2].y, bound);
-	agg::conv_transform<agg::path_storage, agg::trans_bilinear> transb(backupcmds, trans_b);
-	transb.rewind(0);
-	for (int i = 0; i < vertices; i++)
-	{
-		double x, y;
-		transb.vertex(&x, &y);
-		trans.move_to(x, y);
-	}
-
-	trans.rewind(0);
-	for (DrawCmdList::iterator iterate = cmds.begin(); iterate != cmds.end(); iterate++)
-	{
-		DrawCmd* cmd = (*iterate);
-		for (PointList::iterator iterate2 = cmd->controlpoints.begin(); iterate2 != cmd->controlpoints.end(); iterate2++)
-		{
-	        double x, y;
-	        trans.vertex(&x, &y);
-	        int wx, wy;
-			pointsys->FromWxPoint ( wxPoint((int)x, (int)y), wx, wy );
-			(*iterate2)->setXY(wx, wy);
-		}
-	    double x, y;
-	    trans.vertex(&x, &y);
-	    int wx, wy;
-		pointsys->FromWxPoint ( wxPoint((int)x, (int)y), wx, wy );
-		(*iterate)->m_point->setXY(wx, wy);
-	}
+    double bound[8] = {
+        rectbound2[0].x, rectbound2[0].y,
+        rectbound2[1].x, rectbound2[1].y,
+        rectbound2[2].x, rectbound2[2].y,
+        rectbound2[3].x, rectbound2[3].y
+    };
+    agg::path_storage trans;
+    unsigned vertices = backupcmds.total_vertices();
+
+    agg::trans_bilinear trans_b(rectbound[0].x, rectbound[0].y, rectbound[2].x, rectbound[2].y, bound);
+    agg::conv_transform<agg::path_storage, agg::trans_bilinear> transb(backupcmds, trans_b);
+    transb.rewind(0);
+    for (int i = 0; i < vertices; i++) {
+        double x, y;
+        transb.vertex(&x, &y);
+        trans.move_to(x, y);
+    }
+
+    trans.rewind(0);
+    for (DrawCmdList::iterator iterate = cmds.begin(); iterate != cmds.end(); iterate++) {
+        DrawCmd *cmd = (*iterate);
+        for (PointList::iterator iterate2 = cmd->controlpoints.begin(); iterate2 != cmd->controlpoints.end(); iterate2++) {
+            double x, y;
+            trans.vertex(&x, &y);
+            int wx, wy;
+            pointsys->FromWxPoint ( wxPoint((int)x, (int)y), wx, wy );
+            (*iterate2)->setXY(wx, wy);
+        }
+        double x, y;
+        trans.vertex(&x, &y);
+        int wx, wy;
+        pointsys->FromWxPoint ( wxPoint((int)x, (int)y), wx, wy );
+        (*iterate)->m_point->setXY(wx, wy);
+    }
 
 }
 
 void ASSDrawCanvas::CustomOnKeyDown(wxKeyEvent &event)
 {
-	int keycode = event.GetKeyCode();
-	double scrollamount = (event.GetModifiers() == wxMOD_CMD? 10.0:1.0);
-    if (event.GetModifiers() == wxMOD_SHIFT)
-	{
-		MODE d_mode = GetDrawMode();
-        if ((int) d_mode > (int) MODE_ARR && (int) d_mode < (int) MODE_SCALEROTATE)
-		{
-			mode_b4_shift = d_mode;
-			SetDrawMode( MODE_ARR );
-			m_frame->UpdateFrameUI();
-		}
+    int keycode = event.GetKeyCode();
+    double scrollamount = (event.GetModifiers() == wxMOD_CMD ? 10.0 : 1.0);
+    if (event.GetModifiers() == wxMOD_SHIFT) {
+        MODE d_mode = GetDrawMode();
+        if ((int) d_mode > (int) MODE_ARR && (int) d_mode < (int) MODE_SCALEROTATE) {
+            mode_b4_shift = d_mode;
+            SetDrawMode( MODE_ARR );
+            m_frame->UpdateFrameUI();
+        }
     }
-    else
-    {
-		switch (keycode)
-		{
-		case WXK_PAGEUP:
-			ChangeZoomLevel( 1.0 /scrollamount, wxPoint( (int) pointsys->originx, (int) pointsys->originy ) );
-			RefreshDisplay();
-			break;
-		case WXK_PAGEDOWN:
-			ChangeZoomLevel( - 1.0 /scrollamount, wxPoint( (int) pointsys->originx, (int) pointsys->originy ) );
-			RefreshDisplay();
-			break;
-		case WXK_UP:
-			MoveCanvas(0.0, -scrollamount);
-			RefreshDisplay();
-			break;
-		case WXK_DOWN:
-			MoveCanvas(0.0, scrollamount);
-			RefreshDisplay();
-			break;
-		case WXK_LEFT:
-			MoveCanvas(-scrollamount, 0.0);
-			RefreshDisplay();
-			break;
-		case WXK_RIGHT:
-			MoveCanvas(scrollamount, 0.0);
-			RefreshDisplay();
-			break;
-		case WXK_TAB:
-			if (mousedownAt_point == NULL && !IsTransformMode() && cmds.size() > 0)
-			{
-				if (pointedAt_point == NULL)
-				{
-					Point *nearest = NULL;
-					double dist = 0.0;
-					DrawCmdList::iterator it = cmds.begin();
-					while(it != cmds.end())
-					{
-						wxPoint point = (*it)->m_point->ToWxPoint();
-						double distance = sqrt(pow(double(point.x - mouse_point.x), 2) + pow(double(point.y - mouse_point.y), 2));
-						if (nearest == NULL || distance < dist)
-						{
-							nearest = (*it)->m_point;
-							dist = distance;
-						}
-						PointList::iterator it2 = (*it)->controlpoints.begin();
-						while (it2 != (*it)->controlpoints.end())
-						{
-							wxPoint point = (*it2)->ToWxPoint();
-							double distance = sqrt(pow((double)point.x - mouse_point.x, 2) + pow((double)point.y - mouse_point.y, 2));
-							if (nearest == NULL || distance < dist)
-							{
-								nearest = (*it2);
-								dist = distance;
-							}
-							it2++;
-						}
-						it++;
-					}
-					if (nearest != NULL)
-					{
-						wxPoint point = nearest->ToWxPoint();
-						WarpPointer(point.x, point.y);
-					}
-				}
-				else
-				{
-					Point *warpto = NULL;
-					if (pointedAt_point->type == MP && pointedAt_point->cmd_next)
-						if (pointedAt_point->cmd_next->controlpoints.size() > 0)
-							warpto = pointedAt_point->cmd_next->controlpoints.front();
-						else
-							warpto = pointedAt_point->cmd_next->m_point;
-					}
-					else
-					{
-						PointList::iterator it = pointedAt_point->cmd_main->controlpoints.begin();
-						while (*it != pointedAt_point) it++;
-						it++;
-						if (it == pointedAt_point->cmd_main->controlpoints.end())
-							warpto = pointedAt_point->cmd_main->m_point;
-						else
-							warpto = *it;
-					}
-					if (warpto == NULL)
-						warpto = cmds.front()->m_point;
-					wxPoint point = warpto->ToWxPoint();
-					WarpPointer(point.x, point.y);
-				}
-			}
-			break;
-		default:
-	        event.Skip();
-		}
-	}
+    else {
+        switch (keycode) {
+        case WXK_PAGEUP:
+            ChangeZoomLevel( 1.0 / scrollamount, wxPoint( (int) pointsys->originx, (int) pointsys->originy ) );
+            RefreshDisplay();
+            break;
+        case WXK_PAGEDOWN:
+            ChangeZoomLevel( - 1.0 / scrollamount, wxPoint( (int) pointsys->originx, (int) pointsys->originy ) );
+            RefreshDisplay();
+            break;
+        case WXK_UP:
+            MoveCanvas(0.0, -scrollamount);
+            RefreshDisplay();
+            break;
+        case WXK_DOWN:
+            MoveCanvas(0.0, scrollamount);
+            RefreshDisplay();
+            break;
+        case WXK_LEFT:
+            MoveCanvas(-scrollamount, 0.0);
+            RefreshDisplay();
+            break;
+        case WXK_RIGHT:
+            MoveCanvas(scrollamount, 0.0);
+            RefreshDisplay();
+            break;
+        case WXK_TAB:
+            if (mousedownAt_point == NULL && !IsTransformMode() && cmds.size() > 0) {
+                if (pointedAt_point == NULL) {
+                    Point *nearest = NULL;
+                    double dist = 0.0;
+                    DrawCmdList::iterator it = cmds.begin();
+                    while (it != cmds.end()) {
+                        wxPoint point = (*it)->m_point->ToWxPoint();
+                        double distance = sqrt(pow(double(point.x - mouse_point.x), 2) + pow(double(point.y - mouse_point.y), 2));
+                        if (nearest == NULL || distance < dist) {
+                            nearest = (*it)->m_point;
+                            dist = distance;
+                        }
+                        PointList::iterator it2 = (*it)->controlpoints.begin();
+                        while (it2 != (*it)->controlpoints.end()) {
+                            wxPoint point = (*it2)->ToWxPoint();
+                            double distance = sqrt(pow((double)point.x - mouse_point.x, 2) + pow((double)point.y - mouse_point.y, 2));
+                            if (nearest == NULL || distance < dist) {
+                                nearest = (*it2);
+                                dist = distance;
+                            }
+                            it2++;
+                        }
+                        it++;
+                    }
+                    if (nearest != NULL) {
+                        wxPoint point = nearest->ToWxPoint();
+                        WarpPointer(point.x, point.y);
+                    }
+                }
+                else {
+                    Point *warpto = NULL;
+                    if (pointedAt_point->type == MP && pointedAt_point->cmd_next)
+                        if (pointedAt_point->cmd_next->controlpoints.size() > 0)
+                            warpto = pointedAt_point->cmd_next->controlpoints.front();
+                        else
+                            warpto = pointedAt_point->cmd_next->m_point;
+                }
+                else {
+                    PointList::iterator it = pointedAt_point->cmd_main->controlpoints.begin();
+                    while (*it != pointedAt_point) it++;
+                    it++;
+                    if (it == pointedAt_point->cmd_main->controlpoints.end())
+                        warpto = pointedAt_point->cmd_main->m_point;
+                    else
+                        warpto = *it;
+                }
+                if (warpto == NULL)
+                    warpto = cmds.front()->m_point;
+                wxPoint point = warpto->ToWxPoint();
+                WarpPointer(point.x, point.y);
+            }
+        }
+        break;
+    default:
+        event.Skip();
+    }
+}
 }
 
 void ASSDrawCanvas::CustomOnKeyUp(wxKeyEvent &event)
 {
-	if (event.GetModifiers() != wxMOD_SHIFT && (int) mode_b4_shift > (int) MODE_ARR)
-	{
-		SetDrawMode( mode_b4_shift );
-		m_frame->UpdateFrameUI();
-		mode_b4_shift = MODE_ARR;
-	}
+    if (event.GetModifiers() != wxMOD_SHIFT && (int) mode_b4_shift > (int) MODE_ARR) {
+        SetDrawMode( mode_b4_shift );
+        m_frame->UpdateFrameUI();
+        mode_b4_shift = MODE_ARR;
+    }
 }
 
 void ASSDrawCanvas::OnAlphaSliderChanged(wxScrollEvent &event)
 {
-	double pos = (double) event.GetPosition();
-	PrepareBackgroundBitmap(1.0 - pos / 100.0);
-	RefreshDisplay();
+    double pos = (double) event.GetPosition();
+    PrepareBackgroundBitmap(1.0 - pos / 100.0);
+    RefreshDisplay();
 }
 
 void ASSDrawCanvas::CustomOnMouseCaptureLost(wxMouseCaptureLostEvent &)
 {
-	if (capturemouse_left)
-		ProcessOnMouseLeftUp();
+    if (capturemouse_left)
+        ProcessOnMouseLeftUp();
 
-	if (capturemouse_right)
-		ProcessOnMouseRightUp();
+    if (capturemouse_right)
+        ProcessOnMouseRightUp();
 }
 
 void UndoRedo::Import(ASSDrawCanvas *canvas, bool prestage, wxString cmds)
 {
-	if (prestage)
-	{
-		this->cmds = cmds;
-		this->backupcmds.free_all();
-		this->backupcmds.concat_path(canvas->backupcmds);
-		for (int i = 0; i < 4; i++)
-		{
-			this->rectbound[i] = canvas->rectbound[i];
-			this->rectbound2[i] = canvas->rectbound2[i];
-			this->backup[i] = canvas->backup[i];
-		}
-		this->isshapetransformable = canvas->isshapetransformable;
-	}
-	else
-	{
-	    this->originx = canvas->pointsys->originx;
-		this->originy = canvas->pointsys->originy;
-	    this->scale = canvas->pointsys->scale;
-
-		this->bgimgfile = canvas->bgimg.bgimgfile;
-		this->bgdisp = canvas->bgimg.disp;
-		this->bgcenter = canvas->bgimg.center;
-		this->bgscale = canvas->bgimg.scale;
-		this->bgalpha = canvas->bgimg.alpha;
-		this->c1cont = canvas->PrepareC1ContData();
-		this->draw_mode = canvas->draw_mode;
-	}
+    if (prestage) {
+        this->cmds = cmds;
+        this->backupcmds.free_all();
+        this->backupcmds.concat_path(canvas->backupcmds);
+        for (int i = 0; i < 4; i++) {
+            this->rectbound[i] = canvas->rectbound[i];
+            this->rectbound2[i] = canvas->rectbound2[i];
+            this->backup[i] = canvas->backup[i];
+        }
+        this->isshapetransformable = canvas->isshapetransformable;
+    }
+    else {
+        this->originx = canvas->pointsys->originx;
+        this->originy = canvas->pointsys->originy;
+        this->scale = canvas->pointsys->scale;
+
+        this->bgimgfile = canvas->bgimg.bgimgfile;
+        this->bgdisp = canvas->bgimg.disp;
+        this->bgcenter = canvas->bgimg.center;
+        this->bgscale = canvas->bgimg.scale;
+        this->bgalpha = canvas->bgimg.alpha;
+        this->c1cont = canvas->PrepareC1ContData();
+        this->draw_mode = canvas->draw_mode;
+    }
 }
 
 void UndoRedo::Export(ASSDrawCanvas *canvas)
 {
-	canvas->pointsys->originx = this->originx;
-	canvas->pointsys->originy = this->originy;
-	canvas->pointsys->scale = this->scale;
-	canvas->ParseASS( this->cmds );
-	DrawCmdList::iterator it1 = canvas->cmds.begin();
-	std::vector< bool >::iterator it2 = this->c1cont.begin();
-	for(; it1 != canvas->cmds.end() && it2 != this->c1cont.end(); it1++, it2++)
-		if (*it2 && (*it1)->type == B)
-			static_cast<DrawCmd_B*>(*it1)->C1Cont = true;
-
-	if (canvas->bgimg.bgimgfile != this->bgimgfile)
-	{
-		canvas->RemoveBackgroundImage();
-		if (!this->bgimgfile.IsSameAs(_T("<clipboard>")) && ::wxFileExists(this->bgimgfile))
-		{
-			canvas->bgimg.alpha = this->bgalpha;
-			canvas->ReceiveBackgroundImageFileDropEvent(this->bgimgfile);
-		}
-	}
-	else
-	{
-		canvas->bgimg.new_scale = this->bgscale;
-		canvas->bgimg.new_center = this->bgcenter;
-		canvas->bgimg.new_disp = this->bgdisp;
-		canvas->bgimg.alpha = this->bgalpha;
-		canvas->UpdateBackgroundImgScalePosition();
-	}
-
-	canvas->draw_mode = this->draw_mode;
-	if (canvas->IsTransformMode())
-	{
-		canvas->backupcmds.free_all();
-		canvas->backupcmds.concat_path(this->backupcmds);
-		for (int i = 0; i < 4; i++)
-		{
-			canvas->rectbound[i] = this->rectbound[i];
-			canvas->rectbound2[i] = this->rectbound2[i];
-			canvas->backup[i] = this->backup[i];
-		}
-		canvas->UpdateNonUniformTransformation();
-		canvas->InitiateDraggingIfTransformMode();
-		canvas->rectbound2upd = -1;
-		canvas->rectbound2upd2 = -1;
-		canvas->isshapetransformable = this->isshapetransformable;
-	}
+    canvas->pointsys->originx = this->originx;
+    canvas->pointsys->originy = this->originy;
+    canvas->pointsys->scale = this->scale;
+    canvas->ParseASS( this->cmds );
+    DrawCmdList::iterator it1 = canvas->cmds.begin();
+    std::vector< bool >::iterator it2 = this->c1cont.begin();
+    for (; it1 != canvas->cmds.end() && it2 != this->c1cont.end(); it1++, it2++)
+        if (*it2 && (*it1)->type == B)
+            static_cast<DrawCmd_B *>(*it1)->C1Cont = true;
+
+    if (canvas->bgimg.bgimgfile != this->bgimgfile) {
+        canvas->RemoveBackgroundImage();
+        if (!this->bgimgfile.IsSameAs(_T("<clipboard>")) && ::wxFileExists(this->bgimgfile)) {
+            canvas->bgimg.alpha = this->bgalpha;
+            canvas->ReceiveBackgroundImageFileDropEvent(this->bgimgfile);
+        }
+    }
+    else {
+        canvas->bgimg.new_scale = this->bgscale;
+        canvas->bgimg.new_center = this->bgcenter;
+        canvas->bgimg.new_disp = this->bgdisp;
+        canvas->bgimg.alpha = this->bgalpha;
+        canvas->UpdateBackgroundImgScalePosition();
+    }
+
+    canvas->draw_mode = this->draw_mode;
+    if (canvas->IsTransformMode()) {
+        canvas->backupcmds.free_all();
+        canvas->backupcmds.concat_path(this->backupcmds);
+        for (int i = 0; i < 4; i++) {
+            canvas->rectbound[i] = this->rectbound[i];
+            canvas->rectbound2[i] = this->rectbound2[i];
+            canvas->backup[i] = this->backup[i];
+        }
+        canvas->UpdateNonUniformTransformation();
+        canvas->InitiateDraggingIfTransformMode();
+        canvas->rectbound2upd = -1;
+        canvas->rectbound2upd2 = -1;
+        canvas->isshapetransformable = this->isshapetransformable;
+    }
 }
diff --git a/assdraw/canvas.hpp b/assdraw/canvas.hpp
index aee896ee21ed93e946f3c90fc45fd6092cb22544..8f83d6127cd7c1d1292fda3b84dd59be99edb76b 100644
--- a/assdraw/canvas.hpp
+++ b/assdraw/canvas.hpp
@@ -54,52 +54,50 @@
 class ASSDrawFrame;
 class ASSDrawCanvas;
 
-struct UndoRedo
-{
-	wxString cmds;
-	wxString desc;
-	double originx, originy, scale;
-
-	std::vector< bool > c1cont;
-	wxString bgimgfile;
-	wxRealPoint bgdisp, bgcenter;
-	double bgscale, bgalpha;
-
-	MODE draw_mode;
-	agg::path_storage backupcmds;
-	wxRealPoint rectbound[4], rectbound2[4], backup[4];
-	bool isshapetransformable;
-
-	void Import(ASSDrawCanvas *canvas, bool prestage, wxString cmds = _T(""));
-	void Export(ASSDrawCanvas *canvas);
-	
+struct UndoRedo {
+    wxString cmds;
+    wxString desc;
+    double originx, originy, scale;
+
+    std::vector< bool > c1cont;
+    wxString bgimgfile;
+    wxRealPoint bgdisp, bgcenter;
+    double bgscale, bgalpha;
+
+    MODE draw_mode;
+    agg::path_storage backupcmds;
+    wxRealPoint rectbound[4], rectbound2[4], backup[4];
+    bool isshapetransformable;
+
+    void Import(ASSDrawCanvas *canvas, bool prestage, wxString cmds = _T(""));
+    void Export(ASSDrawCanvas *canvas);
+
 };
 
 // for multiple point selection
 enum SELECTMODE { NEW, ADD, DEL };
 
-class ASSDrawCanvas: public ASSDrawEngine, public wxClientData
-{
+class ASSDrawCanvas: public ASSDrawEngine, public wxClientData {
 public:
-	ASSDrawCanvas( wxWindow *parent, ASSDrawFrame *frame, int extraflags = 0 );
+    ASSDrawCanvas( wxWindow *parent, ASSDrawFrame *frame, int extraflags = 0 );
 
     // destructor
     ~ASSDrawCanvas();
 
     virtual void ResetEngine(bool addM);
-	virtual void SetPreviewMode( bool mode );
-	virtual bool IsPreviewMode() { return preview_mode; }
-	virtual void ParseASS(wxString str, bool addundo = false);
-
-	virtual void SetDrawMode( MODE mode );
-	virtual MODE GetDrawMode() { return draw_mode; }
-	virtual bool IsTransformMode();
-	virtual void SetDragMode( DRAGMODE mode );
-	virtual DRAGMODE GetDragMode() { return drag_mode; }
-	virtual void RefreshDisplay();
-	virtual bool CanZoom();
-	virtual bool CanMove();
-	
+    virtual void SetPreviewMode( bool mode );
+    virtual bool IsPreviewMode() { return preview_mode; }
+    virtual void ParseASS(wxString str, bool addundo = false);
+
+    virtual void SetDrawMode( MODE mode );
+    virtual MODE GetDrawMode() { return draw_mode; }
+    virtual bool IsTransformMode();
+    virtual void SetDragMode( DRAGMODE mode );
+    virtual DRAGMODE GetDragMode() { return drag_mode; }
+    virtual void RefreshDisplay();
+    virtual bool CanZoom();
+    virtual bool CanMove();
+
     virtual void OnMouseMove(wxMouseEvent &event);
     virtual void OnMouseLeftUp(wxMouseEvent &event);
     virtual void OnMouseLeftDown(wxMouseEvent &event);
@@ -109,92 +107,92 @@ public:
     virtual void OnMouseWheel(wxMouseEvent &event);
     virtual void CustomOnKeyDown(wxKeyEvent &event);
     virtual void CustomOnKeyUp(wxKeyEvent &event);
-	virtual void ChangeZoomLevel(double zoomamount, wxPoint bgzoomctr);
-	virtual void ChangeZoomLevelTo(double zoom, wxPoint bgzoomctr);
-	virtual void ChangeDrawingZoomLevel(double zoom);
-	virtual void ChangeBackgroundZoomLevel(double zoom, wxRealPoint newcenter);
-	virtual void MoveCanvas(double xamount, double yamount);
-	virtual void MoveCanvasOriginTo(double originx, double originy);
-	virtual void MoveCanvasDrawing(double xamount, double yamount);
-	virtual void MoveCanvasBackground(double xamount, double yamount);
-	virtual void OnSelect_ConvertLineToBezier(wxCommandEvent& WXUNUSED(event));
-	virtual void OnSelect_ConvertBezierToLine(wxCommandEvent& WXUNUSED(event));
-	virtual void OnSelect_C1ContinuityBezier(wxCommandEvent& WXUNUSED(event));
-	virtual void OnSelect_Move00Here(wxCommandEvent& WXUNUSED(event));
-	void OnAlphaSliderChanged(wxScrollEvent &event);
-	
-	// to replace _PointSystem() that has been made protected
-	double GetScale() { return pointsys->scale; }
-	double GetOriginX() { return pointsys->originx; }
-	double GetOriginY() { return pointsys->originy; }
-
-	// undo/redo system
-	virtual void AddUndo( wxString desc );
-	virtual bool UndoOrRedo(bool isundo);
-	virtual bool Undo();
-	virtual bool Redo();
-	virtual wxString GetTopUndo();
-	virtual wxString GetTopRedo();
-	virtual void RefreshUndocmds();
-
-	virtual bool HasBackgroundImage() { return bgimg.bgimg != NULL; }
-	virtual void RemoveBackgroundImage();
-	virtual void ReceiveBackgroundImageFileDropEvent(const wxString& filename);
-	virtual void SetBackgroundImage(const wxImage& img, wxString fname = _T("<clipboard>"), bool ask4alpha = true);
-	virtual void PrepareBackgroundBitmap(double alpha);
-	virtual void AskUserForBackgroundAlpha();
-	virtual bool GetBackgroundInfo(unsigned& w, unsigned& h, wxRealPoint& disp, double& scale);
-	
-	agg::rgba rgba_shape_normal, rgba_outline, rgba_guideline;
-	agg::rgba rgba_mainpoint, rgba_controlpoint, rgba_selectpoint;
-	agg::rgba rgba_origin, rgba_ruler_h, rgba_ruler_v;
-	
+    virtual void ChangeZoomLevel(double zoomamount, wxPoint bgzoomctr);
+    virtual void ChangeZoomLevelTo(double zoom, wxPoint bgzoomctr);
+    virtual void ChangeDrawingZoomLevel(double zoom);
+    virtual void ChangeBackgroundZoomLevel(double zoom, wxRealPoint newcenter);
+    virtual void MoveCanvas(double xamount, double yamount);
+    virtual void MoveCanvasOriginTo(double originx, double originy);
+    virtual void MoveCanvasDrawing(double xamount, double yamount);
+    virtual void MoveCanvasBackground(double xamount, double yamount);
+    virtual void OnSelect_ConvertLineToBezier(wxCommandEvent &WXUNUSED(event));
+    virtual void OnSelect_ConvertBezierToLine(wxCommandEvent &WXUNUSED(event));
+    virtual void OnSelect_C1ContinuityBezier(wxCommandEvent &WXUNUSED(event));
+    virtual void OnSelect_Move00Here(wxCommandEvent &WXUNUSED(event));
+    void OnAlphaSliderChanged(wxScrollEvent &event);
+
+    // to replace _PointSystem() that has been made protected
+    double GetScale() { return pointsys->scale; }
+    double GetOriginX() { return pointsys->originx; }
+    double GetOriginY() { return pointsys->originy; }
+
+    // undo/redo system
+    virtual void AddUndo( wxString desc );
+    virtual bool UndoOrRedo(bool isundo);
+    virtual bool Undo();
+    virtual bool Redo();
+    virtual wxString GetTopUndo();
+    virtual wxString GetTopRedo();
+    virtual void RefreshUndocmds();
+
+    virtual bool HasBackgroundImage() { return bgimg.bgimg != NULL; }
+    virtual void RemoveBackgroundImage();
+    virtual void ReceiveBackgroundImageFileDropEvent(const wxString &filename);
+    virtual void SetBackgroundImage(const wxImage &img, wxString fname = _T("<clipboard>"), bool ask4alpha = true);
+    virtual void PrepareBackgroundBitmap(double alpha);
+    virtual void AskUserForBackgroundAlpha();
+    virtual bool GetBackgroundInfo(unsigned &w, unsigned &h, wxRealPoint &disp, double &scale);
+
+    agg::rgba rgba_shape_normal, rgba_outline, rgba_guideline;
+    agg::rgba rgba_mainpoint, rgba_controlpoint, rgba_selectpoint;
+    agg::rgba rgba_origin, rgba_ruler_h, rgba_ruler_v;
+
 protected:
 
-	typedef PixelFormat::AGGType::color_type color_type;
-	typedef agg::span_interpolator_linear<> interpolator_type;
-	typedef agg::span_image_filter_rgb_bilinear_clip<PixelFormat::AGGType, interpolator_type> span_gen_type;
-	
+    typedef PixelFormat::AGGType::color_type color_type;
+    typedef agg::span_interpolator_linear<> interpolator_type;
+    typedef agg::span_image_filter_rgb_bilinear_clip<PixelFormat::AGGType, interpolator_type> span_gen_type;
+
     // The GUI window
-	ASSDrawFrame* m_frame;
-
-	// highlight mechanism
-	DrawCmd* hilite_cmd;
-	Point* hilite_point;
-		
-	// mouse capture
-	bool capturemouse_left, capturemouse_right;
-	virtual void CustomOnMouseCaptureLost(wxMouseCaptureLostEvent &event);
+    ASSDrawFrame *m_frame;
+
+    // highlight mechanism
+    DrawCmd *hilite_cmd;
+    Point *hilite_point;
+
+    // mouse capture
+    bool capturemouse_left, capturemouse_right;
+    virtual void CustomOnMouseCaptureLost(wxMouseCaptureLostEvent &event);
     virtual void ProcessOnMouseLeftUp();
     virtual void ProcessOnMouseRightUp();
 
-	// selection mechanism
-	PointSet selected_points;
+    // selection mechanism
+    PointSet selected_points;
 
-	// if it has status bar
-	bool hasStatusBar;
+    // if it has status bar
+    bool hasStatusBar;
 
-	// some mouse readings
-    Point* mousedownAt_point;
-	Point* pointedAt_point;
-	Point* dblclicked_point_right;
-	wxPoint mouse_point;
+    // some mouse readings
+    Point *mousedownAt_point;
+    Point *pointedAt_point;
+    Point *dblclicked_point_right;
+    wxPoint mouse_point;
 
-	// The wxPoint being dragged by left button
-    wxPoint* dragAnchor_left;
-	wxPoint* lastDrag_left;
+    // The wxPoint being dragged by left button
+    wxPoint *dragAnchor_left;
+    wxPoint *lastDrag_left;
 
-	// The wxPoint being dragged by right button
-    wxPoint* dragAnchor_right;
-	wxPoint* lastDrag_right;
-	
-	// true if the drawing origin (0, 0) is being dragged
+    // The wxPoint being dragged by right button
+    wxPoint *dragAnchor_right;
+    wxPoint *lastDrag_right;
+
+    // true if the drawing origin (0, 0) is being dragged
     bool dragOrigin;
 
-	// The newest command being initialized thru dragging action
-    DrawCmd* newcommand;
+    // The newest command being initialized thru dragging action
+    DrawCmd *newcommand;
 
-	// the draw mode
+    // the draw mode
     MODE draw_mode;
     DRAGMODE drag_mode;
 
@@ -202,103 +200,99 @@ protected:
     // so we want to save the mode before the key-down to restore it on key-up
     MODE mode_b4_shift;
 
-	// true if preview mode (i.e don't draw anything except the shape itself;
+    // true if preview mode (i.e don't draw anything except the shape itself;
     // also draw the shape as closed)
     bool preview_mode;
 
-	// background image!
-	struct
-	{
-		agg::rendering_buffer ibuf;
-		wxImage *bgimg;
-		wxBitmap *bgbmp;
-		wxString bgimgfile;
-		agg::path_storage bg_path;		
-		agg::span_allocator<color_type> spanalloc;
-		//span_gen_type spangen;
+    // background image!
+    struct {
+        agg::rendering_buffer ibuf;
+        wxImage *bgimg;
+        wxBitmap *bgbmp;
+        wxString bgimgfile;
+        agg::path_storage bg_path;
+        agg::span_allocator<color_type> spanalloc;
+        //span_gen_type spangen;
         agg::trans_affine img_mtx, path_mtx;
-        
+
         wxRealPoint disp, center, new_disp, new_center;
         double scale, new_scale, alpha;
-		wxDialog* alpha_dlg;
-		wxSlider* alpha_slider;
-	} bgimg;
-	
-	// Undo/redo system (simply stores the ASS commands)
-	std::list<UndoRedo> undos;
-	std::list<UndoRedo> redos;
-	UndoRedo _undo;
-
-	// last action and commands (for undo/redo system)
-	wxString undodesc;
-	
-	wxString oldasscmds;
-
-	// was preview_mode
-	//bool was_preview_mode;
-
-	PointSystem* _PointSystem() { return pointsys; }
-
-	// for Undo/Redo system
-	virtual void PrepareUndoRedo(UndoRedo& ur, bool prestage, wxString cmds, wxString desc);
-	
-	// -------------------- points highlight/selection ---------------------------
-
-	// set command and point to highlight
-	virtual void SetHighlighted ( DrawCmd* cmd, Point* point );
-
-	// selects all points within (lx, ty) , (rx, by) returns # of selected points
-	virtual int SelectPointsWithin( int lx, int rx, int ty, int by, SELECTMODE smode = NEW );
-	virtual void ClearPointsSelection();
-	virtual SELECTMODE GetSelectMode(wxMouseEvent &event);
-	
-	// -------------------- misc ---------------------------
-
-	// non-uniform transformation
-	virtual bool InitiateDraggingIfTransformMode();
-	virtual void UpdateTranformModeRectCenter();
-	virtual bool GetThe4thPoint(double ox, double oy, double a1x, double a1y, double a2x, double a2y, double *x, double *y);
-	enum { NONE, LEFT, RIGHT } backupowner;
-	agg::path_storage backupcmds;
-	int rectbound2upd, rectbound2upd2;
-	wxRealPoint rectbound[4], rectbound2[4], backup[4], rectcenter;
-	bool isshapetransformable;
-
-	// do the real drawing
-	virtual void DoDraw( RendererBase& rbase, RendererPrimitives& rprim, RendererSolid& rsolid, agg::trans_affine& mtx );
-
-	// update background image scale & position
-	virtual void UpdateBackgroundImgScalePosition(bool firsttime = false);
-	
-	// perform extra stuff other than calling ASSDrawEngine::ConnectSubsequentCmds
-	virtual void ConnectSubsequentCmds (DrawCmd* cmd1, DrawCmd* cmd2);
-
-	// make sure the c1 continuity is followed after performing a drag-point action
-	virtual void EnforceC1Continuity (DrawCmd* cmd, Point* pnt);
-	
-	// after the bounding quadrangle has changed, update the shape to fill up inside it
-	virtual void UpdateNonUniformTransformation();
-
-	friend struct UndoRedo;
-	
-	DECLARE_EVENT_TABLE()
+        wxDialog *alpha_dlg;
+        wxSlider *alpha_slider;
+    } bgimg;
+
+    // Undo/redo system (simply stores the ASS commands)
+    std::list<UndoRedo> undos;
+    std::list<UndoRedo> redos;
+    UndoRedo _undo;
+
+    // last action and commands (for undo/redo system)
+    wxString undodesc;
+
+    wxString oldasscmds;
+
+    // was preview_mode
+    //bool was_preview_mode;
+
+    PointSystem *_PointSystem() { return pointsys; }
+
+    // for Undo/Redo system
+    virtual void PrepareUndoRedo(UndoRedo &ur, bool prestage, wxString cmds, wxString desc);
+
+    // -------------------- points highlight/selection ---------------------------
+
+    // set command and point to highlight
+    virtual void SetHighlighted ( DrawCmd *cmd, Point *point );
+
+    // selects all points within (lx, ty) , (rx, by) returns # of selected points
+    virtual int SelectPointsWithin( int lx, int rx, int ty, int by, SELECTMODE smode = NEW );
+    virtual void ClearPointsSelection();
+    virtual SELECTMODE GetSelectMode(wxMouseEvent &event);
+
+    // -------------------- misc ---------------------------
+
+    // non-uniform transformation
+    virtual bool InitiateDraggingIfTransformMode();
+    virtual void UpdateTranformModeRectCenter();
+    virtual bool GetThe4thPoint(double ox, double oy, double a1x, double a1y, double a2x, double a2y, double *x, double *y);
+    enum { NONE, LEFT, RIGHT } backupowner;
+    agg::path_storage backupcmds;
+    int rectbound2upd, rectbound2upd2;
+    wxRealPoint rectbound[4], rectbound2[4], backup[4], rectcenter;
+    bool isshapetransformable;
+
+    // do the real drawing
+    virtual void DoDraw( RendererBase &rbase, RendererPrimitives &rprim, RendererSolid &rsolid, agg::trans_affine &mtx );
+
+    // update background image scale & position
+    virtual void UpdateBackgroundImgScalePosition(bool firsttime = false);
+
+    // perform extra stuff other than calling ASSDrawEngine::ConnectSubsequentCmds
+    virtual void ConnectSubsequentCmds (DrawCmd *cmd1, DrawCmd *cmd2);
+
+    // make sure the c1 continuity is followed after performing a drag-point action
+    virtual void EnforceC1Continuity (DrawCmd *cmd, Point *pnt);
+
+    // after the bounding quadrangle has changed, update the shape to fill up inside it
+    virtual void UpdateNonUniformTransformation();
+
+    friend struct UndoRedo;
+
+    DECLARE_EVENT_TABLE()
 };
 
-class ASSDrawFileDropTarget : public wxFileDropTarget
-{
+class ASSDrawFileDropTarget : public wxFileDropTarget {
 public:
-	ASSDrawFileDropTarget(ASSDrawCanvas *canvas): wxFileDropTarget()
-	{
-		m_canvas = canvas;
-	}
+    ASSDrawFileDropTarget(ASSDrawCanvas *canvas): wxFileDropTarget() {
+        m_canvas = canvas;
+    }
 
-	virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames)
-	{
-		m_canvas->ReceiveBackgroundImageFileDropEvent(filenames.Item(0));
-		return true;
-	}
+    virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &filenames) {
+        m_canvas->ReceiveBackgroundImageFileDropEvent(filenames.Item(0));
+        return true;
+    }
 
 protected:
-	ASSDrawCanvas *m_canvas;
+    ASSDrawCanvas *m_canvas;
 
 };
diff --git a/assdraw/canvas_mouse.cpp b/assdraw/canvas_mouse.cpp
index 22b64a5f459c20b957478a90a3ce8094ca5b0e3d..434acdb3e1a6145bc996bdf39e3a16b9d015ced3 100644
--- a/assdraw/canvas_mouse.cpp
+++ b/assdraw/canvas_mouse.cpp
@@ -31,26 +31,26 @@
 DEFINE_EVENT_TYPE( wxEVT_MOUSEONCANVAS )
 
 
-ASSDrawMouseOnCanvasEvent::ASSDrawMouseOnCanvasEvent(const ASSDrawCanvas* canvas)
- : wxNotifyEvent(),
-   _canvas(canvas)
+ASSDrawMouseOnCanvasEvent::ASSDrawMouseOnCanvasEvent(const ASSDrawCanvas *canvas)
+    : wxNotifyEvent(),
+      _canvas(canvas)
 {
-	_data = NULL;
+    _data = NULL;
 }
 
-wxEvent* ASSDrawMouseOnCanvasEvent::Clone()
+wxEvent *ASSDrawMouseOnCanvasEvent::Clone()
 {
-	ASSDrawMouseOnCanvasEvent *clone = new ASSDrawMouseOnCanvasEvent(_canvas);
-	clone->SetData(_data);
-	return clone;
+    ASSDrawMouseOnCanvasEvent *clone = new ASSDrawMouseOnCanvasEvent(_canvas);
+    clone->SetData(_data);
+    return clone;
 }
 
 void ASSDrawMouseOnCanvasEvent::SetData(MouseOnCanvasData *data)
 {
-	_data = data;
+    _data = data;
 }
 
-MouseOnCanvasData* ASSDrawMouseOnCanvasEvent::GetData()
+MouseOnCanvasData *ASSDrawMouseOnCanvasEvent::GetData()
 {
-	return _data;
+    return _data;
 }
diff --git a/assdraw/canvas_mouse.hpp b/assdraw/canvas_mouse.hpp
index d64011336cf8cac65fdc4bf2c67b0f20c7862bc4..52433112f6622e9cda125773e4c1a8a03e4c4dee 100644
--- a/assdraw/canvas_mouse.hpp
+++ b/assdraw/canvas_mouse.hpp
@@ -33,53 +33,50 @@
 
 #include <wx/event.h>
 
-struct MouseOnCanvasData
-{
-	MODE mode;
-	wxMouseEvent event;
-	enum { NONE, LEFT, RIGHT, BOTH } button;
-
-    Point* mousedownAt_point;
-	Point* pointedAt_point;
-	Point* dblclicked_point_right;
-
-	wxPoint mouse_point;
-    wxPoint* dragAnchor_left;
-	wxPoint* lastDrag_left;
-    wxPoint* dragAnchor_right;
-	wxPoint* lastDrag_right;
+struct MouseOnCanvasData {
+    MODE mode;
+    wxMouseEvent event;
+    enum { NONE, LEFT, RIGHT, BOTH } button;
+
+    Point *mousedownAt_point;
+    Point *pointedAt_point;
+    Point *dblclicked_point_right;
+
+    wxPoint mouse_point;
+    wxPoint *dragAnchor_left;
+    wxPoint *lastDrag_left;
+    wxPoint *dragAnchor_right;
+    wxPoint *lastDrag_right;
 };
 
 class ASSDrawCanvas;
 
-class ASSDrawMouseOnCanvasEvent : public wxNotifyEvent
-{
+class ASSDrawMouseOnCanvasEvent : public wxNotifyEvent {
 public:
-	ASSDrawMouseOnCanvasEvent(const ASSDrawCanvas* canvas);
-	
-	wxEvent* Clone();
-	
-	void SetData(MouseOnCanvasData *data);
-	
-	MouseOnCanvasData* GetData();
-	
+    ASSDrawMouseOnCanvasEvent(const ASSDrawCanvas *canvas);
+
+    wxEvent *Clone();
+
+    void SetData(MouseOnCanvasData *data);
+
+    MouseOnCanvasData *GetData();
+
 private:
-	const ASSDrawCanvas* _canvas;
-	MouseOnCanvasData* _data;
+    const ASSDrawCanvas *_canvas;
+    MouseOnCanvasData *_data;
 
 };
 
 DECLARE_EVENT_TYPE( wxEVT_MOUSEONCANVAS, -1 )
 
-typedef void (wxEvtHandler::*wxMouseOnCanvasEventFunction)(ASSDrawMouseOnCanvasEvent&);
+typedef void (wxEvtHandler::*wxMouseOnCanvasEventFunction)(ASSDrawMouseOnCanvasEvent &);
 
 #define EVT_MOUSEONCANVAS(fn) \
     DECLARE_EVENT_TABLE_ENTRY( wxEVT_MOUSEONCANVAS, -1, -1, \
     (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) \
     wxStaticCastEvent( wxMouseOnCanvasEventFunction, & fn ), (wxObject *) NULL ),
 
-class ASSDrawMouseOnCanvasHandler
-{
-	
-	
+class ASSDrawMouseOnCanvasHandler {
+
+
 };
diff --git a/assdraw/cmd.cpp b/assdraw/cmd.cpp
index 58668f68f287630a117fc5a7cdf36241ee1d9b84..445f76e1973ff40fb0b828712c5967aa5fb12cf5 100644
--- a/assdraw/cmd.cpp
+++ b/assdraw/cmd.cpp
@@ -41,15 +41,15 @@
 
 // constructor
 DrawCmd_M::DrawCmd_M ( int x, int y, PointSystem *ps, DrawCmd *prev )
-     : DrawCmd ( x, y, ps, prev )
+    : DrawCmd ( x, y, ps, prev )
 {
-     type = M;
+    type = M;
 }
 
 // to ASS drawing command
 wxString DrawCmd_M::ToString()
 {
-     return wxString::Format(_T("m %d %d"), m_point->x(), m_point->y());
+    return wxString::Format(_T("m %d %d"), m_point->x(), m_point->y());
 }
 
 
@@ -60,15 +60,15 @@ wxString DrawCmd_M::ToString()
 
 // constructor
 DrawCmd_L::DrawCmd_L ( int x, int y, PointSystem *ps, DrawCmd *prev )
-     : DrawCmd ( x, y, ps, prev )
+    : DrawCmd ( x, y, ps, prev )
 {
-     type = L;
+    type = L;
 }
 
 // to ASS drawing command
 wxString DrawCmd_L::ToString()
 {
-     return wxString::Format(_T("l %d %d"), m_point->x(), m_point->y());
+    return wxString::Format(_T("l %d %d"), m_point->x(), m_point->y());
 }
 
 
@@ -82,57 +82,57 @@ DrawCmd_B::DrawCmd_B
 ( int x, int y, int x1, int y1, int x2, int y2, PointSystem *ps, DrawCmd *prev )
     : DrawCmd ( x, y, ps, prev )
 {
-     type = B;
-     controlpoints.push_back( new Point(x1, y1, ps, CP, this, 1) );
-     controlpoints.push_back( new Point(x2, y2, ps, CP, this, 2) );
-     initialized = true;
-     C1Cont = false;
+    type = B;
+    controlpoints.push_back( new Point(x1, y1, ps, CP, this, 1) );
+    controlpoints.push_back( new Point(x2, y2, ps, CP, this, 2) );
+    initialized = true;
+    C1Cont = false;
 }
 
 // constructor
 DrawCmd_B::DrawCmd_B ( int x, int y, PointSystem *ps, DrawCmd *prev )
     : DrawCmd ( x, y, ps, prev )
 {
-     type = B;
-     initialized = false;
-     C1Cont = false;
+    type = B;
+    initialized = false;
+    C1Cont = false;
 }
 
 // initialize; generate control points
 void DrawCmd_B::Init ( unsigned n )
 {
-     // Ignore if this is already initted
-     if (initialized) return;
+    // Ignore if this is already initted
+    if (initialized) return;
 
-     wxPoint wx0 = prev->m_point->ToWxPoint();
-     wxPoint wx1 = m_point->ToWxPoint();
-     int xdiff = (wx1.x - wx0.x) / 3;
-     int ydiff = (wx1.y - wx0.y) / 3;
-     int xg, yg;
+    wxPoint wx0 = prev->m_point->ToWxPoint();
+    wxPoint wx1 = m_point->ToWxPoint();
+    int xdiff = (wx1.x - wx0.x) / 3;
+    int ydiff = (wx1.y - wx0.y) / 3;
+    int xg, yg;
 
-     // first control
-     m_point->pointsys->FromWxPoint( wx0.x + xdiff, wx0.y + ydiff, xg, yg );
-     controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 1 ) );
+    // first control
+    m_point->pointsys->FromWxPoint( wx0.x + xdiff, wx0.y + ydiff, xg, yg );
+    controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 1 ) );
 
-     // second control
-     m_point->pointsys->FromWxPoint( wx1.x - xdiff, wx1.y - ydiff, xg, yg );
-     controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 2 ) );
+    // second control
+    m_point->pointsys->FromWxPoint( wx1.x - xdiff, wx1.y - ydiff, xg, yg );
+    controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 2 ) );
 
-     initialized = true;
+    initialized = true;
 
 }
 
 // to ASS drawing command
 wxString DrawCmd_B::ToString()
 {
-	if (initialized) {
-		PointList::iterator iterate = controlpoints.begin();
-		Point* c1 = (*iterate++);
-		Point* c2 = (*iterate);
-		return wxString::Format(_T("b %d %d %d %d %d %d"), c1->x(), c1->y(), c2->x(), c2->y(), m_point->x(), m_point->y());
-	}
-	else
-		return wxString::Format(_T("b ? ? ? ? %d %d"), m_point->x(), m_point->y());
+    if (initialized) {
+        PointList::iterator iterate = controlpoints.begin();
+        Point *c1 = (*iterate++);
+        Point *c2 = (*iterate);
+        return wxString::Format(_T("b %d %d %d %d %d %d"), c1->x(), c1->y(), c2->x(), c2->y(), m_point->x(), m_point->y());
+    }
+    else
+        return wxString::Format(_T("b ? ? ? ? %d %d"), m_point->x(), m_point->y());
 }
 
 
@@ -142,72 +142,70 @@ wxString DrawCmd_B::ToString()
 
 // constructor
 DrawCmd_S::DrawCmd_S
-	( int x, int y, PointSystem *ps, DrawCmd *prev )
+( int x, int y, PointSystem *ps, DrawCmd *prev )
     : DrawCmd ( x, y, ps, prev )
 {
-	type = S;
-	initialized = false;
-	closed = false;
+    type = S;
+    initialized = false;
+    closed = false;
 }
 
 // constructor
 DrawCmd_S::DrawCmd_S
-	( int x, int y, std::vector< int > vals, PointSystem *ps, DrawCmd *prev )
+( int x, int y, std::vector< int > vals, PointSystem *ps, DrawCmd *prev )
     : DrawCmd ( x, y, ps, prev )
 {
-	type = S;
-	std::vector< int >::iterator it = vals.begin();
-	unsigned n = 0;
-	while (it != vals.end())
-	{
-		int ix = *it; it++;
-		int iy = *it; it++;
-		n++;
-		//::wxLogMessage(_T("%d %d\n"), ix, iy);
-		controlpoints.push_back( new Point( ix, iy, ps, CP, this, n ) );
-	}
-
-	initialized = true;
-	closed = false;
+    type = S;
+    std::vector< int >::iterator it = vals.begin();
+    unsigned n = 0;
+    while (it != vals.end()) {
+        int ix = *it; it++;
+        int iy = *it; it++;
+        n++;
+        //::wxLogMessage(_T("%d %d\n"), ix, iy);
+        controlpoints.push_back( new Point( ix, iy, ps, CP, this, n ) );
+    }
+
+    initialized = true;
+    closed = false;
 }
 
 // initialize; generate control points
 void DrawCmd_S::Init(unsigned n)
 {
-     // Ignore if this is already initted
-     if (initialized) return;
+    // Ignore if this is already initted
+    if (initialized) return;
 
-     wxPoint wx0 = prev->m_point->ToWxPoint();
-     wxPoint wx1 = m_point->ToWxPoint();
-     int xdiff = (wx1.x - wx0.x) / 3;
-     int ydiff = (wx1.y - wx0.y) / 3;
-     int xg, yg;
+    wxPoint wx0 = prev->m_point->ToWxPoint();
+    wxPoint wx1 = m_point->ToWxPoint();
+    int xdiff = (wx1.x - wx0.x) / 3;
+    int ydiff = (wx1.y - wx0.y) / 3;
+    int xg, yg;
 
-     // first control
-     m_point->pointsys->FromWxPoint( wx0.x + xdiff, wx0.y + ydiff, xg, yg );
-     controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 1 ) );
+    // first control
+    m_point->pointsys->FromWxPoint( wx0.x + xdiff, wx0.y + ydiff, xg, yg );
+    controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 1 ) );
 
-     // second control
-     m_point->pointsys->FromWxPoint( wx1.x - xdiff, wx1.y - ydiff, xg, yg );
-     controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 2 ) );
+    // second control
+    m_point->pointsys->FromWxPoint( wx1.x - xdiff, wx1.y - ydiff, xg, yg );
+    controlpoints.push_back( new Point( xg, yg, m_point->pointsys, CP, this, 2 ) );
 
-     initialized = true;
+    initialized = true;
 
 }
 
 // to ASS drawing command
 wxString DrawCmd_S::ToString()
 {
-	PointList::iterator iterate = controlpoints.begin();
-	wxString assout = _T("s");
-	for (; iterate != controlpoints.end(); iterate++)
-	{
-		if (initialized)
-			assout = wxString::Format(_T("%s %d %d"), assout.c_str(), (*iterate)->x(), (*iterate)->y());
-		else
-			assout = wxString::Format(_T("%s ? ?"), assout.c_str());
-	}
-	assout = wxString::Format(_T("%s %d %d"), assout.c_str(), m_point->x(), m_point->y());
-	if (closed) assout = wxString::Format(_T("%s c"), assout.c_str());
-	return assout;
+    PointList::iterator iterate = controlpoints.begin();
+    wxString assout = _T("s");
+    for (; iterate != controlpoints.end(); iterate++) {
+        if (initialized)
+            assout = wxString::Format(_T("%s %d %d"), assout.c_str(), (*iterate)->x(), (*iterate)->y());
+        else
+            assout = wxString::Format(_T("%s ? ?"), assout.c_str());
+    }
+    assout = wxString::Format(_T("%s %d %d"), assout.c_str(), m_point->x(), m_point->y());
+    if (closed) assout = wxString::Format(_T("%s c"), assout.c_str());
+    return assout;
 }
diff --git a/assdraw/cmd.hpp b/assdraw/cmd.hpp
index 25ef16102644b29909116ee6eb36764b752f8af9..3f03470930464a3fa4578275d7932aca84be42b1 100644
--- a/assdraw/cmd.hpp
+++ b/assdraw/cmd.hpp
@@ -45,68 +45,64 @@ class DrawCmd_L;
 class DrawCmd_B;
 
 // The M command
-class DrawCmd_M: public DrawCmd
-{
+class DrawCmd_M: public DrawCmd {
 public:
-	// Constructor
-	DrawCmd_M ( int x, int y, PointSystem *ps, DrawCmd *prev );
-	
-	// to ASS drawing command
-	wxString ToString();
+    // Constructor
+    DrawCmd_M ( int x, int y, PointSystem *ps, DrawCmd *prev );
+
+    // to ASS drawing command
+    wxString ToString();
 
 };
 
 // The L command
-class DrawCmd_L: public DrawCmd
-{
+class DrawCmd_L: public DrawCmd {
 public:
-	// Constructor
-	DrawCmd_L ( int x, int y, PointSystem *ps, DrawCmd *prev );
-	
-	// to ASS drawing command
-	wxString ToString();
-	
+    // Constructor
+    DrawCmd_L ( int x, int y, PointSystem *ps, DrawCmd *prev );
+
+    // to ASS drawing command
+    wxString ToString();
+
 };
 
 // The B command
-class DrawCmd_B: public DrawCmd
-{
+class DrawCmd_B: public DrawCmd {
 public:
-	// Constructor
-	DrawCmd_B ( int x, int y, int x1, int y1, int x2, int y2,  PointSystem *ps, DrawCmd *prev );
-	
-	// Special constructor where only m_point is defined
-	// Need to call Init() to generate the controls
-	DrawCmd_B ( int x, int y, PointSystem *ps, DrawCmd *prev );
-	
-	// Init this B command; generate controlpoints
-	void Init ( unsigned n = 0 );
-	
-	// to ASS drawing command
-	wxString ToString();
-	
-	//special
-	bool C1Cont;
-	
+    // Constructor
+    DrawCmd_B ( int x, int y, int x1, int y1, int x2, int y2,  PointSystem *ps, DrawCmd *prev );
+
+    // Special constructor where only m_point is defined
+    // Need to call Init() to generate the controls
+    DrawCmd_B ( int x, int y, PointSystem *ps, DrawCmd *prev );
+
+    // Init this B command; generate controlpoints
+    void Init ( unsigned n = 0 );
+
+    // to ASS drawing command
+    wxString ToString();
+
+    //special
+    bool C1Cont;
+
 };
 
 // The S command
-class DrawCmd_S: public DrawCmd
-{
+class DrawCmd_S: public DrawCmd {
 public:
-	// Constructor
-	DrawCmd_S ( int x, int y, PointSystem *ps, DrawCmd *prev );
+    // Constructor
+    DrawCmd_S ( int x, int y, PointSystem *ps, DrawCmd *prev );
 
-	// Constructor (with points info)
-	DrawCmd_S ( int x, int y, std::vector< int > vals, PointSystem *ps, DrawCmd *prev );
+    // Constructor (with points info)
+    DrawCmd_S ( int x, int y, std::vector< int > vals, PointSystem *ps, DrawCmd *prev );
 
-	// Init this S command; generate controlpoints
-	void Init ( unsigned n = 0 );
+    // Init this S command; generate controlpoints
+    void Init ( unsigned n = 0 );
 
-	// to ASS drawing command
-	wxString ToString();
+    // to ASS drawing command
+    wxString ToString();
 
-	// special
-	bool closed;
+    // special
+    bool closed;
 };
 
diff --git a/assdraw/dlgctrl.cpp b/assdraw/dlgctrl.cpp
index 10a57d0d7b015f55f3c8f389ced793f242be0b73..a97cec34b8a7f55a0fc8b890125f7236c05b9ca5 100644
--- a/assdraw/dlgctrl.cpp
+++ b/assdraw/dlgctrl.cpp
@@ -40,12 +40,12 @@
 #endif
 
 BEGIN_EVENT_TABLE(ASSDrawSrcTxtCtrl, wxTextCtrl)
-	EVT_CHAR(ASSDrawSrcTxtCtrl::CustomOnChar)
-	EVT_TEXT(wxID_ANY, ASSDrawSrcTxtCtrl::CustomOnText)
+    EVT_CHAR(ASSDrawSrcTxtCtrl::CustomOnChar)
+    EVT_TEXT(wxID_ANY, ASSDrawSrcTxtCtrl::CustomOnText)
 END_EVENT_TABLE()
 
 BEGIN_EVENT_TABLE(ASSDrawTransformDlg, wxDialog)
-	EVT_COMBOBOX(-1, ASSDrawTransformDlg::OnTemplatesCombo)
+    EVT_COMBOBOX(-1, ASSDrawTransformDlg::OnTemplatesCombo)
 END_EVENT_TABLE()
 
 //BEGIN_EVENT_TABLE(ASSDrawCanvasRecenterButton, wxWindow)
@@ -56,182 +56,179 @@ END_EVENT_TABLE()
 // ----------------------------------------------------------------------------
 
 ASSDrawSrcTxtCtrl::ASSDrawSrcTxtCtrl(wxWindow *parent, ASSDrawFrame *frame)
-	: wxTextCtrl(parent, wxID_ANY, _T(""), __DPDS__ , wxTE_MULTILINE )
+    : wxTextCtrl(parent, wxID_ANY, _T(""), __DPDS__, wxTE_MULTILINE )
 {
-	m_frame = frame;
+    m_frame = frame;
 }
 
 void ASSDrawSrcTxtCtrl::CustomOnChar(wxKeyEvent &event)
 {
-	switch (event.GetKeyCode())
-	{
-	case WXK_RETURN:
-		m_frame->UpdateASSCommandStringFromSrcTxtCtrl(GetValue());
-		break;
-	case WXK_TAB:
-		break; //do nothing
-	default:
-		//m_frame->SetTitle(wxString::Format(_T("Key: %d"), event.GetKeyCode()));
-		event.Skip(true);
-	}
-
-	//SetBackgroundColour(IsModified()? wxColour(0xFF, 0xFF, 0x99):*wxWHITE);
+    switch (event.GetKeyCode()) {
+    case WXK_RETURN:
+        m_frame->UpdateASSCommandStringFromSrcTxtCtrl(GetValue());
+        break;
+    case WXK_TAB:
+        break; //do nothing
+    default:
+        //m_frame->SetTitle(wxString::Format(_T("Key: %d"), event.GetKeyCode()));
+        event.Skip(true);
+    }
+
+    //SetBackgroundColour(IsModified()? wxColour(0xFF, 0xFF, 0x99):*wxWHITE);
 }
 
 void ASSDrawSrcTxtCtrl::CustomOnText(wxCommandEvent &event)
 {
-	//SetBackgroundColour(IsModified()? wxColour(0xFF, 0xFF, 0x99):*wxWHITE);
+    //SetBackgroundColour(IsModified()? wxColour(0xFF, 0xFF, 0x99):*wxWHITE);
 }
 
 // ----------------------------------------------------------------------------
 // ASSDrawTransformDlg
 // ----------------------------------------------------------------------------
 
-ASSDrawTransformDlg::ASSDrawTransformDlg(ASSDrawFrame* parent)
- : wxDialog(parent, -1, wxString(_T("Transform")))
+ASSDrawTransformDlg::ASSDrawTransformDlg(ASSDrawFrame *parent)
+    : wxDialog(parent, -1, wxString(_T("Transform")))
 {
-	m_frame = parent;
+    m_frame = parent;
 
-    wxBoxSizer* sizer_main = new wxBoxSizer(wxVERTICAL);
+    wxBoxSizer *sizer_main = new wxBoxSizer(wxVERTICAL);
     this->SetSizer(sizer_main);
 
-    wxBoxSizer* sizer_templates = new wxBoxSizer(wxHORIZONTAL);
-    sizer_main->Add(sizer_templates, 0, wxGROW|wxLEFT, 5);
+    wxBoxSizer *sizer_templates = new wxBoxSizer(wxHORIZONTAL);
+    sizer_main->Add(sizer_templates, 0, wxGROW | wxLEFT, 5);
 
-    sizer_templates->Add(new wxStaticText( this, -1, _("Templates"), __DPDS__ , 0 ),
-						0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+    sizer_templates->Add(new wxStaticText( this, -1, _("Templates"), __DPDS__, 0 ),
+                         0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
 
-    combo_templates = new wxComboBox( this, -1, combo_templatesStrings[0], __DPDS__ , 10, combo_templatesStrings, wxCB_READONLY );
-    sizer_templates->Add(combo_templates, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+    combo_templates = new wxComboBox( this, -1, combo_templatesStrings[0], __DPDS__, 10, combo_templatesStrings, wxCB_READONLY );
+    sizer_templates->Add(combo_templates, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
 
-    wxFlexGridSizer* sizer_fields = new wxFlexGridSizer(3, 4, 0, 0);
-    sizer_main->Add(sizer_fields, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT, 5);
+    wxFlexGridSizer *sizer_fields = new wxFlexGridSizer(3, 4, 0, 0);
+    sizer_main->Add(sizer_fields, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT, 5);
 
-	int flag_txtctrl = wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL;
-	int flag_statictxt = wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL;
+    int flag_txtctrl = wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL;
+    int flag_statictxt = wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL;
 
-	sizer_fields->Add(new wxStaticText( this, -1, _("m11"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("m11"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_m11 = new wxTextCtrl( this, -1, _T("1.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_m11 = new wxTextCtrl( this, -1, _T("1.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_m11, 0, flag_txtctrl, 5);
 
-    sizer_fields->Add(new wxStaticText( this, -1, _("m12"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("m12"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_m12 = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_m12 = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_m12, 0, flag_txtctrl, 5);
 
-    sizer_fields->Add(new wxStaticText( this, -1, _("m21"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("m21"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_m21 = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_m21 = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_m21, 0, flag_txtctrl, 5);
 
-    sizer_fields->Add(new wxStaticText( this, -1, _("m22"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("m22"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_m22 = new wxTextCtrl( this, -1, _T("1.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_m22 = new wxTextCtrl( this, -1, _T("1.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_m22, 0, flag_txtctrl, 5);
 
-    sizer_fields->Add(new wxStaticText( this, -1, _("mx"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("mx"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_mx = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_mx = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_mx, 0, flag_txtctrl, 5);
 
-    sizer_fields->Add(new wxStaticText( this, -1, _("my"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("my"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_my = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_my = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_my, 0, flag_txtctrl, 5);
 
-    sizer_fields->Add(new wxStaticText( this, -1, _("nx"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("nx"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_nx = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_nx = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_nx, 0, flag_txtctrl, 5);
 
-    sizer_fields->Add(new wxStaticText( this, -1, _("ny"), __DPDS__ , 0 ),
-						0, flag_statictxt, 5);
+    sizer_fields->Add(new wxStaticText( this, -1, _("ny"), __DPDS__, 0 ),
+                      0, flag_statictxt, 5);
 
-    txtctrl_ny = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__ , wxTE_RIGHT );
+    txtctrl_ny = new wxTextCtrl( this, -1, _T("0.0"), __DPDS__, wxTE_RIGHT );
     sizer_fields->Add(txtctrl_ny, 0, flag_txtctrl, 5);
 
-    wxStaticBitmap* staticbmp = new wxStaticBitmap( this, -1, wxBITMAP(transform), wxDefaultPosition, wxSize(224, 56), 0 );
-    sizer_main->Add(staticbmp, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+    wxStaticBitmap *staticbmp = new wxStaticBitmap( this, -1, wxBITMAP(transform), wxDefaultPosition, wxSize(224, 56), 0 );
+    sizer_main->Add(staticbmp, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
 
-    wxStdDialogButtonSizer* sizer_stdbutt = new wxStdDialogButtonSizer;
+    wxStdDialogButtonSizer *sizer_stdbutt = new wxStdDialogButtonSizer;
 
-    sizer_main->Add(sizer_stdbutt, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
-    wxButton* button_ok = new wxButton( this, wxID_OK, _("&OK"), __DPDS__ , 0 );
+    sizer_main->Add(sizer_stdbutt, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+    wxButton *button_ok = new wxButton( this, wxID_OK, _("&OK"), __DPDS__, 0 );
     sizer_stdbutt->AddButton(button_ok);
 
-    wxButton* button_cancel = new wxButton( this, wxID_CANCEL, _("&Cancel"), __DPDS__ , 0 );
+    wxButton *button_cancel = new wxButton( this, wxID_CANCEL, _("&Cancel"), __DPDS__, 0 );
     sizer_stdbutt->AddButton(button_cancel);
 
     sizer_stdbutt->Realize();
 
-	sizer_main->Fit(this);
+    sizer_main->Fit(this);
 
 }
 
 void ASSDrawTransformDlg::OnTemplatesCombo(wxCommandEvent &event)
 {
-	int pos = -1;
-	for (int i = 0; i < combo_templatesCount; i++)
-		if (combo_templatesStrings[i].IsSameAs(((wxComboBox *) event.GetEventObject())->GetValue()))
-		{
-			pos = i;
-			break;
-		}
-	if (pos == -1)
-		return;
-
-	txtctrl_m11->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f1) );
-	txtctrl_m12->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f2) );
-	txtctrl_m21->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f3) );
-	txtctrl_m22->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f4) );
-	txtctrl_mx->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f5) );
-	txtctrl_my->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f6) );
-	txtctrl_nx->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f7) );
-	txtctrl_ny->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f8) );
+    int pos = -1;
+    for (int i = 0; i < combo_templatesCount; i++)
+        if (combo_templatesStrings[i].IsSameAs(((wxComboBox *) event.GetEventObject())->GetValue())) {
+            pos = i;
+            break;
+        }
+    if (pos == -1)
+        return;
+
+    txtctrl_m11->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f1) );
+    txtctrl_m12->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f2) );
+    txtctrl_m21->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f3) );
+    txtctrl_m22->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f4) );
+    txtctrl_mx->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f5) );
+    txtctrl_my->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f6) );
+    txtctrl_nx->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f7) );
+    txtctrl_ny->SetValue( wxString::Format(_T("%.1f"), combo_templatesValues[pos].f8) );
 }
 
 void ASSDrawTransformDlg::EndModal(int retCode)
 {
-	if (retCode != wxID_OK)
-	{
-		wxDialog::EndModal(retCode);
-		return;
-	}
-
-	bool ok = true;
-
-	ok = ok && txtctrl_m11->GetValue().ToDouble( &xformvals.f1 );
-	ok = ok && txtctrl_m12->GetValue().ToDouble( &xformvals.f2 );
-	ok = ok && txtctrl_m21->GetValue().ToDouble( &xformvals.f3 );
-	ok = ok && txtctrl_m22->GetValue().ToDouble( &xformvals.f4 );
-	ok = ok && txtctrl_mx->GetValue().ToDouble( &xformvals.f5 );
-	ok = ok && txtctrl_my->GetValue().ToDouble( &xformvals.f6 );
-	ok = ok && txtctrl_nx->GetValue().ToDouble( &xformvals.f7 );
-	ok = ok && txtctrl_ny->GetValue().ToDouble( &xformvals.f8 );
-
-	if (ok)
-		wxDialog::EndModal(wxID_OK);
-	else
-	    wxMessageBox(_T("One or more values entered are not real numbers.\nPlease fix."), _T("Value error"), wxOK | wxICON_INFORMATION, m_frame);
+    if (retCode != wxID_OK) {
+        wxDialog::EndModal(retCode);
+        return;
+    }
+
+    bool ok = true;
+
+    ok = ok && txtctrl_m11->GetValue().ToDouble( &xformvals.f1 );
+    ok = ok && txtctrl_m12->GetValue().ToDouble( &xformvals.f2 );
+    ok = ok && txtctrl_m21->GetValue().ToDouble( &xformvals.f3 );
+    ok = ok && txtctrl_m22->GetValue().ToDouble( &xformvals.f4 );
+    ok = ok && txtctrl_mx->GetValue().ToDouble( &xformvals.f5 );
+    ok = ok && txtctrl_my->GetValue().ToDouble( &xformvals.f6 );
+    ok = ok && txtctrl_nx->GetValue().ToDouble( &xformvals.f7 );
+    ok = ok && txtctrl_ny->GetValue().ToDouble( &xformvals.f8 );
+
+    if (ok)
+        wxDialog::EndModal(wxID_OK);
+    else
+        wxMessageBox(_T("One or more values entered are not real numbers.\nPlease fix."), _T("Value error"), wxOK | wxICON_INFORMATION, m_frame);
 
 }
 
 
 ASSDrawAboutDlg::ASSDrawAboutDlg(ASSDrawFrame *parent, unsigned timeout)
-	: wxDialog(parent, wxID_ANY, wxString(TITLE), __DPDS__ , wxSIMPLE_BORDER), time_out(timeout)
+    : wxDialog(parent, wxID_ANY, wxString(TITLE), __DPDS__, wxSIMPLE_BORDER), time_out(timeout)
 {
-	SetBackgroundColour(*wxWHITE);
-	htmlwin = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxSize(396, 200), wxHW_DEFAULT_STYLE | wxSIMPLE_BORDER);
-	htmlwin->SetPage(
-_T("<html><body> \
+    SetBackgroundColour(*wxWHITE);
+    htmlwin = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxSize(396, 200), wxHW_DEFAULT_STYLE | wxSIMPLE_BORDER);
+    htmlwin->SetPage(
+        _T("<html><body> \
 <p>ASSDraw3 is a tool for designing shapes to be used in ASS subtitle file. \
 <p>To add lines or curves, initiate the draw mode by clicking on the drawing tools. \
 Then, either click on empty space or drag from an existing point to add the new lines/curves. \
@@ -257,119 +254,117 @@ Control points for Bezier curves are generated once you release the mouse button
 </ul> \
 <p>ai-chan recommends Aegisub for all your subtitle and typesetting needs! \
 </body></html>")
-	);
-	htmlwin->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(ASSDrawAboutDlg::OnURL), NULL, this);
-
-	wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
-	sizer->AddGrowableCol(0);
-	//sizer->AddGrowableRow(1);
-
-	sizer->Add(new BigStaticBitmapCtrl(this, wxBITMAP(assdraw3_), *wxWHITE, this), 1, wxEXPAND);
-	sizer->Add(htmlwin, 1, wxLEFT | wxRIGHT, 2);
-	sizer->Add(new wxStaticText(this, wxID_ANY, wxString::Format(_T("Version: %s"), VERSION)), 1, wxEXPAND | wxALL, 2);
-	sizer->Add(new wxButton(this, wxID_OK), 0, wxALIGN_CENTER | wxBOTTOM, 10);
-	SetSizer(sizer);
-	sizer->Layout();
-	sizer->Fit(this);
-
-	Center();
-	//if (CanSetTransparent()) SetTransparent(0xCC);
-
-	timer.SetOwner(this);
-	Connect(wxEVT_TIMER, wxTimerEventHandler(ASSDrawAboutDlg::OnTimeout));
-	Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(ASSDrawAboutDlg::OnMouseEnterWindow));
+    );
+    htmlwin->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler(ASSDrawAboutDlg::OnURL), NULL, this);
+
+    wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
+    sizer->AddGrowableCol(0);
+    //sizer->AddGrowableRow(1);
+
+    sizer->Add(new BigStaticBitmapCtrl(this, wxBITMAP(assdraw3_), *wxWHITE, this), 1, wxEXPAND);
+    sizer->Add(htmlwin, 1, wxLEFT | wxRIGHT, 2);
+    sizer->Add(new wxStaticText(this, wxID_ANY, wxString::Format(_T("Version: %s"), VERSION)), 1, wxEXPAND | wxALL, 2);
+    sizer->Add(new wxButton(this, wxID_OK), 0, wxALIGN_CENTER | wxBOTTOM, 10);
+    SetSizer(sizer);
+    sizer->Layout();
+    sizer->Fit(this);
+
+    Center();
+    //if (CanSetTransparent()) SetTransparent(0xCC);
+
+    timer.SetOwner(this);
+    Connect(wxEVT_TIMER, wxTimerEventHandler(ASSDrawAboutDlg::OnTimeout));
+    Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(ASSDrawAboutDlg::OnMouseEnterWindow));
 }
 
 ASSDrawAboutDlg::~ASSDrawAboutDlg()
 {
-	timer.Stop();
+    timer.Stop();
 }
 
 int ASSDrawAboutDlg::ShowModal()
 {
-	if (time_out > 0)
-		timer.Start(time_out * 1000, true);
-	return wxDialog::ShowModal();
+    if (time_out > 0)
+        timer.Start(time_out * 1000, true);
+    return wxDialog::ShowModal();
 }
 
 void ASSDrawAboutDlg::OnURL(wxHtmlLinkEvent &event)
 {
-	wxString URL(event.GetLinkInfo().GetHref());
-	if (URL.StartsWith(_T("http://")))
-		::wxLaunchDefaultBrowser(URL);
-	else
-		event.Skip(true);
+    wxString URL(event.GetLinkInfo().GetHref());
+    if (URL.StartsWith(_T("http://")))
+        ::wxLaunchDefaultBrowser(URL);
+    else
+        event.Skip(true);
 }
 
-void ASSDrawAboutDlg::OnTimeout(wxTimerEvent& event)
+void ASSDrawAboutDlg::OnTimeout(wxTimerEvent &event)
 {
-	if (IsShown())
-		EndModal(wxID_OK);
+    if (IsShown())
+        EndModal(wxID_OK);
 }
 
-void ASSDrawAboutDlg::OnMouseEnterWindow(wxMouseEvent& event)
+void ASSDrawAboutDlg::OnMouseEnterWindow(wxMouseEvent &event)
 {
-	// if mouse enters this dialog, stop the timout timer
-	// and dialog will only close through user input
-	timer.Stop();
+    // if mouse enters this dialog, stop the timout timer
+    // and dialog will only close through user input
+    timer.Stop();
 }
 
 BEGIN_EVENT_TABLE(BigStaticBitmapCtrl, wxPanel)
-	EVT_PAINT(BigStaticBitmapCtrl::OnPaint)
+    EVT_PAINT(BigStaticBitmapCtrl::OnPaint)
     EVT_MOTION (BigStaticBitmapCtrl::OnMouseMove)
     EVT_LEFT_UP(BigStaticBitmapCtrl::OnMouseLeftUp)
     EVT_LEFT_DOWN(BigStaticBitmapCtrl::OnMouseLeftDown)
 END_EVENT_TABLE()
 
 BigStaticBitmapCtrl::BigStaticBitmapCtrl(wxWindow *parent, wxBitmap bmap, wxColour bgcol, wxWindow *todrag)
-	: wxPanel(parent, wxID_ANY)
+    : wxPanel(parent, wxID_ANY)
 {
-	bitmap = bmap;
-	bgbrush = wxBrush(bgcol);
-	window_to_drag = todrag;
-	SetSize(bitmap.GetWidth(), bitmap.GetHeight());
-	Refresh();
+    bitmap = bmap;
+    bgbrush = wxBrush(bgcol);
+    window_to_drag = todrag;
+    SetSize(bitmap.GetWidth(), bitmap.GetHeight());
+    Refresh();
 }
 
 BigStaticBitmapCtrl::~BigStaticBitmapCtrl()
 {
 }
 
-void BigStaticBitmapCtrl::OnPaint(wxPaintEvent& event)
+void BigStaticBitmapCtrl::OnPaint(wxPaintEvent &event)
 {
     wxPaintDC dc(this);
-	dc.SetBackground(bgbrush);
-	dc.Clear();
-    dc.DrawBitmap(bitmap, wxPoint(0,0));
+    dc.SetBackground(bgbrush);
+    dc.Clear();
+    dc.DrawBitmap(bitmap, wxPoint(0, 0));
 }
 
 void BigStaticBitmapCtrl::OnMouseLeftDown(wxMouseEvent &event)
 {
-	if (window_to_drag != NULL)
-	{
-		dragpoint = event.GetPosition();
-	}
-	CaptureMouse();
+    if (window_to_drag != NULL) {
+        dragpoint = event.GetPosition();
+    }
+    CaptureMouse();
 }
 
 void BigStaticBitmapCtrl::OnMouseLeftUp(wxMouseEvent &event)
 {
-	ReleaseMouse();
+    ReleaseMouse();
 }
 
 void BigStaticBitmapCtrl::OnMouseMove(wxMouseEvent &event)
 {
-	if (window_to_drag != NULL && event.Dragging() && HasCapture())
-	{
-		wxPoint npoint(event.GetPosition());
-		wxPoint wndpos = window_to_drag->GetScreenPosition();
-		wxPoint thispos = this->GetScreenPosition();
-		//ReleaseMouse();
-		window_to_drag->Move(wndpos.x + npoint.x - dragpoint.x,
-							 wndpos.y + npoint.y - dragpoint.y);
-		//CaptureMouse();
-		if (thispos == this->GetScreenPosition()) // if this ctrl did not move when window_to_drag moved
-			dragpoint = npoint;
-	}
-	event.Skip(true);
+    if (window_to_drag != NULL && event.Dragging() && HasCapture()) {
+        wxPoint npoint(event.GetPosition());
+        wxPoint wndpos = window_to_drag->GetScreenPosition();
+        wxPoint thispos = this->GetScreenPosition();
+        //ReleaseMouse();
+        window_to_drag->Move(wndpos.x + npoint.x - dragpoint.x,
+                             wndpos.y + npoint.y - dragpoint.y);
+        //CaptureMouse();
+        if (thispos == this->GetScreenPosition()) // if this ctrl did not move when window_to_drag moved
+            dragpoint = npoint;
+    }
+    event.Skip(true);
 }
diff --git a/assdraw/dlgctrl.hpp b/assdraw/dlgctrl.hpp
index b5225d181a0ff9dba99c92c868205869134529a0..a7e07a814e2742a75808002e3fb8ca1d41bdf166 100644
--- a/assdraw/dlgctrl.hpp
+++ b/assdraw/dlgctrl.hpp
@@ -34,82 +34,77 @@
 
 class ASSDrawFrame;
 
-class ASSDrawSrcTxtCtrl : public wxTextCtrl
-{
+class ASSDrawSrcTxtCtrl : public wxTextCtrl {
 public:
-	ASSDrawSrcTxtCtrl(wxWindow *parent, ASSDrawFrame *frame);
-	virtual void CustomOnChar(wxKeyEvent &event);
-	virtual void CustomOnText(wxCommandEvent &event);
+    ASSDrawSrcTxtCtrl(wxWindow *parent, ASSDrawFrame *frame);
+    virtual void CustomOnChar(wxKeyEvent &event);
+    virtual void CustomOnText(wxCommandEvent &event);
 
 protected:
-	ASSDrawFrame *m_frame;
-	DECLARE_EVENT_TABLE()
+    ASSDrawFrame *m_frame;
+    DECLARE_EVENT_TABLE()
 };
 
-struct EightDouble
-{
-	double f1, f2, f3, f4, f5, f6, f7, f8;
+struct EightDouble {
+    double f1, f2, f3, f4, f5, f6, f7, f8;
 };
 
-class ASSDrawTransformDlg : public wxDialog
-{
+class ASSDrawTransformDlg : public wxDialog {
 
 public:
-	ASSDrawTransformDlg(ASSDrawFrame* parent);
-	void OnTemplatesCombo(wxCommandEvent &event);
-	void EndModal(int retCode);
-
-	ASSDrawFrame* m_frame;
-	wxComboBox* combo_templates;
-	wxTextCtrl* txtctrl_m11;
-	wxTextCtrl* txtctrl_m12;
-	wxTextCtrl* txtctrl_m21;
-	wxTextCtrl* txtctrl_m22;
-	wxTextCtrl* txtctrl_mx;
-	wxTextCtrl* txtctrl_my;
-	wxTextCtrl* txtctrl_nx;
-	wxTextCtrl* txtctrl_ny;
-	EightDouble xformvals;
-
-	static wxString combo_templatesStrings[];
-	static int combo_templatesCount;
-	static EightDouble combo_templatesValues[];
-
-	DECLARE_EVENT_TABLE()
+    ASSDrawTransformDlg(ASSDrawFrame *parent);
+    void OnTemplatesCombo(wxCommandEvent &event);
+    void EndModal(int retCode);
+
+    ASSDrawFrame *m_frame;
+    wxComboBox *combo_templates;
+    wxTextCtrl *txtctrl_m11;
+    wxTextCtrl *txtctrl_m12;
+    wxTextCtrl *txtctrl_m21;
+    wxTextCtrl *txtctrl_m22;
+    wxTextCtrl *txtctrl_mx;
+    wxTextCtrl *txtctrl_my;
+    wxTextCtrl *txtctrl_nx;
+    wxTextCtrl *txtctrl_ny;
+    EightDouble xformvals;
+
+    static wxString combo_templatesStrings[];
+    static int combo_templatesCount;
+    static EightDouble combo_templatesValues[];
+
+    DECLARE_EVENT_TABLE()
 
 };
 
-class ASSDrawAboutDlg : public wxDialog
-{
+class ASSDrawAboutDlg : public wxDialog {
 public:
-	ASSDrawAboutDlg(ASSDrawFrame *parent, unsigned timeout = 0);
-	virtual ~ASSDrawAboutDlg();
-	virtual void OnURL(wxHtmlLinkEvent &event);
-	virtual int ShowModal();
-	virtual void OnTimeout(wxTimerEvent& event);
-	virtual void OnMouseEnterWindow(wxMouseEvent& event);
+    ASSDrawAboutDlg(ASSDrawFrame *parent, unsigned timeout = 0);
+    virtual ~ASSDrawAboutDlg();
+    virtual void OnURL(wxHtmlLinkEvent &event);
+    virtual int ShowModal();
+    virtual void OnTimeout(wxTimerEvent &event);
+    virtual void OnMouseEnterWindow(wxMouseEvent &event);
 
 protected:
-	wxTimer timer;
-	wxHtmlWindow *htmlwin;
-	const unsigned time_out;
+    wxTimer timer;
+    wxHtmlWindow *htmlwin;
+    const unsigned time_out;
 };
 
-class BigStaticBitmapCtrl : public wxPanel
-{
+class BigStaticBitmapCtrl : public wxPanel {
 public:
-	BigStaticBitmapCtrl(wxWindow *parent, wxBitmap bmap, wxColour bgcol, wxWindow *todrag = NULL);
-	virtual ~BigStaticBitmapCtrl();
-	virtual void OnPaint(wxPaintEvent& event);
-	virtual void OnMouseLeftDown(wxMouseEvent &event);
-	virtual void OnMouseLeftUp(wxMouseEvent &event);
-	virtual void OnMouseMove(wxMouseEvent &event);
+    BigStaticBitmapCtrl(wxWindow *parent, wxBitmap bmap, wxColour bgcol, wxWindow *todrag = NULL);
+    virtual ~BigStaticBitmapCtrl();
+    virtual void OnPaint(wxPaintEvent &event);
+    virtual void OnMouseLeftDown(wxMouseEvent &event);
+    virtual void OnMouseLeftUp(wxMouseEvent &event);
+    virtual void OnMouseMove(wxMouseEvent &event);
 
 protected:
-	wxBitmap bitmap;
-	wxBrush bgbrush;
-	wxWindow *window_to_drag;
-	wxPoint dragpoint, wndpos;
+    wxBitmap bitmap;
+    wxBrush bgbrush;
+    wxWindow *window_to_drag;
+    wxPoint dragpoint, wndpos;
 
-	DECLARE_EVENT_TABLE()
+    DECLARE_EVENT_TABLE()
 };
diff --git a/assdraw/engine.cpp b/assdraw/engine.cpp
index 5f78fe5f788017c69e7ac97635dbc24dcd43f490..fa460ebf1fd9c56ed8d3f9783b241f0cdce0b3d9 100644
--- a/assdraw/engine.cpp
+++ b/assdraw/engine.cpp
@@ -47,48 +47,48 @@
 // ----------------------------------------------------------------------------
 
 // constructor
-Point::Point ( int _x, int _y, PointSystem* ps, POINTTYPE t, DrawCmd* cmd, unsigned n )
+Point::Point ( int _x, int _y, PointSystem *ps, POINTTYPE t, DrawCmd *cmd, unsigned n )
 {
-	x_ = _x;
-	y_ = _y;
-	pointsys = ps;
-	cmd_main = cmd;
-	cmd_next = NULL;
-	type = t;
-	isselected = false;
-	num = n;
+    x_ = _x;
+    y_ = _y;
+    pointsys = ps;
+    cmd_main = cmd;
+    cmd_next = NULL;
+    type = t;
+    isselected = false;
+    num = n;
 }
 
 // setters
 void Point::setXY( int _x, int _y)
 {
-	x_ = _x;
-	y_ = _y;
+    x_ = _x;
+    y_ = _y;
 }
 
 // simply returns true if px and py are the coordinate values
 bool Point::IsAt( int px, int py )
 {
-	return (x_ == px && y_ == py );
+    return (x_ == px && y_ == py );
 }
 
 // convert this point to wxPoint using scale and originx, originy
 wxPoint Point::ToWxPoint ( bool useorigin )
 {
-	if (useorigin)
-		return pointsys->ToWxPoint( x_, y_ );
-	else
-		return *(new wxPoint(x_ * (int) pointsys->scale, y_ * (int) pointsys->scale ));
+    if (useorigin)
+        return pointsys->ToWxPoint( x_, y_ );
+    else
+        return *(new wxPoint(x_ * (int) pointsys->scale, y_ * (int) pointsys->scale ));
 }
 
 // check if wxpoint is nearby this point
 bool Point::CheckWxPoint ( wxPoint wxpoint )
 {
-	wxPoint p = ToWxPoint();
-	int cx, cy;
-	pointsys->FromWxPoint( wxpoint, cx, cy );
-	//delete &p;
-	return (x_ == cx && y_ == cy );
+    wxPoint p = ToWxPoint();
+    int cx, cy;
+    pointsys->FromWxPoint( wxpoint, cx, cy );
+    //delete &p;
+    return (x_ == cx && y_ == cy );
 }
 
 
@@ -100,21 +100,21 @@ bool Point::CheckWxPoint ( wxPoint wxpoint )
 // constructor
 DrawCmd::DrawCmd ( int x, int y, PointSystem *ps, DrawCmd *pv )
 {
-	m_point = new Point ( x, y, ps, MP, this );
-	m_point->cmd_main = this;
-	prev = pv;
-	dobreak = false;
-	invisible = false;
+    m_point = new Point ( x, y, ps, MP, this );
+    m_point->cmd_main = this;
+    prev = pv;
+    dobreak = false;
+    invisible = false;
 }
 
 // destructor
 DrawCmd::~DrawCmd ( )
 {
-	if (m_point)
-		delete m_point;
-	for (PointList::iterator iter_cpoint = controlpoints.begin();
-			iter_cpoint != controlpoints.end(); iter_cpoint++)
-		delete (*iter_cpoint);
+    if (m_point)
+        delete m_point;
+    for (PointList::iterator iter_cpoint = controlpoints.begin();
+         iter_cpoint != controlpoints.end(); iter_cpoint++)
+        delete (*iter_cpoint);
 }
 
 
@@ -129,18 +129,18 @@ END_EVENT_TABLE()
 
 // constructor
 ASSDrawEngine::ASSDrawEngine( wxWindow *parent, int extraflags )
- : GUI::AGGWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
-        wxNO_FULL_REPAINT_ON_RESIZE | extraflags )
+    : GUI::AGGWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
+                     wxNO_FULL_REPAINT_ON_RESIZE | extraflags )
 {
-	pointsys = new PointSystem(1, 0, 0) ;
-	refresh_called = false;
-	fitviewpoint_hmargin = 10;
-	fitviewpoint_vmargin = 10;
-	setfitviewpoint = false;
-	rgba_shape = agg::rgba(0,0,1);
-	color_bg = PixelFormat::AGGType::color_type(255, 255, 255);
-	drawcmdset = _T("m n l b s p c _"); //the spaces and underscore are in there for a reason, guess?
-	ResetEngine();
+    pointsys = new PointSystem(1, 0, 0) ;
+    refresh_called = false;
+    fitviewpoint_hmargin = 10;
+    fitviewpoint_vmargin = 10;
+    setfitviewpoint = false;
+    rgba_shape = agg::rgba(0, 0, 1);
+    color_bg = PixelFormat::AGGType::color_type(255, 255, 255);
+    drawcmdset = _T("m n l b s p c _"); //the spaces and underscore are in there for a reason, guess?
+    ResetEngine();
 }
 
 ASSDrawEngine::~ASSDrawEngine()
@@ -152,115 +152,104 @@ ASSDrawEngine::~ASSDrawEngine()
 // parse ASS draw commands; returns the number of parsed commands
 int ASSDrawEngine::ParseASS ( wxString str )
 {
-	ResetEngine( false );
-	str.Replace(_T("\t"), _T(""));
-	str.Replace(_T("\r"), _T(""));
-	str.Replace(_T("\n"), _T(""));
-	str = str.Lower() + _T(" _ _");
-	// we don't use regex because the pattern is too simple
-	wxStringTokenizer tkz( str, _T(" ") );
-	wxString currcmd(_T(""));
-	std::vector<int> val;
-	wxString token;
-	long tmp_int;
-
-	bool n_collected = false;
-	DrawCmd_S *s_command = NULL;
-	wxPoint tmp_n_pnt;
-
-	while ( tkz.HasMoreTokens() )
-	{
-		token = tkz.GetNextToken();
-
-		if ( drawcmdset.Find(token) > -1 )
-		{
-			bool done;
-
-			do {
-				done = true;
-
-				// N
-				if (currcmd.IsSameAs(_T("n")) && val.size() >= 2)
-				{
-					tmp_n_pnt.x = val[0], tmp_n_pnt.y = val[1];
-					n_collected = true;
-				}
-				else if(n_collected)
-				{
-					AppendCmd ( L, tmp_n_pnt.x, tmp_n_pnt.y );
-					n_collected = false;
-				}
-
-				if (s_command != NULL)
-				{
-					bool ends = true;
-					if (currcmd.IsSameAs(_T("p"))&& val.size() >= 2)
-					{
-						s_command->m_point->type = CP;
-						s_command->m_point->num = s_command->controlpoints.size() + 1;
-						s_command->controlpoints.push_back(s_command->m_point);
-						s_command->m_point = new Point(val[0], val[1], pointsys, MP, s_command);
-						ends = false;
-					}
-					else if (currcmd.IsSameAs(_T("c")))
-						s_command->closed = true;
-
-					if (ends)
-					{
-						AppendCmd(s_command);
-						s_command = NULL;
-					}
-				}
-
-				// M
-				if (currcmd.IsSameAs(_T("m")) && val.size() >= 2)
-					AppendCmd ( M, val[0], val[1] );
-
-				// L
-				if (currcmd.IsSameAs(_T("l")) && val.size() >= 2)
-				{
-					AppendCmd ( L, val[0], val[1] );
-					val.erase(val.begin(), val.begin()+2);
-					// L is greedy
-					if (val.size() >= 2)
-						done = false;
-				}
-
-				// B
-				if (currcmd.IsSameAs(_T("b")) && val.size() >= 6)
-				{
-					AppendCmd ( new DrawCmd_B(val[4], val[5], val[0], val[1],
-					val[2], val[3], pointsys, LastCmd()) );
-					val.erase(val.begin(), val.begin()+6);
-					// so is B
-					if (val.size() >= 6)
-						done = false;
-				}
-
-				// S
-				if (currcmd.IsSameAs(_T("s")) && val.size() >= 6)
-				{
-					int num = (val.size() / 2) * 2;
-					std::vector<int> val2;
-					int i = 0;
-					for (; i < num - 2; i++)
-						val2.push_back(val[i]);
-
-					s_command = new DrawCmd_S(val[num - 2], val[num - 1], val2, pointsys, LastCmd());
-				}
-				// more to come later
-			} while (!done);
-
-			val.clear();
-			currcmd = token;
-		}
-		else if (token.ToLong( &tmp_int ))
-		{
-			val.push_back( (int) tmp_int );
-		}
-	}
-
-	return (int) cmds.size();
+    ResetEngine( false );
+    str.Replace(_T("\t"), _T(""));
+    str.Replace(_T("\r"), _T(""));
+    str.Replace(_T("\n"), _T(""));
+    str = str.Lower() + _T(" _ _");
+    // we don't use regex because the pattern is too simple
+    wxStringTokenizer tkz( str, _T(" ") );
+    wxString currcmd(_T(""));
+    std::vector<int> val;
+    wxString token;
+    long tmp_int;
+
+    bool n_collected = false;
+    DrawCmd_S *s_command = NULL;
+    wxPoint tmp_n_pnt;
+
+    while ( tkz.HasMoreTokens() ) {
+        token = tkz.GetNextToken();
+
+        if ( drawcmdset.Find(token) > -1 ) {
+            bool done;
+
+            do {
+                done = true;
+
+                // N
+                if (currcmd.IsSameAs(_T("n")) && val.size() >= 2) {
+                    tmp_n_pnt.x = val[0], tmp_n_pnt.y = val[1];
+                    n_collected = true;
+                }
+                else if (n_collected) {
+                    AppendCmd ( L, tmp_n_pnt.x, tmp_n_pnt.y );
+                    n_collected = false;
+                }
+
+                if (s_command != NULL) {
+                    bool ends = true;
+                    if (currcmd.IsSameAs(_T("p")) && val.size() >= 2) {
+                        s_command->m_point->type = CP;
+                        s_command->m_point->num = s_command->controlpoints.size() + 1;
+                        s_command->controlpoints.push_back(s_command->m_point);
+                        s_command->m_point = new Point(val[0], val[1], pointsys, MP, s_command);
+                        ends = false;
+                    }
+                    else if (currcmd.IsSameAs(_T("c")))
+                        s_command->closed = true;
+
+                    if (ends) {
+                        AppendCmd(s_command);
+                        s_command = NULL;
+                    }
+                }
+
+                // M
+                if (currcmd.IsSameAs(_T("m")) && val.size() >= 2)
+                    AppendCmd ( M, val[0], val[1] );
+
+                // L
+                if (currcmd.IsSameAs(_T("l")) && val.size() >= 2) {
+                    AppendCmd ( L, val[0], val[1] );
+                    val.erase(val.begin(), val.begin() + 2);
+                    // L is greedy
+                    if (val.size() >= 2)
+                        done = false;
+                }
+
+                // B
+                if (currcmd.IsSameAs(_T("b")) && val.size() >= 6) {
+                    AppendCmd ( new DrawCmd_B(val[4], val[5], val[0], val[1],
+                                              val[2], val[3], pointsys, LastCmd()) );
+                    val.erase(val.begin(), val.begin() + 6);
+                    // so is B
+                    if (val.size() >= 6)
+                        done = false;
+                }
+
+                // S
+                if (currcmd.IsSameAs(_T("s")) && val.size() >= 6) {
+                    int num = (val.size() / 2) * 2;
+                    std::vector<int> val2;
+                    int i = 0;
+                    for (; i < num - 2; i++)
+                        val2.push_back(val[i]);
+
+                    s_command = new DrawCmd_S(val[num - 2], val[num - 1], val2, pointsys, LastCmd());
+                }
+                // more to come later
+            } while (!done);
+
+            val.clear();
+            currcmd = token;
+        }
+        else if (token.ToLong( &tmp_int )) {
+            val.push_back( (int) tmp_int );
+        }
+    }
+
+    return (int) cmds.size();
 }
 
 // generate ASS draw commands
@@ -268,430 +257,403 @@ wxString ASSDrawEngine::GenerateASS ( )
 {
     wxString output = _T("");
     for (DrawCmdList::iterator iterate = cmds.begin(); iterate != cmds.end(); iterate++)
-         output = output + (*iterate)->ToString() + _T(" ");
-     return output;
+        output = output + (*iterate)->ToString() + _T(" ");
+    return output;
 }
 
 // reset; delete all points and add a new M(0,0)
 void ASSDrawEngine::ResetEngine()
 {
-     ResetEngine(true);
+    ResetEngine(true);
 }
 
 // reset; delete all points and add a new M(0,0) if addM == true
 void ASSDrawEngine::ResetEngine( bool addM )
 {
-	for (DrawCmdList::iterator iterate = cmds.begin(); iterate != cmds.end(); iterate++)
-		delete (*iterate);
-	cmds.clear();
-	if (addM) AppendCmd( M, 0, 0 );
+    for (DrawCmdList::iterator iterate = cmds.begin(); iterate != cmds.end(); iterate++)
+        delete (*iterate);
+    cmds.clear();
+    if (addM) AppendCmd( M, 0, 0 );
 }
 
 // Create draw command of type 'type' and m_point (x, y), append to the
 // list and return it
-DrawCmd* ASSDrawEngine::AppendCmd ( CMDTYPE type, int x, int y )
+DrawCmd *ASSDrawEngine::AppendCmd ( CMDTYPE type, int x, int y )
 {
 
-	// use a variation of this method
-	return AppendCmd( NewCmd( type, x, y ) );
+    // use a variation of this method
+    return AppendCmd( NewCmd( type, x, y ) );
 }
 
 // Append draw command
-DrawCmd* ASSDrawEngine::AppendCmd ( DrawCmd* cmd )
+DrawCmd *ASSDrawEngine::AppendCmd ( DrawCmd *cmd )
 {
-	// no NULL command!
-	if (cmd == NULL) return NULL;
+    // no NULL command!
+    if (cmd == NULL) return NULL;
 
-	// set dependency of this command on the m_point of the last command
-	if (!cmds.empty())
-		ConnectSubsequentCmds( cmds.back(), cmd );
-	else
-	{
-		// since this is the first command, if it's not an M make it into one
-		if (cmd->type != M)
-			cmd = NewCmd( M, cmd->m_point->x(), cmd->m_point->y() );
-		ConnectSubsequentCmds( NULL, cmd );
-	}
-	// put it in the list
-	cmds.push_back( cmd );
+    // set dependency of this command on the m_point of the last command
+    if (!cmds.empty())
+        ConnectSubsequentCmds( cmds.back(), cmd );
+    else {
+        // since this is the first command, if it's not an M make it into one
+        if (cmd->type != M)
+            cmd = NewCmd( M, cmd->m_point->x(), cmd->m_point->y() );
+        ConnectSubsequentCmds( NULL, cmd );
+    }
+    // put it in the list
+    cmds.push_back( cmd );
 
-	return cmd;
+    return cmd;
 }
 
 // create draw command of type 'type' and m_point (x, y), insert to the
 // list after the _cmd and return it
-DrawCmd* ASSDrawEngine::InsertCmd ( CMDTYPE type, int x, int y, DrawCmd* _cmd )
+DrawCmd *ASSDrawEngine::InsertCmd ( CMDTYPE type, int x, int y, DrawCmd *_cmd )
 {
-     // prepare the new DrawCmd
-     DrawCmd* c = NewCmd( type, x, y );
+    // prepare the new DrawCmd
+    DrawCmd *c = NewCmd( type, x, y );
 
-     // use a variation of this method
-     InsertCmd( c, _cmd );
+    // use a variation of this method
+    InsertCmd( c, _cmd );
 
-     return NULL;
+    return NULL;
 }
 
 // insert draw command cmd after _cmd
-void ASSDrawEngine::InsertCmd ( DrawCmd* cmd, DrawCmd* _cmd )
+void ASSDrawEngine::InsertCmd ( DrawCmd *cmd, DrawCmd *_cmd )
 {
-     DrawCmdList::iterator iterate = cmds.begin();
-     for (; iterate != cmds.end() && *iterate != _cmd; iterate++)
-     {
-         // do nothing
-     }
+    DrawCmdList::iterator iterate = cmds.begin();
+    for (; iterate != cmds.end() && *iterate != _cmd; iterate++) {
+        // do nothing
+    }
 
-     if (iterate == cmds.end())
-     {
+    if (iterate == cmds.end()) {
         AppendCmd( cmd );
-     }
-     else
-     {
+    }
+    else {
         iterate++;
-        if (iterate != cmds.end())
-        {
-           ConnectSubsequentCmds( cmd, (*iterate) );
+        if (iterate != cmds.end()) {
+            ConnectSubsequentCmds( cmd, (*iterate) );
         }
         cmds.insert( iterate, cmd );
         ConnectSubsequentCmds( _cmd, cmd );
-     }
+    }
 }
 
-DrawCmd* ASSDrawEngine::NewCmd ( CMDTYPE type, int x, int y )
+DrawCmd *ASSDrawEngine::NewCmd ( CMDTYPE type, int x, int y )
 {
-     DrawCmd* c = NULL;
+    DrawCmd *c = NULL;
 
-     switch (type)
-     {
-        case M:
-             c = new DrawCmd_M(x, y, pointsys, LastCmd());
-             break;
-        case L:
-             c = new DrawCmd_L(x, y, pointsys, LastCmd());
-             break;
-        case B:
-             c = new DrawCmd_B(x, y, pointsys, LastCmd());
-             break;
-        case S:
-             c = new DrawCmd_S(x, y, pointsys, LastCmd());
-             break;
-     }
-     return c;
+    switch (type) {
+    case M:
+        c = new DrawCmd_M(x, y, pointsys, LastCmd());
+        break;
+    case L:
+        c = new DrawCmd_L(x, y, pointsys, LastCmd());
+        break;
+    case B:
+        c = new DrawCmd_B(x, y, pointsys, LastCmd());
+        break;
+    case S:
+        c = new DrawCmd_S(x, y, pointsys, LastCmd());
+        break;
+    }
+    return c;
 }
 
 // returns the iterator for the list
 DrawCmdList::iterator ASSDrawEngine::Iterator ( )
 {
-	return cmds.begin();
+    return cmds.begin();
 }
 
 // returns the 'end' iterator for the list
 DrawCmdList::iterator ASSDrawEngine::IteratorEnd ( )
 {
-	return cmds.end();
+    return cmds.end();
 }
 
 // returns the last command in the list
-DrawCmd* ASSDrawEngine::LastCmd ()
+DrawCmd *ASSDrawEngine::LastCmd ()
 {
-	if (cmds.size() == 0)
-		return NULL;
-	else
-		return cmds.back();
+    if (cmds.size() == 0)
+        return NULL;
+    else
+        return cmds.back();
 }
 
 // move all points by relative amount of x, y coordinates
 void ASSDrawEngine::MovePoints ( int x, int y )
 {
-     DrawCmdList::iterator iterate = cmds.begin();
-     PointList::iterator iterate2;
+    DrawCmdList::iterator iterate = cmds.begin();
+    PointList::iterator iterate2;
 
-     for (; iterate != cmds.end(); iterate++)
-     {
-         (*iterate)->m_point->setXY( (*iterate)->m_point->x() + x, (*iterate)->m_point->y() + y );
-         for (iterate2 = (*iterate)->controlpoints.begin();
-		 	iterate2 != (*iterate)->controlpoints.end(); iterate2++)
-         {
-			(*iterate2)->setXY( (*iterate2)->x() + x, (*iterate2)->y() + y );
-         }
-	}
+    for (; iterate != cmds.end(); iterate++) {
+        (*iterate)->m_point->setXY( (*iterate)->m_point->x() + x, (*iterate)->m_point->y() + y );
+        for (iterate2 = (*iterate)->controlpoints.begin();
+             iterate2 != (*iterate)->controlpoints.end(); iterate2++) {
+            (*iterate2)->setXY( (*iterate2)->x() + x, (*iterate2)->y() + y );
+        }
+    }
 }
 
 // transform all points using the calculation:
 //   | (m11)  (m12) | x | (x - mx) | + | nx |
 //   | (m21)  (m22) |   | (y - my) |   | ny |
 void ASSDrawEngine::Transform( float m11, float m12, float m21, float m22,
-							float mx, float my, float nx, float ny )
+                               float mx, float my, float nx, float ny )
 {
     DrawCmdList::iterator iterate = cmds.begin();
     PointList::iterator iterate2;
-	float x, y;
-	for (; iterate != cmds.end(); iterate++)
-	{
-		x = ((float) (*iterate)->m_point->x()) - mx;
-		y = ((float) (*iterate)->m_point->y()) - my;
-		(*iterate)->m_point->setXY((int) (x * m11 + y * m12 + nx), (int) (x * m21 + y * m22 + ny) );
-		for (iterate2 = (*iterate)->controlpoints.begin();
-			 iterate2 != (*iterate)->controlpoints.end(); iterate2++)
-		{
-			x = ((float) (*iterate2)->x()) - mx;
-			y = ((float) (*iterate2)->y()) - my;
-			(*iterate2)->setXY((int) (x * m11 + y * m12 + nx), (int) (x * m21 + y * m22 + ny) );
-		}
-	}
+    float x, y;
+    for (; iterate != cmds.end(); iterate++) {
+        x = ((float) (*iterate)->m_point->x()) - mx;
+        y = ((float) (*iterate)->m_point->y()) - my;
+        (*iterate)->m_point->setXY((int) (x * m11 + y * m12 + nx), (int) (x * m21 + y * m22 + ny) );
+        for (iterate2 = (*iterate)->controlpoints.begin();
+             iterate2 != (*iterate)->controlpoints.end(); iterate2++) {
+            x = ((float) (*iterate2)->x()) - mx;
+            y = ((float) (*iterate2)->y()) - my;
+            (*iterate2)->setXY((int) (x * m11 + y * m12 + nx), (int) (x * m21 + y * m22 + ny) );
+        }
+    }
 }
 
 // returns some DrawCmd if its m_point = (x, y)
-DrawCmd* ASSDrawEngine::PointAt ( int x, int y )
+DrawCmd *ASSDrawEngine::PointAt ( int x, int y )
 {
-     DrawCmd* c = NULL;
-	 DrawCmdList::iterator iterate = cmds.begin();
+    DrawCmd *c = NULL;
+    DrawCmdList::iterator iterate = cmds.begin();
 
-     for (; iterate != cmds.end(); iterate++)
-     {
-         if ( (*iterate)->m_point->IsAt( x, y ) )
+    for (; iterate != cmds.end(); iterate++) {
+        if ( (*iterate)->m_point->IsAt( x, y ) )
             c = (*iterate);
-     }
+    }
 
-     //delete &iterate;
+    //delete &iterate;
 
-     return c;
+    return c;
 }
 
 // returns some DrawCmd if one of its control point = (x, y)
 // also set &point to refer to that control point
-DrawCmd* ASSDrawEngine::ControlAt ( int x, int y, Point* &point )
-{
-	DrawCmd* c = NULL;
-	point = NULL;
-	DrawCmdList::iterator cmd_iterator = cmds.begin();
-	PointList::iterator pnt_iterator;
-	PointList::iterator end;
-
-	for (; cmd_iterator != cmds.end(); cmd_iterator++)
-	{
-		pnt_iterator = (*cmd_iterator)->controlpoints.begin();
-		end = (*cmd_iterator)->controlpoints.end();
-		for (; pnt_iterator != end; pnt_iterator++)
-		{
-			if ( (*pnt_iterator)->IsAt( x, y ) )
-			{
-				c = (*cmd_iterator);
-				point = (*pnt_iterator);
-			}
-		}
-	}
-
-	return c;
+DrawCmd *ASSDrawEngine::ControlAt ( int x, int y, Point *&point )
+{
+    DrawCmd *c = NULL;
+    point = NULL;
+    DrawCmdList::iterator cmd_iterator = cmds.begin();
+    PointList::iterator pnt_iterator;
+    PointList::iterator end;
+
+    for (; cmd_iterator != cmds.end(); cmd_iterator++) {
+        pnt_iterator = (*cmd_iterator)->controlpoints.begin();
+        end = (*cmd_iterator)->controlpoints.end();
+        for (; pnt_iterator != end; pnt_iterator++) {
+            if ( (*pnt_iterator)->IsAt( x, y ) ) {
+                c = (*cmd_iterator);
+                point = (*pnt_iterator);
+            }
+        }
+    }
+
+    return c;
 }
 
 // attempts to delete a commmand, returns true|false if successful|fail
-bool ASSDrawEngine::DeleteCommand ( DrawCmd* cmd )
+bool ASSDrawEngine::DeleteCommand ( DrawCmd *cmd )
 {
 
-	DrawCmdList::iterator iterate = cmds.begin();
-	// can't delete the first command without deleting other commands first
-	if ( cmd == (*iterate) && cmds.size() > 1) return false;
-
-	DrawCmd* lastiter = NULL;
-
-	for (; iterate != cmds.end(); iterate++)
-	{
-		if ( cmd == (*iterate) )
-		{
-			iterate++;
-			DrawCmd* nxt = (iterate != cmds.end()? (*iterate):NULL);
-			ConnectSubsequentCmds( lastiter, nxt );
-			iterate--;
-			cmds.erase( iterate );
-			delete cmd;
-			break;
-		}
-		else
-			lastiter = (*iterate);
-	}
+    DrawCmdList::iterator iterate = cmds.begin();
+    // can't delete the first command without deleting other commands first
+    if ( cmd == (*iterate) && cmds.size() > 1) return false;
+
+    DrawCmd *lastiter = NULL;
+
+    for (; iterate != cmds.end(); iterate++) {
+        if ( cmd == (*iterate) ) {
+            iterate++;
+            DrawCmd *nxt = (iterate != cmds.end() ? (*iterate) : NULL);
+            ConnectSubsequentCmds( lastiter, nxt );
+            iterate--;
+            cmds.erase( iterate );
+            delete cmd;
+            break;
+        }
+        else
+            lastiter = (*iterate);
+    }
 
-	return true;
+    return true;
 }
 
 // set stuff to connect two drawing commands cmd1 and cmd2 such that
 // cmd1 comes right before cmd2
-void ASSDrawEngine::ConnectSubsequentCmds (DrawCmd* cmd1, DrawCmd* cmd2)
+void ASSDrawEngine::ConnectSubsequentCmds (DrawCmd *cmd1, DrawCmd *cmd2)
 {
-	if (cmd1 != NULL)
-	{
-		cmd1->m_point->cmd_next = cmd2;
-	}
+    if (cmd1 != NULL) {
+        cmd1->m_point->cmd_next = cmd2;
+    }
 
-	if (cmd2 != NULL)
-	{
-		cmd2->prev = cmd1;
-	}
+    if (cmd2 != NULL) {
+        cmd2->prev = cmd1;
+    }
 }
 
 void ASSDrawEngine::RefreshDisplay()
 {
-	if (!refresh_called)
-	{
-		Refresh();
-		refresh_called = true;
-	}
+    if (!refresh_called) {
+        Refresh();
+        refresh_called = true;
+    }
 }
 
-void ASSDrawEngine::OnPaint(wxPaintEvent& event)
+void ASSDrawEngine::OnPaint(wxPaintEvent &event)
 {
-	draw();
-	onPaint(event);
-	if (setfitviewpoint)
-	{
-		FitToViewPoint( fitviewpoint_hmargin, fitviewpoint_vmargin );
-		setfitviewpoint = false;
-		RefreshDisplay();
-	}
+    draw();
+    onPaint(event);
+    if (setfitviewpoint) {
+        FitToViewPoint( fitviewpoint_hmargin, fitviewpoint_vmargin );
+        setfitviewpoint = false;
+        RefreshDisplay();
+    }
 }
 
 void ASSDrawEngine::draw()
 {
-	refresh_called = false;
+    refresh_called = false;
 
-	PixelFormat::AGGType pixf(rBuf);
-	RendererBase rbase(pixf);
-	RendererPrimitives rprim(rbase);
-	RendererSolid rsolid(rbase);
+    PixelFormat::AGGType pixf(rBuf);
+    RendererBase rbase(pixf);
+    RendererPrimitives rprim(rbase);
+    RendererSolid rsolid(rbase);
 
-	agg::trans_affine mtx;
-	ConstructPathsAndCurves(mtx, rm_path, rb_path, rm_curve);
+    agg::trans_affine mtx;
+    ConstructPathsAndCurves(mtx, rm_path, rb_path, rm_curve);
 
-	rasterizer.reset();
-	update_rendered_bound_coords(true);
-	DoDraw(rbase, rprim, rsolid, mtx);
+    rasterizer.reset();
+    update_rendered_bound_coords(true);
+    DoDraw(rbase, rprim, rsolid, mtx);
 
-	delete rm_path, rb_path, rm_curve;
+    delete rm_path, rb_path, rm_curve;
 }
 
-void ASSDrawEngine::ConstructPathsAndCurves(agg::trans_affine& mtx,
-	trans_path*& _rm_path, trans_path*& _rb_path, agg::conv_curve<trans_path>*& _rm_curve)
+void ASSDrawEngine::ConstructPathsAndCurves(agg::trans_affine &mtx,
+        trans_path *&_rm_path, trans_path *&_rb_path, agg::conv_curve<trans_path> *&_rm_curve)
 {
     mtx *= agg::trans_affine_scaling(pointsys->scale);
     mtx *= agg::trans_affine_translation(pointsys->originx, pointsys->originy);
 
-	m_path.remove_all();
-	b_path.remove_all();
-
-	DrawCmdList::iterator ci = cmds.begin();
-	while (ci != cmds.end())
-	{
-		AddDrawCmdToAGGPathStorage(*ci, m_path);
-		AddDrawCmdToAGGPathStorage(*ci, b_path, CTRL_LN);
-		ci++;
-	}
-	_rm_path = new trans_path(m_path, mtx);
-	_rb_path = new trans_path(b_path, mtx);
+    m_path.remove_all();
+    b_path.remove_all();
+
+    DrawCmdList::iterator ci = cmds.begin();
+    while (ci != cmds.end()) {
+        AddDrawCmdToAGGPathStorage(*ci, m_path);
+        AddDrawCmdToAGGPathStorage(*ci, b_path, CTRL_LN);
+        ci++;
+    }
+    _rm_path = new trans_path(m_path, mtx);
+    _rb_path = new trans_path(b_path, mtx);
     _rm_curve = new agg::conv_curve<trans_path>(*rm_path);
 }
 
-void ASSDrawEngine::DoDraw( RendererBase& rbase, RendererPrimitives& rprim, RendererSolid& rsolid, agg::trans_affine& mtx )
+void ASSDrawEngine::DoDraw( RendererBase &rbase, RendererPrimitives &rprim, RendererSolid &rsolid, agg::trans_affine &mtx )
 {
-	Draw_Clear( rbase );
-	Draw_Draw( rbase, rprim, rsolid, mtx, rgba_shape );
+    Draw_Clear( rbase );
+    Draw_Draw( rbase, rprim, rsolid, mtx, rgba_shape );
 }
 
-void ASSDrawEngine::Draw_Clear( RendererBase& rbase )
+void ASSDrawEngine::Draw_Clear( RendererBase &rbase )
 {
-	rbase.clear(color_bg);
+    rbase.clear(color_bg);
 }
 
-void ASSDrawEngine::Draw_Draw( RendererBase& rbase, RendererPrimitives& rprim, RendererSolid& rsolid, agg::trans_affine& mtx, agg::rgba color )
+void ASSDrawEngine::Draw_Draw( RendererBase &rbase, RendererPrimitives &rprim, RendererSolid &rsolid, agg::trans_affine &mtx, agg::rgba color )
 {
-    agg::conv_contour< agg::conv_curve< agg::conv_transform< agg::path_storage > > > contour(*rm_curve);
-	rasterizer.add_path(contour);
-	render_scanlines_aa_solid(rbase, color);
+    agg::conv_contour< agg::conv_curve< agg::conv_transform< agg::path_storage >>> contour(*rm_curve);
+    rasterizer.add_path(contour);
+    render_scanlines_aa_solid(rbase, color);
 }
 
-void ASSDrawEngine::AddDrawCmdToAGGPathStorage(DrawCmd* cmd, agg::path_storage& path, DRAWCMDMODE mode)
+void ASSDrawEngine::AddDrawCmdToAGGPathStorage(DrawCmd *cmd, agg::path_storage &path, DRAWCMDMODE mode)
 {
-	if (mode == HILITE && cmd->prev)
-		path.move_to(cmd->prev->m_point->x(), cmd->prev->m_point->y());
+    if (mode == HILITE && cmd->prev)
+        path.move_to(cmd->prev->m_point->x(), cmd->prev->m_point->y());
 
-	switch(cmd->type)
-	{
-	case M:
-		path.move_to(cmd->m_point->x(),cmd->m_point->y());
-		break;
+    switch (cmd->type) {
+    case M:
+        path.move_to(cmd->m_point->x(), cmd->m_point->y());
+        break;
 
-	case B:
-		if (cmd->initialized)
-		{
-			//path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
-			PointList::iterator iterate = cmd->controlpoints.begin();
-			int x[2], y[2];
-			x[0] = (*iterate)->x();
-			y[0] = (*iterate)->y();
-			iterate++;
-			x[1] = (*iterate)->x();
-			y[1] = (*iterate)->y();
-			path.curve4(x[0], y[0], x[1], y[1], cmd->m_point->x(),cmd->m_point->y());
-    		break;
-		}
+    case B:
+        if (cmd->initialized) {
+            //path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
+            PointList::iterator iterate = cmd->controlpoints.begin();
+            int x[2], y[2];
+            x[0] = (*iterate)->x();
+            y[0] = (*iterate)->y();
+            iterate++;
+            x[1] = (*iterate)->x();
+            y[1] = (*iterate)->y();
+            path.curve4(x[0], y[0], x[1], y[1], cmd->m_point->x(), cmd->m_point->y());
+            break;
+        }
 
-	case L:
-		if (mode == CTRL_LN)
-			path.move_to(cmd->m_point->x(),cmd->m_point->y());
-		else
-			path.line_to(cmd->m_point->x(),cmd->m_point->y());
-		break;
+    case L:
+        if (mode == CTRL_LN)
+            path.move_to(cmd->m_point->x(), cmd->m_point->y());
+        else
+            path.line_to(cmd->m_point->x(), cmd->m_point->y());
+        break;
 
-	case S:
-		unsigned np = cmd->controlpoints.size();
+    case S:
+        unsigned np = cmd->controlpoints.size();
         agg::pod_array<double> m_polygon(np * 2);
         unsigned _pn = 0;
-		PointList::iterator iterate = cmd->controlpoints.begin();
-		while (iterate != cmd->controlpoints.end())
-		{
-	        m_polygon[_pn] = (*iterate)->x(); _pn++;
-	        m_polygon[_pn] = (*iterate)->y(); _pn++;
-	        iterate++;
-		}
+        PointList::iterator iterate = cmd->controlpoints.begin();
+        while (iterate != cmd->controlpoints.end()) {
+            m_polygon[_pn] = (*iterate)->x(); _pn++;
+            m_polygon[_pn] = (*iterate)->y(); _pn++;
+            iterate++;
+        }
         //m_polygon[_pn++] = cmd->m_point->x();
         //m_polygon[_pn++] = cmd->m_point->y();
-		//path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
-		if (mode == CTRL_LN)
-		{
-			_pn = 0;
-			while (_pn < np * 2)
-			{
-				path.line_to((int) m_polygon[_pn],(int) m_polygon[_pn + 1]);
-				_pn += 2;
-			}
-	        path.line_to(cmd->m_point->x(), cmd->m_point->y());
-		}
-		else
-		{
-			//path.line_to((int) m_polygon[0],(int) m_polygon[1]);
-	        aggpolygon poly(&m_polygon[0], np, false, false);
-	        agg::conv_bcspline<agg::simple_polygon_vertex_source>  bspline(poly);
-	        bspline.interpolation_step(0.01);
-	        agg::path_storage npath;
-	        npath.join_path(bspline);
-	        path.join_path(npath);
-	        if (mode == HILITE)
-	        	path.move_to((int) m_polygon[np * 2 - 2], (int) m_polygon[np * 2 - 1] );
-	        path.line_to(cmd->m_point->x(), cmd->m_point->y());
-		}
-		break;
-	}
-
-}
-
-void ASSDrawEngine::render_scanlines_aa_solid(RendererBase& rbase, agg::rgba rgba, bool affectboundaries)
-{
-	agg::render_scanlines_aa_solid(rasterizer, scanline, rbase, rgba);
-	if (affectboundaries) update_rendered_bound_coords();
-}
-
-void ASSDrawEngine::render_scanlines(RendererSolid& rsolid, bool affectboundaries)
-{
-	agg::render_scanlines(rasterizer, scanline, rsolid);
-	if (affectboundaries) update_rendered_bound_coords();
+        //path.move_to(cmd->prev->m_point->x(),cmd->prev->m_point->y());
+        if (mode == CTRL_LN) {
+            _pn = 0;
+            while (_pn < np * 2) {
+                path.line_to((int) m_polygon[_pn], (int) m_polygon[_pn + 1]);
+                _pn += 2;
+            }
+            path.line_to(cmd->m_point->x(), cmd->m_point->y());
+        }
+        else {
+            //path.line_to((int) m_polygon[0],(int) m_polygon[1]);
+            aggpolygon poly(&m_polygon[0], np, false, false);
+            agg::conv_bcspline<agg::simple_polygon_vertex_source>  bspline(poly);
+            bspline.interpolation_step(0.01);
+            agg::path_storage npath;
+            npath.join_path(bspline);
+            path.join_path(npath);
+            if (mode == HILITE)
+                path.move_to((int) m_polygon[np * 2 - 2], (int) m_polygon[np * 2 - 1] );
+            path.line_to(cmd->m_point->x(), cmd->m_point->y());
+        }
+        break;
+    }
+
+}
+
+void ASSDrawEngine::render_scanlines_aa_solid(RendererBase &rbase, agg::rgba rgba, bool affectboundaries)
+{
+    agg::render_scanlines_aa_solid(rasterizer, scanline, rbase, rgba);
+    if (affectboundaries) update_rendered_bound_coords();
+}
+
+void ASSDrawEngine::render_scanlines(RendererSolid &rsolid, bool affectboundaries)
+{
+    agg::render_scanlines(rasterizer, scanline, rsolid);
+    if (affectboundaries) update_rendered_bound_coords();
 }
 
 void ASSDrawEngine::update_rendered_bound_coords(bool rendered_fresh)
@@ -700,50 +662,48 @@ void ASSDrawEngine::update_rendered_bound_coords(bool rendered_fresh)
     int min_y = rasterizer.min_y();
     int max_x = rasterizer.max_x();
     int max_y = rasterizer.max_y();
-	if (min_x < rendered_min_x || rendered_fresh) rendered_min_x = min_x;
-	if (min_y < rendered_min_y || rendered_fresh) rendered_min_y = min_y;
-	if (max_x > rendered_max_x || rendered_fresh) rendered_max_x = max_x;
-	if (max_y > rendered_max_y || rendered_fresh) rendered_max_y = max_y;
+    if (min_x < rendered_min_x || rendered_fresh) rendered_min_x = min_x;
+    if (min_y < rendered_min_y || rendered_fresh) rendered_min_y = min_y;
+    if (max_x > rendered_max_x || rendered_fresh) rendered_max_x = max_x;
+    if (max_y > rendered_max_y || rendered_fresh) rendered_max_y = max_y;
 }
 
 void ASSDrawEngine::FitToViewPoint(int hmargin, int vmargin)
 {
-	wxSize v = GetClientSize();
-	double wide = rendered_max_x - rendered_min_x;
-	double high = rendered_max_y - rendered_min_y;
-	double widthratio = (double) (v.x - hmargin * 2) / wide;
-	double heightratio = (double) (v.y - vmargin * 2) / high;
-	double ratio = (widthratio < heightratio? widthratio:heightratio);
-	pointsys->scale = pointsys->scale * ratio;
-	if (pointsys->scale < 0.01) pointsys->scale = 0.01;
-	double new_min_x = pointsys->originx + (rendered_min_x - pointsys->originx) * ratio;
-	double new_max_x = pointsys->originx + (rendered_max_x - pointsys->originx) * ratio;
-	pointsys->originx += (v.x - new_max_x + new_min_x) / 2 - new_min_x;
-	double new_min_y = pointsys->originy + (rendered_min_y - pointsys->originy) * ratio;
-	double new_max_y = pointsys->originy + (rendered_max_y - pointsys->originy) * ratio;
-	pointsys->originy += (v.y - new_max_y + new_min_y) / 2 - new_min_y;
-	RefreshDisplay();
+    wxSize v = GetClientSize();
+    double wide = rendered_max_x - rendered_min_x;
+    double high = rendered_max_y - rendered_min_y;
+    double widthratio = (double) (v.x - hmargin * 2) / wide;
+    double heightratio = (double) (v.y - vmargin * 2) / high;
+    double ratio = (widthratio < heightratio ? widthratio : heightratio);
+    pointsys->scale = pointsys->scale * ratio;
+    if (pointsys->scale < 0.01) pointsys->scale = 0.01;
+    double new_min_x = pointsys->originx + (rendered_min_x - pointsys->originx) * ratio;
+    double new_max_x = pointsys->originx + (rendered_max_x - pointsys->originx) * ratio;
+    pointsys->originx += (v.x - new_max_x + new_min_x) / 2 - new_min_x;
+    double new_min_y = pointsys->originy + (rendered_min_y - pointsys->originy) * ratio;
+    double new_max_y = pointsys->originy + (rendered_max_y - pointsys->originy) * ratio;
+    pointsys->originy += (v.y - new_max_y + new_min_y) / 2 - new_min_y;
+    RefreshDisplay();
 }
 
 void ASSDrawEngine::SetFitToViewPointOnNextPaint(int hmargin, int vmargin)
 {
-	if (vmargin >= 0) fitviewpoint_vmargin = vmargin;
-	if (hmargin >= 0) fitviewpoint_hmargin = hmargin;
-	setfitviewpoint = true;
+    if (vmargin >= 0) fitviewpoint_vmargin = vmargin;
+    if (hmargin >= 0) fitviewpoint_hmargin = hmargin;
+    setfitviewpoint = true;
 }
 
 std::vector< bool > ASSDrawEngine::PrepareC1ContData()
 {
-	std::vector< bool > out;
-	for (DrawCmdList::iterator it = cmds.begin(); it != cmds.end(); it++)
-	{
-		bool c1 = false;
-		if ((*it)->type == B)
-		{
-			DrawCmd_B *cmdb = static_cast<DrawCmd_B *>(*it);
-			c1 = cmdb->C1Cont;
-		}
-		out.push_back(c1);
-	}
-	return out;
+    std::vector< bool > out;
+    for (DrawCmdList::iterator it = cmds.begin(); it != cmds.end(); it++) {
+        bool c1 = false;
+        if ((*it)->type == B) {
+            DrawCmd_B *cmdb = static_cast<DrawCmd_B *>(*it);
+            c1 = cmdb->C1Cont;
+        }
+        out.push_back(c1);
+    }
+    return out;
 }
diff --git a/assdraw/engine.hpp b/assdraw/engine.hpp
index b730ec6fcc2f996e98af4fd2b6785598901ee78a..30c1d4e604ef1c709bce846241ac8de2921c6bec 100644
--- a/assdraw/engine.hpp
+++ b/assdraw/engine.hpp
@@ -67,340 +67,325 @@ class Point;
 class PointSystem;
 class DrawCmd;
 
-typedef std::list<DrawCmd*> DrawCmdList;
-typedef std::list<Point*> PointList;
-typedef std::set<Point*> PointSet;
+typedef std::list<DrawCmd *> DrawCmdList;
+typedef std::list<Point *> PointList;
+typedef std::set<Point *> PointSet;
 
 // Command type
-enum CMDTYPE 
-{
-     M = 0,
-     N = 1,
-     L = 2,
-     B = 3,
-     S = 4,
-     P = 5,
-     C = 6     
+enum CMDTYPE {
+    M = 0,
+    N = 1,
+    L = 2,
+    B = 3,
+    S = 4,
+    P = 5,
+    C = 6
 };
 
 // Point type
-enum POINTTYPE
-{
-	MP, // main point
-	CP  // control point
+enum POINTTYPE {
+    MP, // main point
+    CP  // control point
 };
 
 // A PointSystem is a centralized entity holding the parameters:
 // scale, originx and originy, all of which are needed by Point
-class PointSystem
-{
+class PointSystem {
 public:
-	double scale, originx, originy;
-
-	PointSystem ( double sc = 1.0, double origx = 0.0, double origy = 0.0 )
-	{ 	Set( sc, origx, origy ); }
-
-	// set scale, originx and originy;
-	void Set( double sc, double origx, double origy )
-	{ scale = sc, originx = origx, originy = origy; }
-	
-	wxRealPoint ToWxRealPoint ( double x, double y )
-	{ return wxRealPoint( originx + x * scale, originy + y * scale ); }
-
-	// given drawing command coordinates returns the wxPoint on the GUI
-	wxPoint ToWxPoint ( double x, double y )
-	{ return wxPoint( (int) (originx + x * scale), (int) (originy + y * scale) ); }
-
-	// given wxPoint on the GUI returns the nearest drawing command coords
-	void FromWxPoint ( int wxpx, int wxpy, int &x, int &y )
-	{
-		x = int( floor( ((double) wxpx - originx) / scale + 0.5 ) );
-		y = int( floor( ((double) wxpy - originy) / scale + 0.5 ) );
-	}                   
-
-	// given wxPoint on the GUI returns the nearest drawing command coords
-	void FromWxPoint ( wxPoint wxp, int &x, int &y )
-	{
-		FromWxPoint( wxp.x, wxp.y, x, y );
-	}
+    double scale, originx, originy;
+
+    PointSystem ( double sc = 1.0, double origx = 0.0, double origy = 0.0 )
+    { 	Set( sc, origx, origy ); }
+
+    // set scale, originx and originy;
+    void Set( double sc, double origx, double origy )
+    { scale = sc, originx = origx, originy = origy; }
+
+    wxRealPoint ToWxRealPoint ( double x, double y )
+    { return wxRealPoint( originx + x * scale, originy + y * scale ); }
+
+    // given drawing command coordinates returns the wxPoint on the GUI
+    wxPoint ToWxPoint ( double x, double y )
+    { return wxPoint( (int) (originx + x * scale), (int) (originy + y * scale) ); }
+
+    // given wxPoint on the GUI returns the nearest drawing command coords
+    void FromWxPoint ( int wxpx, int wxpy, int &x, int &y ) {
+        x = int( floor( ((double) wxpx - originx) / scale + 0.5 ) );
+        y = int( floor( ((double) wxpy - originy) / scale + 0.5 ) );
+    }
+
+    // given wxPoint on the GUI returns the nearest drawing command coords
+    void FromWxPoint ( wxPoint wxp, int &x, int &y ) {
+        FromWxPoint( wxp.x, wxp.y, x, y );
+    }
 };
 
 // The point class
 // note: this actually refers to the x,y-coordinate in drawing commands,
 // not the coordinate in the GUI
-class Point
-{
+class Point {
 public:
-	POINTTYPE type;
-	PointSystem *pointsys;
+    POINTTYPE type;
+    PointSystem *pointsys;
+
+    // drawing commands that depend on this point
+    DrawCmd *cmd_main;
+    DrawCmd *cmd_next;
+    bool isselected;
+    unsigned num;
 
-	// drawing commands that depend on this point
-	DrawCmd* cmd_main;
-	DrawCmd* cmd_next;
-	bool isselected;
-	unsigned num;
+    // constructor
+    //Point ( ) { cmd_main = NULL; cmd_next = NULL; }
 
-	// constructor
-	//Point ( ) { cmd_main = NULL; cmd_next = NULL; }
+    // constructor
+    Point ( int _x, int _y, PointSystem *ps, POINTTYPE t, DrawCmd *cmd, unsigned n = 0 );
 
-	// constructor
-	Point ( int _x, int _y, PointSystem* ps, POINTTYPE t, DrawCmd* cmd, unsigned n = 0 );
+    // getters
+    int x() { return x_; }
 
-	// getters
-	int x() { return x_; }
+    int y() { return y_; }
 
-	int y() { return y_; }
+    //set x and y
+    void setXY( int _x, int _y);
 
-	//set x and y
-	void setXY( int _x, int _y);
-	
-	// simply returns true if px and py are the coordinate values
-	bool IsAt( int px, int py );
+    // simply returns true if px and py are the coordinate values
+    bool IsAt( int px, int py );
 
-	// convert this point to wxPoint using scale and originx, originy
-	wxPoint ToWxPoint () { return ToWxPoint(true); }
+    // convert this point to wxPoint using scale and originx, originy
+    wxPoint ToWxPoint () { return ToWxPoint(true); }
 
-	// convert this point to wxPoint using scale;
-	// also use originx and originy if useorigin = true
-	wxPoint ToWxPoint (bool useorigin);
+    // convert this point to wxPoint using scale;
+    // also use originx and originy if useorigin = true
+    wxPoint ToWxPoint (bool useorigin);
 
-	// check if wxpoint is nearby this point
-	bool CheckWxPoint ( wxPoint wxpoint );
+    // check if wxpoint is nearby this point
+    bool CheckWxPoint ( wxPoint wxpoint );
 
 private:
-	int x_, y_;
+    int x_, y_;
 
 };
 
 // The base class for all draw commands
-class DrawCmd
-{
+class DrawCmd {
 public:
-	CMDTYPE type;
-	      
-	// main point (almost every command has one)
-	// for B and S it's the last (destination) point
-	Point* m_point;
+    CMDTYPE type;
 
-	// other points than the main point
-	// subclasses must populate this list even if they define 
-	// new variables for other points
-	PointList controlpoints; 
+    // main point (almost every command has one)
+    // for B and S it's the last (destination) point
+    Point *m_point;
 
-	// Linked list feature
-	DrawCmd *prev;
+    // other points than the main point
+    // subclasses must populate this list even if they define
+    // new variables for other points
+    PointList controlpoints;
 
-	// Must set to true if the next command should NOT utilize this command
-	// for the drawing
-	bool dobreak;
+    // Linked list feature
+    DrawCmd *prev;
 
-	// Set to true if invisible m_point (not drawn)
-	bool invisible;
+    // Must set to true if the next command should NOT utilize this command
+    // for the drawing
+    bool dobreak;
 
-	// true if this DrawCmd has been initialized with Init(), false otherwise
-	// (initialized means that the control points have been generated)
-	bool initialized;
+    // Set to true if invisible m_point (not drawn)
+    bool invisible;
 
-	// -----------------------------------------------------------
-	// Constructor(s)
-	DrawCmd ( int x, int y, PointSystem *ps, DrawCmd *pv );
-	      
-	// Destructor
-	virtual ~DrawCmd ();
+    // true if this DrawCmd has been initialized with Init(), false otherwise
+    // (initialized means that the control points have been generated)
+    bool initialized;
 
-	// Init the draw command (for example to generate the control points)
-	virtual void Init(unsigned n = 0) { initialized = true; }
+    // -----------------------------------------------------------
+    // Constructor(s)
+    DrawCmd ( int x, int y, PointSystem *ps, DrawCmd *pv );
 
-	virtual wxString ToString() { return wxT(""); }
+    // Destructor
+    virtual ~DrawCmd ();
+
+    // Init the draw command (for example to generate the control points)
+    virtual void Init(unsigned n = 0) { initialized = true; }
+
+    virtual wxString ToString() { return wxT(""); }
 
 };
 
-class ASSDrawEngine: public GUI::AGGWindow
-{
+class ASSDrawEngine: public GUI::AGGWindow {
 public:
-	ASSDrawEngine( wxWindow *parent, int extraflags = 0 );
+    ASSDrawEngine( wxWindow *parent, int extraflags = 0 );
 
     // destructor
     ~ASSDrawEngine();
 
-	virtual void SetDrawCmdSet(wxString set) { drawcmdset = set; }
+    virtual void SetDrawCmdSet(wxString set) { drawcmdset = set; }
 
     virtual void ResetEngine();
     virtual void ResetEngine(bool addM);
     virtual void RefreshDisplay();
 
-	void FitToViewPoint(int hmargin, int vmargin);
-	void SetFitToViewPointOnNextPaint(int hmargin = -1, int vmargin = -1);
+    void FitToViewPoint(int hmargin, int vmargin);
+    void SetFitToViewPointOnNextPaint(int hmargin = -1, int vmargin = -1);
 
-	PointSystem* _PointSystem() { return pointsys; }
+    PointSystem *_PointSystem() { return pointsys; }
 
-	// ASS draw commands; returns the number of parsed commands
-	virtual int ParseASS ( wxString str );
-	// generate ASS draw commands
-	virtual wxString GenerateASS ( );
+    // ASS draw commands; returns the number of parsed commands
+    virtual int ParseASS ( wxString str );
+    // generate ASS draw commands
+    virtual wxString GenerateASS ( );
 
-	// drawing
+    // drawing
     virtual void OnPaint(wxPaintEvent &event);
 
-	// -------------------- adding new commands ----------------------------
+    // -------------------- adding new commands ----------------------------
 
-	// create draw command of type 'type' and m_point (x, y), append to the
-	// list and return it
-	virtual DrawCmd* AppendCmd ( CMDTYPE type, int x, int y );
+    // create draw command of type 'type' and m_point (x, y), append to the
+    // list and return it
+    virtual DrawCmd *AppendCmd ( CMDTYPE type, int x, int y );
 
-	// append draw command
-	virtual DrawCmd* AppendCmd ( DrawCmd* cmd );
+    // append draw command
+    virtual DrawCmd *AppendCmd ( DrawCmd *cmd );
 
-	// create draw command of type 'type' and m_point (x, y), insert to the
-	// list after the _cmd and return it
-	virtual DrawCmd* InsertCmd ( CMDTYPE type, int x, int y, DrawCmd* _cmd );
+    // create draw command of type 'type' and m_point (x, y), insert to the
+    // list after the _cmd and return it
+    virtual DrawCmd *InsertCmd ( CMDTYPE type, int x, int y, DrawCmd *_cmd );
 
-	// insert draw command cmd after _cmd
-	virtual void InsertCmd ( DrawCmd* cmd, DrawCmd* _cmd );
+    // insert draw command cmd after _cmd
+    virtual void InsertCmd ( DrawCmd *cmd, DrawCmd *_cmd );
 
-	// Create new DrawCmd
-	DrawCmd* NewCmd ( CMDTYPE type, int x, int y );
+    // Create new DrawCmd
+    DrawCmd *NewCmd ( CMDTYPE type, int x, int y );
 
-	// -------------------- read/modify commands ---------------------------
+    // -------------------- read/modify commands ---------------------------
 
-	// returns the iterator for the list
-	virtual DrawCmdList::iterator Iterator ( );
+    // returns the iterator for the list
+    virtual DrawCmdList::iterator Iterator ( );
 
-	// returns the 'end' iterator for the list
-	virtual DrawCmdList::iterator IteratorEnd ( );
+    // returns the 'end' iterator for the list
+    virtual DrawCmdList::iterator IteratorEnd ( );
 
-	// returns the last command in the list
-	virtual DrawCmd* LastCmd ();
+    // returns the last command in the list
+    virtual DrawCmd *LastCmd ();
 
-	// returns the total number of commands in the list
-	//virtual int CmdCount () { return cmds.size(); }
+    // returns the total number of commands in the list
+    //virtual int CmdCount () { return cmds.size(); }
 
-	// move all points by relative amount of x, y coordinates
-	virtual void MovePoints ( int x, int y );
+    // move all points by relative amount of x, y coordinates
+    virtual void MovePoints ( int x, int y );
 
-	// transform all points using the calculation:
-	//   | (m11)  (m12) | x | (x - mx) | + | nx |
-	//   | (m21)  (m22) |   | (y - my) |   | ny |
-	virtual void Transform( float m11, float m12, float m21, float m22,
-							float mx, float my, float nx, float ny );
+    // transform all points using the calculation:
+    //   | (m11)  (m12) | x | (x - mx) | + | nx |
+    //   | (m21)  (m22) |   | (y - my) |   | ny |
+    virtual void Transform( float m11, float m12, float m21, float m22,
+                            float mx, float my, float nx, float ny );
 
-	// returns some DrawCmd if its m_point = (x, y)
-	virtual DrawCmd* PointAt ( int x, int y );
+    // returns some DrawCmd if its m_point = (x, y)
+    virtual DrawCmd *PointAt ( int x, int y );
 
-	// returns some DrawCmd if one of its control point = (x, y)
-	// also set &point to refer to that control point
-	virtual DrawCmd* ControlAt ( int x, int y, Point* &point );
+    // returns some DrawCmd if one of its control point = (x, y)
+    // also set &point to refer to that control point
+    virtual DrawCmd *ControlAt ( int x, int y, Point *&point );
 
-	// attempts to delete a commmand, returns true|false if successful|fail
-	virtual bool DeleteCommand ( DrawCmd* cmd );
-	
-	agg::rgba rgba_shape;
-	PixelFormat::AGGType::color_type color_bg;
+    // attempts to delete a commmand, returns true|false if successful|fail
+    virtual bool DeleteCommand ( DrawCmd *cmd );
+
+    agg::rgba rgba_shape;
+    PixelFormat::AGGType::color_type color_bg;
 
 protected:
-	/// The AGG base renderer
-	typedef agg::renderer_base<PixelFormat::AGGType> RendererBase;
-	/// The AGG primitives renderer
-	typedef agg::renderer_primitives<RendererBase> RendererPrimitives;
-	/// The AGG solid renderer
-	typedef agg::renderer_scanline_aa_solid<RendererBase> RendererSolid;
-	
-	enum DRAWCMDMODE {
-		NORMAL,
-		CTRL_LN,
-		HILITE
-	};
-
-	DrawCmdList cmds;
-	wxString drawcmdset;
-
-	PointSystem* pointsys;
-	
-	// for FitToViewPoint feature
-	bool setfitviewpoint;
-	int fitviewpoint_vmargin, fitviewpoint_hmargin;
-
-	// AGG
-	agg::rasterizer_scanline_aa<> rasterizer;   ///< Scanline rasterizer
-	agg::scanline_p8  scanline;                 ///< Scanline container
-	void render_scanlines_aa_solid(RendererBase& rbase, agg::rgba rbga, bool affectboundaries = true);
-	void render_scanlines(RendererSolid& rsolid, bool affectboundaries = true);
-	int rendered_min_x, rendered_min_y, rendered_max_x, rendered_max_y; //bounding coord of rendered shapes
-	void update_rendered_bound_coords(bool rendered_fresh = false);
-
-	typedef agg::conv_transform<agg::path_storage> trans_path;
-	agg::path_storage m_path, b_path;
-	trans_path *rm_path, *rb_path;
-	agg::conv_curve<trans_path> *rm_curve;
-
-	void draw();
-	virtual void ConstructPathsAndCurves(agg::trans_affine& mtx, trans_path*& _rm_path, trans_path*& _rb_path, agg::conv_curve<trans_path>*& _rm_curve);
-	virtual void DoDraw( RendererBase& rbase, RendererPrimitives& rprim, RendererSolid& rsolid, agg::trans_affine& mtx  );
-	virtual void Draw_Clear( RendererBase& rbase );
-	virtual void Draw_Draw( RendererBase& rbase, RendererPrimitives& rprim, RendererSolid& rsolid, agg::trans_affine& mtx, agg::rgba color );
-	bool refresh_called;
-	
-	// set stuff to connect two drawing commands cmd1 and cmd2 such that
-	// cmd1 comes right before cmd2
-	virtual void ConnectSubsequentCmds (DrawCmd* cmd1, DrawCmd* cmd2);
-	
-	virtual void AddDrawCmdToAGGPathStorage(DrawCmd* cmd, agg::path_storage& path, DRAWCMDMODE mode = NORMAL);
-	
-	virtual std::vector< bool > PrepareC1ContData();
-
-	DECLARE_EVENT_TABLE()
-};
+    /// The AGG base renderer
+    typedef agg::renderer_base<PixelFormat::AGGType> RendererBase;
+    /// The AGG primitives renderer
+    typedef agg::renderer_primitives<RendererBase> RendererPrimitives;
+    /// The AGG solid renderer
+    typedef agg::renderer_scanline_aa_solid<RendererBase> RendererSolid;
+
+    enum DRAWCMDMODE {
+        NORMAL,
+        CTRL_LN,
+        HILITE
+    };
 
-namespace agg
-{
-    class simple_polygon_vertex_source
-    {
-    public:
-        simple_polygon_vertex_source(const double* polygon, unsigned np, 
-                                     bool roundoff = false,
-                                     bool close = true) :
-            m_polygon(polygon),
-            m_num_points(np),
-            m_vertex(0),
-            m_roundoff(roundoff),
-            m_close(close)
-        {
-        }
+    DrawCmdList cmds;
+    wxString drawcmdset;
 
-        void close(bool f) { m_close = f;    }
-        bool close() const { return m_close; }
+    PointSystem *pointsys;
 
-        void rewind(unsigned)
-        {
-            m_vertex = 0;
-        }
+    // for FitToViewPoint feature
+    bool setfitviewpoint;
+    int fitviewpoint_vmargin, fitviewpoint_hmargin;
 
-        unsigned vertex(double* x, double* y)
-        {
-            if(m_vertex > m_num_points) return path_cmd_stop;
-            if(m_vertex == m_num_points) 
-            {
-                ++m_vertex;
-                return path_cmd_end_poly | (m_close ? path_flags_close : 0);
-            }
-            *x = m_polygon[m_vertex * 2];
-            *y = m_polygon[m_vertex * 2 + 1];
-            if(m_roundoff)
-            {
-                *x = floor(*x) + 0.5;
-                *y = floor(*y) + 0.5;
-            }
+    // AGG
+    agg::rasterizer_scanline_aa<> rasterizer;   ///< Scanline rasterizer
+    agg::scanline_p8  scanline;                 ///< Scanline container
+    void render_scanlines_aa_solid(RendererBase &rbase, agg::rgba rbga, bool affectboundaries = true);
+    void render_scanlines(RendererSolid &rsolid, bool affectboundaries = true);
+    int rendered_min_x, rendered_min_y, rendered_max_x, rendered_max_y; //bounding coord of rendered shapes
+    void update_rendered_bound_coords(bool rendered_fresh = false);
+
+    typedef agg::conv_transform<agg::path_storage> trans_path;
+    agg::path_storage m_path, b_path;
+    trans_path *rm_path, *rb_path;
+    agg::conv_curve<trans_path> *rm_curve;
+
+    void draw();
+    virtual void ConstructPathsAndCurves(agg::trans_affine &mtx, trans_path *&_rm_path, trans_path *&_rb_path, agg::conv_curve<trans_path> *&_rm_curve);
+    virtual void DoDraw( RendererBase &rbase, RendererPrimitives &rprim, RendererSolid &rsolid, agg::trans_affine &mtx  );
+    virtual void Draw_Clear( RendererBase &rbase );
+    virtual void Draw_Draw( RendererBase &rbase, RendererPrimitives &rprim, RendererSolid &rsolid, agg::trans_affine &mtx, agg::rgba color );
+    bool refresh_called;
+
+    // set stuff to connect two drawing commands cmd1 and cmd2 such that
+    // cmd1 comes right before cmd2
+    virtual void ConnectSubsequentCmds (DrawCmd *cmd1, DrawCmd *cmd2);
+
+    virtual void AddDrawCmdToAGGPathStorage(DrawCmd *cmd, agg::path_storage &path, DRAWCMDMODE mode = NORMAL);
+
+    virtual std::vector< bool > PrepareC1ContData();
+
+    DECLARE_EVENT_TABLE()
+};
+
+namespace agg {
+class simple_polygon_vertex_source {
+public:
+    simple_polygon_vertex_source(const double *polygon, unsigned np,
+                                 bool roundoff = false,
+                                 bool close = true) :
+        m_polygon(polygon),
+        m_num_points(np),
+        m_vertex(0),
+        m_roundoff(roundoff),
+        m_close(close) {
+    }
+
+    void close(bool f) { m_close = f;    }
+    bool close() const { return m_close; }
+
+    void rewind(unsigned) {
+        m_vertex = 0;
+    }
+
+    unsigned vertex(double *x, double *y) {
+        if (m_vertex > m_num_points) return path_cmd_stop;
+        if (m_vertex == m_num_points) {
             ++m_vertex;
-            return (m_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
+            return path_cmd_end_poly | (m_close ? path_flags_close : 0);
+        }
+        *x = m_polygon[m_vertex * 2];
+        *y = m_polygon[m_vertex * 2 + 1];
+        if (m_roundoff) {
+            *x = floor(*x) + 0.5;
+            *y = floor(*y) + 0.5;
         }
+        ++m_vertex;
+        return (m_vertex == 1) ? path_cmd_move_to : path_cmd_line_to;
+    }
 
-    private:
-        const double* m_polygon;
-        unsigned m_num_points;
-        unsigned m_vertex;
-        bool     m_roundoff;
-        bool     m_close;
-    };
+private:
+    const double *m_polygon;
+    unsigned m_num_points;
+    unsigned m_vertex;
+    bool     m_roundoff;
+    bool     m_close;
+};
 };
 
 typedef agg::simple_polygon_vertex_source aggpolygon;
diff --git a/assdraw/enums.hpp b/assdraw/enums.hpp
index e5921705687ebffb7d25fccdd9eb56512b41a424..9ed01607d9f58216e2fbb8832885201e5409ad0f 100644
--- a/assdraw/enums.hpp
+++ b/assdraw/enums.hpp
@@ -29,50 +29,49 @@
 
 // enum for IDs of menus
 enum {
-	MENU_DUMMY = 200,
-	MENU_CLEAR,
-	MENU_PREVIEW,
-	MENU_TRANSFORM,
-	MENU_LIBRARY,
-	MENU_HELP,
-	MENU_RESETPERSPECTIVE,
-	MENU_SETTINGS,
-	MENU_UNDO,
-	MENU_REDO,
-	MENU_PASTE,
-	MENU_BGIMG_LOAD,
-	MENU_BGIMG_ALPHA,
-	MENU_BGIMG_REMOVE,
-	MENU_RECENTER,
-	MENU_TBAR,
-	MENU_REPOS_TOPLEFT,
-	MENU_REPOS_TOPRIGHT,
-	MENU_REPOS_CENTER,
-	MENU_REPOS_BOTLEFT,
-	MENU_REPOS_BOTRIGHT,
-	MENU_BGIMG_RECENTER,
-	MENU_REPOS_BGTOPLEFT,
-	MENU_REPOS_BGTOPRIGHT,
-	MENU_REPOS_BGCENTER,
-	MENU_REPOS_BGBOTLEFT,
-	MENU_REPOS_BGBOTRIGHT,
-	MENU_DRC_LNTOBEZ,
-	MENU_DRC_C1CONTBEZ,
-	MENU_DRC_BEZTOLN,
-	MENU_DRC_MOVE00,
-	MENU_TB_ALL,
-	MENU_TB_NONE,
-	MENU_TB_DOCK,
-	MENU_TB_UNDOCK,
-	MENU_TB_DRAW,
-	MENU_TB_MODE,
-	MENU_TB_BGIMG
+    MENU_DUMMY = 200,
+    MENU_CLEAR,
+    MENU_PREVIEW,
+    MENU_TRANSFORM,
+    MENU_LIBRARY,
+    MENU_HELP,
+    MENU_RESETPERSPECTIVE,
+    MENU_SETTINGS,
+    MENU_UNDO,
+    MENU_REDO,
+    MENU_PASTE,
+    MENU_BGIMG_LOAD,
+    MENU_BGIMG_ALPHA,
+    MENU_BGIMG_REMOVE,
+    MENU_RECENTER,
+    MENU_TBAR,
+    MENU_REPOS_TOPLEFT,
+    MENU_REPOS_TOPRIGHT,
+    MENU_REPOS_CENTER,
+    MENU_REPOS_BOTLEFT,
+    MENU_REPOS_BOTRIGHT,
+    MENU_BGIMG_RECENTER,
+    MENU_REPOS_BGTOPLEFT,
+    MENU_REPOS_BGTOPRIGHT,
+    MENU_REPOS_BGCENTER,
+    MENU_REPOS_BGBOTLEFT,
+    MENU_REPOS_BGBOTRIGHT,
+    MENU_DRC_LNTOBEZ,
+    MENU_DRC_C1CONTBEZ,
+    MENU_DRC_BEZTOLN,
+    MENU_DRC_MOVE00,
+    MENU_TB_ALL,
+    MENU_TB_NONE,
+    MENU_TB_DOCK,
+    MENU_TB_UNDOCK,
+    MENU_TB_DRAW,
+    MENU_TB_MODE,
+    MENU_TB_BGIMG
 };
 
 // enum for modes (i.e. create m, b, l etc or normal mode)
 // also use as tools IDs
-enum MODE
-{
+enum MODE {
     MODE_ARR = 100,
     MODE_M = 101,
     MODE_N = 102,
@@ -82,32 +81,30 @@ enum MODE
     MODE_P = 106,
     MODE_C = 107,
     MODE_DEL = 108,
-	MODE_SCALEROTATE = 109,
-	MODE_NUT_BILINEAR = 110
+    MODE_SCALEROTATE = 109,
+    MODE_NUT_BILINEAR = 110
 };
 
 // enum for IDs of other tools on the toolbar
 enum {
-     TB_CLEAR = 111,
-     TB_EDITSRC = 112,
-     TB_PREVIEW = 113,
-     TB_TRANSFORM = 114,
-     TB_HELP = 115,
-     TB_ZOOMSLIDER = 116,
-     TB_BGALPHA_SLIDER = 117
+    TB_CLEAR = 111,
+    TB_EDITSRC = 112,
+    TB_PREVIEW = 113,
+    TB_TRANSFORM = 114,
+    TB_HELP = 115,
+    TB_ZOOMSLIDER = 116,
+    TB_BGALPHA_SLIDER = 117
 };
 
-enum DRAGMODETOOL
-{
+enum DRAGMODETOOL {
     DRAG_DWG = 120,
     DRAG_BGIMG = 121,
     DRAG_BOTH = 122
 };
 
-struct DRAGMODE
-{
-	bool drawing;
-	bool bgimg;
-	DRAGMODE() { drawing = true, bgimg = false; }
-	DRAGMODE(bool d, bool b) { drawing = d, bgimg = b; }
+struct DRAGMODE {
+    bool drawing;
+    bool bgimg;
+    DRAGMODE() { drawing = true, bgimg = false; }
+    DRAGMODE(bool d, bool b) { drawing = d, bgimg = b; }
 };
diff --git a/assdraw/include_once.hpp b/assdraw/include_once.hpp
index 9ef9e8eea3b01b2f1ed0dfa47cea69a4ba08af38..3679cad89a38a3ada6185b2457192c7bc157d576 100644
--- a/assdraw/include_once.hpp
+++ b/assdraw/include_once.hpp
@@ -66,29 +66,29 @@ const wxString TBNAME_BGIMG = wxT("Background");
 const wxString TBNAME_ZOOM = wxT("Zoom");
 
 wxString ASSDrawTransformDlg::combo_templatesStrings[] = {
-	_("<Select>"),
-	_("Move 5 units down"),
-	_("Move 5 units right"),
-	_("Rotate 90\370 clockwise at (1, 2)"),
-	_("Rotate 90\370 counterclockwise at (-1, 2)"),
-	_("Rotate 180\370 at (0, 0)"),
-	_("Flip horizontally at X = 4"),
-	_("Flip vertically at Y = 3"),
-	_("Scale up horizontally by a factor of 2"),
-	_("Scale up vertically by a factor of 3")
+    _("<Select>"),
+    _("Move 5 units down"),
+    _("Move 5 units right"),
+    _("Rotate 90\370 clockwise at (1, 2)"),
+    _("Rotate 90\370 counterclockwise at (-1, 2)"),
+    _("Rotate 180\370 at (0, 0)"),
+    _("Flip horizontally at X = 4"),
+    _("Flip vertically at Y = 3"),
+    _("Scale up horizontally by a factor of 2"),
+    _("Scale up vertically by a factor of 3")
 };
 
 int ASSDrawTransformDlg::combo_templatesCount = 10;
 
 EightDouble ASSDrawTransformDlg::combo_templatesValues[] = {
-	{ 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, //<Select>
-	{ 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 5.0f }, //5 units down
-	{ 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 5.0f, 0.0f }, //5 units left
-	{ 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 2.0f, 1.0f, 2.0f }, //90 CW (1,2)
-	{ 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 2.0f, -1.0f, 2.0f }, //90 CCW, (-1,2)
-	{ -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, //180 (0,0)
-	{ -1.0f, 0.0f, 0.0f, 1.0f, 4.0f, 0.0f, 4.0f, 0.0f }, //Flip X = 4
-	{ 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 3.0f, 0.0f, 3.0f }, //Flip Y = 3
-	{ 2.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, //Scale X * 2
-	{ 1.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f } //Scale Y * 3
+    { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, //<Select>
+    { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 5.0f }, //5 units down
+    { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 5.0f, 0.0f }, //5 units left
+    { 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 2.0f, 1.0f, 2.0f }, //90 CW (1,2)
+    { 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 2.0f, -1.0f, 2.0f }, //90 CCW, (-1,2)
+    { -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, //180 (0,0)
+    { -1.0f, 0.0f, 0.0f, 1.0f, 4.0f, 0.0f, 4.0f, 0.0f }, //Flip X = 4
+    { 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 3.0f, 0.0f, 3.0f }, //Flip Y = 3
+    { 2.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, //Scale X * 2
+    { 1.0f, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f } //Scale Y * 3
 };
diff --git a/assdraw/library.cpp b/assdraw/library.cpp
index bfb7e9d9770faf3c525bd952f84f608e7b07068f..6ff7056221a533a26889e5a6ab05fe08101d2247 100644
--- a/assdraw/library.cpp
+++ b/assdraw/library.cpp
@@ -39,24 +39,24 @@ BEGIN_EVENT_TABLE(ASSDrawShapePreview, ASSDrawEngine)
 END_EVENT_TABLE()
 
 ASSDrawShapePreview::ASSDrawShapePreview( wxWindow *parent, ASSDrawShapeLibrary *_shapelib, wxString initialcmds )
-	: ASSDrawEngine(parent, wxSIMPLE_BORDER)
+    : ASSDrawEngine(parent, wxSIMPLE_BORDER)
 {
-	shapelib = _shapelib;
-	if (ParseASS(initialcmds) > 0)
-		SetFitToViewPointOnNextPaint(5, 5);
-	cb = new wxCheckBox(this, wxID_ANY, _T(""));
+    shapelib = _shapelib;
+    if (ParseASS(initialcmds) > 0)
+        SetFitToViewPointOnNextPaint(5, 5);
+    cb = new wxCheckBox(this, wxID_ANY, _T(""));
 }
 
-void ASSDrawShapePreview::OnSize(wxSizeEvent& event)
+void ASSDrawShapePreview::OnSize(wxSizeEvent &event)
 {
-	return;
-	wxSize siz = event.GetSize();
+    return;
+    wxSize siz = event.GetSize();
 
-	if (shapelib->layout == HORIZONTAL)
-		SetSize(siz.x, siz.x);
-	else
-		SetSize(siz.y, siz.y);
-	SetFitToViewPointOnNextPaint(10, 10);
+    if (shapelib->layout == HORIZONTAL)
+        SetSize(siz.x, siz.x);
+    else
+        SetSize(siz.y, siz.y);
+    SetFitToViewPointOnNextPaint(10, 10);
 }
 
 BEGIN_EVENT_TABLE(ASSDrawShapeLibrary, wxScrolledWindow)
@@ -68,198 +68,189 @@ BEGIN_EVENT_TABLE(ASSDrawShapeLibrary, wxScrolledWindow)
 END_EVENT_TABLE()
 
 ASSDrawShapeLibrary::ASSDrawShapeLibrary( wxWindow *parent, ASSDrawFrame *frame )
-	: wxScrolledWindow(parent, wxID_ANY)
+    : wxScrolledWindow(parent, wxID_ANY)
 {
-	m_frame = frame;
-	//sizer = NULL;
-	layout = VERTICAL;
+    m_frame = frame;
+    //sizer = NULL;
+    layout = VERTICAL;
 
-	wxToolBar *tbar = new wxToolBar(this, wxID_ANY, __DPDS__ , wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT | wxTB_NODIVIDER);
-	tbar->SetMargins(0, 3);
-	tbar->AddTool(TOOL_SAVE, _T("Save canvas"), wxBITMAP(add));
-	tbar->AddSeparator();
-	tbar->AddTool(TOOL_CHECK, _T("Select all"), wxBITMAP(check));
-	tbar->AddTool(TOOL_UNCHECK, _T("Select none"), wxBITMAP(uncheck));
-	tbar->AddTool(TOOL_DELETE, _T("Delete selected"), wxBITMAP(delcross));
+    wxToolBar *tbar = new wxToolBar(this, wxID_ANY, __DPDS__, wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT | wxTB_NODIVIDER);
+    tbar->SetMargins(0, 3);
+    tbar->AddTool(TOOL_SAVE, _T("Save canvas"), wxBITMAP(add));
+    tbar->AddSeparator();
+    tbar->AddTool(TOOL_CHECK, _T("Select all"), wxBITMAP(check));
+    tbar->AddTool(TOOL_UNCHECK, _T("Select none"), wxBITMAP(uncheck));
+    tbar->AddTool(TOOL_DELETE, _T("Delete selected"), wxBITMAP(delcross));
 
-	libarea = new wxScrolledWindow(this, wxID_ANY, __DPDS__ , wxScrolledWindowStyle | wxSIMPLE_BORDER);
-	libarea->SetBackgroundColour(wxColour(0xFF, 0xFF, 0x99));
-	sizer = new wxFlexGridSizer(0, 1, 0, 0);
-	((wxFlexGridSizer*) sizer)->AddGrowableCol(0);
-	libarea->SetSizer(sizer);
-	libarea->SetScrollbars(20, 20, 50, 50);
-	libsizer = new wxFlexGridSizer(2, 1, 0, 0);
-	libsizer->AddGrowableCol(0);
-	libsizer->AddGrowableRow(1);
-	libsizer->Add(tbar, 0, wxBOTTOM, 2);
-	libsizer->Add(libarea,1,wxEXPAND);
-	tbar->Realize();
-	libsizer->Layout();
+    libarea = new wxScrolledWindow(this, wxID_ANY, __DPDS__, wxScrolledWindowStyle | wxSIMPLE_BORDER);
+    libarea->SetBackgroundColour(wxColour(0xFF, 0xFF, 0x99));
+    sizer = new wxFlexGridSizer(0, 1, 0, 0);
+    ((wxFlexGridSizer *) sizer)->AddGrowableCol(0);
+    libarea->SetSizer(sizer);
+    libarea->SetScrollbars(20, 20, 50, 50);
+    libsizer = new wxFlexGridSizer(2, 1, 0, 0);
+    libsizer->AddGrowableCol(0);
+    libsizer->AddGrowableRow(1);
+    libsizer->Add(tbar, 0, wxBOTTOM, 2);
+    libsizer->Add(libarea, 1, wxEXPAND);
+    tbar->Realize();
+    libsizer->Layout();
 
-	SetSizer(libsizer);
+    SetSizer(libsizer);
 }
 
-void ASSDrawShapeLibrary::OnSize(wxSizeEvent& event)
+void ASSDrawShapeLibrary::OnSize(wxSizeEvent &event)
 {
-	if (sizer == NULL || sizer->GetChildren().size() == 0) return;
+    if (sizer == NULL || sizer->GetChildren().size() == 0) return;
 
-	wxSize siz = GetClientSize();
-	libsizer->SetDimension(0, 0, siz.x, siz.y);
+    wxSize siz = GetClientSize();
+    libsizer->SetDimension(0, 0, siz.x, siz.y);
 
-	UpdatePreviewDisplays();
+    UpdatePreviewDisplays();
 }
 
-ASSDrawShapePreview* ASSDrawShapeLibrary::AddShapePreview(wxString cmds, bool addtotop)
+ASSDrawShapePreview *ASSDrawShapeLibrary::AddShapePreview(wxString cmds, bool addtotop)
 {
-	ASSDrawShapePreview *prev = new ASSDrawShapePreview(libarea, this, cmds);
-	prev->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(ASSDrawShapeLibrary::OnMouseLeftDClick), NULL, this);
-	prev->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(ASSDrawShapeLibrary::OnMouseRightClick), NULL, this);
-	ASSDrawFrame::wxColourToAggRGBA(m_frame->colors.library_shape, prev->rgba_shape);
-	if (addtotop)
-		sizer->Insert(0, prev, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
-	else
-		sizer->Add(prev, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
-	UpdatePreviewDisplays();
-	return prev;
+    ASSDrawShapePreview *prev = new ASSDrawShapePreview(libarea, this, cmds);
+    prev->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(ASSDrawShapeLibrary::OnMouseLeftDClick), NULL, this);
+    prev->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(ASSDrawShapeLibrary::OnMouseRightClick), NULL, this);
+    ASSDrawFrame::wxColourToAggRGBA(m_frame->colors.library_shape, prev->rgba_shape);
+    if (addtotop)
+        sizer->Insert(0, prev, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
+    else
+        sizer->Add(prev, 1, wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5);
+    UpdatePreviewDisplays();
+    return prev;
 }
 
 void ASSDrawShapeLibrary::UpdatePreviewDisplays()
 {
-	wxSize siz = GetClientSize();
-	int dim = siz.x - 15;
-	libarea->Show(false);
-	wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
-	while (node != NULL)
-	{
-		ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
-		shprvw->SetSize(dim, dim);
-		sizer->SetItemMinSize(shprvw, dim - 20, dim - 20);
-		shprvw->SetFitToViewPointOnNextPaint(10, 10);
-		shprvw->Refresh();
-		node = node->GetNext();
-	}
-	sizer->Layout();
-	sizer->FitInside(libarea);
-	libarea->Show(true);
+    wxSize siz = GetClientSize();
+    int dim = siz.x - 15;
+    libarea->Show(false);
+    wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
+    while (node != NULL) {
+        ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
+        shprvw->SetSize(dim, dim);
+        sizer->SetItemMinSize(shprvw, dim - 20, dim - 20);
+        shprvw->SetFitToViewPointOnNextPaint(10, 10);
+        shprvw->Refresh();
+        node = node->GetNext();
+    }
+    sizer->Layout();
+    sizer->FitInside(libarea);
+    libarea->Show(true);
 }
 
 void ASSDrawShapeLibrary::OnMouseLeftDClick(wxMouseEvent &event)
 {
-	ASSDrawShapePreview *preview = (ASSDrawShapePreview *) event.GetEventObject();
-	LoadToCanvas(preview);
+    ASSDrawShapePreview *preview = (ASSDrawShapePreview *) event.GetEventObject();
+    LoadToCanvas(preview);
 }
 
 void ASSDrawShapeLibrary::OnMouseRightClick(wxMouseEvent &event)
 {
-	ASSDrawShapePreview *prev = (ASSDrawShapePreview *) event.GetEventObject();
-	if (prev && prev->shapelib == this)
-	{
-		activepreview = prev;
-		wxMenu *menu = new wxMenu;
-		wxMenuItem *menuload = new wxMenuItem(menu, MENU_LOAD, _T("Load to canvas"));
+    ASSDrawShapePreview *prev = (ASSDrawShapePreview *) event.GetEventObject();
+    if (prev && prev->shapelib == this) {
+        activepreview = prev;
+        wxMenu *menu = new wxMenu;
+        wxMenuItem *menuload = new wxMenuItem(menu, MENU_LOAD, _T("Load to canvas"));
 #ifdef __WINDOWS__
-		wxFont f = menuload->GetFont();
-		f.SetWeight(wxFONTWEIGHT_BOLD);
-		menuload->SetFont(f);
+        wxFont f = menuload->GetFont();
+        f.SetWeight(wxFONTWEIGHT_BOLD);
+        menuload->SetFont(f);
 #endif
-		menu->Append(menuload);
-		//menu->Append(MENU_LOAD, _T("Load to canvas"))->GetFont().SetWeight(wxFONTWEIGHT_BOLD);
-		menu->Append(MENU_COPYCLIPBOARD, _T("Copy commands to clipboard"));
-		menu->Append(MENU_SAVECANVAS, _T("Save canvas here"));
-		wxMenu *submenu = new wxMenu;
-		submenu->Append(MENU_DELETE, _T("Confirm delete?"));
-		menu->Append(MENU_DUMMY, _T("Delete from library"), submenu);
-		PopupMenu(menu);
-		delete menu;
-	}
+        menu->Append(menuload);
+        //menu->Append(MENU_LOAD, _T("Load to canvas"))->GetFont().SetWeight(wxFONTWEIGHT_BOLD);
+        menu->Append(MENU_COPYCLIPBOARD, _T("Copy commands to clipboard"));
+        menu->Append(MENU_SAVECANVAS, _T("Save canvas here"));
+        wxMenu *submenu = new wxMenu;
+        submenu->Append(MENU_DELETE, _T("Confirm delete?"));
+        menu->Append(MENU_DUMMY, _T("Delete from library"), submenu);
+        PopupMenu(menu);
+        delete menu;
+    }
 }
 
 void ASSDrawShapeLibrary::OnPopupMenuClicked(wxCommandEvent &event)
 {
-	int id = event.GetId();
-	switch(id)
-	{
-	case MENU_LOAD:
-		LoadToCanvas(activepreview);
-		break;
-	case MENU_COPYCLIPBOARD:
-		if (wxTheClipboard->Open())
-		{
-			if (wxTheClipboard->IsSupported( wxDF_TEXT ))
-			{
-				wxTheClipboard->SetData( new wxTextDataObject( activepreview->GenerateASS() ) );
-			}
-			wxTheClipboard->Close();
-		}
-		break;
-	case MENU_SAVECANVAS:
-		activepreview->ParseASS(m_frame->m_canvas->GenerateASS());
-		activepreview->SetFitToViewPointOnNextPaint();
-		activepreview->RefreshDisplay();
-		break;
-	case MENU_DELETE:
-		sizer->Detach(activepreview);
-		activepreview->Show(false);
-		activepreview->Destroy();
-		UpdatePreviewDisplays();
-		Refresh();
-		break;
-	}
+    int id = event.GetId();
+    switch (id) {
+    case MENU_LOAD:
+        LoadToCanvas(activepreview);
+        break;
+    case MENU_COPYCLIPBOARD:
+        if (wxTheClipboard->Open()) {
+            if (wxTheClipboard->IsSupported( wxDF_TEXT )) {
+                wxTheClipboard->SetData( new wxTextDataObject( activepreview->GenerateASS() ) );
+            }
+            wxTheClipboard->Close();
+        }
+        break;
+    case MENU_SAVECANVAS:
+        activepreview->ParseASS(m_frame->m_canvas->GenerateASS());
+        activepreview->SetFitToViewPointOnNextPaint();
+        activepreview->RefreshDisplay();
+        break;
+    case MENU_DELETE:
+        sizer->Detach(activepreview);
+        activepreview->Show(false);
+        activepreview->Destroy();
+        UpdatePreviewDisplays();
+        Refresh();
+        break;
+    }
 }
 
-void ASSDrawShapeLibrary::SaveShapeFromCanvas(wxCommandEvent& WXUNUSED(event))
+void ASSDrawShapeLibrary::SaveShapeFromCanvas(wxCommandEvent &WXUNUSED(event))
 {
-	AddShapePreview(m_frame->m_canvas->GenerateASS(), true);
+    AddShapePreview(m_frame->m_canvas->GenerateASS(), true);
 }
 
 void ASSDrawShapeLibrary::CheckUncheckAllPreviews(wxCommandEvent &event)
 {
-	bool checked = event.GetId() == TOOL_CHECK;
-	wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
-	while (node != NULL)
-	{
-		ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
-		shprvw->cb->SetValue(checked);
-		node = node->GetNext();
-	}
+    bool checked = event.GetId() == TOOL_CHECK;
+    wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
+    while (node != NULL) {
+        ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
+        shprvw->cb->SetValue(checked);
+        node = node->GetNext();
+    }
 }
 
-void ASSDrawShapeLibrary::DeleteChecked(wxCommandEvent& WXUNUSED(event))
+void ASSDrawShapeLibrary::DeleteChecked(wxCommandEvent &WXUNUSED(event))
 {
-	wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
-	while (node != NULL)
-	{
-		ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
-		if (shprvw->cb->GetValue())
-		{
-			sizer->Detach(shprvw);
-			shprvw->Show(false);
-			shprvw->Destroy();
-		}
-		node = node->GetNext();
-	}
-	UpdatePreviewDisplays();
-	Refresh();
+    wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
+    while (node != NULL) {
+        ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
+        if (shprvw->cb->GetValue()) {
+            sizer->Detach(shprvw);
+            shprvw->Show(false);
+            shprvw->Destroy();
+        }
+        node = node->GetNext();
+    }
+    UpdatePreviewDisplays();
+    Refresh();
 }
 
 std::vector< ASSDrawShapePreview *> ASSDrawShapeLibrary::GetShapePreviews()
 {
-	std::vector< ASSDrawShapePreview *> out;
-	wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
-	while (node != NULL)
-	{
-		ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
-		out.push_back(shprvw);
-		node = node->GetNext();
-	}
-	return out;
+    std::vector< ASSDrawShapePreview *> out;
+    wxwxSizerItemListNode *node = sizer->GetChildren().GetFirst();
+    while (node != NULL) {
+        ASSDrawShapePreview *shprvw = (ASSDrawShapePreview *) node->GetData()->GetWindow();
+        out.push_back(shprvw);
+        node = node->GetNext();
+    }
+    return out;
 }
 
 void ASSDrawShapeLibrary::LoadToCanvas(ASSDrawShapePreview *preview)
 {
-	m_frame->m_canvas->AddUndo(_T("Load shape from library"));
-	m_frame->m_canvas->ParseASS(preview->GenerateASS());
-	m_frame->m_canvas->RefreshDisplay();
-	m_frame->m_canvas->RefreshUndocmds();
-	m_frame->UpdateFrameUI();
+    m_frame->m_canvas->AddUndo(_T("Load shape from library"));
+    m_frame->m_canvas->ParseASS(preview->GenerateASS());
+    m_frame->m_canvas->RefreshDisplay();
+    m_frame->m_canvas->RefreshUndocmds();
+    m_frame->UpdateFrameUI();
 }
diff --git a/assdraw/library.hpp b/assdraw/library.hpp
index 20179d12f2e7845a1541701cb22c95d46d7e83e6..56f9e43d3093563d06905c4bbb2543fa45e80b17 100644
--- a/assdraw/library.hpp
+++ b/assdraw/library.hpp
@@ -36,53 +36,51 @@ class ASSDrawShapeLibrary;
 enum LIBLAYOUT { VERTICAL, HORIZONTAL };
 
 enum {
-	MENU_RANGE_START = 450,
-	MENU_LOAD,
-	MENU_COPYCLIPBOARD,
-	MENU_SAVECANVAS,
-	MENU_DELETE,
-	MENU_RANGE_END,
-	TOOL_SAVE,
-	TOOL_CHECK,
-	TOOL_UNCHECK,
-	TOOL_DELETE
+    MENU_RANGE_START = 450,
+    MENU_LOAD,
+    MENU_COPYCLIPBOARD,
+    MENU_SAVECANVAS,
+    MENU_DELETE,
+    MENU_RANGE_END,
+    TOOL_SAVE,
+    TOOL_CHECK,
+    TOOL_UNCHECK,
+    TOOL_DELETE
 };
 
-class ASSDrawShapePreview : public ASSDrawEngine
-{
+class ASSDrawShapePreview : public ASSDrawEngine {
 protected:
-	ASSDrawShapePreview( wxWindow *parent, ASSDrawShapeLibrary *shapelib, wxString initialcmds = _T(""));
-	virtual void OnSize(wxSizeEvent& event);
+    ASSDrawShapePreview( wxWindow *parent, ASSDrawShapeLibrary *shapelib, wxString initialcmds = _T(""));
+    virtual void OnSize(wxSizeEvent &event);
 
-	ASSDrawShapeLibrary *shapelib;
-	wxCheckBox *cb;
-	DECLARE_EVENT_TABLE()
-	friend class ASSDrawShapeLibrary;
+    ASSDrawShapeLibrary *shapelib;
+    wxCheckBox *cb;
+    DECLARE_EVENT_TABLE()
+    friend class ASSDrawShapeLibrary;
 };
 
-class ASSDrawShapeLibrary : public wxScrolledWindow
-{
+class ASSDrawShapeLibrary : public wxScrolledWindow {
 public:
-	ASSDrawShapeLibrary( wxWindow *parent, ASSDrawFrame *frame );
-	virtual ASSDrawShapePreview* AddShapePreview(wxString cmds, bool addtotop = false);
-	virtual void OnSize(wxSizeEvent& event);
-	virtual void OnMouseLeftDClick(wxMouseEvent &event);
-	virtual void OnMouseRightClick(wxMouseEvent &event);
-	virtual void OnPopupMenuClicked(wxCommandEvent &event);
-	virtual void SaveShapeFromCanvas(wxCommandEvent& WXUNUSED(event));
-	virtual void CheckUncheckAllPreviews(wxCommandEvent &event);
-	virtual void DeleteChecked(wxCommandEvent& WXUNUSED(event));
-	virtual void UpdatePreviewDisplays();
-	virtual std::vector< ASSDrawShapePreview *> GetShapePreviews();
-	virtual void LoadToCanvas(ASSDrawShapePreview *preview);
-	
-	wxScrolledWindow* libarea;
-	wxFlexGridSizer *libsizer;
-	wxSizer* sizer;
-	LIBLAYOUT layout;
+    ASSDrawShapeLibrary( wxWindow *parent, ASSDrawFrame *frame );
+    virtual ASSDrawShapePreview *AddShapePreview(wxString cmds, bool addtotop = false);
+    virtual void OnSize(wxSizeEvent &event);
+    virtual void OnMouseLeftDClick(wxMouseEvent &event);
+    virtual void OnMouseRightClick(wxMouseEvent &event);
+    virtual void OnPopupMenuClicked(wxCommandEvent &event);
+    virtual void SaveShapeFromCanvas(wxCommandEvent &WXUNUSED(event));
+    virtual void CheckUncheckAllPreviews(wxCommandEvent &event);
+    virtual void DeleteChecked(wxCommandEvent &WXUNUSED(event));
+    virtual void UpdatePreviewDisplays();
+    virtual std::vector< ASSDrawShapePreview *> GetShapePreviews();
+    virtual void LoadToCanvas(ASSDrawShapePreview *preview);
+
+    wxScrolledWindow *libarea;
+    wxFlexGridSizer *libsizer;
+    wxSizer *sizer;
+    LIBLAYOUT layout;
 protected:
-	ASSDrawFrame *m_frame;
-	ASSDrawShapePreview *activepreview;
+    ASSDrawFrame *m_frame;
+    ASSDrawShapePreview *activepreview;
 
-	DECLARE_EVENT_TABLE()
+    DECLARE_EVENT_TABLE()
 };
diff --git a/assdraw/resource.h b/assdraw/resource.h
index dab23b6f5eca659ec0413ba3d8883374829280f5..a8754f2bd8c77d1a008297171867a47a06874ae9 100644
--- a/assdraw/resource.h
+++ b/assdraw/resource.h
@@ -4,7 +4,7 @@
 //
 
 // Next default values for new objects
-// 
+//
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        105
diff --git a/assdraw/settings.cpp b/assdraw/settings.cpp
index 35246a4b3b214856500e4624d01c547044972951..c8ea23deb74a011094f4c3d53d71ec4dd104e7dd 100644
--- a/assdraw/settings.cpp
+++ b/assdraw/settings.cpp
@@ -43,137 +43,137 @@ DEFINE_EVENT_TYPE(wxEVT_SETTINGS_CHANGED)
 // ----------------------------------------------------------------------------
 
 ASSDrawSettingsDialog::ASSDrawSettingsDialog(wxWindow *parent, ASSDrawFrame *frame, int id)
- : wxPanel(parent, id)
+    : wxPanel(parent, id)
 {
-	m_frame = frame;
-	propgrid = NULL;
+    m_frame = frame;
+    propgrid = NULL;
 }
 
 void ASSDrawSettingsDialog::Init()
 {
     propgrid = new wxPropertyGrid(this,
-		wxID_ANY,
-		wxDefaultPosition,
-		wxDefaultSize,
-		//wxPG_BOLD_MODIFIED |
-		//wxPG_SPLITTER_AUTO_CENTER |
-		//wxPG_AUTO_SORT |
-		//wxPG_HIDE_MARGIN | wxPG_STATIC_SPLITTER |
-		wxPG_TOOLTIPS |
-		//wxPG_NOCATEGORIES |
-		wxTAB_TRAVERSAL //|
-		//wxSUNKEN_BORDER
-	);
-
-    #define APPENDCOLOURPROP(pgid, label, color) pgid = propgrid->Append(new wxColourProperty(label, wxPG_LABEL, color));
-    #define APPENDUINTPROP(pgid, label, uint) \
+                                  wxID_ANY,
+                                  wxDefaultPosition,
+                                  wxDefaultSize,
+                                  //wxPG_BOLD_MODIFIED |
+                                  //wxPG_SPLITTER_AUTO_CENTER |
+                                  //wxPG_AUTO_SORT |
+                                  //wxPG_HIDE_MARGIN | wxPG_STATIC_SPLITTER |
+                                  wxPG_TOOLTIPS |
+                                  //wxPG_NOCATEGORIES |
+                                  wxTAB_TRAVERSAL //|
+                                  //wxSUNKEN_BORDER
+                                 );
+
+#define APPENDCOLOURPROP(pgid, label, color) pgid = propgrid->Append(new wxColourProperty(label, wxPG_LABEL, color));
+#define APPENDUINTPROP(pgid, label, uint) \
 		pgid = propgrid->Append(new wxUIntProperty(label, wxPG_LABEL, uint) ); \
 		propgrid->SetPropertyValidator( pgid, validator );
-    #define APPENDBOOLPROP(pgid, label, boolvar) \
+#define APPENDBOOLPROP(pgid, label, boolvar) \
 	    pgid = propgrid->Append(new wxBoolProperty (label, wxPG_LABEL, boolvar ) ); \
     	propgrid->SetPropertyAttribute( pgid, wxPG_BOOL_USE_CHECKBOX, (long)1 );
-	wxLongPropertyValidator validator(0x0,0xFF);
-
-    propgrid->Append(new wxPropertyCategory(_T("Appearance"),wxPG_LABEL) );
-	APPENDCOLOURPROP(colors_canvas_bg_pgid, _T("Canvas"), m_frame->colors.canvas_bg)
-	APPENDCOLOURPROP(colors_canvas_shape_normal_pgid, _T("Drawing"), m_frame->colors.canvas_shape_normal)
-	APPENDUINTPROP(alphas_canvas_shape_normal_pgid, _T("Drawing @"), m_frame->alphas.canvas_shape_normal)
-	APPENDCOLOURPROP(colors_canvas_shape_preview_pgid, _T("Preview"), m_frame->colors.canvas_shape_preview)
-	APPENDUINTPROP(alphas_canvas_shape_preview_pgid, _T("Preview @"), m_frame->alphas.canvas_shape_preview)
-	APPENDCOLOURPROP(colors_canvas_shape_outline_pgid, _T("Outline"), m_frame->colors.canvas_shape_outline)
-	APPENDUINTPROP(alphas_canvas_shape_outline_pgid, _T("Outline @"), m_frame->alphas.canvas_shape_outline)
-	APPENDCOLOURPROP(colors_canvas_shape_guideline_pgid, _T("Control lines"), m_frame->colors.canvas_shape_guideline)
-	APPENDUINTPROP(alphas_canvas_shape_guideline_pgid, _T("Control lines @"), m_frame->alphas.canvas_shape_guideline)
-	APPENDCOLOURPROP(colors_canvas_shape_mainpoint_pgid, _T("Points"), m_frame->colors.canvas_shape_mainpoint)
-	APPENDUINTPROP(alphas_canvas_shape_mainpoint_pgid, _T("Points @"), m_frame->alphas.canvas_shape_mainpoint)
-	APPENDCOLOURPROP(colors_canvas_shape_controlpoint_pgid, _T("Control points"), m_frame->colors.canvas_shape_controlpoint)
-	APPENDUINTPROP(alphas_canvas_shape_controlpoint_pgid, _T("Control points @"), m_frame->alphas.canvas_shape_controlpoint)
-	APPENDCOLOURPROP(colors_canvas_shape_selectpoint_pgid, _T("Selected points"), m_frame->colors.canvas_shape_selectpoint)
-	APPENDUINTPROP(alphas_canvas_shape_selectpoint_pgid, _T("Selected points @"), m_frame->alphas.canvas_shape_selectpoint)
-	APPENDCOLOURPROP(colors_library_libarea_pgid, _T("Library"), m_frame->colors.library_libarea)
-	APPENDCOLOURPROP(colors_library_shape_pgid, _T("Library shapes"), m_frame->colors.library_shape)
-	APPENDCOLOURPROP(colors_origin_pgid, _T("Origin"), m_frame->colors.origin)
-	APPENDUINTPROP(sizes_origincross_pgid, _T("Origin cross size"), m_frame->sizes.origincross)
-	APPENDCOLOURPROP(colors_ruler_h_pgid, _T("H ruler"), m_frame->colors.ruler_h)
-	APPENDCOLOURPROP(colors_ruler_v_pgid, _T("V ruler"), m_frame->colors.ruler_v)
-
-    propgrid->Append(new wxPropertyCategory(_T("Behaviors"),wxPG_LABEL) );
-	APPENDBOOLPROP(behaviors_capitalizecmds_pgid, _T("Capitalize commands"), m_frame->behaviors.capitalizecmds);
-	APPENDBOOLPROP(behaviors_autoaskimgopac_pgid, _T("Ask for image opacity"), m_frame->behaviors.autoaskimgopac);
-	APPENDBOOLPROP(behaviors_parse_spc_pgid, _T("Parse S/P/C"), m_frame->behaviors.parse_spc);
-	APPENDBOOLPROP(behaviors_nosplashscreen_pgid, _T("No splash screen"), m_frame->behaviors.nosplashscreen);
-	APPENDBOOLPROP(behaviors_confirmquit_pgid, _T("Confirm quit"), m_frame->behaviors.confirmquit);
-
-	wxFlexGridSizer *sizer = new wxFlexGridSizer(2, 1, 0, 0);
-	sizer->AddGrowableCol(0);
-	sizer->AddGrowableRow(0);
-	sizer->Add(propgrid, 1, wxEXPAND);
-
-	wxBoxSizer *bsizer = new wxBoxSizer(wxHORIZONTAL);
-	wxButton *abutton = new wxButton(this, wxID_ANY, _T("Apply"));
-	abutton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(ASSDrawSettingsDialog::OnSettingsApplyButtonClicked), NULL, this);
-	bsizer->Add(abutton, 2, wxEXPAND);
-	wxButton *rbutton = new wxButton(this, wxID_ANY, _T("Revert"));
-	rbutton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(ASSDrawSettingsDialog::OnSettingsRevertButtonClicked), NULL, this);
-	bsizer->Add(rbutton, 1, wxEXPAND);
-	bsizer->Layout();
-
-	sizer->Add(bsizer, 1, wxEXPAND);
-	sizer->Layout();
-	SetSizer(sizer);
+    wxLongPropertyValidator validator(0x0, 0xFF);
+
+    propgrid->Append(new wxPropertyCategory(_T("Appearance"), wxPG_LABEL) );
+    APPENDCOLOURPROP(colors_canvas_bg_pgid, _T("Canvas"), m_frame->colors.canvas_bg)
+    APPENDCOLOURPROP(colors_canvas_shape_normal_pgid, _T("Drawing"), m_frame->colors.canvas_shape_normal)
+    APPENDUINTPROP(alphas_canvas_shape_normal_pgid, _T("Drawing @"), m_frame->alphas.canvas_shape_normal)
+    APPENDCOLOURPROP(colors_canvas_shape_preview_pgid, _T("Preview"), m_frame->colors.canvas_shape_preview)
+    APPENDUINTPROP(alphas_canvas_shape_preview_pgid, _T("Preview @"), m_frame->alphas.canvas_shape_preview)
+    APPENDCOLOURPROP(colors_canvas_shape_outline_pgid, _T("Outline"), m_frame->colors.canvas_shape_outline)
+    APPENDUINTPROP(alphas_canvas_shape_outline_pgid, _T("Outline @"), m_frame->alphas.canvas_shape_outline)
+    APPENDCOLOURPROP(colors_canvas_shape_guideline_pgid, _T("Control lines"), m_frame->colors.canvas_shape_guideline)
+    APPENDUINTPROP(alphas_canvas_shape_guideline_pgid, _T("Control lines @"), m_frame->alphas.canvas_shape_guideline)
+    APPENDCOLOURPROP(colors_canvas_shape_mainpoint_pgid, _T("Points"), m_frame->colors.canvas_shape_mainpoint)
+    APPENDUINTPROP(alphas_canvas_shape_mainpoint_pgid, _T("Points @"), m_frame->alphas.canvas_shape_mainpoint)
+    APPENDCOLOURPROP(colors_canvas_shape_controlpoint_pgid, _T("Control points"), m_frame->colors.canvas_shape_controlpoint)
+    APPENDUINTPROP(alphas_canvas_shape_controlpoint_pgid, _T("Control points @"), m_frame->alphas.canvas_shape_controlpoint)
+    APPENDCOLOURPROP(colors_canvas_shape_selectpoint_pgid, _T("Selected points"), m_frame->colors.canvas_shape_selectpoint)
+    APPENDUINTPROP(alphas_canvas_shape_selectpoint_pgid, _T("Selected points @"), m_frame->alphas.canvas_shape_selectpoint)
+    APPENDCOLOURPROP(colors_library_libarea_pgid, _T("Library"), m_frame->colors.library_libarea)
+    APPENDCOLOURPROP(colors_library_shape_pgid, _T("Library shapes"), m_frame->colors.library_shape)
+    APPENDCOLOURPROP(colors_origin_pgid, _T("Origin"), m_frame->colors.origin)
+    APPENDUINTPROP(sizes_origincross_pgid, _T("Origin cross size"), m_frame->sizes.origincross)
+    APPENDCOLOURPROP(colors_ruler_h_pgid, _T("H ruler"), m_frame->colors.ruler_h)
+    APPENDCOLOURPROP(colors_ruler_v_pgid, _T("V ruler"), m_frame->colors.ruler_v)
+
+    propgrid->Append(new wxPropertyCategory(_T("Behaviors"), wxPG_LABEL) );
+    APPENDBOOLPROP(behaviors_capitalizecmds_pgid, _T("Capitalize commands"), m_frame->behaviors.capitalizecmds);
+    APPENDBOOLPROP(behaviors_autoaskimgopac_pgid, _T("Ask for image opacity"), m_frame->behaviors.autoaskimgopac);
+    APPENDBOOLPROP(behaviors_parse_spc_pgid, _T("Parse S/P/C"), m_frame->behaviors.parse_spc);
+    APPENDBOOLPROP(behaviors_nosplashscreen_pgid, _T("No splash screen"), m_frame->behaviors.nosplashscreen);
+    APPENDBOOLPROP(behaviors_confirmquit_pgid, _T("Confirm quit"), m_frame->behaviors.confirmquit);
+
+    wxFlexGridSizer *sizer = new wxFlexGridSizer(2, 1, 0, 0);
+    sizer->AddGrowableCol(0);
+    sizer->AddGrowableRow(0);
+    sizer->Add(propgrid, 1, wxEXPAND);
+
+    wxBoxSizer *bsizer = new wxBoxSizer(wxHORIZONTAL);
+    wxButton *abutton = new wxButton(this, wxID_ANY, _T("Apply"));
+    abutton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(ASSDrawSettingsDialog::OnSettingsApplyButtonClicked), NULL, this);
+    bsizer->Add(abutton, 2, wxEXPAND);
+    wxButton *rbutton = new wxButton(this, wxID_ANY, _T("Revert"));
+    rbutton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(ASSDrawSettingsDialog::OnSettingsRevertButtonClicked), NULL, this);
+    bsizer->Add(rbutton, 1, wxEXPAND);
+    bsizer->Layout();
+
+    sizer->Add(bsizer, 1, wxEXPAND);
+    sizer->Layout();
+    SetSizer(sizer);
 }
 
 ASSDrawSettingsDialog::~ASSDrawSettingsDialog()
 {
-	if (propgrid) propgrid->Clear();
+    if (propgrid) propgrid->Clear();
 }
 
 void ASSDrawSettingsDialog::OnSettingsApplyButtonClicked(wxCommandEvent &event)
 {
 
-	wxButton *button = (wxButton *) event.GetEventObject();
-	//wxPropertyGrid *propgrid = (wxPropertyGrid *) button->GetClientData();
-	if (propgrid == NULL) return;
+    wxButton *button = (wxButton *) event.GetEventObject();
+    //wxPropertyGrid *propgrid = (wxPropertyGrid *) button->GetClientData();
+    if (propgrid == NULL) return;
 
-	#define PARSECOLOR(color, pgid) \
+#define PARSECOLOR(color, pgid) \
 	{ \
 		wxVariant variant = propgrid->GetPropertyValue(pgid); \
 		color = *wxGetVariantCast(variant,wxColour); \
 	}
 
-	#define PARSE(ptr, pgid) propgrid->GetPropertyValue(pgid).Convert(ptr);
-
-	PARSECOLOR(m_frame->colors.canvas_bg, colors_canvas_bg_pgid)
-	PARSECOLOR(m_frame->colors.canvas_shape_controlpoint, colors_canvas_shape_controlpoint_pgid)
-	PARSECOLOR(m_frame->colors.canvas_shape_guideline, colors_canvas_shape_guideline_pgid)
-	PARSECOLOR(m_frame->colors.canvas_shape_mainpoint, colors_canvas_shape_mainpoint_pgid)
-	PARSECOLOR(m_frame->colors.canvas_shape_normal, colors_canvas_shape_normal_pgid)
-	PARSECOLOR(m_frame->colors.canvas_shape_outline, colors_canvas_shape_outline_pgid)
-	PARSECOLOR(m_frame->colors.canvas_shape_preview, colors_canvas_shape_preview_pgid)
-	PARSECOLOR(m_frame->colors.canvas_shape_selectpoint, colors_canvas_shape_selectpoint_pgid)
-	PARSECOLOR(m_frame->colors.library_libarea, colors_library_libarea_pgid)
-	PARSECOLOR(m_frame->colors.library_shape, colors_library_shape_pgid)
-	PARSECOLOR(m_frame->colors.origin, colors_origin_pgid)
-	PARSECOLOR(m_frame->colors.ruler_h, colors_ruler_h_pgid)
-	PARSECOLOR(m_frame->colors.ruler_v, colors_ruler_v_pgid)
-
-	PARSE(&m_frame->alphas.canvas_shape_controlpoint, alphas_canvas_shape_controlpoint_pgid)
-	PARSE(&m_frame->alphas.canvas_shape_guideline, alphas_canvas_shape_guideline_pgid)
-	PARSE(&m_frame->alphas.canvas_shape_mainpoint, alphas_canvas_shape_mainpoint_pgid)
-	PARSE(&m_frame->alphas.canvas_shape_normal, alphas_canvas_shape_normal_pgid)
-	PARSE(&m_frame->alphas.canvas_shape_outline, alphas_canvas_shape_outline_pgid)
-	PARSE(&m_frame->alphas.canvas_shape_preview, alphas_canvas_shape_preview_pgid)
-	PARSE(&m_frame->alphas.canvas_shape_selectpoint, alphas_canvas_shape_selectpoint_pgid)
-
-	PARSE(&m_frame->sizes.origincross, sizes_origincross_pgid)
-
-	PARSE(&m_frame->behaviors.autoaskimgopac, behaviors_autoaskimgopac_pgid)
-	PARSE(&m_frame->behaviors.capitalizecmds, behaviors_capitalizecmds_pgid)
-	PARSE(&m_frame->behaviors.parse_spc, behaviors_parse_spc_pgid)
-	PARSE(&m_frame->behaviors.nosplashscreen, behaviors_nosplashscreen_pgid)
-	PARSE(&m_frame->behaviors.confirmquit, behaviors_confirmquit_pgid)
-
-	wxCommandEvent evento( wxEVT_SETTINGS_CHANGED, event.GetId() );
+#define PARSE(ptr, pgid) propgrid->GetPropertyValue(pgid).Convert(ptr);
+
+    PARSECOLOR(m_frame->colors.canvas_bg, colors_canvas_bg_pgid)
+    PARSECOLOR(m_frame->colors.canvas_shape_controlpoint, colors_canvas_shape_controlpoint_pgid)
+    PARSECOLOR(m_frame->colors.canvas_shape_guideline, colors_canvas_shape_guideline_pgid)
+    PARSECOLOR(m_frame->colors.canvas_shape_mainpoint, colors_canvas_shape_mainpoint_pgid)
+    PARSECOLOR(m_frame->colors.canvas_shape_normal, colors_canvas_shape_normal_pgid)
+    PARSECOLOR(m_frame->colors.canvas_shape_outline, colors_canvas_shape_outline_pgid)
+    PARSECOLOR(m_frame->colors.canvas_shape_preview, colors_canvas_shape_preview_pgid)
+    PARSECOLOR(m_frame->colors.canvas_shape_selectpoint, colors_canvas_shape_selectpoint_pgid)
+    PARSECOLOR(m_frame->colors.library_libarea, colors_library_libarea_pgid)
+    PARSECOLOR(m_frame->colors.library_shape, colors_library_shape_pgid)
+    PARSECOLOR(m_frame->colors.origin, colors_origin_pgid)
+    PARSECOLOR(m_frame->colors.ruler_h, colors_ruler_h_pgid)
+    PARSECOLOR(m_frame->colors.ruler_v, colors_ruler_v_pgid)
+
+    PARSE(&m_frame->alphas.canvas_shape_controlpoint, alphas_canvas_shape_controlpoint_pgid)
+    PARSE(&m_frame->alphas.canvas_shape_guideline, alphas_canvas_shape_guideline_pgid)
+    PARSE(&m_frame->alphas.canvas_shape_mainpoint, alphas_canvas_shape_mainpoint_pgid)
+    PARSE(&m_frame->alphas.canvas_shape_normal, alphas_canvas_shape_normal_pgid)
+    PARSE(&m_frame->alphas.canvas_shape_outline, alphas_canvas_shape_outline_pgid)
+    PARSE(&m_frame->alphas.canvas_shape_preview, alphas_canvas_shape_preview_pgid)
+    PARSE(&m_frame->alphas.canvas_shape_selectpoint, alphas_canvas_shape_selectpoint_pgid)
+
+    PARSE(&m_frame->sizes.origincross, sizes_origincross_pgid)
+
+    PARSE(&m_frame->behaviors.autoaskimgopac, behaviors_autoaskimgopac_pgid)
+    PARSE(&m_frame->behaviors.capitalizecmds, behaviors_capitalizecmds_pgid)
+    PARSE(&m_frame->behaviors.parse_spc, behaviors_parse_spc_pgid)
+    PARSE(&m_frame->behaviors.nosplashscreen, behaviors_nosplashscreen_pgid)
+    PARSE(&m_frame->behaviors.confirmquit, behaviors_confirmquit_pgid)
+
+    wxCommandEvent evento( wxEVT_SETTINGS_CHANGED, event.GetId() );
     evento.SetEventObject( button );
     m_frame->GetEventHandler()->ProcessEvent( evento );
 
@@ -181,43 +181,43 @@ void ASSDrawSettingsDialog::OnSettingsApplyButtonClicked(wxCommandEvent &event)
 
 void ASSDrawSettingsDialog::OnSettingsRevertButtonClicked(wxCommandEvent &event)
 {
-	RefreshSettingsDisplay();
+    RefreshSettingsDisplay();
 }
 
 void ASSDrawSettingsDialog::RefreshSettingsDisplay()
 {
-	if (propgrid == NULL) return;
-
-	#define UPDATESETTING(value, pgid) propgrid->SetPropertyValue(pgid, value);
-
-	UPDATESETTING(m_frame->colors.canvas_bg, colors_canvas_bg_pgid)
-	UPDATESETTING(m_frame->colors.canvas_shape_controlpoint, colors_canvas_shape_controlpoint_pgid)
-	UPDATESETTING(m_frame->colors.canvas_shape_guideline, colors_canvas_shape_guideline_pgid)
-	UPDATESETTING(m_frame->colors.canvas_shape_mainpoint, colors_canvas_shape_mainpoint_pgid)
-	UPDATESETTING(m_frame->colors.canvas_shape_normal, colors_canvas_shape_normal_pgid)
-	UPDATESETTING(m_frame->colors.canvas_shape_outline, colors_canvas_shape_outline_pgid)
-	UPDATESETTING(m_frame->colors.canvas_shape_preview, colors_canvas_shape_preview_pgid)
-	UPDATESETTING(m_frame->colors.canvas_shape_selectpoint, colors_canvas_shape_selectpoint_pgid)
-	UPDATESETTING(m_frame->colors.library_libarea, colors_library_libarea_pgid)
-	UPDATESETTING(m_frame->colors.library_shape, colors_library_shape_pgid)
-	UPDATESETTING(m_frame->colors.origin, colors_origin_pgid)
-	UPDATESETTING(m_frame->colors.ruler_h, colors_ruler_h_pgid)
-	UPDATESETTING(m_frame->colors.ruler_v, colors_ruler_v_pgid)
-
-	UPDATESETTING(m_frame->alphas.canvas_shape_controlpoint, alphas_canvas_shape_controlpoint_pgid)
-	UPDATESETTING(m_frame->alphas.canvas_shape_guideline, alphas_canvas_shape_guideline_pgid)
-	UPDATESETTING(m_frame->alphas.canvas_shape_mainpoint, alphas_canvas_shape_mainpoint_pgid)
-	UPDATESETTING(m_frame->alphas.canvas_shape_normal, alphas_canvas_shape_normal_pgid)
-	UPDATESETTING(m_frame->alphas.canvas_shape_outline, alphas_canvas_shape_outline_pgid)
-	UPDATESETTING(m_frame->alphas.canvas_shape_preview, alphas_canvas_shape_preview_pgid)
-	UPDATESETTING(m_frame->alphas.canvas_shape_selectpoint, alphas_canvas_shape_selectpoint_pgid)
-
-	UPDATESETTING(m_frame->sizes.origincross, sizes_origincross_pgid)
-
-	UPDATESETTING(m_frame->behaviors.capitalizecmds, behaviors_capitalizecmds_pgid)
-	UPDATESETTING(m_frame->behaviors.autoaskimgopac, behaviors_autoaskimgopac_pgid)
-	UPDATESETTING(m_frame->behaviors.parse_spc, behaviors_parse_spc_pgid)
-	UPDATESETTING(m_frame->behaviors.nosplashscreen, behaviors_nosplashscreen_pgid)
-	UPDATESETTING(m_frame->behaviors.confirmquit, behaviors_confirmquit_pgid)
+    if (propgrid == NULL) return;
+
+#define UPDATESETTING(value, pgid) propgrid->SetPropertyValue(pgid, value);
+
+    UPDATESETTING(m_frame->colors.canvas_bg, colors_canvas_bg_pgid)
+    UPDATESETTING(m_frame->colors.canvas_shape_controlpoint, colors_canvas_shape_controlpoint_pgid)
+    UPDATESETTING(m_frame->colors.canvas_shape_guideline, colors_canvas_shape_guideline_pgid)
+    UPDATESETTING(m_frame->colors.canvas_shape_mainpoint, colors_canvas_shape_mainpoint_pgid)
+    UPDATESETTING(m_frame->colors.canvas_shape_normal, colors_canvas_shape_normal_pgid)
+    UPDATESETTING(m_frame->colors.canvas_shape_outline, colors_canvas_shape_outline_pgid)
+    UPDATESETTING(m_frame->colors.canvas_shape_preview, colors_canvas_shape_preview_pgid)
+    UPDATESETTING(m_frame->colors.canvas_shape_selectpoint, colors_canvas_shape_selectpoint_pgid)
+    UPDATESETTING(m_frame->colors.library_libarea, colors_library_libarea_pgid)
+    UPDATESETTING(m_frame->colors.library_shape, colors_library_shape_pgid)
+    UPDATESETTING(m_frame->colors.origin, colors_origin_pgid)
+    UPDATESETTING(m_frame->colors.ruler_h, colors_ruler_h_pgid)
+    UPDATESETTING(m_frame->colors.ruler_v, colors_ruler_v_pgid)
+
+    UPDATESETTING(m_frame->alphas.canvas_shape_controlpoint, alphas_canvas_shape_controlpoint_pgid)
+    UPDATESETTING(m_frame->alphas.canvas_shape_guideline, alphas_canvas_shape_guideline_pgid)
+    UPDATESETTING(m_frame->alphas.canvas_shape_mainpoint, alphas_canvas_shape_mainpoint_pgid)
+    UPDATESETTING(m_frame->alphas.canvas_shape_normal, alphas_canvas_shape_normal_pgid)
+    UPDATESETTING(m_frame->alphas.canvas_shape_outline, alphas_canvas_shape_outline_pgid)
+    UPDATESETTING(m_frame->alphas.canvas_shape_preview, alphas_canvas_shape_preview_pgid)
+    UPDATESETTING(m_frame->alphas.canvas_shape_selectpoint, alphas_canvas_shape_selectpoint_pgid)
+
+    UPDATESETTING(m_frame->sizes.origincross, sizes_origincross_pgid)
+
+    UPDATESETTING(m_frame->behaviors.capitalizecmds, behaviors_capitalizecmds_pgid)
+    UPDATESETTING(m_frame->behaviors.autoaskimgopac, behaviors_autoaskimgopac_pgid)
+    UPDATESETTING(m_frame->behaviors.parse_spc, behaviors_parse_spc_pgid)
+    UPDATESETTING(m_frame->behaviors.nosplashscreen, behaviors_nosplashscreen_pgid)
+    UPDATESETTING(m_frame->behaviors.confirmquit, behaviors_confirmquit_pgid)
 
 }
diff --git a/assdraw/settings.hpp b/assdraw/settings.hpp
index 835fe7df7874aa72d483d5bc544f3e7d13759f3f..aed6e32699cc46e3c01ef6760194020e46306ef4 100644
--- a/assdraw/settings.hpp
+++ b/assdraw/settings.hpp
@@ -35,86 +35,81 @@ class ASSDrawFrame;
 
 DECLARE_EVENT_TYPE(wxEVT_SETTINGS_CHANGED, -1)
 
-typedef wxPGProperty* wxPGId;
+typedef wxPGProperty *wxPGId;
 
-class ASSDrawSettingsDialog : public wxPanel
-{
+class ASSDrawSettingsDialog : public wxPanel {
 public:
 
-	ASSDrawFrame* m_frame;
-
-	ASSDrawSettingsDialog( wxWindow *parent, ASSDrawFrame *frame, int id = wxID_ANY );
-	virtual ~ASSDrawSettingsDialog();
-
-	virtual void Init();
-	virtual void OnSettingsApplyButtonClicked(wxCommandEvent &event);
-	virtual void OnSettingsRevertButtonClicked(wxCommandEvent &event);
-	virtual void RefreshSettingsDisplay();
-
-	wxPGId colors_canvas_bg_pgid;
-	wxPGId colors_canvas_shape_normal_pgid;
-	wxPGId colors_canvas_shape_preview_pgid;
-	wxPGId colors_canvas_shape_outline_pgid;
-	wxPGId colors_canvas_shape_guideline_pgid;
-	wxPGId colors_canvas_shape_mainpoint_pgid;
-	wxPGId colors_canvas_shape_controlpoint_pgid;
-	wxPGId colors_canvas_shape_selectpoint_pgid;
-	wxPGId colors_library_shape_pgid;
-	wxPGId colors_library_libarea_pgid;
-	wxPGId colors_origin_pgid;
-	wxPGId colors_ruler_h_pgid;
-	wxPGId colors_ruler_v_pgid;
-	wxPGId alphas_canvas_shape_normal_pgid;
-	wxPGId alphas_canvas_shape_preview_pgid;
-	wxPGId alphas_canvas_shape_outline_pgid;
-	wxPGId alphas_canvas_shape_guideline_pgid;
-	wxPGId alphas_canvas_shape_mainpoint_pgid;
-	wxPGId alphas_canvas_shape_controlpoint_pgid;
-	wxPGId alphas_canvas_shape_selectpoint_pgid;
-	wxPGId sizes_origincross_pgid;
-	wxPGId behaviors_capitalizecmds_pgid;
-	wxPGId behaviors_autoaskimgopac_pgid;
-	wxPGId behaviors_parse_spc_pgid;
-	wxPGId behaviors_nosplashscreen_pgid;
-	wxPGId behaviors_confirmquit_pgid;
-
-	wxPropertyGrid *propgrid;
-	//DECLARE_EVENT_TABLE()
+    ASSDrawFrame *m_frame;
+
+    ASSDrawSettingsDialog( wxWindow *parent, ASSDrawFrame *frame, int id = wxID_ANY );
+    virtual ~ASSDrawSettingsDialog();
+
+    virtual void Init();
+    virtual void OnSettingsApplyButtonClicked(wxCommandEvent &event);
+    virtual void OnSettingsRevertButtonClicked(wxCommandEvent &event);
+    virtual void RefreshSettingsDisplay();
+
+    wxPGId colors_canvas_bg_pgid;
+    wxPGId colors_canvas_shape_normal_pgid;
+    wxPGId colors_canvas_shape_preview_pgid;
+    wxPGId colors_canvas_shape_outline_pgid;
+    wxPGId colors_canvas_shape_guideline_pgid;
+    wxPGId colors_canvas_shape_mainpoint_pgid;
+    wxPGId colors_canvas_shape_controlpoint_pgid;
+    wxPGId colors_canvas_shape_selectpoint_pgid;
+    wxPGId colors_library_shape_pgid;
+    wxPGId colors_library_libarea_pgid;
+    wxPGId colors_origin_pgid;
+    wxPGId colors_ruler_h_pgid;
+    wxPGId colors_ruler_v_pgid;
+    wxPGId alphas_canvas_shape_normal_pgid;
+    wxPGId alphas_canvas_shape_preview_pgid;
+    wxPGId alphas_canvas_shape_outline_pgid;
+    wxPGId alphas_canvas_shape_guideline_pgid;
+    wxPGId alphas_canvas_shape_mainpoint_pgid;
+    wxPGId alphas_canvas_shape_controlpoint_pgid;
+    wxPGId alphas_canvas_shape_selectpoint_pgid;
+    wxPGId sizes_origincross_pgid;
+    wxPGId behaviors_capitalizecmds_pgid;
+    wxPGId behaviors_autoaskimgopac_pgid;
+    wxPGId behaviors_parse_spc_pgid;
+    wxPGId behaviors_nosplashscreen_pgid;
+    wxPGId behaviors_confirmquit_pgid;
+
+    wxPropertyGrid *propgrid;
+    //DECLARE_EVENT_TABLE()
 
 };
 
-class wxLongPropertyValidator : public wxValidator
-{
+class wxLongPropertyValidator : public wxValidator {
 public:
 
     wxLongPropertyValidator( const int min, const int max )
-        : wxValidator()
-    {
-		m_min = min, m_max = max;
+        : wxValidator() {
+        m_min = min, m_max = max;
     }
 
-    virtual wxObject* Clone() const
-    {
+    virtual wxObject *Clone() const {
         return new wxLongPropertyValidator( m_min, m_max );
     }
 
-    virtual bool Validate(wxWindow* WXUNUSED(parent))
-	{
-	    wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
-	    wxCHECK_MSG(tc, true, wxT("validator window must be wxTextCtrl"));
+    virtual bool Validate(wxWindow *WXUNUSED(parent)) {
+        wxTextCtrl *tc = wxDynamicCast(GetWindow(), wxTextCtrl);
+        wxCHECK_MSG(tc, true, wxT("validator window must be wxTextCtrl"));
 
-	    wxString val = tc->GetValue();
+        wxString val = tc->GetValue();
 
-		long valint = 0;
-		val.ToLong(&valint);
+        long valint = 0;
+        val.ToLong(&valint);
 
-		if (valint < m_min) valint = m_min;
-		if (valint > m_max) valint = m_max;
+        if (valint < m_min) valint = m_min;
+        if (valint > m_max) valint = m_max;
 
-		tc->SetValue(wxString::Format(_T("%d"), valint));
+        tc->SetValue(wxString::Format(_T("%d"), valint));
 
-	    return true;
-	}
+        return true;
+    }
 
 private:
     int m_min, m_max;
diff --git a/assdraw/wxAGG/AGGWindow.cpp b/assdraw/wxAGG/AGGWindow.cpp
index 1e5233c15c313ad7dc544273ea89d434c90a51c6..f412edfcf0864829abb2b71b50637a644bc60698 100644
--- a/assdraw/wxAGG/AGGWindow.cpp
+++ b/assdraw/wxAGG/AGGWindow.cpp
@@ -7,121 +7,126 @@
 
 namespace GUI {
 
-    BEGIN_EVENT_TABLE(AGGWindow, wxWindow)
-        EVT_PAINT(AGGWindow::onPaint)
-        EVT_SIZE(AGGWindow::onSize)
-        EVT_ERASE_BACKGROUND(AGGWindow::onEraseBackground)
-    END_EVENT_TABLE()
-
-    AGGWindow::AGGWindow(wxWindow* parent, wxWindowID id,
-                       const wxPoint& pos, const wxSize& size, long style):
-        wxWindow(parent, id, pos, size, style, wxT("AGGWindow")),
-        bitmap(NULL) {
-    }
+BEGIN_EVENT_TABLE(AGGWindow, wxWindow)
+    EVT_PAINT(AGGWindow::onPaint)
+    EVT_SIZE(AGGWindow::onSize)
+    EVT_ERASE_BACKGROUND(AGGWindow::onEraseBackground)
+END_EVENT_TABLE()
+
+AGGWindow::AGGWindow(wxWindow *parent, wxWindowID id,
+                     const wxPoint &pos, const wxSize &size, long style):
+    wxWindow(parent, id, pos, size, style, wxT("AGGWindow")),
+    bitmap(NULL)
+{
+}
 
-    void AGGWindow::init(const int width, const int height) {
-        memDC.SelectObject(wxNullBitmap);
-        delete bitmap;
+void AGGWindow::init(const int width, const int height)
+{
+    memDC.SelectObject(wxNullBitmap);
+    delete bitmap;
 
-        int ncheight = height, ncwidth = width;
-        if (ncwidth < 1) ncwidth = 1;
-        if (ncheight < 1) ncheight = 1;
+    int ncheight = height, ncwidth = width;
+    if (ncwidth < 1) ncwidth = 1;
+    if (ncheight < 1) ncheight = 1;
 
-        bitmap = new wxBitmap(ncwidth, ncheight, PixelFormat::wxWidgetsType::BitsPerPixel);
+    bitmap = new wxBitmap(ncwidth, ncheight, PixelFormat::wxWidgetsType::BitsPerPixel);
 
-        // Draw the bitmap
-        attachAndDraw();
+    // Draw the bitmap
+    attachAndDraw();
 
-        memDC.SelectObject(*bitmap);
+    memDC.SelectObject(*bitmap);
 
-        // Request a full redraw of the window
-        Refresh(false);
-    }
+    // Request a full redraw of the window
+    Refresh(false);
+}
 
-    AGGWindow::~AGGWindow() {
-        memDC.SelectObject(wxNullBitmap);
-        delete bitmap;
-    }
+AGGWindow::~AGGWindow()
+{
+    memDC.SelectObject(wxNullBitmap);
+    delete bitmap;
+}
 
-    void AGGWindow::attachAndDraw() {
-        // Get raw access to the wxWidgets bitmap -- this locks the pixels and
-        // unlocks on destruction.
-        PixelData data(*bitmap);
-        assert(data);
+void AGGWindow::attachAndDraw()
+{
+    // Get raw access to the wxWidgets bitmap -- this locks the pixels and
+    // unlocks on destruction.
+    PixelData data(*bitmap);
+    assert(data);
 
 #if 1
-        // This cast looks like it is ignoring byte-ordering, but the
-        // pixel format already explicitly handles that.
-        assert(data.GetPixels().IsOk());
-        wxAlphaPixelFormat::ChannelType* pd = (wxAlphaPixelFormat::ChannelType*) &data.GetPixels().Data();
-
-        // wxWidgets always returns a pointer to the first row of pixels, whether
-        // that is stored at the beginning of the buffer (stride > 0) or at the
-        // end of the buffer (stride < 0).  AGG always wants a pointer to the
-        // beginning of the buffer, no matter what the stride.  (AGG does handle
-        // negative strides correctly.)
-        // Upshot: if the stride is negative, rewind the pointer from the end of
-        // the buffer to the beginning.
-        const int stride = data.GetRowStride();
-        if (stride < 0)
-            pd += (data.GetHeight() - 1) * stride;
-
-        rBuf.attach(pd, data.GetWidth(), data.GetHeight(), stride);
-
-        // Call the user code to actually draw.
-        draw();
+    // This cast looks like it is ignoring byte-ordering, but the
+    // pixel format already explicitly handles that.
+    assert(data.GetPixels().IsOk());
+    wxAlphaPixelFormat::ChannelType *pd = (wxAlphaPixelFormat::ChannelType *) &data.GetPixels().Data();
+
+    // wxWidgets always returns a pointer to the first row of pixels, whether
+    // that is stored at the beginning of the buffer (stride > 0) or at the
+    // end of the buffer (stride < 0).  AGG always wants a pointer to the
+    // beginning of the buffer, no matter what the stride.  (AGG does handle
+    // negative strides correctly.)
+    // Upshot: if the stride is negative, rewind the pointer from the end of
+    // the buffer to the beginning.
+    const int stride = data.GetRowStride();
+    if (stride < 0)
+        pd += (data.GetHeight() - 1) * stride;
+
+    rBuf.attach(pd, data.GetWidth(), data.GetHeight(), stride);
+
+    // Call the user code to actually draw.
+    draw();
 #else
-        PixelData::Iterator p(data);
-
-        // we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
-        p.Offset(data, 10, 10);
+    PixelData::Iterator p(data);
 
-        for ( int y = 0; y < 10; ++y )
-        {
-            PixelData::Iterator rowStart = p;
+    // we draw a (10, 10)-(20, 20) rect manually using the given r, g, b
+    p.Offset(data, 10, 10);
 
-            for ( int x = 0; x < 10; ++x, ++p )
-            {
-                p.Red() = 255;
-                p.Green() = 0;
-                p.Blue() = 255;
-            }
+    for ( int y = 0; y < 10; ++y ) {
+        PixelData::Iterator rowStart = p;
 
-            p = rowStart;
-            p.OffsetY(data, 1);
+        for ( int x = 0; x < 10; ++x, ++p ) {
+            p.Red() = 255;
+            p.Green() = 0;
+            p.Blue() = 255;
         }
-#endif
+
+        p = rowStart;
+        p.OffsetY(data, 1);
     }
+#endif
+}
 
-    void AGGWindow::onSize(wxSizeEvent& event) {
-        const wxSize size = GetClientSize();
-        if (bitmap && size.GetWidth() == bitmap->GetWidth() && size.GetHeight() == bitmap->GetHeight())
-            return;
+void AGGWindow::onSize(wxSizeEvent &event)
+{
+    const wxSize size = GetClientSize();
+    if (bitmap && size.GetWidth() == bitmap->GetWidth() && size.GetHeight() == bitmap->GetHeight())
+        return;
 
-        init(size.GetWidth(), size.GetHeight());
-    }
+    init(size.GetWidth(), size.GetHeight());
+}
 
-    void AGGWindow::onPaint(wxPaintEvent& event) {
-        wxPaintDC dc(this);
-
-        wxCoord width, height;
-        dc.GetSize(&width, &height);
-        if (!bitmap || bitmap->GetWidth() != width || bitmap->GetHeight() != height)
-            init(width, height);
-
-        // Iterate over regions needing repainting
-        wxRegionIterator regions(GetUpdateRegion());
-        wxRect rect;
-        while (regions) {
-            rect = regions.GetRect();
-            dc.Blit(rect.x, rect.y, rect.width, rect.height, &memDC, rect.x, rect.y);
-            ++regions;
-        }
+void AGGWindow::onPaint(wxPaintEvent &event)
+{
+    wxPaintDC dc(this);
+
+    wxCoord width, height;
+    dc.GetSize(&width, &height);
+    if (!bitmap || bitmap->GetWidth() != width || bitmap->GetHeight() != height)
+        init(width, height);
+
+    // Iterate over regions needing repainting
+    wxRegionIterator regions(GetUpdateRegion());
+    wxRect rect;
+    while (regions) {
+        rect = regions.GetRect();
+        dc.Blit(rect.x, rect.y, rect.width, rect.height, &memDC, rect.x, rect.y);
+        ++regions;
     }
+}
 
-    void AGGWindow::onEraseBackground(wxEraseEvent& WXUNUSED(event)) {
-	    // Do nothing to "avoid flashing in MSW"  Grr.
-    }
+void AGGWindow::onEraseBackground(wxEraseEvent &WXUNUSED(event))
+{
+    // Do nothing to "avoid flashing in MSW"  Grr.
+}
 
 }
 
diff --git a/assdraw/wxAGG/AGGWindow.h b/assdraw/wxAGG/AGGWindow.h
index 01039da39f2ef62e016e83fb80c1611c7f7c4862..3c46990c8f7a7e2e34d722319a1b3fc093d89040 100644
--- a/assdraw/wxAGG/AGGWindow.h
+++ b/assdraw/wxAGG/AGGWindow.h
@@ -11,58 +11,58 @@
 #include "agg_rendering_buffer.h"
 
 namespace GUI {
-    
-    /// A simple widget that displays a bitmap that AGG can draw on.
-    /// It reallocates the bitmap so that it always is the current size of the 
-    /// entire panel and calls the virtual method draw() to draw to the bitmap.
-    /// This should be useable anywhere a wxWindow can be, e.g. in actual windows, 
-    /// buttons, etc.
-    class AGGWindow: public wxWindow {
-        public:
-        /// Create an AGGWindow.  Defaults are taken from wxWindow::wxWindow(), see 
-        /// that documentation for more information.
-        AGGWindow(wxWindow* parent, wxWindowID id = wxID_ANY, 
-                  const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, 
-                  long style = wxTAB_TRAVERSAL);
-        
-        /// Clean up resources held
-        virtual ~AGGWindow();
-        
-        protected:
-           
-        /// The conversion between wxWidgets' pixel format and AGG's pixel format
-        typedef PixelFormatConvertor<wxNativePixelFormat> PixelFormat;
-
-        /// The wxWidgets "pixel data" type, an accessor to the raw pixels
-        typedef wxPixelData<wxBitmap, PixelFormat::wxWidgetsType> PixelData;
-
-        
-        /// Create the bitmap given the current size.
-        void init(const int width, const int height);
-
-        /// Attach the AGG rendering buffer to the bitmap and call the user draw() code.
-        void attachAndDraw();
-    
-        /// Paint the bitmap onto the panel.
-        void onPaint(wxPaintEvent& event);
-        
-        /// Resize the bitmap to match the window.
-        void onSize(wxSizeEvent& event);
-
-        /// Handle the erase-background event.
-        void onEraseBackground(wxEraseEvent& event);
-        
-        /// Draw into the bitmap using AGG.
-        virtual void draw() = 0;
-
-        
-        wxBitmap* bitmap;               ///< wxWidgets bitmap for AGG to draw into
-        wxMemoryDC memDC;               ///< Memory "device context" for drawing the bitmap
-        
-        agg::rendering_buffer rBuf;     ///< AGG's rendering buffer, pointing into the bitmap
-    
-        DECLARE_EVENT_TABLE()           /// Allocate wxWidgets storage for event handlers
-    };
+
+/// A simple widget that displays a bitmap that AGG can draw on.
+/// It reallocates the bitmap so that it always is the current size of the
+/// entire panel and calls the virtual method draw() to draw to the bitmap.
+/// This should be useable anywhere a wxWindow can be, e.g. in actual windows,
+/// buttons, etc.
+class AGGWindow: public wxWindow {
+public:
+    /// Create an AGGWindow.  Defaults are taken from wxWindow::wxWindow(), see
+    /// that documentation for more information.
+    AGGWindow(wxWindow *parent, wxWindowID id = wxID_ANY,
+              const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
+              long style = wxTAB_TRAVERSAL);
+
+    /// Clean up resources held
+    virtual ~AGGWindow();
+
+protected:
+
+    /// The conversion between wxWidgets' pixel format and AGG's pixel format
+    typedef PixelFormatConvertor<wxNativePixelFormat> PixelFormat;
+
+    /// The wxWidgets "pixel data" type, an accessor to the raw pixels
+    typedef wxPixelData<wxBitmap, PixelFormat::wxWidgetsType> PixelData;
+
+
+    /// Create the bitmap given the current size.
+    void init(const int width, const int height);
+
+    /// Attach the AGG rendering buffer to the bitmap and call the user draw() code.
+    void attachAndDraw();
+
+    /// Paint the bitmap onto the panel.
+    void onPaint(wxPaintEvent &event);
+
+    /// Resize the bitmap to match the window.
+    void onSize(wxSizeEvent &event);
+
+    /// Handle the erase-background event.
+    void onEraseBackground(wxEraseEvent &event);
+
+    /// Draw into the bitmap using AGG.
+    virtual void draw() = 0;
+
+
+    wxBitmap *bitmap;               ///< wxWidgets bitmap for AGG to draw into
+    wxMemoryDC memDC;               ///< Memory "device context" for drawing the bitmap
+
+    agg::rendering_buffer rBuf;     ///< AGG's rendering buffer, pointing into the bitmap
+
+    DECLARE_EVENT_TABLE()           /// Allocate wxWidgets storage for event handlers
+};
 }
-    
+
 #endif
diff --git a/assdraw/wxAGG/PixelFormatConvertor.h b/assdraw/wxAGG/PixelFormatConvertor.h
index d1b0741c4235fa71dd8c23674e2df381e81f886d..4f89c44949b012a84724564c141ccba681c4b60d 100644
--- a/assdraw/wxAGG/PixelFormatConvertor.h
+++ b/assdraw/wxAGG/PixelFormatConvertor.h
@@ -33,85 +33,85 @@
 
 namespace {
 
-    /// Given a particular combination of channel type, bits per pixel and 
-    /// channel indices, return the AGG format that matches.
-    /// The actual template specializations that follow give the actual types, 
-    /// and using a combination of parameters that are not listed will give 
-    /// a compile-time error.
-    template <typename Channel, int bitsPerPixel, int r, int g, int b, int a> 
-    struct wxWidgetsToAGGHelper {
-        //empty
-    };
-
-    /// 24-bit RGB 
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 24, 0, 1, 2, -1> {
-        typedef agg::pixfmt_rgb24 format;
-    };
-
-    /// 24-bit BGR
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 24, 2, 1, 0, -1> {
-        typedef agg::pixfmt_bgr24 format;
-    };
-
-    /// 32-bit RGB, alpha unused but stored as ARGB. 
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 1, 2, 3, -1> {
-        typedef agg::pixfmt_argb32 format;
-    };
-
-    /// 32-bit RGB, alpha unused but stored as RGBA.
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 0, 1, 2, -1> {
-        typedef agg::pixfmt_rgba32 format;
-    };
-
-    /// 32-bit BGR, alpha unused but stored as ABGR. 
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 3, 2, 1, -1> {
-        typedef agg::pixfmt_abgr32 format;
-    };
-
-    /// 32-bit BGR, alpha unused but stored as BGRA.
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 2, 1, 0, -1> {
-        typedef agg::pixfmt_bgra32 format;
-    };
-
-    /// 32-bit RGBA
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 0, 1, 2, 3> {
-        typedef agg::pixfmt_rgba32 format;
-    };
-
-    /// 32-bit BGRA
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 2, 1, 0, 3> {
-        typedef agg::pixfmt_bgra32 format;
-    };
-
-    /// 32-bit ARGB
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 1, 2, 3, 0> {
-        typedef agg::pixfmt_argb32 format;
-    };
-
-    /// 32-bit ABGR
-    template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 3, 2, 1, 0> {
-        typedef agg::pixfmt_abgr32 format;
-    };
+/// Given a particular combination of channel type, bits per pixel and
+/// channel indices, return the AGG format that matches.
+/// The actual template specializations that follow give the actual types,
+/// and using a combination of parameters that are not listed will give
+/// a compile-time error.
+template <typename Channel, int bitsPerPixel, int r, int g, int b, int a>
+struct wxWidgetsToAGGHelper {
+    //empty
+};
+
+/// 24-bit RGB
+template <> struct wxWidgetsToAGGHelper < unsigned char, 24, 0, 1, 2, -1 > {
+    typedef agg::pixfmt_rgb24 format;
+};
+
+/// 24-bit BGR
+template <> struct wxWidgetsToAGGHelper < unsigned char, 24, 2, 1, 0, -1 > {
+    typedef agg::pixfmt_bgr24 format;
+};
+
+/// 32-bit RGB, alpha unused but stored as ARGB.
+template <> struct wxWidgetsToAGGHelper < unsigned char, 32, 1, 2, 3, -1 > {
+    typedef agg::pixfmt_argb32 format;
+};
+
+/// 32-bit RGB, alpha unused but stored as RGBA.
+template <> struct wxWidgetsToAGGHelper < unsigned char, 32, 0, 1, 2, -1 > {
+    typedef agg::pixfmt_rgba32 format;
+};
+
+/// 32-bit BGR, alpha unused but stored as ABGR.
+template <> struct wxWidgetsToAGGHelper < unsigned char, 32, 3, 2, 1, -1 > {
+    typedef agg::pixfmt_abgr32 format;
+};
+
+/// 32-bit BGR, alpha unused but stored as BGRA.
+template <> struct wxWidgetsToAGGHelper < unsigned char, 32, 2, 1, 0, -1 > {
+    typedef agg::pixfmt_bgra32 format;
+};
+
+/// 32-bit RGBA
+template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 0, 1, 2, 3> {
+    typedef agg::pixfmt_rgba32 format;
+};
+
+/// 32-bit BGRA
+template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 2, 1, 0, 3> {
+    typedef agg::pixfmt_bgra32 format;
+};
+
+/// 32-bit ARGB
+template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 1, 2, 3, 0> {
+    typedef agg::pixfmt_argb32 format;
+};
+
+/// 32-bit ABGR
+template <> struct wxWidgetsToAGGHelper<unsigned char, 32, 3, 2, 1, 0> {
+    typedef agg::pixfmt_abgr32 format;
+};
 }
 
 namespace GUI {
-    /// Convert between a wxWidgets pixel format class and an AGG pixel format class.
-    /// Usage examples: 
-    /// PixelFormatConvertor<wxNativePixelFormat>::AGGType or 
-    /// PixelFormatConvertor<wxAlphaPixelFormat>::AGGType.
-    template <typename wxWidgetsPixelFormat>
-    class PixelFormatConvertor {
-    public:
-        typedef wxWidgetsPixelFormat wxWidgetsType;
-
-        // Break out the wxWidgets parameters and feed to the helper class.
-        typedef typename wxWidgetsToAGGHelper<typename wxWidgetsPixelFormat::ChannelType, 
-                                              wxWidgetsPixelFormat::BitsPerPixel,
-                                              wxWidgetsPixelFormat::RED,
-                                              wxWidgetsPixelFormat::GREEN,
-                                              wxWidgetsPixelFormat::BLUE,
-                                              wxWidgetsPixelFormat::ALPHA>::format AGGType;
-    };
+/// Convert between a wxWidgets pixel format class and an AGG pixel format class.
+/// Usage examples:
+/// PixelFormatConvertor<wxNativePixelFormat>::AGGType or
+/// PixelFormatConvertor<wxAlphaPixelFormat>::AGGType.
+template <typename wxWidgetsPixelFormat>
+class PixelFormatConvertor {
+public:
+    typedef wxWidgetsPixelFormat wxWidgetsType;
+
+    // Break out the wxWidgets parameters and feed to the helper class.
+    typedef typename wxWidgetsToAGGHelper<typename wxWidgetsPixelFormat::ChannelType,
+            wxWidgetsPixelFormat::BitsPerPixel,
+            wxWidgetsPixelFormat::RED,
+            wxWidgetsPixelFormat::GREEN,
+            wxWidgetsPixelFormat::BLUE,
+            wxWidgetsPixelFormat::ALPHA>::format AGGType;
+};
 }
 
 #endif
diff --git a/libaegisub/lua/modules/lfs.cpp b/libaegisub/lua/modules/lfs.cpp
index 38f29d7928852a64ba247379c0ff366c067b6220..8053b6893a76fc28af0a6a77d308c5a86af398c8 100644
--- a/libaegisub/lua/modules/lfs.cpp
+++ b/libaegisub/lua/modules/lfs.cpp
@@ -112,7 +112,7 @@ DirectoryIterator *dir_new(const char *path, char **err)
 
 const char *get_mode(const char *path, char **err)
 {
-    return wrap(err, [ = ]() -> const char * {
+    return wrap(err, [ = ]() -> const char* {
         switch (bfs::status(path).type())
         {
         case bfs::file_not_found: return nullptr;         break;
diff --git a/src/mkv_wrap.cpp b/src/mkv_wrap.cpp
index acb4be0e7c9732b0be224ea1f3ad2bdc0c26c282..bc9aa58d97a978112a6e5279b3822a6574cb01a3 100644
--- a/src/mkv_wrap.cpp
+++ b/src/mkv_wrap.cpp
@@ -105,7 +105,7 @@ struct MkvStdIO final : InputStream {
         read = &MkvStdIO::Read;
         scan = &MkvStdIO::Scan;
         getcachesize = [](InputStream *) -> unsigned int { return 16 * 1024 * 1024; };
-        geterror = [](InputStream * st) -> const char * { return ((MkvStdIO *)st)->error.c_str(); };
+        geterror = [](InputStream * st) -> const char* { return ((MkvStdIO *)st)->error.c_str(); };
         memalloc = [](InputStream *, size_t size) { return malloc(size); };
         memrealloc = [](InputStream *, void *mem, size_t size) { return realloc(mem, size); };
         memfree = [](InputStream *, void *mem) { free(mem); };
diff --git a/tools/astyle.bash b/tools/astyle.bash
index e37303069b0516014b8af0a3f35263aa717e6986..19397201e5fd0d150321c418f5796b20564b0c97 100755
--- a/tools/astyle.bash
+++ b/tools/astyle.bash
@@ -29,7 +29,7 @@ OPTIONS='
     --keep-one-line-blocks --keep-one-line-statements
 '
 
-SRC='./src ./automation ./libaegisub'
+SRC='./src ./automation ./libaegisub ./assdraw'
 
 if [ $# -gt 0 ] && [ "$1" = "--check" ] ; then
     astyle $OPTIONS --dry-run -R ./*.c | grep Formatted