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.Visual; 26 27 private import gdk.Screen; 28 private import glib.ListG; 29 private import gobject.ObjectG; 30 private import gtkc.gdk; 31 public import gtkc.gdktypes; 32 33 34 /** 35 * A #GdkVisual contains information about 36 * a particular visual. 37 */ 38 public class Visual : ObjectG 39 { 40 /** the main Gtk struct */ 41 protected GdkVisual* gdkVisual; 42 43 /** Get the main Gtk struct */ 44 public GdkVisual* getVisualStruct() 45 { 46 return gdkVisual; 47 } 48 49 /** the main Gtk struct as a void* */ 50 protected override void* getStruct() 51 { 52 return cast(void*)gdkVisual; 53 } 54 55 protected override void setStruct(GObject* obj) 56 { 57 gdkVisual = cast(GdkVisual*)obj; 58 super.setStruct(obj); 59 } 60 61 /** 62 * Sets our main struct and passes it to the parent class. 63 */ 64 public this (GdkVisual* gdkVisual, bool ownedRef = false) 65 { 66 this.gdkVisual = gdkVisual; 67 super(cast(GObject*)gdkVisual, ownedRef); 68 } 69 70 /** 71 */ 72 73 public static GType getType() 74 { 75 return gdk_visual_get_type(); 76 } 77 78 /** 79 * Get the visual with the most available colors for the default 80 * GDK screen. The return value should not be freed. 81 * 82 * Return: best visual 83 */ 84 public static Visual getBest() 85 { 86 auto p = gdk_visual_get_best(); 87 88 if(p is null) 89 { 90 return null; 91 } 92 93 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 94 } 95 96 /** 97 * Get the best available depth for the default GDK screen. “Best” 98 * means “largest,” i.e. 32 preferred over 24 preferred over 8 bits 99 * per pixel. 100 * 101 * Return: best available depth 102 */ 103 public static int getBestDepth() 104 { 105 return gdk_visual_get_best_depth(); 106 } 107 108 /** 109 * Return the best available visual type for the default GDK screen. 110 * 111 * Return: best visual type 112 */ 113 public static GdkVisualType getBestType() 114 { 115 return gdk_visual_get_best_type(); 116 } 117 118 /** 119 * Combines gdk_visual_get_best_with_depth() and 120 * gdk_visual_get_best_with_type(). 121 * 122 * Params: 123 * depth = a bit depth 124 * visualType = a visual type 125 * 126 * Return: best visual with both @depth 127 * and @visual_type, or %NULL if none 128 */ 129 public static Visual getBestWithBoth(int depth, GdkVisualType visualType) 130 { 131 auto p = gdk_visual_get_best_with_both(depth, visualType); 132 133 if(p is null) 134 { 135 return null; 136 } 137 138 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 139 } 140 141 /** 142 * Get the best visual with depth @depth for the default GDK screen. 143 * Color visuals and visuals with mutable colormaps are preferred 144 * over grayscale or fixed-colormap visuals. The return value should 145 * not be freed. %NULL may be returned if no visual supports @depth. 146 * 147 * Params: 148 * depth = a bit depth 149 * 150 * Return: best visual for the given depth 151 */ 152 public static Visual getBestWithDepth(int depth) 153 { 154 auto p = gdk_visual_get_best_with_depth(depth); 155 156 if(p is null) 157 { 158 return null; 159 } 160 161 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 162 } 163 164 /** 165 * Get the best visual of the given @visual_type for the default GDK screen. 166 * Visuals with higher color depths are considered better. The return value 167 * should not be freed. %NULL may be returned if no visual has type 168 * @visual_type. 169 * 170 * Params: 171 * visualType = a visual type 172 * 173 * Return: best visual of the given type 174 */ 175 public static Visual getBestWithType(GdkVisualType visualType) 176 { 177 auto p = gdk_visual_get_best_with_type(visualType); 178 179 if(p is null) 180 { 181 return null; 182 } 183 184 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 185 } 186 187 /** 188 * Get the system’s default visual for the default GDK screen. 189 * This is the visual for the root window of the display. 190 * The return value should not be freed. 191 * 192 * Return: system visual 193 */ 194 public static Visual getSystem() 195 { 196 auto p = gdk_visual_get_system(); 197 198 if(p is null) 199 { 200 return null; 201 } 202 203 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 204 } 205 206 /** 207 * Returns the number of significant bits per red, green and blue value. 208 * 209 * Return: The number of significant bits per color value for @visual. 210 * 211 * Since: 2.22 212 */ 213 public int getBitsPerRgb() 214 { 215 return gdk_visual_get_bits_per_rgb(gdkVisual); 216 } 217 218 /** 219 * Obtains values that are needed to calculate blue pixel values in TrueColor 220 * and DirectColor. The “mask” is the significant bits within the pixel. 221 * The “shift” is the number of bits left we must shift a primary for it 222 * to be in position (according to the "mask"). Finally, "precision" refers 223 * to how much precision the pixel value contains for a particular primary. 224 * 225 * Params: 226 * mask = A pointer to a #guint32 to be filled in, or %NULL 227 * shift = A pointer to a #gint to be filled in, or %NULL 228 * precision = A pointer to a #gint to be filled in, or %NULL 229 * 230 * Since: 2.22 231 */ 232 public void getBluePixelDetails(out uint mask, out int shift, out int precision) 233 { 234 gdk_visual_get_blue_pixel_details(gdkVisual, &mask, &shift, &precision); 235 } 236 237 /** 238 * Returns the byte order of this visual. 239 * 240 * Return: A #GdkByteOrder stating the byte order of @visual. 241 * 242 * Since: 2.22 243 */ 244 public GdkByteOrder getByteOrder() 245 { 246 return gdk_visual_get_byte_order(gdkVisual); 247 } 248 249 /** 250 * Returns the size of a colormap for this visual. 251 * 252 * Return: The size of a colormap that is suitable for @visual. 253 * 254 * Since: 2.22 255 */ 256 public int getColormapSize() 257 { 258 return gdk_visual_get_colormap_size(gdkVisual); 259 } 260 261 /** 262 * Returns the bit depth of this visual. 263 * 264 * Return: The bit depth of this visual. 265 * 266 * Since: 2.22 267 */ 268 public int getDepth() 269 { 270 return gdk_visual_get_depth(gdkVisual); 271 } 272 273 /** 274 * Obtains values that are needed to calculate green pixel values in TrueColor 275 * and DirectColor. The “mask” is the significant bits within the pixel. 276 * The “shift” is the number of bits left we must shift a primary for it 277 * to be in position (according to the "mask"). Finally, "precision" refers 278 * to how much precision the pixel value contains for a particular primary. 279 * 280 * Params: 281 * mask = A pointer to a #guint32 to be filled in, or %NULL 282 * shift = A pointer to a #gint to be filled in, or %NULL 283 * precision = A pointer to a #gint to be filled in, or %NULL 284 * 285 * Since: 2.22 286 */ 287 public void getGreenPixelDetails(out uint mask, out int shift, out int precision) 288 { 289 gdk_visual_get_green_pixel_details(gdkVisual, &mask, &shift, &precision); 290 } 291 292 /** 293 * Obtains values that are needed to calculate red pixel values in TrueColor 294 * and DirectColor. The “mask” is the significant bits within the pixel. 295 * The “shift” is the number of bits left we must shift a primary for it 296 * to be in position (according to the "mask"). Finally, "precision" refers 297 * to how much precision the pixel value contains for a particular primary. 298 * 299 * Params: 300 * mask = A pointer to a #guint32 to be filled in, or %NULL 301 * shift = A pointer to a #gint to be filled in, or %NULL 302 * precision = A pointer to a #gint to be filled in, or %NULL 303 * 304 * Since: 2.22 305 */ 306 public void getRedPixelDetails(out uint mask, out int shift, out int precision) 307 { 308 gdk_visual_get_red_pixel_details(gdkVisual, &mask, &shift, &precision); 309 } 310 311 /** 312 * Gets the screen to which this visual belongs 313 * 314 * Return: the screen to which this visual belongs. 315 * 316 * Since: 2.2 317 */ 318 public Screen getScreen() 319 { 320 auto p = gdk_visual_get_screen(gdkVisual); 321 322 if(p is null) 323 { 324 return null; 325 } 326 327 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 328 } 329 330 /** 331 * Returns the type of visual this is (PseudoColor, TrueColor, etc). 332 * 333 * Return: A #GdkVisualType stating the type of @visual. 334 * 335 * Since: 2.22 336 */ 337 public GdkVisualType getVisualType() 338 { 339 return gdk_visual_get_visual_type(gdkVisual); 340 } 341 342 /** 343 * Lists the available visuals for the default screen. 344 * (See gdk_screen_list_visuals()) 345 * A visual describes a hardware image data format. 346 * For example, a visual might support 24-bit color, or 8-bit color, 347 * and might expect pixels to be in a certain format. 348 * 349 * Call g_list_free() on the return value when you’re finished with it. 350 * 351 * Return: a list of visuals; the list must be freed, but not its contents 352 */ 353 public static ListG listVisuals() 354 { 355 auto p = gdk_list_visuals(); 356 357 if(p is null) 358 { 359 return null; 360 } 361 362 return new ListG(cast(GList*) p); 363 } 364 365 /** 366 * This function returns the available bit depths for the default 367 * screen. It’s equivalent to listing the visuals 368 * (gdk_list_visuals()) and then looking at the depth field in each 369 * visual, removing duplicates. 370 * 371 * The array returned by this function should not be freed. 372 * 373 * Params: 374 * depths = return 375 * location for available depths 376 * count = return location for number of available depths 377 */ 378 public static void queryDepths(out int[] depths) 379 { 380 int* outdepths = null; 381 int count; 382 383 gdk_query_depths(&outdepths, &count); 384 385 depths = outdepths[0 .. count]; 386 } 387 388 /** 389 * This function returns the available visual types for the default 390 * screen. It’s equivalent to listing the visuals 391 * (gdk_list_visuals()) and then looking at the type field in each 392 * visual, removing duplicates. 393 * 394 * The array returned by this function should not be freed. 395 * 396 * Params: 397 * visualTypes = return 398 * location for the available visual types 399 * count = return location for the number of available visual types 400 */ 401 public static void queryVisualTypes(out GdkVisualType[] visualTypes) 402 { 403 GdkVisualType* outvisualTypes = null; 404 int count; 405 406 gdk_query_visual_types(&outvisualTypes, &count); 407 408 visualTypes = outvisualTypes[0 .. count]; 409 } 410 }