1 /*
2  * This file is part of d-dazzle.
3  *
4  * d-dazzle is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * d-dazzle is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with d-dazzle; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 module dazzle.GraphLineRenderer;
20 
21 private import dazzle.GraphRendererIF;
22 private import dazzle.GraphRendererT;
23 private import dazzle.c.functions;
24 public  import dazzle.c.types;
25 private import gdk.RGBA;
26 private import glib.ConstructionException;
27 private import glib.Str;
28 private import gobject.ObjectG;
29 
30 
31 /** */
32 public class GraphLineRenderer : ObjectG, GraphRendererIF
33 {
34 	/** the main Gtk struct */
35 	protected DzlGraphLineRenderer* dzlGraphLineRenderer;
36 
37 	/** Get the main Gtk struct */
38 	public DzlGraphLineRenderer* getGraphLineRendererStruct(bool transferOwnership = false)
39 	{
40 		if (transferOwnership)
41 			ownedRef = false;
42 		return dzlGraphLineRenderer;
43 	}
44 
45 	/** the main Gtk struct as a void* */
46 	protected override void* getStruct()
47 	{
48 		return cast(void*)dzlGraphLineRenderer;
49 	}
50 
51 	/**
52 	 * Sets our main struct and passes it to the parent class.
53 	 */
54 	public this (DzlGraphLineRenderer* dzlGraphLineRenderer, bool ownedRef = false)
55 	{
56 		this.dzlGraphLineRenderer = dzlGraphLineRenderer;
57 		super(cast(GObject*)dzlGraphLineRenderer, ownedRef);
58 	}
59 
60 	// add the GraphRenderer capabilities
61 	mixin GraphRendererT!(DzlGraphLineRenderer);
62 
63 
64 	/** */
65 	public static GType getType()
66 	{
67 		return dzl_graph_view_line_renderer_get_type();
68 	}
69 
70 	/** */
71 	public this()
72 	{
73 		auto p = dzl_graph_view_line_renderer_new();
74 
75 		if(p is null)
76 		{
77 			throw new ConstructionException("null returned by new");
78 		}
79 
80 		this(cast(DzlGraphLineRenderer*) p, true);
81 	}
82 
83 	/** */
84 	public RGBA getStrokeColorRgba()
85 	{
86 		auto p = dzl_graph_view_line_renderer_get_stroke_color_rgba(dzlGraphLineRenderer);
87 
88 		if(p is null)
89 		{
90 			return null;
91 		}
92 
93 		return ObjectG.getDObject!(RGBA)(cast(GdkRGBA*) p);
94 	}
95 
96 	/** */
97 	public void setStrokeColor(string strokeColor)
98 	{
99 		dzl_graph_view_line_renderer_set_stroke_color(dzlGraphLineRenderer, Str.toStringz(strokeColor));
100 	}
101 
102 	/** */
103 	public void setStrokeColorRgba(RGBA strokeColorRgba)
104 	{
105 		dzl_graph_view_line_renderer_set_stroke_color_rgba(dzlGraphLineRenderer, (strokeColorRgba is null) ? null : strokeColorRgba.getRGBAStruct());
106 	}
107 }