1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD 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  * gtkD 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 gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gsk.BorderNode;
26 
27 private import gdk.RGBA;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import gsk.RenderNode;
31 private import gsk.RoundedRect;
32 private import gsk.c.functions;
33 public  import gsk.c.types;
34 
35 
36 /**
37  * A render node for a border.
38  */
39 public class BorderNode : RenderNode
40 {
41 	/** the main Gtk struct */
42 	protected GskBorderNode* gskBorderNode;
43 
44 	/** Get the main Gtk struct */
45 	public GskBorderNode* getBorderNodeStruct(bool transferOwnership = false)
46 	{
47 		if (transferOwnership)
48 			ownedRef = false;
49 		return gskBorderNode;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected override void* getStruct()
54 	{
55 		return cast(void*)gskBorderNode;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (GskBorderNode* gskBorderNode, bool ownedRef = false)
62 	{
63 		this.gskBorderNode = gskBorderNode;
64 		super(cast(GskRenderNode*)gskBorderNode, ownedRef);
65 	}
66 
67 
68 	/** */
69 	public static GType getType()
70 	{
71 		return gsk_border_node_get_type();
72 	}
73 
74 	/**
75 	 * Creates a `GskRenderNode` that will stroke a border rectangle inside the
76 	 * given @outline.
77 	 *
78 	 * The 4 sides of the border can have different widths and colors.
79 	 *
80 	 * Params:
81 	 *     outline = a #GskRoundedRect describing the outline of the border
82 	 *     borderWidth = the stroke width of the border on
83 	 *         the top, right, bottom and left side respectively.
84 	 *     borderColor = the color used on the top, right,
85 	 *         bottom and left side.
86 	 *
87 	 * Returns: A new `GskRenderNode`
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this(RoundedRect outline, float[4] borderWidth, RGBA[4] borderColor)
92 	{
93 		GdkRGBA[] borderColorArray = new GdkRGBA[borderColor.length];
94 		for ( int i = 0; i < borderColor.length; i++ )
95 		{
96 			borderColorArray[i] = *(borderColor[i].getRGBAStruct());
97 		}
98 
99 		auto __p = gsk_border_node_new((outline is null) ? null : outline.getRoundedRectStruct(), borderWidth.ptr, borderColorArray.ptr);
100 
101 		if(__p is null)
102 		{
103 			throw new ConstructionException("null returned by new");
104 		}
105 
106 		this(cast(GskBorderNode*) __p);
107 	}
108 
109 	/**
110 	 * Retrieves the colors of the border.
111 	 *
112 	 * Returns: an array of 4 #GdkRGBA structs
113 	 *     for the top, right, bottom and left color of the border
114 	 */
115 	public RGBA getColors()
116 	{
117 		auto __p = gsk_border_node_get_colors(cast(GskRenderNode*)gskBorderNode);
118 
119 		if(__p is null)
120 		{
121 			return null;
122 		}
123 
124 		return ObjectG.getDObject!(RGBA)(cast(GdkRGBA*) __p);
125 	}
126 
127 	/**
128 	 * Retrieves the outline of the border.
129 	 *
130 	 * Returns: the outline of the border
131 	 */
132 	public RoundedRect getOutline()
133 	{
134 		auto __p = gsk_border_node_get_outline(cast(GskRenderNode*)gskBorderNode);
135 
136 		if(__p is null)
137 		{
138 			return null;
139 		}
140 
141 		return ObjectG.getDObject!(RoundedRect)(cast(GskRoundedRect*) __p);
142 	}
143 
144 	/**
145 	 * Retrieves the stroke widths of the border.
146 	 *
147 	 * Returns: an array of 4 floats
148 	 *     for the top, right, bottom and left stroke width of the border,
149 	 *     respectively
150 	 */
151 	public float[4] getWidths()
152 	{
153 		auto __p = gsk_border_node_get_widths(cast(GskRenderNode*)gskBorderNode);
154 
155 		return __p[0 .. 4];
156 	}
157 }