Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gdk::Visual Class Reference

A GdkVisual C++ wrapper class. More...

#include <xfc/gdk/visual.hh>

Inheritance diagram for Xfc::Gdk::Visual:

Xfc::G::Object Xfc::G::TypeInstance Xfc::Trackable List of all members.

Public Member Functions

Constructors
Accessors

Static Public Member Functions

Accessors
Methods

Protected Member Functions

Constructors

Detailed Description

A GdkVisual C++ wrapper class.

A Visual describes a particular video hardware display format. It includes information about the number of bits used for each color, the way the bits are translated into an RGB value for display, and the way the bits are stored in memory. For example, a piece of display hardware might support 24-bit color, 16-bit color, or 8-bit color; meaning 24/16/8-bit pixel sizes. For a given pixel size, pixels can be in different formats; for example the "red" element of an RGB pixel may be in the top 8 bits of the pixel, or may be in the lower 4 bits.

Usually you can avoid thinking about visuals in GTK+. Visuals are useful to interpret the contents of a Gdk::Image, but you should avoid Gdk::Image precisely because its contents depend on the display hardware; use Gdk::Pixbuf instead, for all but the most low-level purposes. Also, anytime you provide a Gdk::Colormap, the visual is implied as part of the colormap (Gdk::Colormap::get_visual()), so you won't have to provide a visual in addition.

There are several standard visuals. The visual returned by get_system() is the system's default visual. A number of methods are provided for determining the "best" available visual. For the purposes of making this determination, higher bit depths are considered better, and for visuals of the same bit depth, VISUAL_PSEUDO_COLOR is preferred at 8bpp, otherwise, the visual types are ranked in the order of (highest to lowest) VISUAL_DIRECT_COLOR, VISUAL_TRUE_COLOR, VISUAL_PSEUDO_COLOR, VISUAL_STATIC_COLOR, VISUAL_GRAYSCALE, then VISUAL_STATIC_GRAY.


Constructor & Destructor Documentation

Xfc::Gdk::Visual::Visual GdkVisual *  visual,
bool  owns_reference = true
[explicit, protected]
 

Construct a new Visual from an existing GdkVisual.

Parameters:
visual A pointer to a GdkVisual.
owns_reference Set false if the initial reference count is floating, set true if it's not.
The visual can be a newly created GdkVisual or an existing GdkVisual. (see G::Object::Object).


Member Function Documentation

int Xfc::Gdk::Visual::blue_shift  )  const
 

Returns the blue_shift.

The blue_shift and blue_prec give an alternate presentation of the information in blue_mask (see example in red_shift()).

int Xfc::Gdk::Visual::colormap_size  )  const
 

Returns the number of entries in the colormap, for visuals of type VISUAL_PSEUDO_COLOR or VISUAL_GRAY_SCALE, for other visual types, it is the number of possible levels per color component.

If the visual has different numbers of levels for different components, the value of this field is undefined.

const Visual* Xfc::Gdk::Visual::get_best int  depth,
VisualType  visual_type
[static]
 

Get the best visual of the given visual_type with depth depth for the default Gdk::Screen.

Parameters:
depth A bit depth.
visual_type A visual type.
Returns:
The best visual with both depth and visual_type, or null if none.

const Visual* Xfc::Gdk::Visual::get_best VisualType  visual_type  )  [static]
 

Get the best visual of the given visual_type for the default Gdk::Screen.

Parameters:
visual_type A visual type.
Returns:
The best visual of the given type; or null if no visual has type visual_type.
Visuals with higher color depths are considered better.

const Visual* Xfc::Gdk::Visual::get_best int  depth  )  [static]
 

Get the best visual with depth depth for the default Gdk::Screen.

Parameters:
depth A bit depth.
Returns:
The best visual for the given depth, or null if no visual supports depth.
Color visuals and visuals with mutable colormaps are preferred over grayscale or fixed-colormap visuals. Null may be returned if no visual supports depth.

int Xfc::Gdk::Visual::get_best_depth  )  const
 

Get the best available depth for the default Gdk::Screen.

Returns:
The best available depth.
"Best" means "largest," i.e. 32 preferred over 24 preferred over 8 bits per pixel.

VisualType Xfc::Gdk::Visual::get_best_type  )  const
 

Return the best available visual type for the default Gdk::Screen.

Returns:
The best visual type.

const Visual* Xfc::Gdk::Visual::get_system  )  [static]
 

Returns the system's default visual for the default Gdk::Screen.

This is the visual for the root window of the display.

int Xfc::Gdk::Visual::green_shift  )  const
 

Returns the green_shift.

The green_shift and green_prec give an alternate presentation of the information in green_mask (see example in red_shift()).

bool Xfc::Gdk::Visual::list_visuals std::vector< const Visual * > &  visuals  )  [static]
 

Lists the available visuals for the default screen (see Gdk::Screen::list_visuals()).

Parameters:
visuals A reference to a vector of const Visual* to hold the list of available visuals.
Returns:
true if the vector is not empty.
A visual describes a hardware image data format. For example, a visual might support 24-bit color, or 8-bit color, and might expect pixels to be in a certain format.

std::vector<int> Xfc::Gdk::Visual::query_depths  )  [static]
 

This method returns the available bit depths for the default screen.

Returns:
A vector of int holding the available depths.
It's equivalent to listing the visuals (list_visuals()) and then looking at the depth() field in each visual, removing duplicates.

bool Xfc::Gdk::Visual::query_visual_types std::vector< VisualType > &  visual_types  )  [static]
 

This method returns the available visual types for the default screen.

Parameters:
visual_types A reference to a vector of VisualType to hold the available visual types.
Returns:
true if the vector is not empty.
It's equivalent to listing the visuals (list_visuals()) and then looking at the type() field in each visual, removing duplicates.

unsigned int Xfc::Gdk::Visual::red_mask  )  const
 

Returns a mask giving the bits in a pixel value that correspond to the red field.

Significant only for VISUAL_PSEUDOCOLOR and VISUAL_DIRECTCOLOR.

int Xfc::Gdk::Visual::red_shift  )  const
 

Returns the red_shift.

The red_shift() and red_prec() give an alternate presentation of the information in red_mask(). The red_mask is a contiguous sequence of red_prec bits starting at bit number red_shift.

Example: Constructing a pixel value out of three 16 bit color values.

             unsigned int
             pixel_from_rgb(const Gdk::Visual& visual, unsigned short r, unsigned short b, unsigned short g)
             {
                return ((r >> (16 - visual.red_prec()))   << visual->red_shift()) |
                       ((g >> (16 - visual.green_prec())) << visual->green_shift()) |
                       ((r >> (16 - visual.blue_prec()))  << visual->blue_shift());
             }


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3