Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gdk::Visual Class Reference

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

`#include <inti/gdk/visual.h>`

Inheritance diagram for Inti::Gdk::Visual:

List of all members.

## Public Member Functions

Constructors

- virtual ~Visual ()
    Destructor.

Accessors

- GdkVisual * gdk_visual () const
    Get a pointer to the GdkVisual structure.
- GdkVisualClass * gdk_visual_class () const
    Get a pointer to the GdkVisualClass structure.
- operator GdkVisual * () const
    Conversion operator; safely converts a Visual to a GdkVisual pointer.
- VisualType type () const
    Returns the type of this visual.
- int depth () const
    Returns the number of bits per pixel.
- ByteOrder byte_order () const
    Returns the byte-order for this visual.
- int 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.
- int bits_per_rgb () const
    Returns the number of significant bits per red, green, or blue when specifying colors for this visual (for instance, for Gdk::Colormap::alloc_color()).
- unsigned int red_mask () const
    Returns a mask giving the bits in a pixel value that correspond to the red field.
- int red_shift () const
    Returns the red_shift.
- int red_prec () const
    Returns the red_prec (see red_shift()).
- unsigned int green_mask () const
    Returns a mask giving the bits in a pixel value that correspond to the green field.
- int green_shift () const
    Returns the green_shift.
- int green_prec () const
    Returns the green_prec (see green_shift()).
- unsigned int blue_mask () const
    Returns a mask giving the bits in a pixel value that correspond to the blue field.
- int blue_shift () const
    Returns the blue_shift.
- int blue_prec () const
    Returns the blue_prec (see blue_shift()).
- int get_best_depth () const
    Get the best available depth for the default Gdk::Screen.
- VisualType get_best_type () const
    Return the best available visual type for the default Gdk::Screen.

## Static Public Member Functions

- const Visual * get_best ()
    Returns the visual with the most available colors for the default Gdk::Screen.
- const Visual * get_best (int depth)
    Get the best visual with depth depth for the default Gdk::Screen.
- const Visual * get_best (VisualType visual_type)
    Get the best visual of the given visual_type for the default Gdk::Screen.
- const Visual * get_best (int depth, VisualType visual_type)
    Get the best visual of the given visual_type with depth depth for the default Gdk::Screen.
- const Visual * get_system ()
    Returns the system's default visual for the default Gdk::Screen.
- std::vector< int > query_depths ()
    This method returns the available bit depths for the default screen.
- bool query_visual_types (std::vector< VisualType > &visual_types)
    This method returns the available visual types for the default screen.
- bool list_visuals (std::vector< const Visual * > &visuals)
    Lists the available visuals for the default screen (see Gdk::Screen::list_visuals()).

## Protected Member Functions

Constructors

- Visual (GdkVisual *visual, bool reference=true)
    Construct a new Visual from an existing GdkVisual.

## 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

Inti::Gdk::Visual::Visual | ( | GdkVisual * | visual,
|  | bool | reference = true
| ) | `[explicit, protected]`

Construct a new Visual from an existing GdkVisual.

Parameters:

  visual | A pointer to a GdkVisual.
  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 Inti::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 Inti::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* Inti::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* Inti::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* Inti::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 Inti::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 Inti::Gdk::Visual::get_best_type | ( |  | ) | const

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

Returns:
  The best visual type.

const Visual* Inti::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 Inti::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 Inti::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> Inti::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 Inti::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 Inti::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 Inti::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:

- visual.h

Main Page - Footer