[dia/alpha: 1/7] Bug #591525 - Transparent objects by adding alpha to Color structure



commit dc6f456db309c76a0019c22e66f7fbed51ed3909
Author: Jason Childs <oblivian users sourceforge net>
Date:   Tue Aug 11 23:55:20 2009 -0400

    Bug #591525 - Transparent objects by adding alpha to Color structure
    
    From: Jason Childs <oblivian users sourceforge net>
    Date: Tue, 11 Aug 2009 23:55:20 -0400
    Subject: [PATCH] Color transparency support
    
    Add alpha to Color structure to support transparency. This change tries
    to be a uninstrusive as possible, any and all references to Color have
    either been upgraded to read/write the new alpha parameter or they
    default to 1.0 to retain the existing functionality.
    If the plugin/importer/exporter does not support transparency, it will
    render the same as before.  The cairo renderer has been updated to use
    alpha and the dia file format has been extended to understand both the
    new alpha value and support older files that don't have alpha for color
    values.

 app/color_area.c                        |   17 +-
 app/connectionpoint_ops.c               |    4 +-
 app/handle_ops.c                        |   24 +-
 app/preferences.h                       |    4 +-
 app/render_gdk.c                        |    6 +-
 bindings/dia-properties.cpp             |    4 +-
 bindings/dia.swig                       |  739 ++++++++++++++++---------------
 lib/arrows.c                            |    2 +-
 lib/attributes.c                        |    4 +-
 lib/bezier_conn.c                       |    2 +-
 lib/beziershape.c                       |    2 +-
 lib/color.c                             |   29 +-
 lib/color.h                             |    9 +-
 lib/dia_svg.c                           |   13 +-
 lib/dia_xml.c                           |   13 +-
 lib/diasvgrenderer.c                    |    6 +-
 lib/layer.c                             |    1 +
 lib/libdia.def                          |    1 +
 lib/prop_attr.c                         |    1 +
 lib/widgets.c                           |   70 +++-
 objects/Database/compound.c             |    2 +-
 objects/FS/flow-ortho.c                 |    8 +-
 objects/FS/flow.c                       |    6 +-
 objects/GRAFCET/action.c                |    2 +-
 objects/GRAFCET/step.c                  |    2 +-
 objects/KAOS/metabinrel.c               |    2 +-
 objects/Misc/analog_clock.c             |    2 +
 objects/Misc/grid_object.c              |    1 +
 objects/SADT/annotation.c               |    1 +
 objects/SISSI/area.c                    |    2 +-
 objects/SISSI/faraday.c                 |    2 +-
 objects/SISSI/room.c                    |    2 +-
 objects/SISSI/site.c                    |    2 +-
 objects/chronogram/chronoline.c         |    2 +
 objects/custom/custom_object.c          |    7 +-
 objects/custom_lines/line_info.c        |    3 +
 objects/network/network.c               |    2 +-
 plug-ins/cairo/diacairo-interactive.c   |    6 +-
 plug-ins/cairo/diacairo-renderer.c      |   27 +-
 plug-ins/cgm/cgm.c                      |   24 +-
 plug-ins/drs/dia-render-script-import.c |    1 +
 plug-ins/dxf/dxf-import.c               |   18 +-
 plug-ins/libart/dialibartrenderer.c     |    6 +-
 plug-ins/libart/render_libart.c         |    6 +-
 plug-ins/python/diasvg_import.py        |    6 +-
 plug-ins/python/pydia-color.c           |   10 +-
 plug-ins/python/pydia-property.c        |    2 +
 plug-ins/svg/svg-import.c               |    1 +
 plug-ins/vdx/vdx-export.c               |    6 +-
 plug-ins/vdx/vdx-import.c               |    7 +-
 plug-ins/wpg/wpg.c                      |    2 +-
 plug-ins/xfig/xfig-common.c             |   16 +-
 plug-ins/xfig/xfig-import.c             |    4 +
 53 files changed, 639 insertions(+), 502 deletions(-)
---
diff --git a/app/color_area.c b/app/color_area.c
index 2e9f9dc..b842a7a 100644
--- a/app/color_area.c
+++ b/app/color_area.c
@@ -219,6 +219,7 @@ color_selection_ok (GtkWidget               *w,
 {
   GtkColorSelection *colorsel;
   GdkColor color;
+  guint alpha;
   Color col;
 
   colorsel=GTK_COLOR_SELECTION(cs->colorsel);
@@ -226,6 +227,9 @@ color_selection_ok (GtkWidget               *w,
   gtk_color_selection_get_current_color(colorsel,&color);
   GDK_COLOR_TO_DIA(color, col);
 
+  alpha = gtk_color_selection_get_current_alpha(colorsel);
+  col.alpha = alpha / 65535.0;
+
   if (edit_color == FOREGROUND) {
     attributes_set_foreground(&col);
   } else {
@@ -276,6 +280,7 @@ color_selection_changed (GtkWidget *w,
 {
   GtkColorSelection *colorsel;
   GdkColor color;
+  guint alpha;
   Color col;
 
   colorsel=GTK_COLOR_SELECTION(cs->colorsel);
@@ -283,6 +288,10 @@ color_selection_changed (GtkWidget *w,
   gtk_color_selection_get_current_color(colorsel,&color);
   GDK_COLOR_TO_DIA(color, col);
 
+  alpha = gtk_color_selection_get_current_alpha(colorsel);
+  printf ("col.alpha = %f, alpha = %u\n", col.alpha, alpha);
+  col.alpha = alpha / 65535.0;
+
   if (edit_color == FOREGROUND) {
     attributes_set_foreground(&col);
   } else {
@@ -317,6 +326,9 @@ color_area_edit (void)
 				     _("Select foreground color"):
 				     _("Select background color"));
     color_select_active = 1;
+    gtk_color_selection_set_has_opacity_control(
+        GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (window)->colorsel),
+        TRUE);
 
     gtk_color_selection_set_has_palette (
 	GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (window)->colorsel),
@@ -368,7 +380,10 @@ color_area_edit (void)
   gtk_color_selection_set_current_color(
 	GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (color_select)->colorsel),
 	&color);
-
+  printf ("col.alpha = %f\n", col.alpha);
+  gtk_color_selection_set_current_alpha(
+        GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (color_select)->colorsel),
+        (guint)(col.alpha * 65535.0));
 }
 
 static gint
diff --git a/app/connectionpoint_ops.c b/app/connectionpoint_ops.c
index a329bc0..09da0a8 100644
--- a/app/connectionpoint_ops.c
+++ b/app/connectionpoint_ops.c
@@ -23,7 +23,7 @@
 #include "object_ops.h"
 #include "color.h"
 
-static Color connectionpoint_color = { 0.4, 0.4, 1.0 };
+static Color connectionpoint_color = { 0.4, 0.4, 1.0, 1.0 };
 
 #define CP_SZ (CONNECTIONPOINT_SIZE/2)
 
@@ -42,7 +42,7 @@ connectionpoint_draw(ConnectionPoint *conpoint,
    * have snap-to-grid */
   if (conpoint->flags & CP_FLAG_ANYPLACE) {
     if (!ddisp->mainpoint_magnetism) {
-      static Color midpoint_color = { 1.0, 0.0, 0.0 };
+      static Color midpoint_color = { 1.0, 0.0, 0.0, 1.0 };
       
       ddisplay_transform_coords(ddisp, point->x, point->y, &x, &y);
          
diff --git a/app/handle_ops.c b/app/handle_ops.c
index ce9aa56..7918738 100644
--- a/app/handle_ops.c
+++ b/app/handle_ops.c
@@ -25,24 +25,24 @@
 
 static const Color handle_color[NUM_HANDLE_TYPES<<1] =
 {
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 0.0, 1.0, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 1.0, 0.6, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 0.0, 1.0, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 1.0, 0.6, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
   /* dim down the color if the handle is in a group of selected objects */
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 0.0, 0.7, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 0.7, 0.4, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 0.0, 0.7, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 0.7, 0.4, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
 };
 
 static const Color handle_color_connected[NUM_HANDLE_TYPES<<1] =
 {
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 1.0, 0.0, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 1.0, 0.4, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 1.0, 0.0, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 1.0, 0.4, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
   /* dim down the color if the handle is in a group of selected objects */
-  { 0.0, 0.0, 0.5}, /* HANDLE_NON_MOVABLE */
-  { 0.7, 0.0, 0.0}, /* HANDLE_MAJOR_CONTROL */
-  { 0.7, 0.3, 0.0}, /* HANDLE_MINOR_CONTROL */
+  { 0.0, 0.0, 0.5, 1.0 }, /* HANDLE_NON_MOVABLE */
+  { 0.7, 0.0, 0.0, 1.0 }, /* HANDLE_MAJOR_CONTROL */
+  { 0.7, 0.3, 0.0, 1.0 }, /* HANDLE_MINOR_CONTROL */
 };
 
 void
diff --git a/app/preferences.h b/app/preferences.h
index e6e27f8..4421c14 100644
--- a/app/preferences.h
+++ b/app/preferences.h
@@ -24,8 +24,8 @@
 #include "diagramdata.h"
 #include "lib/widgets.h"
 
-#define DEFAULT_GRID_COLOR { 0.85, .90, .90 }
-#define DEFAULT_PAGEBREAK_COLOR { 0.0, 0.0, 0.6 }
+#define DEFAULT_GRID_COLOR { 0.85, .90, .90, 1.0 }
+#define DEFAULT_PAGEBREAK_COLOR { 0.0, 0.0, 0.6, 1.0 }
 
 struct DiaPreferences {
   struct {
diff --git a/app/render_gdk.c b/app/render_gdk.c
index 50c7393..ddd7143 100644
--- a/app/render_gdk.c
+++ b/app/render_gdk.c
@@ -30,11 +30,11 @@
 
 
 /** Used for highlighting mainpoint connections. */
-static Color cp_main_color = { 1.0, 0.8, 0.0 };
+static Color cp_main_color = { 1.0, 0.8, 0.0, 1.0 };
 /** Used for highlighting normal connections. */
-static Color cp_color = { 1.0, 0.0, 0.0 };
+static Color cp_color = { 1.0, 0.0, 0.0, 1.0 };
 
-static Color text_edit_color = {1.0, 1.0, 0.0 };
+static Color text_edit_color = {1.0, 1.0, 0.0, 1.0 };
 
 
 static void clip_region_clear(DiaRenderer *renderer);
diff --git a/bindings/dia-properties.cpp b/bindings/dia-properties.cpp
index 605c8d0..12fbdf1 100644
--- a/bindings/dia-properties.cpp
+++ b/bindings/dia-properties.cpp
@@ -234,6 +234,7 @@ set_prop (::Property* p, const char* v)
             ((ColorProperty*)p)->color_data.red = color.red / 65535.0; 
             ((ColorProperty*)p)->color_data.green = color.green / 65535.0; 
             ((ColorProperty*)p)->color_data.blue = color.blue / 65535.0;
+            ((ColorProperty*)p)->color_data.alpha = 1.0;
         }
     }
     else if (strcmp (p->type, PROP_TYPE_STRING) == 0) {
@@ -370,10 +371,11 @@ dia::Properties::setitem (const char* s, const std::vector<double>& v)
     ::Property *p = object_prop_by_name (object, s);
     if (p) {
         bool apply = true;
-        if (strcmp (p->type, PROP_TYPE_COLOUR) == 0 && v.size() == 3) {
+        if (strcmp (p->type, PROP_TYPE_COLOUR) == 0 && v.size() == 4) {
             ((ColorProperty*)p)->color_data.red   = v[0]; 
             ((ColorProperty*)p)->color_data.green = v[1]; 
             ((ColorProperty*)p)->color_data.blue  = v[2];
+            ((ColorProperty*)p)->color_data.alpha = v[3];
 	}
 	else if (strcmp (p->type, PROP_TYPE_LINESTYLE) == 0 && v.size() == 2) {
 	    ((LinestyleProperty *)p)->style = (::LineStyle)(int)v[0];
diff --git a/bindings/dia.swig b/bindings/dia.swig
index f7a6501..66207f5 100644
--- a/bindings/dia.swig
+++ b/bindings/dia.swig
@@ -1,372 +1,373 @@
-%module dia
-%{
-#include "object.h"
-#include "diarenderer.h"
-#include "diagramdata.h"
-#include "filter.h"
-#include "plug-ins.h"
-#include "properties.h"
-
-// helper functions
-#ifdef SWIGPYTHON
-#include "dia-python-extra.h"
-#endif
-#include "dia-extra.h"
-
-// the wrapper headers
-#include "dia-properties.h"
-#include "dia-object.h"
-#include "dia-renderer.h"
-#include "dia-diagramdata.h"
-%}
-
-#define G_GNUC_CONST
-#define G_BEGIN_DECLS
-#define G_END_DECLS
-#define G_INLINE_FUNC
-// for SWIG these are the same types
-typedef char gchar;
-
-%ignore TYPES_H;
-%include "diatypes.h"
-
-// the renaming needs to be done before SWIG sees the declarations
-%rename(Rectangle) _Rectangle;
-// this should be merged with rectangle somehow
-%rename(IntRectangle) _IntRectangle;
-%rename(Point) _Point;
-%rename(BezPoint) _BezPoint;
-
-%ignore GEOMETRY_H;
-// and a bunch of other stuff not yet needed
-%ignore point_add;
-%ignore point_sub;
-%ignore point_dot;
-%ignore point_len;
-%ignore point_scale;
-%ignore point_rotate;
-%ignore point_normalize;
-%ignore point_get_perp;
-%ignore point_copy;
-%ignore point_add_scaled;
-%ignore point_convex;
-%ignore point_get_normed;
-%ignore point_copy_add_scaled;
-%ignore point_in_rectangle;
-%ignore rectangle_in_rectangle;
-%ignore rectangle_union;
-%ignore int_rectangle_union;
-%ignore rectangle_intersection;
-%ignore rectangle_intersects;
-%ignore rectangle_add_point;
-%ignore rectangle_equals;
-%ignore closest_to;
-%ignore distance_bez_seg_point;
-%ignore distance_point_point;
-%ignore distance_point_point_manhattan;
-%ignore distance_rectangle_point;
-%ignore distance_line_point;
-%ignore distance_polygon_point;
-%ignore distance_bez_line_point;
-%ignore distance_bez_shape_point;
-%ignore distance_ellipse_point;
-%ignore identity_matrix;
-%ignore mult_matrix;
-%ignore translate_matrix;
-%ignore rotate_matrix;
-%ignore transform_point;
-%ignore scale_matrix;
-%ignore xshear_matrix;
-%ignore yshear_matrix;
-%ignore dot2;
-%ignore line_coef;
-%ignore line_to_point;
-%ignore point_perp;
-%ignore fillet;
-%ignore point_cross;
-%ignore calculate_object_edge;
-%include "geometry.h"
-
-// again using the original header
-%nodefaultctor;        // Don't create default constructors
-%rename(ImportFilter) _DiaImportFilter;
-%rename(ExportFilter) _DiaExportFilter;
-%rename(CallbackFilter) _DiaCallbackFilter;
-%immutable; // the following are all read-only
-%include "filter.h"
-%clearnodefaultctor;   // Re-enable default constructors
-%mutable;
-
-%rename(Color) _Color;
-// redefinition - the original header 'color.h' is too ugly to parse
-struct _Color
-{
-   float red;
-   float green;
-   float blue;
-};
-
-#if 0 /* works for vc7.1, but not with vc6 and *not* for const char* ? 
-       * All the partial specialization needs to be avoided with vc6, no compiler support!
-       */
-%include "std_vector.i"
-using namespace std;
-namespace std {
-    %template(vectorString) vector<char*>;
-}
-#else
-#  ifdef SWIGPYTHON
-// after hours of trying starting with 'const std::vector<const char*>&' this one seems to work ...
-%typemap (out) std::vector<char*> {
-    int size = $1.size();
-    $result = PyList_New(size);
-    for (int i=0; i<size; i++)
-        PyList_SetItem($result,i,PyString_FromString ($1[i]));
-}
-#  endif
-#endif
-
-// hide the internal helper of all our wrapper clsses
-%ignore *::Self;
-
-%ignore dia::Property;
-%rename(Property) dia::IProperty;
-%include attribute.i
-%attribute(dia::IProperty, char*, type, get_type);
-%attribute(dia::IProperty, char*, name, get_name);
-%nodefaultctor;        // Don't create default constructors
-%include "dia-properties.h"
-%clearnodefaultctor;   // Re-enable default constructors
-
-// in general we can't handle any of our objects being NULL
-%include "constraints.i"
-%apply Pointer NONNULL { dia::IProperty * };
-%apply Pointer NONNULL { dia::Object * };
-%apply Pointer NONNULL { dia::Layer * };
-%apply Pointer NONNULL { dia::DiagramData * };
-
-// this is needed to make iteration via __getitem__ work, i.e. not returning None objects.
-// It tells SWIG to check every such pointer return and set/do the appropriate error/return.
-%typemap(ret) dia::Object*, dia::Handle*, dia::ConnectionPoint*, dia::Layer* {
-  if ($1 == NULL) {
-    PyErr_SetString (PyExc_IndexError, "not in list");
-    return NULL;
-  }
-}
-%typemap(ret) dia::IProperty*, dia::ObjectType* {
-  if ($1 == NULL) {
-    PyErr_SetString (PyExc_KeyError, "none such");
-    return NULL;
-  }
-}
-
-#ifdef SWIGPYTHON
-%extend dia::IProperty {
-   %immutable; 
-   PyObject* value;
-   %mutable;
-};
-%inline %{
-PyObject* dia_IProperty_value_get (dia::IProperty* self) {
-     int vi;
-     if (self->get (&vi)) return PyInt_FromLong(vi);
-     double vd;
-     if (self->get (&vd)) return PyFloat_FromDouble(vd);
-     const char* vcs;
-     if (self->get (&vcs)) return PyString_FromString(vcs);
-     char* vs; // not sure if this duplication const char* vs. char* is really needed
-     if (self->get (&vs)) return PyString_FromString(vs);
-     ::_Point vp;
-     if (self->get (&vp)) return SWIG_NewPointerObj(&vp, SWIGTYPE_p__Point, 0);
-     ::_Rectangle vr;
-     if (self->get (&vr)) return SWIG_NewPointerObj(&vr, SWIGTYPE_p__Rectangle, 0);
-     ::_Color vc;
-     if (self->get (&vc)) return SWIG_NewPointerObj(&vc, SWIGTYPE_p__Color, 0);
-     const std::vector<dia::IProperty*>* vecProp;
-     if (self->get (&vecProp)) {
-       const size_t n = vecProp->size();
-       PyObject* ret = PyTuple_New(n);
-       for (int i = 0; i < n; ++i)
-         PyTuple_SetItem(ret, i, SWIG_NewPointerObj((*vecProp)[i], SWIGTYPE_p_dia__IProperty, 0));
-       return ret;
-     }
-
-     // generic fallback - not of much use if one is interested in value
-     return SWIG_NewPointerObj(self, SWIGTYPE_p_dia__IProperty, 0);
-}
-%}
-#endif
-
-// must do this 'by hand' cause all the std::map stuff doesn't work with msvc6
-%extend dia::Properties {
-  dia::IProperty* __getitem__(const char* s) { return self->getitem(s); }
-
-  void __setitem__(const char* s, int v) { self->setitem(s, v); }
-  void __setitem__(const char* s, double v) { self->setitem(s, v); }
-  void __setitem__(const char* s, const char* v) { self->setitem(s, v); }
-#ifdef SWIGPYTHON
-  void __setitem__(const char* s, PyObject* v) {
-    std::vector<double> vecDouble;
-    std::vector<dia::IProperty*> vecProp;
-    if (DiaPythonExtra_ToVector (v, vecDouble))
-	self->setitem (s, vecDouble);
-    else if (DiaPythonExtra_ToVector (v, vecProp))
-	self->setitem (s, vecProp);
-    else {
-        PyObject* vs = PyObject_Str (v);
-        printf ("NOT assigning '%s' = %s\n", s, PyString_AsString (vs));
-    }
-  }
-#endif
-};
-
-%nodefaultctor;        // Don't create default constructors
-%include "dia-connections.h"
-%clearnodefaultctor;   // Re-enable default constructors
-// again by hand: provide a Python compatible sequence interface
-%extend dia::Connections {
-  int __len__ () { return self->len(); }
-  dia::ConnectionPoint* __getitem__ (int n) { return self->getitem(n); }
-};
-%extend dia::Handles {
-  int __len__ () { return self->len(); }
-  dia::Handle* __getitem__ (int n) { return self->getitem(n); }
-};
-
-%attribute(dia::Handle, dia::ConnectionPoint*, connected_to, get_connected_to);
-%attribute(dia::ConnectionPoint, dia::Object*, object, get_object);
-%extend dia::Objects {
-  int __len__ () { return self->len(); }
-  dia::Object* __getitem__ (int n) { return self->getitem(n); }
-};
-
-%nodefaultctor;        // Don't create default constructors
-%ignore dia::Object::bbox;
-%include "dia-object.h"
-%clearnodefaultctor;   // Re-enable default constructors
-#ifdef SWIGPYTHON
-// there may be a target language independent way to do this but not w/o understanding typemaps ;)
-%extend dia::ObjectType {
-  // not only creates the object but also two handles to be returned
-  PyObject* create (double x, double y) {
-    PyObject* ret = PyTuple_New(3);
-    dia::Handle *h1, *h2;
-    dia::Object *o = self->create (x,y, &h1, &h2);
-    PyTuple_SetItem(ret,0,SWIG_NewPointerObj(o, SWIGTYPE_p_dia__Object, 0));
-    PyTuple_SetItem(ret,1,SWIG_NewPointerObj(h1, SWIGTYPE_p_dia__Handle, 0));
-    PyTuple_SetItem(ret,2,SWIG_NewPointerObj(h2, SWIGTYPE_p_dia__Handle, 0));
-    return ret;
-  }
-};
-%include attribute.i
-%attribute(dia::Object, _Rectangle, bounding_box, bbox);
-%extend dia::Object {
-  // convenience/compatibility taking the position as tuple
-  PyObject* move_handle (dia::Handle* h, PyObject* pos, int reason, int modifiers)
-  {
-    double x = PyFloat_AsDouble(PyTuple_GetItem (pos, 0));
-    double y = PyFloat_AsDouble(PyTuple_GetItem (pos, 1));
-    self->move_handle (h, x, y, (HandleMoveReason)reason, (ModifierKeys)modifiers);
-    Py_INCREF(Py_None);
-    return Py_None;
-  }
-};
-#endif
-
-%nodefaultctor;        // Don't create default constructors
-%include "dia-diagramdata.h"
-%clearnodefaultctor;   // Re-enable default constructors
-
-#if 0 // again no partial templates with msvc6
-%include "std_vector.i"
-%template(Layers) std::vector<const dia::Layer*>;
-#else
-%extend dia::Layers {
-  int __len__ () { return self->len(); }
-  dia::Layer* __getitem__ (int n) { return self->getitem(n); }
-};
-#endif
-
-%nodefaultctor;        // Don't create default constructors
-%include "dia-renderer.h"
-%clearnodefaultctor;   // Re-enable default constructors
-
-// afaik SWIG does not support cross language callbacks; so let's build one
-// NOTE: although renamed above we need to use the old name here
-%extend _DiaExportFilter {
-  // don't use 'export' as this produces nothing w/o warning
+%module dia
+%{
+#include "object.h"
+#include "diarenderer.h"
+#include "diagramdata.h"
+#include "filter.h"
+#include "plug-ins.h"
+#include "properties.h"
+
+// helper functions
+#ifdef SWIGPYTHON
+#include "dia-python-extra.h"
+#endif
+#include "dia-extra.h"
+
+// the wrapper headers
+#include "dia-properties.h"
+#include "dia-object.h"
+#include "dia-renderer.h"
+#include "dia-diagramdata.h"
+%}
+
+#define G_GNUC_CONST
+#define G_BEGIN_DECLS
+#define G_END_DECLS
+#define G_INLINE_FUNC
+// for SWIG these are the same types
+typedef char gchar;
+
+%ignore TYPES_H;
+%include "diatypes.h"
+
+// the renaming needs to be done before SWIG sees the declarations
+%rename(Rectangle) _Rectangle;
+// this should be merged with rectangle somehow
+%rename(IntRectangle) _IntRectangle;
+%rename(Point) _Point;
+%rename(BezPoint) _BezPoint;
+
+%ignore GEOMETRY_H;
+// and a bunch of other stuff not yet needed
+%ignore point_add;
+%ignore point_sub;
+%ignore point_dot;
+%ignore point_len;
+%ignore point_scale;
+%ignore point_rotate;
+%ignore point_normalize;
+%ignore point_get_perp;
+%ignore point_copy;
+%ignore point_add_scaled;
+%ignore point_convex;
+%ignore point_get_normed;
+%ignore point_copy_add_scaled;
+%ignore point_in_rectangle;
+%ignore rectangle_in_rectangle;
+%ignore rectangle_union;
+%ignore int_rectangle_union;
+%ignore rectangle_intersection;
+%ignore rectangle_intersects;
+%ignore rectangle_add_point;
+%ignore rectangle_equals;
+%ignore closest_to;
+%ignore distance_bez_seg_point;
+%ignore distance_point_point;
+%ignore distance_point_point_manhattan;
+%ignore distance_rectangle_point;
+%ignore distance_line_point;
+%ignore distance_polygon_point;
+%ignore distance_bez_line_point;
+%ignore distance_bez_shape_point;
+%ignore distance_ellipse_point;
+%ignore identity_matrix;
+%ignore mult_matrix;
+%ignore translate_matrix;
+%ignore rotate_matrix;
+%ignore transform_point;
+%ignore scale_matrix;
+%ignore xshear_matrix;
+%ignore yshear_matrix;
+%ignore dot2;
+%ignore line_coef;
+%ignore line_to_point;
+%ignore point_perp;
+%ignore fillet;
+%ignore point_cross;
+%ignore calculate_object_edge;
+%include "geometry.h"
+
+// again using the original header
+%nodefaultctor;        // Don't create default constructors
+%rename(ImportFilter) _DiaImportFilter;
+%rename(ExportFilter) _DiaExportFilter;
+%rename(CallbackFilter) _DiaCallbackFilter;
+%immutable; // the following are all read-only
+%include "filter.h"
+%clearnodefaultctor;   // Re-enable default constructors
+%mutable;
+
+%rename(Color) _Color;
+// redefinition - the original header 'color.h' is too ugly to parse
+struct _Color
+{
+   float red;
+   float green;
+   float blue;
+   float alpha;
+};
+
+#if 0 /* works for vc7.1, but not with vc6 and *not* for const char* ? 
+       * All the partial specialization needs to be avoided with vc6, no compiler support!
+       */
+%include "std_vector.i"
+using namespace std;
+namespace std {
+    %template(vectorString) vector<char*>;
+}
+#else
+#  ifdef SWIGPYTHON
+// after hours of trying starting with 'const std::vector<const char*>&' this one seems to work ...
+%typemap (out) std::vector<char*> {
+    int size = $1.size();
+    $result = PyList_New(size);
+    for (int i=0; i<size; i++)
+        PyList_SetItem($result,i,PyString_FromString ($1[i]));
+}
+#  endif
+#endif
+
+// hide the internal helper of all our wrapper clsses
+%ignore *::Self;
+
+%ignore dia::Property;
+%rename(Property) dia::IProperty;
+%include attribute.i
+%attribute(dia::IProperty, char*, type, get_type);
+%attribute(dia::IProperty, char*, name, get_name);
+%nodefaultctor;        // Don't create default constructors
+%include "dia-properties.h"
+%clearnodefaultctor;   // Re-enable default constructors
+
+// in general we can't handle any of our objects being NULL
+%include "constraints.i"
+%apply Pointer NONNULL { dia::IProperty * };
+%apply Pointer NONNULL { dia::Object * };
+%apply Pointer NONNULL { dia::Layer * };
+%apply Pointer NONNULL { dia::DiagramData * };
+
+// this is needed to make iteration via __getitem__ work, i.e. not returning None objects.
+// It tells SWIG to check every such pointer return and set/do the appropriate error/return.
+%typemap(ret) dia::Object*, dia::Handle*, dia::ConnectionPoint*, dia::Layer* {
+  if ($1 == NULL) {
+    PyErr_SetString (PyExc_IndexError, "not in list");
+    return NULL;
+  }
+}
+%typemap(ret) dia::IProperty*, dia::ObjectType* {
+  if ($1 == NULL) {
+    PyErr_SetString (PyExc_KeyError, "none such");
+    return NULL;
+  }
+}
+
+#ifdef SWIGPYTHON
+%extend dia::IProperty {
+   %immutable; 
+   PyObject* value;
+   %mutable;
+};
+%inline %{
+PyObject* dia_IProperty_value_get (dia::IProperty* self) {
+     int vi;
+     if (self->get (&vi)) return PyInt_FromLong(vi);
+     double vd;
+     if (self->get (&vd)) return PyFloat_FromDouble(vd);
+     const char* vcs;
+     if (self->get (&vcs)) return PyString_FromString(vcs);
+     char* vs; // not sure if this duplication const char* vs. char* is really needed
+     if (self->get (&vs)) return PyString_FromString(vs);
+     ::_Point vp;
+     if (self->get (&vp)) return SWIG_NewPointerObj(&vp, SWIGTYPE_p__Point, 0);
+     ::_Rectangle vr;
+     if (self->get (&vr)) return SWIG_NewPointerObj(&vr, SWIGTYPE_p__Rectangle, 0);
+     ::_Color vc;
+     if (self->get (&vc)) return SWIG_NewPointerObj(&vc, SWIGTYPE_p__Color, 0);
+     const std::vector<dia::IProperty*>* vecProp;
+     if (self->get (&vecProp)) {
+       const size_t n = vecProp->size();
+       PyObject* ret = PyTuple_New(n);
+       for (int i = 0; i < n; ++i)
+         PyTuple_SetItem(ret, i, SWIG_NewPointerObj((*vecProp)[i], SWIGTYPE_p_dia__IProperty, 0));
+       return ret;
+     }
+
+     // generic fallback - not of much use if one is interested in value
+     return SWIG_NewPointerObj(self, SWIGTYPE_p_dia__IProperty, 0);
+}
+%}
+#endif
+
+// must do this 'by hand' cause all the std::map stuff doesn't work with msvc6
+%extend dia::Properties {
+  dia::IProperty* __getitem__(const char* s) { return self->getitem(s); }
+
+  void __setitem__(const char* s, int v) { self->setitem(s, v); }
+  void __setitem__(const char* s, double v) { self->setitem(s, v); }
+  void __setitem__(const char* s, const char* v) { self->setitem(s, v); }
+#ifdef SWIGPYTHON
+  void __setitem__(const char* s, PyObject* v) {
+    std::vector<double> vecDouble;
+    std::vector<dia::IProperty*> vecProp;
+    if (DiaPythonExtra_ToVector (v, vecDouble))
+	self->setitem (s, vecDouble);
+    else if (DiaPythonExtra_ToVector (v, vecProp))
+	self->setitem (s, vecProp);
+    else {
+        PyObject* vs = PyObject_Str (v);
+        printf ("NOT assigning '%s' = %s\n", s, PyString_AsString (vs));
+    }
+  }
+#endif
+};
+
+%nodefaultctor;        // Don't create default constructors
+%include "dia-connections.h"
+%clearnodefaultctor;   // Re-enable default constructors
+// again by hand: provide a Python compatible sequence interface
+%extend dia::Connections {
+  int __len__ () { return self->len(); }
+  dia::ConnectionPoint* __getitem__ (int n) { return self->getitem(n); }
+};
+%extend dia::Handles {
+  int __len__ () { return self->len(); }
+  dia::Handle* __getitem__ (int n) { return self->getitem(n); }
+};
+
+%attribute(dia::Handle, dia::ConnectionPoint*, connected_to, get_connected_to);
+%attribute(dia::ConnectionPoint, dia::Object*, object, get_object);
+%extend dia::Objects {
+  int __len__ () { return self->len(); }
+  dia::Object* __getitem__ (int n) { return self->getitem(n); }
+};
+
+%nodefaultctor;        // Don't create default constructors
+%ignore dia::Object::bbox;
+%include "dia-object.h"
+%clearnodefaultctor;   // Re-enable default constructors
+#ifdef SWIGPYTHON
+// there may be a target language independent way to do this but not w/o understanding typemaps ;)
+%extend dia::ObjectType {
+  // not only creates the object but also two handles to be returned
+  PyObject* create (double x, double y) {
+    PyObject* ret = PyTuple_New(3);
+    dia::Handle *h1, *h2;
+    dia::Object *o = self->create (x,y, &h1, &h2);
+    PyTuple_SetItem(ret,0,SWIG_NewPointerObj(o, SWIGTYPE_p_dia__Object, 0));
+    PyTuple_SetItem(ret,1,SWIG_NewPointerObj(h1, SWIGTYPE_p_dia__Handle, 0));
+    PyTuple_SetItem(ret,2,SWIG_NewPointerObj(h2, SWIGTYPE_p_dia__Handle, 0));
+    return ret;
+  }
+};
+%include attribute.i
+%attribute(dia::Object, _Rectangle, bounding_box, bbox);
+%extend dia::Object {
+  // convenience/compatibility taking the position as tuple
+  PyObject* move_handle (dia::Handle* h, PyObject* pos, int reason, int modifiers)
+  {
+    double x = PyFloat_AsDouble(PyTuple_GetItem (pos, 0));
+    double y = PyFloat_AsDouble(PyTuple_GetItem (pos, 1));
+    self->move_handle (h, x, y, (HandleMoveReason)reason, (ModifierKeys)modifiers);
+    Py_INCREF(Py_None);
+    return Py_None;
+  }
+};
+#endif
+
+%nodefaultctor;        // Don't create default constructors
+%include "dia-diagramdata.h"
+%clearnodefaultctor;   // Re-enable default constructors
+
+#if 0 // again no partial templates with msvc6
+%include "std_vector.i"
+%template(Layers) std::vector<const dia::Layer*>;
+#else
+%extend dia::Layers {
+  int __len__ () { return self->len(); }
+  dia::Layer* __getitem__ (int n) { return self->getitem(n); }
+};
+#endif
+
+%nodefaultctor;        // Don't create default constructors
+%include "dia-renderer.h"
+%clearnodefaultctor;   // Re-enable default constructors
+
+// afaik SWIG does not support cross language callbacks; so let's build one
+// NOTE: although renamed above we need to use the old name here
+%extend _DiaExportFilter {
+  // don't use 'export' as this produces nothing w/o warning
   void do_export (dia::DiagramData *dia, const gchar *filename) {
-    if (dia)
+    if (dia)
       self->export_func (dia->Self(), filename, filename, self->user_data);
     else
-      g_warning ( "%s no data", G_STRFUNC);
-  }
-};
-
-%include "dia-extra.h"
-
-%ignore _ot_item;
-#ifdef SWIGPYTHON
-%inline %{
-// compatibility functions, just to leave the original plug-ins unchanged
-void register_import (const char* name, const char* ext, PyObject* user)
-{
-    printf ("dia.register_import ('%s', '%s', ...) faked.\n", name, ext);
-}
-void register_callback (const char* desc, const char* menu, PyObject* user)
-{
-    printf ("dia.register_import ('%s', '%s', ...) faked.\n", desc, menu);
-}
-void register_action (const char* desc, const char* action, const char* menu, PyObject* user)
-{
-    printf ("dia.register_action ('%s', <%s>'%s', ...) faked.\n", desc, action, menu);
-}
-//! callback to be applied on every object in the map
-static void
-_ot_item (gpointer key,
-          gpointer value,
-          gpointer user_data)
-{
-    gchar *name = (gchar *)key;
-    DiaObjectType *type = (DiaObjectType *)value;
-    PyObject *dict = (PyObject *)user_data;
-    PyObject *k, *v;
-
-    k = PyString_FromString(name);
-    v = SWIG_NewPointerObj(type, SWIGTYPE_p_dia__ObjectType, 0);
-    if (k && v)
-        PyDict_SetItem(dict, k, v);
-    Py_XDECREF(k);
-    Py_XDECREF(v);
-}
-PyObject* registered_types () 
-{
-    PyObject *dict = PyDict_New();
-    
-    object_registry_foreach(_ot_item, dict);
-
-    return dict;
-}
-%}
-#endif
-
-// as long as we are not dependending on app/* - which we dont want! - we need to 
-// fake Display to some extent to make old pydia plug-ins work
-%pythoncode %{
-class Display :
-    def add_update_all (self) :
-        pass
-class Diagram :
-    def __init__ (self) :
-        self.data = DiagramData ()
-    def display (self) :
-	return Display ()
-    def update_extents (self) :
-        self.data.update_extents ()
-    def flush (self) :
-        pass
-def new (s) :
-    return Diagram()
-def active_display () :
-    return None
-%}
+      g_warning ( "%s no data", G_STRFUNC);
+  }
+};
+
+%include "dia-extra.h"
+
+%ignore _ot_item;
+#ifdef SWIGPYTHON
+%inline %{
+// compatibility functions, just to leave the original plug-ins unchanged
+void register_import (const char* name, const char* ext, PyObject* user)
+{
+    printf ("dia.register_import ('%s', '%s', ...) faked.\n", name, ext);
+}
+void register_callback (const char* desc, const char* menu, PyObject* user)
+{
+    printf ("dia.register_import ('%s', '%s', ...) faked.\n", desc, menu);
+}
+void register_action (const char* desc, const char* action, const char* menu, PyObject* user)
+{
+    printf ("dia.register_action ('%s', <%s>'%s', ...) faked.\n", desc, action, menu);
+}
+//! callback to be applied on every object in the map
+static void
+_ot_item (gpointer key,
+          gpointer value,
+          gpointer user_data)
+{
+    gchar *name = (gchar *)key;
+    DiaObjectType *type = (DiaObjectType *)value;
+    PyObject *dict = (PyObject *)user_data;
+    PyObject *k, *v;
+
+    k = PyString_FromString(name);
+    v = SWIG_NewPointerObj(type, SWIGTYPE_p_dia__ObjectType, 0);
+    if (k && v)
+        PyDict_SetItem(dict, k, v);
+    Py_XDECREF(k);
+    Py_XDECREF(v);
+}
+PyObject* registered_types () 
+{
+    PyObject *dict = PyDict_New();
+    
+    object_registry_foreach(_ot_item, dict);
+
+    return dict;
+}
+%}
+#endif
+
+// as long as we are not dependending on app/* - which we dont want! - we need to 
+// fake Display to some extent to make old pydia plug-ins work
+%pythoncode %{
+class Display :
+    def add_update_all (self) :
+        pass
+class Diagram :
+    def __init__ (self) :
+        self.data = DiagramData ()
+    def display (self) :
+	return Display ()
+    def update_extents (self) :
+        self.data.update_extents ()
+    def flush (self) :
+        pass
+def new (s) :
+    return Diagram()
+def active_display () :
+    return None
+%}
diff --git a/lib/arrows.c b/lib/arrows.c
index b0dc3a7..ac07159 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -2018,7 +2018,7 @@ arrow_draw(DiaRenderer *renderer, ArrowType type,
     Arrow arrow = {type, length, width};
     Rectangle bbox = {0, };
     Point p1, p2;
-    Color col = {1.0, 0.0, 1.0};
+    Color col = { 1.0, 0.0, 1.0, 1.0 };
     
     arrow_bbox (&arrow, linewidth, to, from, &bbox);
 
diff --git a/lib/attributes.c b/lib/attributes.c
index 72d37f7..7a44ae3 100644
--- a/lib/attributes.c
+++ b/lib/attributes.c
@@ -21,8 +21,8 @@
 #include "intl.h"
 #include "persistence.h"
 
-static Color attributes_foreground = { 0.0f, 0.0f, 0.0f };
-static Color attributes_background = { 1.0f, 1.0f, 1.0f };
+static Color attributes_foreground = { 0.0f, 0.0f, 0.0f, 1.0f };
+static Color attributes_background = { 1.0f, 1.0f, 1.0f, 1.0f };
 
 static real attributes_default_linewidth = 0.1;
 
diff --git a/lib/bezier_conn.c b/lib/bezier_conn.c
index ea38be9..d782031 100644
--- a/lib/bezier_conn.c
+++ b/lib/bezier_conn.c
@@ -743,7 +743,7 @@ bezierconn_simple_draw(BezierConn *bez, DiaRenderer *renderer, real width)
 void
 bezierconn_draw_control_lines(BezierConn *bez, DiaRenderer *renderer)
 {
-  Color line_colour = {0.0, 0.0, 0.6};
+  Color line_colour = { 0.0, 0.0, 0.6, 1.0 };
   Point startpoint;
   int i;
   
diff --git a/lib/beziershape.c b/lib/beziershape.c
index 736d352..981343e 100644
--- a/lib/beziershape.c
+++ b/lib/beziershape.c
@@ -754,7 +754,7 @@ beziershape_simple_draw(BezierShape *bezier, DiaRenderer *renderer, real width)
 void
 beziershape_draw_control_lines(BezierShape *bez, DiaRenderer *renderer)
 {
-  Color line_colour = {0.0, 0.0, 0.6};
+  Color line_colour = { 0.0, 0.0, 0.6, 1.0 };
   Point startpoint;
   int i;
   
diff --git a/lib/color.c b/lib/color.c
index 838a219..ac26af8 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -29,8 +29,8 @@
 static GdkColormap *colormap = NULL;
 
 #ifndef G_OS_WIN32 
-Color color_black = { 0.0f, 0.0f, 0.0f };
-Color color_white = { 1.0f, 1.0f, 1.0f };
+Color color_black = { 0.0f, 0.0f, 0.0f, 1.0f };
+Color color_white = { 1.0f, 1.0f, 1.0f, 1.0f };
 #endif
 
 GdkColor color_gdk_black, color_gdk_white;
@@ -54,18 +54,38 @@ color_init(void)
 }
 
 /** Allocate a new color object wtih the given values.
+ * Initializes alpha component to 1.0
  * @param r Red component (0 <= r <= 1)
  * @param g Green component (0 <= g <= 1)
  * @param b Blue component (0 <= b <= 1)
  * @returns A newly allocated color object.  This should be freed after use.
  */
 Color *
-color_new_rgb(float r, float g, float b) 
+color_new_rgb(float r, float g, float b)
 {
   Color *col = g_new(Color, 1);
   col->red = r;
   col->green = g;
   col->blue = b;
+  col->alpha = 1.0;
+  return col;
+}
+
+/** Allocate a new color object wtih the given values.
+ * @param r Red component (0 <= r <= 1)
+ * @param g Green component (0 <= g <= 1)
+ * @param b Blue component (0 <= b <= 1)
+ * @param alpha Alpha component (0 <= alpha <= 1)
+ * @returns A newly allocated color object.  This should be freed after use.
+ */
+Color *
+color_new_rgba(float r, float g, float b, float alpha)
+{
+  Color *col = g_new(Color, 1);
+  col->red = r;
+  col->green = g;
+  col->blue = b;
+  col->alpha = alpha;
   return col;
 }
 
@@ -98,5 +118,6 @@ color_equals(Color *color1, Color *color2)
 {
   return (color1->red == color2->red) &&
     (color1->green == color2->green) &&
-    (color1->blue == color2->blue);
+    (color1->blue == color2->blue) &&
+    (color1->alpha == color2->alpha);
 }
diff --git a/lib/color.h b/lib/color.h
index ff3f432..c0a50f9 100644
--- a/lib/color.h
+++ b/lib/color.h
@@ -29,16 +29,18 @@ struct _Color {
   float red;
   float green;
   float blue;
+  float alpha;
 };
 
 void color_init(void);
 Color *color_new_rgb(float r, float g, float b);
+Color *color_new_rgba(float r, float g, float b, float alpha);
 void color_convert(Color *color, GdkColor *gdkcolor);
 gboolean color_equals(Color *color1, Color *color2);
 
 #ifdef G_OS_WIN32
-static Color color_black = { 0.0f, 0.0f, 0.0f };
-static Color color_white = { 1.0f, 1.0f, 1.0f };
+static Color color_black = { 0.0f, 0.0f, 0.0f, 1.0f };
+static Color color_white = { 1.0f, 1.0f, 1.0f, 1.0f };
 #else
 DIAVAR Color color_black, color_white;
 #endif
@@ -52,6 +54,7 @@ DIAVAR GdkColor color_gdk_black, color_gdk_white;
 #define GDK_COLOR_TO_DIA(from, to) \
 (to).red = (from).red/65535.0; \
 (to).green = (from).green/65535.0; \
-(to).blue = (from).blue/65535.0;
+(to).blue = (from).blue/65535.0; \
+(to).alpha = 1.0;
 
 #endif /* COLOR_H */
diff --git a/lib/dia_svg.c b/lib/dia_svg.c
index 96c95d5..fe8c899 100644
--- a/lib/dia_svg.c
+++ b/lib/dia_svg.c
@@ -101,7 +101,14 @@ _parse_color(gint32 *color, const char *str)
   else if (0 == strncmp(str, "rgb(", 4)) {
     int r = 0, g = 0, b = 0;
     if (3 == sscanf (str+4, "%d,%d,%d", &r, &g, &b))
-      *color = ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF);
+      /* Set alpha to 1.0 */
+      *color = ((0xFF<<24) & 0xFF000000) | ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF);
+    else
+      return FALSE;
+  } else if (0 == strncmp(str, "rgba(", 5)) {
+    int r = 0, g = 0, b = 0, a = 0;
+    if (4 == sscanf (str+4, "%d,%d,%d,%d", &r, &g, &b, &a))
+      *color = ((a<<24) & 0xFF000000) | ((r<<16) & 0xFF0000) | ((g<<8) & 0xFF00) | (b & 0xFF);
     else
       return FALSE;
   } else {
@@ -111,7 +118,7 @@ _parse_color(gint32 *color, const char *str)
 
     if (!se) {
       if (pango_color_parse (&pc, str))
-	*color = ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
+	*color = ((0xFF<<24) & 0xFF000000) | ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
       else
 	return FALSE;
     } else {
@@ -119,7 +126,7 @@ _parse_color(gint32 *color, const char *str)
       gboolean ret = pango_color_parse (&pc, str);
 
       if (ret)
-	*color = ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
+	*color = ((0xFF<<24) & 0xFF000000) | ((pc.red >> 8) << 16) | ((pc.green >> 8) << 8) | (pc.blue >> 8);
       g_free (sz);
       return ret;
     }
diff --git a/lib/dia_xml.c b/lib/dia_xml.c
index 97dd3ad..4408bb0 100644
--- a/lib/dia_xml.c
+++ b/lib/dia_xml.c
@@ -555,7 +555,7 @@ void
 data_color(DataNode data, Color *col)
 {
   xmlChar *val;
-  int r=0, g=0, b=0;
+  int r=0, g=0, b=0, a=0;
   
   if (data_type(data)!=DATATYPE_COLOR) {
     message_error("Taking color value of non-color node.");
@@ -571,6 +571,11 @@ data_color(DataNode data, Color *col)
     r = hex_digit(val[1])*16 + hex_digit(val[2]);
     g = hex_digit(val[3])*16 + hex_digit(val[4]);
     b = hex_digit(val[5])*16 + hex_digit(val[6]);
+    if (xmlStrlen(val) >= 9) {
+      a = hex_digit(val[7])*16 + hex_digit(val[8]);
+    } else {
+      a = 0xff;
+    }
   }
 
   if (val) xmlFree(val);
@@ -578,6 +583,7 @@ data_color(DataNode data, Color *col)
   col->red = (float)(r/255.0);
   col->green = (float)(g/255.0);
   col->blue = (float)(b/255.0);
+  col->alpha = (float)(a/255.0);
 }
 
 /** Return the value of a point-type data node.
@@ -1013,14 +1019,15 @@ convert_to_hex(float x, char *str)
 void
 data_add_color(AttributeNode attr, const Color *col)
 {
-  char buffer[1+6+1];
+  char buffer[1+8+1];
   DataNode data_node;
 
   buffer[0] = '#';
   convert_to_hex(col->red, &buffer[1]);
   convert_to_hex(col->green, &buffer[3]);
   convert_to_hex(col->blue, &buffer[5]);
-  buffer[7] = 0;
+  convert_to_hex(col->alpha, &buffer[7]);
+  buffer[9] = 0;
 
   data_node = xmlNewChild(attr, NULL, (const xmlChar *)"color", NULL);
   xmlSetProp(data_node, (const xmlChar *)"val", (xmlChar *)buffer);
diff --git a/lib/diasvgrenderer.c b/lib/diasvgrenderer.c
index 40b3e7f..5cac7b1 100644
--- a/lib/diasvgrenderer.c
+++ b/lib/diasvgrenderer.c
@@ -226,7 +226,7 @@ get_draw_style(DiaSvgRenderer *renderer,
   g_string_truncate(str, 0);
 
   /* TODO(CHECK): the shape-export didn't have 'fill: none' here */
-  g_string_printf(str, "fill: none; fill-opacity:0; stroke-width: %s", dia_svg_dtostr(linewidth_buf, renderer->linewidth) );
+  g_string_printf(str, "fill: none; fill-opacity: %f; stroke-width: %s", colour->alpha, dia_svg_dtostr(linewidth_buf, renderer->linewidth) );
   if (strcmp(renderer->linecap, "butt"))
     g_string_append_printf(str, "; stroke-linecap: %s", renderer->linecap);
   if (strcmp(renderer->linejoin, "miter"))
@@ -251,9 +251,9 @@ get_fill_style(DiaSvgRenderer *renderer,
 
   if (!str) str = g_string_new(NULL);
 
-  g_string_printf(str, "fill: #%02x%02x%02x",
+  g_string_printf(str, "fill: #%02x%02x%02x; fill-opacity: %f",
 		   (int)ceil(255*colour->red), (int)ceil(255*colour->green),
-		   (int)ceil(255*colour->blue));
+		   (int)ceil(255*colour->blue), colour->alpha);
 
   return str->str;
 }
diff --git a/lib/layer.c b/lib/layer.c
index de30a8b..cd44b0e 100644
--- a/lib/layer.c
+++ b/lib/layer.c
@@ -83,6 +83,7 @@ layer_render(Layer *layer, DiaRenderer *renderer, Rectangle *update,
 	col.red = 1.0;
 	col.green = 0.0;
 	col.blue = 1.0;
+	col.alpha = 1.0;
 
         DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer,0.01);
 	DIA_RENDERER_GET_CLASS(renderer)->draw_rect(renderer, &p1, &p2, &col);
diff --git a/lib/libdia.def b/lib/libdia.def
index e417c8b..c590880 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -85,6 +85,7 @@ EXPORTS
  color_equals
  color_init
  color_new_rgb
+ color_new_rgba
 
  composite_add_attribute
  composite_find_attribute
diff --git a/lib/prop_attr.c b/lib/prop_attr.c
index 14e91ac..d5137d7 100644
--- a/lib/prop_attr.c
+++ b/lib/prop_attr.c
@@ -277,6 +277,7 @@ colorprop_new(const PropDescription *pdesc, PropDescToPropPredicate reason)
   prop->color_data.red = 0.0;
   prop->color_data.green = 0.0;
   prop->color_data.blue = 1.0;
+  prop->color_data.alpha = 1.0;
   return prop;
 }
 
diff --git a/lib/widgets.c b/lib/widgets.c
index 5563d2f..e667e58 100644
--- a/lib/widgets.c
+++ b/lib/widgets.c
@@ -1022,21 +1022,26 @@ static GtkWidget *
 dia_color_selector_create_string_item(DiaDynamicMenu *ddm, gchar *string)
 {
   GtkWidget *item = gtk_menu_item_new_with_label(string);
-  gint r, g, b;
-  sscanf(string, "#%2x%2x%2x", &r, &g, &b);
+  gint r, g, b, a;
+  gchar *markup;
   
+  sscanf(string, "#%2x%2x%2x%2x", &r, &g, &b, &a);
+
+  markup = g_strdup_printf("#%02X%02X%02X", r, g, b);
+
   /* See http://web.umr.edu/~rhall/commentary/color_readability.htm for
    * explanation of this formula */
   if (r*299+g*587+b*114 > 500 * 256) {
-    gchar *label = g_strdup_printf("<span foreground=\"black\" background=\"%s\">%s</span>", string, string);
+    gchar *label = g_strdup_printf("<span foreground=\"black\" background=\"%s\">%s</span>", markup, string);
     gtk_label_set_markup(GTK_LABEL(gtk_bin_get_child(GTK_BIN(item))), label);
     g_free(label);
   } else {
-    gchar *label = g_strdup_printf("<span foreground=\"white\" background=\"%s\">%s</span>", string, string);
+    gchar *label = g_strdup_printf("<span foreground=\"white\" background=\"%s\">%s</span>", markup, string);
     gtk_label_set_markup(GTK_LABEL(gtk_bin_get_child(GTK_BIN(item))), label);
     g_free(label);
   }
   
+  g_free(markup);
   return item;
 }
 
@@ -1046,6 +1051,7 @@ dia_color_selector_more_ok(GtkWidget *ok, gpointer userdata)
   DiaDynamicMenu *ddm = g_object_get_data(G_OBJECT(userdata), "ddm");
   GtkWidget *colorsel = GTK_WIDGET(userdata);
   GdkColor gcol;
+  guint galpha;
   gchar *entry;
 
   gtk_color_selection_get_current_color(
@@ -1053,7 +1059,11 @@ dia_color_selector_more_ok(GtkWidget *ok, gpointer userdata)
 	    GTK_COLOR_SELECTION_DIALOG(colorsel)->colorsel),
 	&gcol);
 
-  entry = g_strdup_printf("#%02X%02X%02X", gcol.red/256, gcol.green/256, gcol.blue/256);
+  galpha = gtk_color_selection_get_current_alpha(
+        GTK_COLOR_SELECTION(
+            GTK_COLOR_SELECTION_DIALOG(colorsel)->colorsel));
+
+  entry = g_strdup_printf("#%02X%02X%02X%02X", gcol.red/256, gcol.green/256, gcol.blue/256, galpha/256);
   dia_dynamic_menu_select_entry(ddm, entry);
   g_free(entry);
 
@@ -1069,6 +1079,9 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
   GString *palette = g_string_new ("");
 
   gchar *old_color = dia_dynamic_menu_get_entry(ddm);
+
+  gtk_color_selection_set_has_opacity_control(colorsel, TRUE);
+
   /* Force history to the old place */
   dia_dynamic_menu_select_entry(ddm, old_color);
 
@@ -1081,6 +1094,7 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
          tmplist != NULL || advance; 
          tmplist = g_list_next(tmplist)) {
       const gchar* spec;
+      guint r, g, b, a, old_a;
       GdkColor color;
 
       /* handle both lists */
@@ -1090,8 +1104,20 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
         if (!tmplist)
           break;
       }
-      spec = (gchar *)tmplist->data;
 
+      if (sscanf((gchar *)tmplist->data,"#%02X%02X%02X%02X", &r, &g, &b, &a) != 4) {
+        /* We don't have alpha, default to 1.0 */
+        a = 65535;
+      } else {
+        a = (guint)((((float)a) / 255.0) * 65535.0);
+      }
+      if (sscanf(old_color,"#%02X%02X%02X%02X", &r, &g, &b, &old_a) != 4) {
+        /* We don't have alpha, default to 1.0 */
+        old_a = 65535;
+      } else {
+        old_a = (guint)((((float)old_a) / 255.0) * 65535.0);
+      }
+      spec = g_strndup((gchar *)tmplist->data, 7);
       gdk_color_parse (spec, &color);
 #if 0
       /* the easy way if the Gtk Team would decide to make it public */
@@ -1100,11 +1126,14 @@ dia_color_selector_more_callback(GtkWidget *widget, gpointer userdata)
       g_string_append (palette, spec);
       g_string_append (palette, ":");
 #endif
-      if (0 == strcmp (spec, old_color)) {
+      if (0 == strcmp ((gchar *)tmplist->data, old_color) && a == old_a) {
         gtk_color_selection_set_previous_color (colorsel, &color);
         gtk_color_selection_set_current_color (colorsel, &color);
+        gtk_color_selection_set_previous_alpha (colorsel, a);
+        gtk_color_selection_set_current_alpha (colorsel, a);
       }
       index++;
+      g_free(spec);
     }
   }
 
@@ -1135,15 +1164,15 @@ dia_color_selector_new ()
 					GTK_MENU_ITEM(otheritem),
 					"color-menu");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#000000");
+				     "#000000FF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#FFFFFF");
+				     "#FFFFFFFF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#FF0000");
+				     "#FF0000FF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#00FF00");
+				     "#00FF00FF");
   dia_dynamic_menu_add_default_entry(DIA_DYNAMIC_MENU(ddm),
-				     "#0000FF");
+				     "#0000FFFF");
   g_signal_connect(G_OBJECT(otheritem), "activate",
 		   G_CALLBACK(dia_color_selector_more_callback), ddm);
   gtk_widget_show(otheritem);
@@ -1155,32 +1184,35 @@ void
 dia_color_selector_get_color(GtkWidget *widget, Color *color)
 {
   gchar *entry = dia_dynamic_menu_get_entry(DIA_DYNAMIC_MENU(widget));
-  gint r, g, b;
+  gint r, g, b, a;
 
-  sscanf(entry, "#%2x%2x%2x", &r, &g, &b);
+  sscanf(entry, "#%2x%2x%2x%2x", &r, &g, &b, &a);
   g_free(entry);
   color->red = r / 255.0;
   color->green = g / 255.0;
   color->blue = b / 255.0;
+  color->alpha = a / 255.0;
 }
 
 void
 dia_color_selector_set_color (GtkWidget *widget,
 			      const Color *color)
 {
-  gint red, green, blue;
+  gint red, green, blue, alpha;
   gchar *entry;
   red = color->red * 255;
   green = color->green * 255;
   blue = color->blue * 255;
-  if (color->red > 1.0 || color->green > 1.0 || color->blue > 1.0) {
-    printf("Color out of range: r %f, g %f, b %f\n",
-	   color->red, color->green, color->blue);
+  alpha = color->alpha * 255;
+  if (color->red > 1.0 || color->green > 1.0 || color->blue > 1.0 || color->alpha > 1.0) {
+    printf("Color out of range: r %f, g %f, b %f, a %f\n",
+	   color->red, color->green, color->blue, color->alpha);
     red = MIN(red, 255);
     green = MIN(green, 255);
     blue = MIN(blue, 255);
+    alpha = MIN(alpha, 255);
   }
-  entry = g_strdup_printf("#%02X%02X%02X", red, green, blue);
+  entry = g_strdup_printf("#%02X%02X%02X%02X", red, green, blue, alpha);
   dia_dynamic_menu_select_entry(DIA_DYNAMIC_MENU(widget), entry);
   g_free (entry);
 }
diff --git a/objects/Database/compound.c b/objects/Database/compound.c
index b742d7f..fe0554e 100644
--- a/objects/Database/compound.c
+++ b/objects/Database/compound.c
@@ -563,7 +563,7 @@ compound_draw (Compound * comp, DiaRenderer * renderer)
 #if DEBUG_DRAW_MP_DIRECTION
  {
    Point p = comp->mount_point.pos;
-   Color red = {1.0, 0.0, 0.0};
+   Color red = { 1.0, 0.0, 0.0, 1.0 };
    gchar dirs = comp->mount_point.directions;
    if (dirs & DIR_NORTH)
      p.y -= 1.0;
diff --git a/objects/FS/flow-ortho.c b/objects/FS/flow-ortho.c
index 81b87cb..85fbc9c 100644
--- a/objects/FS/flow-ortho.c
+++ b/objects/FS/flow-ortho.c
@@ -78,11 +78,11 @@ struct _OrthflowChange {
   char*				text ;
 };
 
-Color orthflow_color_energy   = { 1.0f, 0.0f, 0.0f };
-Color orthflow_color_material = { 0.8f, 0.0f, 0.8f };
-Color orthflow_color_signal   = { 0.0f, 0.0f, 1.0f };
+Color orthflow_color_energy   = { 1.0f, 0.0f, 0.0f, 1.0f };
+Color orthflow_color_material = { 0.8f, 0.0f, 0.8f, 1.0f };
+Color orthflow_color_signal   = { 0.0f, 0.0f, 1.0f, 1.0f };
+
 
-  
 #define ORTHFLOW_WIDTH 0.1
 #define ORTHFLOW_MATERIAL_WIDTH 0.2
 #define ORTHFLOW_DASHLEN 0.4
diff --git a/objects/FS/flow.c b/objects/FS/flow.c
index 0277c68..d8024d5 100644
--- a/objects/FS/flow.c
+++ b/objects/FS/flow.c
@@ -40,9 +40,9 @@
 
 #include "pixmaps/flow.xpm"
 
-Color flow_color_energy   = { 1.0f, 0.0f, 0.0f };
-Color flow_color_material = { 0.8f, 0.0f, 0.8f };
-Color flow_color_signal   = { 0.0f, 0.0f, 1.0f };
+Color flow_color_energy   = { 1.0f, 0.0f, 0.0f, 1.0f };
+Color flow_color_material = { 0.8f, 0.0f, 0.8f, 1.0f };
+Color flow_color_signal   = { 0.0f, 0.0f, 1.0f, 1.0f };
 
 typedef struct _Flow Flow;
 typedef enum {
diff --git a/objects/GRAFCET/action.c b/objects/GRAFCET/action.c
index 2e8582b..5c89623 100644
--- a/objects/GRAFCET/action.c
+++ b/objects/GRAFCET/action.c
@@ -385,7 +385,7 @@ action_draw(Action *action, DiaRenderer *renderer)
     renderer_ops->draw_line(renderer,&p1,&p2,&color_black);
   }
 
-  cl.red = 1.0; cl.blue = cl.green = .2; 
+  cl.red = 1.0; cl.blue = cl.green = .2; cl.alpha = 1.0;
   renderer_ops->draw_rect(renderer,&ul,&br,&color_black);
 }
 
diff --git a/objects/GRAFCET/step.c b/objects/GRAFCET/step.c
index 4c4019f..2407232 100644
--- a/objects/GRAFCET/step.c
+++ b/objects/GRAFCET/step.c
@@ -244,7 +244,7 @@ static void step_been_renamed(const gchar *sid)
   if (*endptr == '\0') __stepnum = snum + 1; 
 }
 
-static Color color_red = { 1.0f, 0.0f, 0.0f };
+static Color color_red = { 1.0f, 0.0f, 0.0f, 1.0f };
 
 static real
 step_distance_from(Step *step, Point *point)
diff --git a/objects/KAOS/metabinrel.c b/objects/KAOS/metabinrel.c
index c88acdc..a8bce30 100644
--- a/objects/KAOS/metabinrel.c
+++ b/objects/KAOS/metabinrel.c
@@ -91,7 +91,7 @@ struct _Mbr {
 
 #define MBR_DEC_SIZE 1.0
 
-static Color color_red = { 1.0f, 0.0f, 0.0f };
+static Color color_red = { 1.0f, 0.0f, 0.0f, 1.0f };
 
 static DiaFont *mbr_font = NULL;
 
diff --git a/objects/Misc/analog_clock.c b/objects/Misc/analog_clock.c
index b344004..a557515 100644
--- a/objects/Misc/analog_clock.c
+++ b/objects/Misc/analog_clock.c
@@ -411,10 +411,12 @@ analog_clock_create(Point *startpoint,
   analog_clock->arrow_color.red = 0.0;
   analog_clock->arrow_color.green = 0.0;
   analog_clock->arrow_color.blue = 0.5;
+  analog_clock->arrow_color.alpha = 1.0;
   analog_clock->arrow_line_width = attributes_get_default_linewidth();
   analog_clock->sec_arrow_color.red = 1.0;
   analog_clock->sec_arrow_color.green = 0.0;
   analog_clock->sec_arrow_color.blue = 0.0;
+  analog_clock->sec_arrow_color.alpha = 1.0;
   analog_clock->sec_arrow_line_width = attributes_get_default_linewidth()/3;
   analog_clock->show_ticks = TRUE;
 
diff --git a/objects/Misc/grid_object.c b/objects/Misc/grid_object.c
index 73f6734..3f33827 100644
--- a/objects/Misc/grid_object.c
+++ b/objects/Misc/grid_object.c
@@ -388,6 +388,7 @@ grid_object_create(Point *startpoint,
   grid_object->gridline_color.red = 0.5;
   grid_object->gridline_color.green = 0.5;
   grid_object->gridline_color.blue = 0.5;
+  grid_object->gridline_color.alpha = 1.0;
   grid_object->gridline_width = attributes_get_default_linewidth();
 
   for (i = 0; i < 9; ++i)
diff --git a/objects/SADT/annotation.c b/objects/SADT/annotation.c
index a30e147..afc40ea 100644
--- a/objects/SADT/annotation.c
+++ b/objects/SADT/annotation.c
@@ -129,6 +129,7 @@ handle_btn1(Annotation *annotation, Property *prop) {
   col.red = g_random_double();
   col.green = g_random_double();
   col.blue = g_random_double();
+  col.alpha = 1.0;
   annotation->attrs.color = col;
   text_set_attributes(annotation->text,&annotation->attrs);
   /* g_message("end of handle_btn1 for object %p col=%.2f:%.2f:%.2f",
diff --git a/objects/SISSI/area.c b/objects/SISSI/area.c
index f082c0e..5aefa76 100644
--- a/objects/SISSI/area.c
+++ b/objects/SISSI/area.c
@@ -65,7 +65,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_gris_clear = { 0.95f, 0.95f, 0.95f };
+static Color color_gris_clear = { 0.95f, 0.95f, 0.95f, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/SISSI/faraday.c b/objects/SISSI/faraday.c
index ad85c8d..be5eef3 100644
--- a/objects/SISSI/faraday.c
+++ b/objects/SISSI/faraday.c
@@ -66,7 +66,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_red = { 1.0f, 0.0f, 0.0f };
+static Color color_red = { 1.0f, 0.0f, 0.0f, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/SISSI/room.c b/objects/SISSI/room.c
index 7ba7511..01e6d68 100644
--- a/objects/SISSI/room.c
+++ b/objects/SISSI/room.c
@@ -66,7 +66,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_gris = { 0.5f, 0.5f, 0.5f };
+static Color color_gris = { 0.5f, 0.5f, 0.5f, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/SISSI/site.c b/objects/SISSI/site.c
index cad894b..582ca55 100644
--- a/objects/SISSI/site.c
+++ b/objects/SISSI/site.c
@@ -66,7 +66,7 @@
 #define TEXT_HEIGHT (2.0)
 #define NUM_CONNECTIONS 9
 
-static Color color_green_clear = { 0.87, 0.98f, 0.91 };
+static Color color_green_clear = { 0.87, 0.98f, 0.91, 1.0f };
 
 #ifdef G_OS_WIN32
 #include <io.h>
diff --git a/objects/chronogram/chronoline.c b/objects/chronogram/chronoline.c
index c8eb69b..dae667f 100644
--- a/objects/chronogram/chronoline.c
+++ b/objects/chronogram/chronoline.c
@@ -478,6 +478,7 @@ inline static void grayify(Color *col,Color *src)
   col->red = .5 * (src->red + color_white.red);
   col->green = .5 * (src->green + color_white.green);
   col->blue = .5 * (src->blue + color_white.blue);
+  col->alpha = .5 * (src->alpha + color_white.alpha);
 }
 
 static void
@@ -634,6 +635,7 @@ chronoline_create(Point *startpoint,
   chronoline->data_color.red = 1.0;
   chronoline->data_color.green = 0.0;
   chronoline->data_color.blue = 0.0;
+  chronoline->data_color.alpha = 1.0;
   chronoline->multibit = FALSE;
   
   chronoline->evtlist = NULL;
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index a1cdad9..4c5c381 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -827,9 +827,10 @@ get_colour(Custom *custom, Color *colour, gint32 c)
     *colour = custom->text->color;
     break;
   default:
-    colour->red   = ((c & 0xff0000) >> 16) / 255.0;
-    colour->green = ((c & 0x00ff00) >> 8) / 255.0;
-    colour->blue  =  (c & 0x0000ff) / 255.0;
+    colour->alpha = ((c & 0xff000000) >> 24) / 255.0;
+    colour->red   = ((c & 0x00ff0000) >> 16) / 255.0;
+    colour->green = ((c & 0x0000ff00) >> 8) / 255.0;
+    colour->blue  =  (c & 0x000000ff) / 255.0;
     break;
   }
 }
diff --git a/objects/custom_lines/line_info.c b/objects/custom_lines/line_info.c
index 6708d0d..6e7efe2 100644
--- a/objects/custom_lines/line_info.c
+++ b/objects/custom_lines/line_info.c
@@ -260,6 +260,7 @@ line_info_get_line_color( const gchar* filename, xmlNodePtr node, LineInfo* info
     else if (/*node->ns == shape_ns &&*/ !strcmp((char*)child_node->name, "blue"))
       info->line_color.blue = line_info_get_as_float(filename, child_node);
   }
+  info->line_color.alpha = 1.0;
 }
 
 LineInfo* line_info_load_and_apply_from_xmlfile(const gchar *filename, LineInfo* info);
@@ -276,6 +277,7 @@ LineInfo* line_info_load(const gchar *filename)
   res->line_color.red   = 0.0f;
   res->line_color.green = 0.0f;
   res->line_color.blue  = 0.0f;
+  res->line_color.alpha = 1.0f;
   res->line_style = LINESTYLE_SOLID;
   res->dashlength = 1.0f;
   res->line_width = 0.1f;
@@ -301,6 +303,7 @@ LineInfo* line_info_clone(LineInfo* info)
   res->line_color.red     = info->line_color.red;
   res->line_color.green   = info->line_color.green;
   res->line_color.blue    = info->line_color.blue;
+  res->line_color.alpha   = info->line_color.alpha;
   res->line_style 	  = info->line_style;
   res->dashlength 	  = info->dashlength;
   res->line_width 	  = info->line_width;
diff --git a/objects/network/network.c b/objects/network/network.c
index 072b3de..64ea5c8 100644
--- a/objects/network/network.c
+++ b/objects/network/network.c
@@ -27,7 +27,7 @@
 #include "network.h"
 #include "plug-ins.h"
 
-Color computer_color = { 0.7, 0.7, 0.7 };
+Color computer_color = { 0.7, 0.7, 0.7, 1.0 };
 
 extern DiaObjectType bus_type;
 extern DiaObjectType bus_type_std;
diff --git a/plug-ins/cairo/diacairo-interactive.c b/plug-ins/cairo/diacairo-interactive.c
index c83ab92..ff9c9e4 100644
--- a/plug-ins/cairo/diacairo-interactive.c
+++ b/plug-ins/cairo/diacairo-interactive.c
@@ -411,7 +411,7 @@ draw_pixel_line(DiaRenderer *object,
   cairo_device_to_user (renderer->cr, &x1u, &y1u);
   cairo_device_to_user (renderer->cr, &x2u, &y2u);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_move_to (renderer->cr, x1u, y1u);
   cairo_line_to (renderer->cr, x2u, y2u);
   cairo_stroke (renderer->cr);
@@ -434,7 +434,7 @@ draw_pixel_rect(DiaRenderer *object,
   cairo_device_to_user (renderer->cr, &x1u, &y1u);
   cairo_device_to_user (renderer->cr, &x2u, &y2u);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_rectangle (renderer->cr, x1u, y1u, x2u - x1u, y2u - y1u);
   cairo_stroke (renderer->cr);
 }
@@ -467,7 +467,7 @@ fill_pixel_rect(DiaRenderer *object,
   cairo_device_to_user (renderer->cr, &x1u, &y1u);
   cairo_device_to_user (renderer->cr, &x2u, &y2u);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_rectangle (renderer->cr, x1u, y1u, x2u - x1u, y2u - y1u);
   cairo_fill (renderer->cr);
 #endif
diff --git a/plug-ins/cairo/diacairo-renderer.c b/plug-ins/cairo/diacairo-renderer.c
index 4110a9b..97884cf 100644
--- a/plug-ins/cairo/diacairo-renderer.c
+++ b/plug-ins/cairo/diacairo-renderer.c
@@ -97,7 +97,7 @@ begin_render(DiaRenderer *self)
                              renderer->dia->bg_color.red, 
                              renderer->dia->bg_color.green, 
                              renderer->dia->bg_color.blue,
-                             0.0);
+                             renderer->dia->bg_color.alpha);
     }
   else
     {
@@ -116,7 +116,7 @@ begin_render(DiaRenderer *self)
                              renderer->dia->bg_color.red, 
                              renderer->dia->bg_color.green, 
                              renderer->dia->bg_color.blue,
-                             1.0);
+                             renderer->dia->bg_color.alpha);
     }
 #ifdef HAVE_PANGOCAIRO_H
   if (!renderer->layout)
@@ -297,6 +297,7 @@ set_dashlength(DiaRenderer *self, real length)
 static void
 set_fillstyle(DiaRenderer *self, FillStyle mode)
 {
+  DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
   DIAG_NOTE(g_message("set_fillstyle %d", mode));
 
   switch(mode) {
@@ -362,7 +363,7 @@ draw_line(DiaRenderer *self,
   DIAG_NOTE(g_message("draw_line %f,%f -> %f, %f", 
             start->x, start->y, end->x, end->y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   cairo_move_to (renderer->cr, start->x, start->y);
   cairo_line_to (renderer->cr, end->x, end->y);
   cairo_stroke (renderer->cr);
@@ -382,7 +383,7 @@ draw_polyline(DiaRenderer *self,
 
   g_return_if_fail(1 < num_points);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   /* point data */
@@ -410,7 +411,7 @@ _polygon(DiaRenderer *self,
 
   g_return_if_fail(1 < num_points);
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   /* point data */
@@ -456,7 +457,7 @@ _rect(DiaRenderer *self,
             fill ? "fill" : "draw",
             ul_corner->x, ul_corner->y, lr_corner->x, lr_corner->y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   
   cairo_rectangle (renderer->cr, 
                    ul_corner->x, ul_corner->y, 
@@ -499,7 +500,7 @@ draw_arc(DiaRenderer *self,
   DIAG_NOTE(g_message("draw_arc %fx%f <%f,<%f", 
             width, height, angle1, angle2));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   /* Dia and Cairo don't agree on arc definitions, so it needs
    * to be converted, i.e. mirrored at the x axis
@@ -532,7 +533,7 @@ fill_arc(DiaRenderer *self,
   DIAG_NOTE(g_message("draw_arc %fx%f <%f,<%f", 
             width, height, angle1, angle2));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   
   cairo_new_path (renderer->cr);
   start.x = center->x + (width / 2.0)  * cos((M_PI / 180.0) * angle1);
@@ -564,7 +565,7 @@ _ellipse(DiaRenderer *self,
   DIAG_NOTE(g_message("%s_ellipse %fx%f center @ %f,%f", 
             fill ? "fill" : "draw", width, height, center->x, center->y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
   
 #if 1
   cairo_save (renderer->cr);
@@ -631,7 +632,7 @@ _bezier(DiaRenderer *self,
   DIAG_NOTE(g_message("%s_bezier n:%d %fx%f ...", 
             fill ? "fill" : "draw", numpoints, points->p1.x, points->p1.y));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   for (i = 0; i < numpoints; i++)
@@ -694,7 +695,7 @@ draw_string(DiaRenderer *self,
 
   if (len < 1) return; /* shouldn't this be handled by Dia's core ? */
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 #ifdef HAVE_PANGOCAIRO_H
   cairo_save (renderer->cr);
   /* alignment calculation done by pangocairo? */
@@ -724,7 +725,7 @@ draw_string(DiaRenderer *self,
   {
     cairo_text_extents_t extents;
     double x = 0, y = 0;
-    cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+    cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
     cairo_text_extents (renderer->cr,
                         text,
                         &extents);
@@ -872,7 +873,7 @@ _rounded_rect (DiaRenderer *self,
             fill ? "fill" : "draw",
             topleft->x, topleft->y, bottomright->x, bottomright->y, radius));
 
-  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
+  cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, color->alpha);
 
   cairo_new_path (renderer->cr);
   cairo_move_to (renderer->cr, /* north-west */
diff --git a/plug-ins/cgm/cgm.c b/plug-ins/cgm/cgm.c
index 9f3f032..11f86b3 100644
--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -319,6 +319,7 @@ init_attributes( CgmRenderer *renderer )
     renderer->lcurrent.color.red   = 0;
     renderer->lcurrent.color.green = 0;
     renderer->lcurrent.color.blue  = 0;
+    renderer->lcurrent.color.alpha = 1.0;
 
     renderer->linfile.cap    = -1;
     renderer->linfile.join   = -1;
@@ -327,12 +328,14 @@ init_attributes( CgmRenderer *renderer )
     renderer->linfile.color.red   = -1;
     renderer->linfile.color.green = -1;
     renderer->linfile.color.blue  = -1;
+    renderer->linfile.color.alpha = 1.0;
 
     /* fill/edge defaults */
     renderer->fcurrent.fill_style = 1;          /* solid */
     renderer->fcurrent.fill_color.red = 0;
     renderer->fcurrent.fill_color.green = 0;
     renderer->fcurrent.fill_color.blue = 0;
+    renderer->fcurrent.fill_color.alpha = 1.0;
 
     renderer->fcurrent.edgevis = 0;
     renderer->fcurrent.cap   = 3;            /* round */
@@ -342,11 +345,13 @@ init_attributes( CgmRenderer *renderer )
     renderer->fcurrent.color.red   = 0;
     renderer->fcurrent.color.green = 0;
     renderer->fcurrent.color.blue  = 0;
-   
+    renderer->fcurrent.color.alpha = 1.0;
+
     renderer->finfile.fill_style = -1;
     renderer->finfile.fill_color.red = -1;
     renderer->finfile.fill_color.green = -1;
     renderer->finfile.fill_color.blue = -1;
+    renderer->finfile.fill_color.alpha = 1.0;
 
     renderer->finfile.edgevis = -1;
     renderer->finfile.cap   = -1;            
@@ -356,19 +361,22 @@ init_attributes( CgmRenderer *renderer )
     renderer->finfile.color.red   = -1.0;
     renderer->finfile.color.green = -1.0;
     renderer->finfile.color.blue  = -1.0;
+    renderer->finfile.color.alpha = 1.0;
 
     renderer->tcurrent.font_num    = 1;
     renderer->tcurrent.font_height = 0.1;
     renderer->tcurrent.color.red   = 0.0;
     renderer->tcurrent.color.green = 0.0;
     renderer->tcurrent.color.blue  = 0.0;
+    renderer->tcurrent.color.alpha = 1.0;
 
     renderer->tinfile.font_num    = -1;
     renderer->tinfile.font_height = -1.0;
     renderer->tinfile.color.red   = -1.0;
     renderer->tinfile.color.green = -1.0;
     renderer->tinfile.color.blue  = -1.0;
-   
+    renderer->tinfile.color.alpha = 1.0;
+
 }
     
 
@@ -417,7 +425,8 @@ LineAttrCGM    *lnew, *lold;
     lnew->color = *color;
     if ( lnew->color.red != lold->color.red ||
          lnew->color.green != lold->color.green ||
-         lnew->color.blue != lold->color.blue )
+         lnew->color.blue != lold->color.blue ||
+         lnew->color.alpha != lold->color.alpha)
     {
         write_elhead(renderer->file, 5, 4, 3); /* line colour */
         write_colour(renderer->file, &lnew->color);
@@ -498,7 +507,8 @@ FillEdgeAttrCGM    *fnew, *fold;
         fnew->color = *edge_color;
         if ( fnew->color.red != fold->color.red ||
              fnew->color.green != fold->color.green ||
-             fnew->color.blue != fold->color.blue )
+             fnew->color.blue != fold->color.blue ||
+             fnew->color.alpha != fold->color.alpha)
         {
             write_elhead(renderer->file, 5, 29, 3); /* line colour */
             write_colour(renderer->file, &fnew->color);
@@ -529,7 +539,8 @@ FillEdgeAttrCGM    *fnew, *fold;
         fnew->fill_color = *fill_color;
         if ( fnew->fill_color.red != fold->fill_color.red ||
              fnew->fill_color.green != fold->fill_color.green ||
-             fnew->fill_color.blue != fold->fill_color.blue )
+             fnew->fill_color.blue != fold->fill_color.blue ||
+             fnew->fill_color.alpha != fold->fill_color.alpha)
         {
             write_elhead(renderer->file, 5, 23, 3);   /* fill colour */
             write_colour(renderer->file, &fnew->fill_color);
@@ -578,7 +589,8 @@ TextAttrCGM    *tnew, *told;
     tnew->color = *text_color;
     if ( tnew->color.red != told->color.red ||
          tnew->color.green != told->color.green ||
-         tnew->color.blue != told->color.blue )
+         tnew->color.blue != told->color.blue ||
+         tnew->color.alpha != told->color.alpha)
     {
         write_elhead(renderer->file, 5, 14, 3);   /* text colour */
         write_colour(renderer->file, &tnew->color);
diff --git a/plug-ins/drs/dia-render-script-import.c b/plug-ins/drs/dia-render-script-import.c
index 8e93a23..eab4a45 100644
--- a/plug-ins/drs/dia-render-script-import.c
+++ b/plug-ins/drs/dia-render-script-import.c
@@ -127,6 +127,7 @@ _parse_color (xmlNodePtr node, const char *attrib)
       val->red = color.red / 65535.0; 
       val->green = color.green / 65535.0; 
       val->blue = color.blue / 65535.0;
+      val->alpha = 1.0;
     }
     xmlFree(str);
   }
diff --git a/plug-ins/dxf/dxf-import.c b/plug-ins/dxf/dxf-import.c
index 0b8025c..abd1b4c 100644
--- a/plug-ins/dxf/dxf-import.c
+++ b/plug-ins/dxf/dxf-import.c
@@ -158,7 +158,7 @@ read_entity_line_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
     
     DiaObject *line_obj;
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
     RGB_t color;
     GPtrArray *props;
     PointProperty *ptprop;
@@ -203,6 +203,7 @@ read_entity_line_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
 	    line_colour.red = color.r / 255.0;
 	    line_colour.green = color.g / 255.0;
 	    line_colour.blue = color.b / 255.0;
+	    line_colour.alpha = 1.0;
             break;
         }	
     } while(data->code != 0);
@@ -262,7 +263,7 @@ read_entity_solid_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
    DiaObject *polygon_obj;
    MultipointCreateData *pcd;
 
-   Color fill_colour = { 0.5, 0.5, 0.5 };
+   Color fill_colour = { 0.5, 0.5, 0.5, 1.0 };
 
    GPtrArray *props;
    LinestyleProperty *lsprop;
@@ -330,6 +331,7 @@ read_entity_solid_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
 	    fill_colour.red = color.r / 255.0;
 	    fill_colour.green = color.g / 255.0;
 	    fill_colour.blue = color.b / 255.0;
+	    fill_colour.alpha = 1.0;
             break;
         }	
     } while(data->code != 0);
@@ -412,7 +414,7 @@ read_entity_polyline_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     DiaObject *polyline_obj;
     MultipointCreateData *pcd;
 
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     GPtrArray *props;
     LinestyleProperty *lsprop;
@@ -489,6 +491,7 @@ read_entity_polyline_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
                 line_colour.red = color.r / 255.0;
                 line_colour.green = color.g / 255.0;
                 line_colour.blue = color.b / 255.0;
+                line_colour.alpha = 1.0;
                 break;
             case 70:
                 closed = 1 & atoi( data->value );
@@ -634,7 +637,7 @@ DiaObject *read_entity_circle_dxf(FILE *filedxf, DxfData *data, DiagramData *dia
     Handle *h1, *h2;
     
     DiaObject *ellipse_obj;
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     PointProperty *ptprop;
     RealProperty *rprop;
@@ -721,7 +724,7 @@ DiaObject *read_entity_arc_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
   
     DiaObject *arc_obj;
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     ColorProperty *cprop;
     PointProperty *ptprop;
@@ -815,7 +818,7 @@ read_entity_ellipse_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
     
     DiaObject *ellipse_obj; 
-    Color line_colour = { 0.0, 0.0, 0.0 };
+    Color line_colour = { 0.0, 0.0, 0.0, 1.0 };
     PointProperty *ptprop;
     RealProperty *rprop;
     BoolProperty *bprop;
@@ -903,7 +906,7 @@ read_entity_text_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
     Handle *h1, *h2;
     
     DiaObject *text_obj;
-    Color text_colour = { 0.0, 0.0, 0.0 };
+    Color text_colour = { 0.0, 0.0, 0.0, 1.0 };
 
     TextProperty *tprop;
     GPtrArray *props;
@@ -961,6 +964,7 @@ read_entity_text_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
 	   text_colour.red = color.r / 255.0;
 	   text_colour.green = color.g / 255.0;
 	   text_colour.blue = color.b / 255.0;
+	   text_colour.alpha = 1.0;
             break;
         case 72: 
 	   switch(atoi(data->value))
diff --git a/plug-ins/libart/dialibartrenderer.c b/plug-ins/libart/dialibartrenderer.c
index 7a6bc08..e9e32c0 100644
--- a/plug-ins/libart/dialibartrenderer.c
+++ b/plug-ins/libart/dialibartrenderer.c
@@ -65,7 +65,7 @@ color_to_abgr(Color *col)
 {
   int rgba;
 
-  rgba = 0x0;
+  rgba = (guint)(0xFF*col->alpha) << 24;
   rgba |= (guint)(0xFF*col->blue) << 16;
   rgba |= (guint)(0xFF*col->green) << 8;
   rgba |= (guint)(0xFF*col->red);
@@ -79,12 +79,12 @@ color_to_rgba(DiaLibartRenderer *renderer, Color *col)
   int rgba;
 
   if (renderer->highlight_color != NULL) {
-      rgba = 0xFF;
+      rgba = (guint)(0xFF*renderer->highlight_color->alpha);
       rgba |= (guint)(0xFF*renderer->highlight_color->red) << 24;
       rgba |= (guint)(0xFF*renderer->highlight_color->green) << 16;
       rgba |= (guint)(0xFF*renderer->highlight_color->blue) << 8;
   } else {
-    rgba = 0xFF;
+    rgba = (guint)(0xFF*col->alpha);
     rgba |= (guint)(0xFF*col->red) << 24;
     rgba |= (guint)(0xFF*col->green) << 16;
     rgba |= (guint)(0xFF*col->blue) << 8;
diff --git a/plug-ins/libart/render_libart.c b/plug-ins/libart/render_libart.c
index bcf7c3c..fd59054 100644
--- a/plug-ins/libart/render_libart.c
+++ b/plug-ins/libart/render_libart.c
@@ -33,11 +33,11 @@
 #include "color.h"
 
 /** Used for highlighting mainpoint connections. */
-static Color cp_main_color = { 1.0, 0.8, 0.0 };
+static Color cp_main_color = { 1.0, 0.8, 0.0, 1.0 };
 /** Used for highlighting normal connections. */
-static Color cp_color = { 1.0, 0.0, 0.0 };
+static Color cp_color = { 1.0, 0.0, 0.0, 1.0 };
 
-static Color text_edit_color = {1.0, 1.0, 0.0 };
+static Color text_edit_color = {1.0, 1.0, 0.0, 1.0 };
 
 
 static void clip_region_clear(DiaRenderer *self);
diff --git a/plug-ins/python/diasvg_import.py b/plug-ins/python/diasvg_import.py
index af9d8ed..3fdccef 100644
--- a/plug-ins/python/diasvg_import.py
+++ b/plug-ins/python/diasvg_import.py
@@ -38,6 +38,7 @@ dictUnitScales = {
 
 # only compile once
 rColor = re.compile(r"rgb\s*\(\s*(\d+)[, ]+(\d+)[, +](\d+)\s*\)")
+rColora = re.compile(r"rgba\s*\(\s*(\d+)[, ]+(\d+)[, +](\d+)[, +](\d+)\s*\)")
 # not really parsing numbers (Scaled will deal with more)
 rTranslate = re.compile(r"translate\s*\(\s*([^,]+),([^)]+)\s*\)")
 #FIXME: parse more - e.g. AQT - of the strange path data
@@ -68,7 +69,10 @@ def Color(s) :
 	# deliver a StdProp compatible Color (or the original string)
 	m = rColor.match(s)
 	if m :
-		return (int(m.group(1)) / 255.0, int(m.group(2)) / 255.0, int(m.group(2)) / 255.0)
+		return (int(m.group(1)) / 255.0, int(m.group(2)) / 255.0, int(m.group(3)) / 255.0, 1.0)
+	else:
+		m = rColora.match(s)
+		return (int(m.group(1)) / 255.0, int(m.group(2)) / 255.0, int(m.group(3)) / 255.0, int(m.group(4)) / 255.0)
 	# any more ugly color definitions not compatible with pango_color_parse() ?
 	return string.strip(s)
 def _eval (s, _locals) :
diff --git a/plug-ins/python/pydia-color.c b/plug-ins/python/pydia-color.c
index 7bcf30d..e9bda1d 100644
--- a/plug-ins/python/pydia-color.c
+++ b/plug-ins/python/pydia-color.c
@@ -72,14 +72,15 @@ static PyObject *
 PyDiaColor_GetAttr(PyDiaColor *self, gchar *attr)
 {
   if (!strcmp(attr, "__members__"))
-    return Py_BuildValue("[sss]", "red", "green", "blue");
+    return Py_BuildValue("[ssss]", "red", "green", "blue", "alpha");
   else if (!strcmp(attr, "red"))
     return PyFloat_FromDouble(self->color.red);
   else if (!strcmp(attr, "green"))
     return PyFloat_FromDouble(self->color.green);
   else if (!strcmp(attr, "blue"))
     return PyFloat_FromDouble(self->color.blue);
-
+  else if (!strcmp(attr, "alpha"))
+    return PyFloat_FromDouble(self->color.alpha);
   PyErr_SetString(PyExc_AttributeError, attr);
   return NULL;
 }
@@ -91,10 +92,11 @@ static PyObject *
 PyDiaColor_Str(PyDiaColor *self)
 {
   PyObject* py_s;
-  gchar* s = g_strdup_printf("(%f,%f,%f)",
+  gchar* s = g_strdup_printf("(%f,%f,%f,%f)",
                              (float)(self->color.red),
                              (float)(self->color.green),
-                             (float)(self->color.blue));
+                             (float)(self->color.blue),
+                             (float)(self->color.alpha));
   py_s = PyString_FromString(s);
   g_free (s);
   return py_s;
diff --git a/plug-ins/python/pydia-property.c b/plug-ins/python/pydia-property.c
index e445d41..cdf2906 100644
--- a/plug-ins/python/pydia-property.c
+++ b/plug-ins/python/pydia-property.c
@@ -290,6 +290,7 @@ PyDia_set_Color (Property *prop, PyObject *val)
       p->color_data.red = color.red / 65535.0; 
       p->color_data.green = color.green / 65535.0; 
       p->color_data.blue = color.blue / 65535.0;
+      p->color_data.alpha = 1.0;
       return 0;
     } else
       g_debug("Failed to parse color string '%s'", str);
@@ -310,6 +311,7 @@ PyDia_set_Color (Property *prop, PyObject *val)
     p->color_data.red = f[0]; 
     p->color_data.green = f[1]; 
     p->color_data.blue = f[2];
+    p->color_data.alpha = 1.0;
     return 0;
   }
   /* also convert char/255 ? */
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index 46f6d01..2901ca6 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -67,6 +67,7 @@ get_colour(gint32 c)
     colour.red   = ((c & 0xff0000) >> 16) / 255.0;
     colour.green = ((c & 0x00ff00) >> 8) / 255.0;
     colour.blue  =  (c & 0x0000ff) / 255.0;
+    colour.alpha = 1.0;
 
     return colour;
 }
diff --git a/plug-ins/vdx/vdx-export.c b/plug-ins/vdx/vdx-export.c
index cfc0377..13dc6b1 100644
--- a/plug-ins/vdx/vdx-export.c
+++ b/plug-ins/vdx/vdx-export.c
@@ -291,9 +291,9 @@ begin_render(DiaRenderer *self)
     /* renderer->version = 0; */
 
     /* Black and white are 0 and 1 respectively */
-    c.red = 0.0; c.green = 0.0; c.blue = 0.0;
+    c.red = 0.0; c.green = 0.0; c.blue = 0.0; c.alpha = 1.0;
     vdxCheckColor(renderer, &c);
-    c.red = 1.0; c.green = 1.0; c.blue = 1.0;
+    c.red = 1.0; c.green = 1.0; c.blue = 1.0; c.alpha = 1.0;
     vdxCheckColor(renderer, &c);
 }
 
@@ -1638,7 +1638,7 @@ write_header(DiagramData *data, VDXRenderer *renderer)
     struct vdx_Char Char;
     struct vdx_Para Para;
     struct vdx_Tabs Tabs;
-    static Color color_black = {0,0,0};
+    static Color color_black = { 0.0, 0.0, 0.0, 1.0 };
 
     g_debug("write_header");
 
diff --git a/plug-ins/vdx/vdx-import.c b/plug-ins/vdx/vdx-import.c
index 202f3f7..8359e6b 100644
--- a/plug-ins/vdx/vdx-import.c
+++ b/plug-ins/vdx/vdx-import.c
@@ -204,13 +204,16 @@ Color
 vdx_parse_color(const char *s, const VDXDocument *theDoc)
 {
     int colorvalues;
-    Color c = {0, 0, 0};
+    Color c = {0, 0, 0, 0};
     if (s[0] == '#')
     {
         sscanf(s, "#%xd", &colorvalues);
+        /* A wild fabricated guess? */
+        /* c.alpha = ((colorvalues & 0xff000000)>>24) / 255.0; */
         c.red = ((colorvalues & 0x00ff0000)>>16) / 255.0;
         c.green = ((colorvalues & 0x0000ff00)>>8) / 255.0;
         c.blue = (colorvalues & 0x000000ff) / 255.0;
+        c.alpha = 1.0;
         return c;
     }
     if (g_ascii_isdigit(s[0]))
@@ -720,6 +723,7 @@ vdx_simple_properties(DiaObject *obj,
             cprop->color_data.red = 0;
             cprop->color_data.green = 0;
             cprop->color_data.blue = 0;
+            cprop->color_data.alpha = 1.0;
         }
         else
         {
@@ -727,6 +731,7 @@ vdx_simple_properties(DiaObject *obj,
             cprop->color_data.red = 1;
             cprop->color_data.green = (theDoc->shape_id >> 8)/255.0;
             cprop->color_data.blue = (theDoc->shape_id & 0xff)/255.0;
+            cprop->color_data.alpha = 1.0;
         }
     }
 
diff --git a/plug-ins/wpg/wpg.c b/plug-ins/wpg/wpg.c
index a2a3bb4..944b6f4 100644
--- a/plug-ins/wpg/wpg.c
+++ b/plug-ins/wpg/wpg.c
@@ -275,7 +275,7 @@ begin_render(DiaRenderer *self)
 
   gint16 i;
   guint8* pPal;
-  Color color = {1, 1, 1};
+  Color color = { 1.0, 1.0, 1.0, 1.0 };
 
   DIAG_NOTE(g_message("begin_render"));
 
diff --git a/plug-ins/xfig/xfig-common.c b/plug-ins/xfig/xfig-common.c
index a980d74..639a00d 100644
--- a/plug-ins/xfig/xfig-common.c
+++ b/plug-ins/xfig/xfig-common.c
@@ -21,14 +21,14 @@
 #include "xfig.h"
 
 Color fig_default_colors[FIG_MAX_DEFAULT_COLORS] =
-{ { 0x00, 0x00, 0x00}, {0x00, 0x00, 0xff}, {0x00, 0xff, 0x00}, {0x00, 0xff, 0xff}, 
-  { 0xff, 0x00, 0x00}, {0xff, 0x00, 0xff}, {0xff, 0xff, 0x00}, {0xff, 0xff, 0xff},
-  { 0x00, 0x00, 0x8f}, {0x00, 0x00, 0xb0}, {0x00, 0x00, 0xd1}, {0x87, 0xcf, 0xff},
-  { 0x00, 0x8f, 0x00}, {0x00, 0xb0, 0x00}, {0x00, 0xd1, 0x00}, {0x00, 0x8f, 0x8f},
-  { 0x00, 0xb0, 0xb0}, {0x00, 0xd1, 0xd1}, {0x8f, 0x00, 0x00}, {0xb0, 0x00, 0x00},
-  { 0xd1, 0x00, 0x00}, {0x8f, 0x00, 0x8f}, {0xb0, 0x00, 0xb0}, {0xd1, 0x00, 0xd1},
-  { 0x7f, 0x30, 0x00}, {0xa1, 0x3f, 0x00}, {0xbf, 0x61, 0x00}, {0xff, 0x7f, 0x7f},
-  { 0xff, 0xa1, 0xa1}, {0xff, 0xbf, 0xbf}, {0xff, 0xe1, 0xe1}, {0xff, 0xd7, 0x00}};
+{ { 0x00, 0x00, 0x00, 0xff }, { 0x00, 0x00, 0xff, 0xff }, { 0x00, 0xff, 0x00, 0xff }, { 0x00, 0xff, 0xff, 0xff },
+  { 0xff, 0x00, 0x00, 0xff }, { 0xff, 0x00, 0xff, 0xff }, { 0xff, 0xff, 0x00, 0xff }, { 0xff, 0xff, 0xff, 0xff },
+  { 0x00, 0x00, 0x8f, 0xff }, { 0x00, 0x00, 0xb0, 0xff }, { 0x00, 0x00, 0xd1, 0xff }, { 0x87, 0xcf, 0xff, 0xff },
+  { 0x00, 0x8f, 0x00, 0xff }, { 0x00, 0xb0, 0x00, 0xff }, { 0x00, 0xd1, 0x00, 0xff }, { 0x00, 0x8f, 0x8f, 0xff },
+  { 0x00, 0xb0, 0xb0, 0xff }, { 0x00, 0xd1, 0xd1, 0xff }, { 0x8f, 0x00, 0x00, 0xff }, { 0xb0, 0x00, 0x00, 0xff },
+  { 0xd1, 0x00, 0x00, 0xff }, { 0x8f, 0x00, 0x8f, 0xff }, { 0xb0, 0x00, 0xb0, 0xff }, { 0xd1, 0x00, 0xd1, 0xff },
+  { 0x7f, 0x30, 0x00, 0xff }, { 0xa1, 0x3f, 0x00, 0xff }, { 0xbf, 0x61, 0x00, 0xff }, { 0xff, 0x7f, 0x7f, 0xff },
+  { 0xff, 0xa1, 0xa1, 0xff }, { 0xff, 0xbf, 0xbf, 0xff }, { 0xff, 0xe1, 0xe1, 0xff }, { 0xff, 0xd7, 0x00, 0xff }};
 
 /** These are the "old-name" font names corresponding to the XFig standard
  *  fonts.  See the list in font.c.
diff --git a/plug-ins/xfig/xfig-import.c b/plug-ins/xfig/xfig-import.c
index 1c78097..9c82611 100644
--- a/plug-ins/xfig/xfig-import.c
+++ b/plug-ins/xfig/xfig-import.c
@@ -124,16 +124,19 @@ fig_area_fill_color(int area_fill, int color_index) {
 	    col.red = 0xff*(20-area_fill)/20;
 	    col.green = 0xff*(20-area_fill)/20;
 	    col.blue = 0xff*(20-area_fill)/20;
+	    col.alpha = 1.0;
 	} else {
 	    col.red = (col.red*area_fill)/20;
 	    col.green = (col.green*area_fill)/20;
 	    col.blue = (col.blue*area_fill)/20;
+	    col.alpha = 1.0;
 	}
     } else if (area_fill > 20 && area_fill <= 40) {
 	/* White and black area illegal here */
 	col.red += (0xff-col.red)*(area_fill-20)/20;
 	col.green += (0xff-col.green)*(area_fill-20)/20;
 	col.blue += (0xff-col.blue)*(area_fill-20)/20;
+	col.alpha = 1.0;
     } else {
 	message_warning(_("Patterns are not supported by Dia"));
     }
@@ -1056,6 +1059,7 @@ fig_read_object(FILE *file) {
 	color.red = ((colorvalues & 0x00ff0000)>>16) / 255.0;
 	color.green = ((colorvalues & 0x0000ff00)>>8) / 255.0;
 	color.blue = (colorvalues & 0x000000ff) / 255.0;
+	color.alpha = 1.0;
 
 	fig_colors[colornumber-32] = color;
 	break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]