Skip to content

Commit

Permalink
REPLACED GdkPixmap with cairo_surface_t
Browse files Browse the repository at this point in the history
  • Loading branch information
ksterker committed Nov 6, 2013
1 parent ce18be0 commit 550f2ac
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 37 deletions.
6 changes: 2 additions & 4 deletions src/dlgedit/dlg_arrow.cc
@@ -1,6 +1,4 @@
/*
$Id: dlg_arrow.cc,v 1.1 2004/07/25 15:52:22 ksterker Exp $
Copyright (C) 2002/2003 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Expand Down Expand Up @@ -199,9 +197,9 @@ DlgPoint DlgArrow::getIntersection (DlgPoint &start, DlgPoint &end, DlgRect &sha
}

// draw the Arrow
void DlgArrow::draw (GdkPixmap *surface, DlgPoint &point, GtkWidget *widget)
void DlgArrow::draw (cairo_surface_t *surface, DlgPoint &point, GtkWidget *widget)
{
cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE(surface));
cairo_t *cr = cairo_create (surface);
const GdkColor *color = GuiResources::getColor (mode_, type_);

DlgPoint l[2];
Expand Down
6 changes: 2 additions & 4 deletions src/dlgedit/dlg_arrow.h
@@ -1,6 +1,4 @@
/*
$Id: dlg_arrow.h,v 1.1 2004/07/25 15:52:22 ksterker Exp $
Copyright (C) 2002 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Expand Down Expand Up @@ -62,11 +60,11 @@ class DlgArrow : public DlgNode
/**
* Draw this node to the given surface with the specified offset.
* The node's current mode determines the color thw node is drawn with.
* @param surface the GdkPixmap to draw to
* @param surface the cairo_surface_t to draw to
* @param offset the DlgPoint to use as offset
* @param widget the GtkWidget to update after drawing
*/
void draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget);
void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget);

/**
* Init the Arrow from a file. The file to load from is a global
Expand Down
4 changes: 2 additions & 2 deletions src/dlgedit/dlg_circle.cc
Expand Up @@ -78,9 +78,9 @@ bool DlgCircle::hasChild (DlgNode *child)
}

// draw the circle
void DlgCircle::draw (GdkPixmap *surface, DlgPoint &os, GtkWidget *widget)
void DlgCircle::draw (cairo_surface_t *surface, DlgPoint &os, GtkWidget *widget)
{
cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE(surface));
cairo_t *cr = cairo_create (surface);

// get the color and fill for drawing the circle
const GdkColor *gc = GuiResources::getColor (mode_, type_);
Expand Down
6 changes: 2 additions & 4 deletions src/dlgedit/dlg_circle.h
@@ -1,6 +1,4 @@
/*
$Id: dlg_circle.h,v 1.1 2004/07/25 15:52:22 ksterker Exp $
Copyright (C) 2002/2003 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Expand Down Expand Up @@ -110,11 +108,11 @@ class DlgCircle : public DlgNode
/**
* Draw this node to the given surface with the specified offset.
* The node's current mode determines the color thw node is drawn with.
* @param surface the GdkPixmap to draw to
* @param surface the cairo_surface_t to draw to
* @param offset the DlgPoint to use as offset
* @param widget the GtkWidget to update after drawing
*/
void draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget);
void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget);

/**
* Get the contents of this node.
Expand Down
4 changes: 2 additions & 2 deletions src/dlgedit/dlg_module.cc
Expand Up @@ -280,9 +280,9 @@ void DlgModule::setChanged (bool changed)
}

// draw the module
void DlgModule::draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget)
void DlgModule::draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget)
{
cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE(surface));
cairo_t *cr = cairo_create (surface);

// get the color for drawing the circle
const GdkColor *gc = GuiResources::getColor (mode_, type_);
Expand Down
4 changes: 2 additions & 2 deletions src/dlgedit/dlg_module.h
Expand Up @@ -92,11 +92,11 @@ class DlgModule : public DlgNode
/**
* Draw this node to the given surface with the specified offset.
* The node's current mode determines the color thw node is drawn with.
* @param surface the GdkPixmap to draw to
* @param surface the cairo_surface_t to draw to
* @param offset the DlgPoint to use as offset
* @param widget the GtkWidget to update after drawing
*/
void draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget);
void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget);
//@}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dlgedit/dlg_node.cc
Expand Up @@ -151,7 +151,7 @@ void DlgNode::removePrev (DlgNode *node)
}

// draw the node (with a certain mode)
void DlgNode::draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget, mode_type m)
void DlgNode::draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget, mode_type m)
{
// change the mode temporarily
mode_type oldMode = mode_;
Expand Down
10 changes: 4 additions & 6 deletions src/dlgedit/dlg_node.h
@@ -1,6 +1,4 @@
/*
$Id: dlg_node.h,v 1.1 2004/07/25 15:52:23 ksterker Exp $
Copyright (C) 2002/2003 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Expand Down Expand Up @@ -128,20 +126,20 @@ class DlgNode : public DlgNodeGfx
/**
* Draw this node to the given surface. During drawing, the mode is
* temporarily changed to the given mode.
* @param surface the GdkPixmap to draw to
* @param surface the cairo_surface_t to draw to
* @param offset the DlgPoint to use as offset
* @param widget the GtkWidget to update after drawing
* @param mode the new mode of the node
*/
void draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget, mode_type mode);
void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget, mode_type mode);

/**
* Draw this node to the given surface.
* @param surface the GdkPixmap to draw to
* @param surface the cairo_surface_t to draw to
* @param offset the DlgPoint to use as offset
* @param widget the GtkWidget to update after drawing
*/
virtual void draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget)
virtual void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget)
{
}

Expand Down
10 changes: 4 additions & 6 deletions src/dlgedit/dlg_node_gfx.h
@@ -1,6 +1,4 @@
/*
$Id: dlg_node_gfx.h,v 1.1 2004/07/25 15:52:23 ksterker Exp $
Copyright (C) 2002 Kai Sterker <kaisterker@linuxgames.com>
Part of the Adonthell Project http://adonthell.linuxgames.com
Expand Down Expand Up @@ -68,21 +66,21 @@ class DlgNodeGfx : public DlgRect
/**
* Draw this node to the given surface with the specified offset.
* The node's current mode determines the color thw node is drawn with.
* @param surface the GdkPixmap to draw to
* @param surface the cairo_surface_t to draw to
* @param offset the DlgPoint to use as offset
* @param widget the GtkWidget to update after drawing
*/
virtual void draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget) = 0;
virtual void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget) = 0;

/**
* Draw this node to the given surface. During drawing, the mode is
* temporarily changed to the given mode.
* @param surface the GdkPixmap to draw to
* @param surface the cairo_surface_t to draw to
* @param offset the DlgPoint to use as offset
* @param widget the GtkWidget to update after drawing
* @param mode the new mode of the node
*/
virtual void draw (GdkPixmap *surface, DlgPoint &offset, GtkWidget *widget, mode_type mode) = 0;
virtual void draw (cairo_surface_t *surface, DlgPoint &offset, GtkWidget *widget, mode_type mode) = 0;

/**
* Check whether the node is located at the given point.
Expand Down
7 changes: 4 additions & 3 deletions src/dlgedit/gui_graph.cc
Expand Up @@ -67,6 +67,7 @@ GuiGraph::GuiGraph (GtkWidget *paned) : Scrollable ()
// dtor
GuiGraph::~GuiGraph()
{
cairo_surface_destroy(surface);
}

// attach a module
Expand Down Expand Up @@ -753,7 +754,7 @@ void GuiGraph::resizeSurface (GtkWidget *widget)
if (surface) g_object_unref (surface);

// create a new one with the proper size
surface = gdk_pixmap_new (gtk_widget_get_window(widget), allocation.width, allocation.height, -1);
surface = gdk_window_create_similar_surface (gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, allocation.width, allocation.height);

// init the surface
if (GuiResources::getColor (GC_GREY)) clear ();
Expand All @@ -770,7 +771,7 @@ void GuiGraph::clear ()
GtkAllocation allocation;
gtk_widget_get_allocation (graph, &allocation);

cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE(surface));
cairo_t *cr = cairo_create (surface);
gdk_cairo_set_source_color(cr, GuiResources::getColor (GC_GREY));
cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
cairo_fill(cr);
Expand Down Expand Up @@ -803,7 +804,7 @@ void GuiGraph::draw ()
DlgRect rect (t);

// Clear graph
cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE(surface));
cairo_t *cr = cairo_create (surface);
gdk_cairo_set_source_color(cr, GuiResources::getColor (GC_WHITE));
cairo_rectangle(cr, 0, 0, t.width, t.height);
cairo_fill(cr);
Expand Down
4 changes: 2 additions & 2 deletions src/dlgedit/gui_graph.h
Expand Up @@ -257,7 +257,7 @@ class GuiGraph : public Scrollable
* Return a pointer to the drawing surface.
* @return the drawing surface
*/
GdkPixmap *pixmap () { return surface; }
cairo_surface_t *pixmap () { return surface; }
/**
* Return the attached dialogue module.
* @return the DlgModule currently attached to the view
Expand All @@ -281,7 +281,7 @@ class GuiGraph : public Scrollable
DlgModule *module; // Module assigned to the graph view
DlgPoint *offset; // Module's relative position to the origin
GtkWidget *graph; // Drawing Area
GdkPixmap *surface; // Drawing surface
cairo_surface_t *surface; // Drawing surface
DlgRect drawing_area; // Size of the Drawing Area
GuiTooltip *tooltip; // Tooltip for displaying node-text
};
Expand Down
2 changes: 1 addition & 1 deletion src/dlgedit/gui_graph_events.cc
Expand Up @@ -53,7 +53,7 @@ gint expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer data)
GuiGraph *graph = (GuiGraph *) data;

cairo_t *cr = gdk_cairo_create (GDK_DRAWABLE(gtk_widget_get_window(widget)));
gdk_cairo_set_source_pixmap (cr, graph->pixmap (), 0, 0);
cairo_set_source_surface (cr, graph->pixmap (), 0, 0);
gdk_cairo_rectangle (cr, &event->area);
cairo_fill (cr);
cairo_destroy(cr);
Expand Down

0 comments on commit 550f2ac

Please sign in to comment.