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