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 gdk.MonitorGdk;
26 
27 private import gdk.Display;
28 private import gdk.c.functions;
29 public  import gdk.c.types;
30 private import glib.Str;
31 private import glib.c.functions;
32 private import gobject.ObjectG;
33 private import gobject.Signals;
34 private import std.algorithm;
35 
36 
37 /**
38  * `GdkMonitor` objects represent the individual outputs that are
39  * associated with a `GdkDisplay`.
40  * 
41  * `GdkDisplay` keeps a `GListModel` to enumerate and monitor
42  * monitors with [method@Gdk.Display.get_monitors]. You can use
43  * [method@Gdk.Display.get_monitor_at_surface] to find a particular
44  * monitor.
45  */
46 public class MonitorGdk : ObjectG
47 {
48 	/** the main Gtk struct */
49 	protected GdkMonitor* gdkMonitor;
50 
51 	/** Get the main Gtk struct */
52 	public GdkMonitor* getMonitorGdkStruct(bool transferOwnership = false)
53 	{
54 		if (transferOwnership)
55 			ownedRef = false;
56 		return gdkMonitor;
57 	}
58 
59 	/** the main Gtk struct as a void* */
60 	protected override void* getStruct()
61 	{
62 		return cast(void*)gdkMonitor;
63 	}
64 
65 	/**
66 	 * Sets our main struct and passes it to the parent class.
67 	 */
68 	public this (GdkMonitor* gdkMonitor, bool ownedRef = false)
69 	{
70 		this.gdkMonitor = gdkMonitor;
71 		super(cast(GObject*)gdkMonitor, ownedRef);
72 	}
73 
74 
75 	/** */
76 	public static GType getType()
77 	{
78 		return gdk_monitor_get_type();
79 	}
80 
81 	/**
82 	 * Gets the name of the monitor's connector, if available.
83 	 *
84 	 * Returns: the name of the connector
85 	 */
86 	public string getConnector()
87 	{
88 		return Str.toString(gdk_monitor_get_connector(gdkMonitor));
89 	}
90 
91 	/**
92 	 * Gets the display that this monitor belongs to.
93 	 *
94 	 * Returns: the display
95 	 */
96 	public Display getDisplay()
97 	{
98 		auto __p = gdk_monitor_get_display(gdkMonitor);
99 
100 		if(__p is null)
101 		{
102 			return null;
103 		}
104 
105 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) __p);
106 	}
107 
108 	/**
109 	 * Retrieves the size and position of the monitor within the
110 	 * display coordinate space.
111 	 *
112 	 * The returned geometry is in  ”application pixels”, not in
113 	 * ”device pixels” (see [method@Gdk.Monitor.get_scale_factor]).
114 	 *
115 	 * Params:
116 	 *     geometry = a `GdkRectangle` to be filled with the monitor geometry
117 	 */
118 	public void getGeometry(out GdkRectangle geometry)
119 	{
120 		gdk_monitor_get_geometry(gdkMonitor, &geometry);
121 	}
122 
123 	/**
124 	 * Gets the height in millimeters of the monitor.
125 	 *
126 	 * Returns: the physical height of the monitor
127 	 */
128 	public int getHeightMm()
129 	{
130 		return gdk_monitor_get_height_mm(gdkMonitor);
131 	}
132 
133 	/**
134 	 * Gets the name or PNP ID of the monitor's manufacturer.
135 	 *
136 	 * Note that this value might also vary depending on actual
137 	 * display backend.
138 	 *
139 	 * The PNP ID registry is located at
140 	 * [https://uefi.org/pnp_id_list](https://uefi.org/pnp_id_list).
141 	 *
142 	 * Returns: the name of the manufacturer,
143 	 *     or %NULL
144 	 */
145 	public string getManufacturer()
146 	{
147 		return Str.toString(gdk_monitor_get_manufacturer(gdkMonitor));
148 	}
149 
150 	/**
151 	 * Gets the string identifying the monitor model, if available.
152 	 *
153 	 * Returns: the monitor model, or %NULL
154 	 */
155 	public string getModel()
156 	{
157 		return Str.toString(gdk_monitor_get_model(gdkMonitor));
158 	}
159 
160 	/**
161 	 * Gets the refresh rate of the monitor, if available.
162 	 *
163 	 * The value is in milli-Hertz, so a refresh rate of 60Hz
164 	 * is returned as 60000.
165 	 *
166 	 * Returns: the refresh rate in milli-Hertz, or 0
167 	 */
168 	public int getRefreshRate()
169 	{
170 		return gdk_monitor_get_refresh_rate(gdkMonitor);
171 	}
172 
173 	/**
174 	 * Gets the internal scale factor that maps from monitor coordinates
175 	 * to device pixels.
176 	 *
177 	 * On traditional systems this is 1, but on very high density outputs
178 	 * it can be a higher value (often 2).
179 	 *
180 	 * This can be used if you want to create pixel based data for a
181 	 * particular monitor, but most of the time you’re drawing to a surface
182 	 * where it is better to use [method@Gdk.Surface.get_scale_factor] instead.
183 	 *
184 	 * Returns: the scale factor
185 	 */
186 	public int getScaleFactor()
187 	{
188 		return gdk_monitor_get_scale_factor(gdkMonitor);
189 	}
190 
191 	/**
192 	 * Gets information about the layout of red, green and blue
193 	 * primaries for pixels.
194 	 *
195 	 * Returns: the subpixel layout
196 	 */
197 	public GdkSubpixelLayout getSubpixelLayout()
198 	{
199 		return gdk_monitor_get_subpixel_layout(gdkMonitor);
200 	}
201 
202 	/**
203 	 * Gets the width in millimeters of the monitor.
204 	 *
205 	 * Returns: the physical width of the monitor
206 	 */
207 	public int getWidthMm()
208 	{
209 		return gdk_monitor_get_width_mm(gdkMonitor);
210 	}
211 
212 	/**
213 	 * Returns %TRUE if the @monitor object corresponds to a
214 	 * physical monitor.
215 	 *
216 	 * The @monitor becomes invalid when the physical monitor
217 	 * is unplugged or removed.
218 	 *
219 	 * Returns: %TRUE if the object corresponds to a physical monitor
220 	 */
221 	public bool isValid()
222 	{
223 		return gdk_monitor_is_valid(gdkMonitor) != 0;
224 	}
225 
226 	/**
227 	 * Emitted when the output represented by @monitor gets disconnected.
228 	 */
229 	gulong addOnInvalidate(void delegate(MonitorGdk) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
230 	{
231 		return Signals.connect(this, "invalidate", dlg, connectFlags ^ ConnectFlags.SWAPPED);
232 	}
233 }