Blame gdk/gdkvisual.c

Packit 98cdb6
/* GDK - The GIMP Drawing Kit
Packit 98cdb6
 * gdkvisual.c
Packit 98cdb6
 * 
Packit 98cdb6
 * Copyright 2001 Sun Microsystems Inc. 
Packit 98cdb6
 *
Packit 98cdb6
 * Erwann Chenede <erwann.chenede@sun.com>
Packit 98cdb6
 *
Packit 98cdb6
 * This library is free software; you can redistribute it and/or
Packit 98cdb6
 * modify it under the terms of the GNU Library General Public
Packit 98cdb6
 * License as published by the Free Software Foundation; either
Packit 98cdb6
 * version 2 of the License, or (at your option) any later version.
Packit 98cdb6
 *
Packit 98cdb6
 * This library is distributed in the hope that it will be useful,
Packit 98cdb6
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 98cdb6
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 98cdb6
 * Library General Public License for more details.
Packit 98cdb6
 *
Packit 98cdb6
 * You should have received a copy of the GNU Library General Public
Packit 98cdb6
 * License along with this library; if not, write to the
Packit 98cdb6
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit 98cdb6
 * Boston, MA 02111-1307, USA.
Packit 98cdb6
 */
Packit 98cdb6
Packit 98cdb6
#include "config.h"
Packit 98cdb6
#include "gdkvisual.h"
Packit 98cdb6
#include "gdkscreen.h"
Packit 98cdb6
#include "gdkalias.h"
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_list_visuals:
Packit 98cdb6
 * 
Packit 98cdb6
 * Lists the available visuals for the default screen.
Packit 98cdb6
 * (See gdk_screen_list_visuals())
Packit 98cdb6
 * A visual describes a hardware image data format.
Packit 98cdb6
 * For example, a visual might support 24-bit color, or 8-bit color,
Packit 98cdb6
 * and might expect pixels to be in a certain format.
Packit 98cdb6
 *
Packit 98cdb6
 * Call g_list_free() on the return value when you're finished with it.
Packit 98cdb6
 * 
Packit 98cdb6
 * Return value: (transfer container) (element-type GdkVisual):
Packit 98cdb6
 *     a list of visuals; the list must be freed, but not its contents
Packit 98cdb6
 **/
Packit 98cdb6
GList*
Packit 98cdb6
gdk_list_visuals (void)
Packit 98cdb6
{
Packit 98cdb6
  return gdk_screen_list_visuals (gdk_screen_get_default ());
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_system:
Packit 98cdb6
 * 
Packit 98cdb6
 * Get the system's default visual for the default GDK screen.
Packit 98cdb6
 * This is the visual for the root window of the display.
Packit 98cdb6
 * The return value should not be freed.
Packit 98cdb6
 * 
Packit 98cdb6
 * Return value: (transfer none): system visual
Packit 98cdb6
 **/
Packit 98cdb6
GdkVisual*
Packit 98cdb6
gdk_visual_get_system (void)
Packit 98cdb6
{
Packit 98cdb6
  return gdk_screen_get_system_visual (gdk_screen_get_default());
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_visual_type:
Packit 98cdb6
 * @visual: A #GdkVisual.
Packit 98cdb6
 *
Packit 98cdb6
 * Returns the type of visual this is (PseudoColor, TrueColor, etc).
Packit 98cdb6
 *
Packit 98cdb6
 * Return value: A #GdkVisualType stating the type of @visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
GdkVisualType
Packit 98cdb6
gdk_visual_get_visual_type (GdkVisual *visual)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
Packit 98cdb6
Packit 98cdb6
  return visual->type;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_depth:
Packit 98cdb6
 * @visual: A #GdkVisual.
Packit 98cdb6
 *
Packit 98cdb6
 * Returns the bit depth of this visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Return value: The bit depth of this visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
gint
Packit 98cdb6
gdk_visual_get_depth (GdkVisual *visual)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
Packit 98cdb6
Packit 98cdb6
  return visual->depth;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_byte_order:
Packit 98cdb6
 * @visual: A #GdkVisual.
Packit 98cdb6
 *
Packit 98cdb6
 * Returns the byte order of this visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Return value: A #GdkByteOrder stating the byte order of @visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
GdkByteOrder
Packit 98cdb6
gdk_visual_get_byte_order (GdkVisual *visual)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
Packit 98cdb6
Packit 98cdb6
  return visual->byte_order;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_colormap_size:
Packit 98cdb6
 * @visual: A #GdkVisual.
Packit 98cdb6
 *
Packit 98cdb6
 * Returns the size of a colormap for this visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Return value: The size of a colormap that is suitable for @visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
gint
Packit 98cdb6
gdk_visual_get_colormap_size (GdkVisual *visual)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
Packit 98cdb6
Packit 98cdb6
  return visual->colormap_size;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_bits_per_rgb:
Packit 98cdb6
 * @visual: a #GdkVisual
Packit 98cdb6
 *
Packit 98cdb6
 * Returns the number of significant bits per red, green and blue value.
Packit 98cdb6
 *
Packit 98cdb6
 * Return value: The number of significant bits per color value for @visual.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
gint
Packit 98cdb6
gdk_visual_get_bits_per_rgb (GdkVisual *visual)
Packit 98cdb6
{
Packit 98cdb6
  g_return_val_if_fail (GDK_IS_VISUAL (visual), 0);
Packit 98cdb6
Packit 98cdb6
  return visual->bits_per_rgb;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_red_pixel_details:
Packit 98cdb6
 * @visual: A #GdkVisual.
Packit 98cdb6
 * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
Packit 98cdb6
 * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
Packit 98cdb6
 * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
Packit 98cdb6
 *
Packit 98cdb6
 * Obtains values that are needed to calculate red pixel values in TrueColor
Packit 98cdb6
 * and DirectColor.  The "mask" is the significant bits within the pixel.
Packit 98cdb6
 * The "shift" is the number of bits left we must shift a primary for it
Packit 98cdb6
 * to be in position (according to the "mask").  Finally, "precision" refers
Packit 98cdb6
 * to how much precision the pixel value contains for a particular primary.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
void
Packit 98cdb6
gdk_visual_get_red_pixel_details (GdkVisual *visual,
Packit 98cdb6
                                  guint32   *mask,
Packit 98cdb6
                                  gint      *shift,
Packit 98cdb6
                                  gint      *precision)
Packit 98cdb6
{
Packit 98cdb6
  g_return_if_fail (GDK_IS_VISUAL (visual));
Packit 98cdb6
Packit 98cdb6
  if (mask)
Packit 98cdb6
    *mask = visual->red_mask;
Packit 98cdb6
Packit 98cdb6
  if (shift)
Packit 98cdb6
    *shift = visual->red_shift;
Packit 98cdb6
Packit 98cdb6
  if (precision)
Packit 98cdb6
    *precision = visual->red_prec;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_green_pixel_details:
Packit 98cdb6
 * @visual: a #GdkVisual
Packit 98cdb6
 * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
Packit 98cdb6
 * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
Packit 98cdb6
 * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
Packit 98cdb6
 *
Packit 98cdb6
 * Obtains values that are needed to calculate green pixel values in TrueColor
Packit 98cdb6
 * and DirectColor.  The "mask" is the significant bits within the pixel.
Packit 98cdb6
 * The "shift" is the number of bits left we must shift a primary for it
Packit 98cdb6
 * to be in position (according to the "mask").  Finally, "precision" refers
Packit 98cdb6
 * to how much precision the pixel value contains for a particular primary.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
void
Packit 98cdb6
gdk_visual_get_green_pixel_details (GdkVisual *visual,
Packit 98cdb6
                                    guint32   *mask,
Packit 98cdb6
                                    gint      *shift,
Packit 98cdb6
                                    gint      *precision)
Packit 98cdb6
{
Packit 98cdb6
  g_return_if_fail (GDK_IS_VISUAL (visual));
Packit 98cdb6
Packit 98cdb6
  if (mask)
Packit 98cdb6
    *mask = visual->green_mask;
Packit 98cdb6
Packit 98cdb6
  if (shift)
Packit 98cdb6
    *shift = visual->green_shift;
Packit 98cdb6
Packit 98cdb6
  if (precision)
Packit 98cdb6
    *precision = visual->green_prec;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
/**
Packit 98cdb6
 * gdk_visual_get_blue_pixel_details:
Packit 98cdb6
 * @visual: a #GdkVisual
Packit 98cdb6
 * @mask: (out) (allow-none): A pointer to a #guint32 to be filled in, or %NULL.
Packit 98cdb6
 * @shift: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
Packit 98cdb6
 * @precision: (out) (allow-none): A pointer to a #gint to be filled in, or %NULL.
Packit 98cdb6
 *
Packit 98cdb6
 * Obtains values that are needed to calculate blue pixel values in TrueColor
Packit 98cdb6
 * and DirectColor.  The "mask" is the significant bits within the pixel.
Packit 98cdb6
 * The "shift" is the number of bits left we must shift a primary for it
Packit 98cdb6
 * to be in position (according to the "mask").  Finally, "precision" refers
Packit 98cdb6
 * to how much precision the pixel value contains for a particular primary.
Packit 98cdb6
 *
Packit 98cdb6
 * Since: 2.22
Packit 98cdb6
 */
Packit 98cdb6
void
Packit 98cdb6
gdk_visual_get_blue_pixel_details (GdkVisual *visual,
Packit 98cdb6
                                   guint32   *mask,
Packit 98cdb6
                                   gint      *shift,
Packit 98cdb6
                                   gint      *precision)
Packit 98cdb6
{
Packit 98cdb6
  g_return_if_fail (GDK_IS_VISUAL (visual));
Packit 98cdb6
Packit 98cdb6
  if (mask)
Packit 98cdb6
    *mask = visual->blue_mask;
Packit 98cdb6
Packit 98cdb6
  if (shift)
Packit 98cdb6
    *shift = visual->blue_shift;
Packit 98cdb6
Packit 98cdb6
  if (precision)
Packit 98cdb6
    *precision = visual->blue_prec;
Packit 98cdb6
}
Packit 98cdb6
Packit 98cdb6
#define __GDK_VISUAL_C__
Packit 98cdb6
#include "gdkaliasdef.c"