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