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.MonitorG;
26 
27 private import gdk.Display;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtkc.gdk;
32 public  import gtkc.gdktypes;
33 
34 
35 /**
36  * GdkMonitor objects represent the individual outputs that are
37  * associated with a #GdkDisplay. GdkDisplay has APIs to enumerate
38  * monitors with gdk_display_get_monitors() and to find particular
39  * monitors with gdk_display_get_primary_monitor() or
40  * gdk_display_get_monitor_at_window().
41  * 
42  * GdkMonitor was introduced in GTK+ 3.22 and supersedes earlier
43  * APIs in GdkScreen to obtain monitor-related information.
44  */
45 public class MonitorG : ObjectG
46 {
47 	/** the main Gtk struct */
48 	protected GdkMonitor* gdkMonitor;
49 
50 	/** Get the main Gtk struct */
51 	public GdkMonitor* getMonitorGStruct()
52 	{
53 		return gdkMonitor;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected override void* getStruct()
58 	{
59 		return cast(void*)gdkMonitor;
60 	}
61 
62 	protected override void setStruct(GObject* obj)
63 	{
64 		gdkMonitor = cast(GdkMonitor*)obj;
65 		super.setStruct(obj);
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GdkMonitor* gdkMonitor, bool ownedRef = false)
72 	{
73 		this.gdkMonitor = gdkMonitor;
74 		super(cast(GObject*)gdkMonitor, ownedRef);
75 	}
76 
77 
78 	/** */
79 	public static GType getType()
80 	{
81 		return gdk_monitor_get_type();
82 	}
83 
84 	/**
85 	 * Gets the display that this monitor belongs to.
86 	 *
87 	 * Return: the display
88 	 *
89 	 * Since: 3.22
90 	 */
91 	public Display getDisplay()
92 	{
93 		auto p = gdk_monitor_get_display(gdkMonitor);
94 		
95 		if(p is null)
96 		{
97 			return null;
98 		}
99 		
100 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p);
101 	}
102 
103 	/**
104 	 * Retrieves the size and position of an individual monitor within the
105 	 * display coordinate space. The returned geometry is in  ”application pixels”,
106 	 * not in ”device pixels” (see gdk_monitor_get_scale_factor()).
107 	 *
108 	 * Params:
109 	 *     geometry = a #GdkRectangle to be filled wiht the monitor geometry
110 	 *
111 	 * Since: 3.22
112 	 */
113 	public void getGeometry(out GdkRectangle geometry)
114 	{
115 		gdk_monitor_get_geometry(gdkMonitor, &geometry);
116 	}
117 
118 	/**
119 	 * Gets the height in millimeters of the monitor.
120 	 *
121 	 * Return: the physical height of the monitor
122 	 *
123 	 * Since: 3.22
124 	 */
125 	public int getHeightMm()
126 	{
127 		return gdk_monitor_get_height_mm(gdkMonitor);
128 	}
129 
130 	/**
131 	 * Gets the name of the monitor's manufacturer, if available.
132 	 *
133 	 * Return: the name of the manufacturer, or %NULL
134 	 */
135 	public string getManufacturer()
136 	{
137 		return Str.toString(gdk_monitor_get_manufacturer(gdkMonitor));
138 	}
139 
140 	/**
141 	 * Gets the a string identifying the monitor model, if available.
142 	 *
143 	 * Return: the monitor model, or %NULL
144 	 */
145 	public string getModel()
146 	{
147 		return Str.toString(gdk_monitor_get_model(gdkMonitor));
148 	}
149 
150 	/**
151 	 * Gets the refresh rate of the monitor, if available.
152 	 *
153 	 * The value is in milli-Hertz, so a refresh rate of 60Hz
154 	 * is returned as 60000.
155 	 *
156 	 * Return: the refresh rate in milli-Hertz, or 0
157 	 *
158 	 * Since: 3.22
159 	 */
160 	public int getRefreshRate()
161 	{
162 		return gdk_monitor_get_refresh_rate(gdkMonitor);
163 	}
164 
165 	/**
166 	 * Gets the internal scale factor that maps from monitor coordinates
167 	 * to the actual device pixels. On traditional systems this is 1, but
168 	 * on very high density outputs this can be a higher value (often 2).
169 	 *
170 	 * This can be used if you want to create pixel based data for a
171 	 * particular monitor, but most of the time you’re drawing to a window
172 	 * where it is better to use gdk_window_get_scale_factor() instead.
173 	 *
174 	 * Return: the scale factor
175 	 *
176 	 * Since: 3.22
177 	 */
178 	public int getScaleFactor()
179 	{
180 		return gdk_monitor_get_scale_factor(gdkMonitor);
181 	}
182 
183 	/**
184 	 * Gets information about the layout of red, green and blue
185 	 * primaries for each pixel in this monitor, if available.
186 	 *
187 	 * Return: the subpixel layout
188 	 *
189 	 * Since: 3.22
190 	 */
191 	public GdkSubpixelLayout getSubpixelLayout()
192 	{
193 		return gdk_monitor_get_subpixel_layout(gdkMonitor);
194 	}
195 
196 	/**
197 	 * Gets the width in millimeters of the monitor.
198 	 *
199 	 * Return: the physical width of the monitor
200 	 *
201 	 * Since: 3.22
202 	 */
203 	public int getWidthMm()
204 	{
205 		return gdk_monitor_get_width_mm(gdkMonitor);
206 	}
207 
208 	/**
209 	 * Retrieves the size and position of the “work area” on a monitor
210 	 * within the display coordinate space. The returned geometry is in
211 	 * ”application pixels”, not in ”device pixels” (see
212 	 * gdk_monitor_get_scale_factor()).
213 	 *
214 	 * The work area should be considered when positioning menus and
215 	 * similar popups, to avoid placing them below panels, docks or other
216 	 * desktop components.
217 	 *
218 	 * Note that not all backends may have a concept of workarea. This
219 	 * function will return the monitor geometry if a workarea is not
220 	 * available, or does not apply.
221 	 *
222 	 * Params:
223 	 *     workarea = a #GdkRectangle to be filled with
224 	 *         the monitor workarea
225 	 *
226 	 * Since: 3.22
227 	 */
228 	public void getWorkarea(out GdkRectangle workarea)
229 	{
230 		gdk_monitor_get_workarea(gdkMonitor, &workarea);
231 	}
232 
233 	/**
234 	 * Gets whether this monitor should be considered primary
235 	 * (see gdk_display_get_primary_monitor()).
236 	 *
237 	 * Return: %TRUE if @monitor is primary
238 	 *
239 	 * Since: 3.22
240 	 */
241 	public bool isPrimary()
242 	{
243 		return gdk_monitor_is_primary(gdkMonitor) != 0;
244 	}
245 
246 	int[string] connectedSignals;
247 
248 	void delegate(MonitorG)[] onInvalidateListeners;
249 	/** */
250 	void addOnInvalidate(void delegate(MonitorG) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
251 	{
252 		if ( "invalidate" !in connectedSignals )
253 		{
254 			Signals.connectData(
255 				this,
256 				"invalidate",
257 				cast(GCallback)&callBackInvalidate,
258 				cast(void*)this,
259 				null,
260 				connectFlags);
261 			connectedSignals["invalidate"] = 1;
262 		}
263 		onInvalidateListeners ~= dlg;
264 	}
265 	extern(C) static void callBackInvalidate(GdkMonitor* monitorgStruct, MonitorG _monitorg)
266 	{
267 		foreach ( void delegate(MonitorG) dlg; _monitorg.onInvalidateListeners )
268 		{
269 			dlg(_monitorg);
270 		}
271 	}
272 }