1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26 
27 #ifndef __GDK_VISUAL_H__
28 #define __GDK_VISUAL_H__
29 
30 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
31 #error "Only <gdk/gdk.h> can be included directly."
32 #endif
33 
34 #include <gdk/gdktypes.h>
35 
36 G_BEGIN_DECLS
37 
38 #define GDK_TYPE_VISUAL              (gdk_visual_get_type ())
39 #define GDK_VISUAL(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_VISUAL, GdkVisual))
40 #define GDK_VISUAL_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_VISUAL, GdkVisualClass))
41 #define GDK_IS_VISUAL(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_VISUAL))
42 #define GDK_IS_VISUAL_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_VISUAL))
43 #define GDK_VISUAL_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_VISUAL, GdkVisualClass))
44 
45 typedef struct _GdkVisualClass    GdkVisualClass;
46 
47 /* Types of visuals.
48  *   StaticGray:
49  *   Grayscale:
50  *   StaticColor:
51  *   PseudoColor:
52  *   TrueColor:
53  *   DirectColor:
54  */
55 typedef enum
56 {
57   GDK_VISUAL_STATIC_GRAY,
58   GDK_VISUAL_GRAYSCALE,
59   GDK_VISUAL_STATIC_COLOR,
60   GDK_VISUAL_PSEUDO_COLOR,
61   GDK_VISUAL_TRUE_COLOR,
62   GDK_VISUAL_DIRECT_COLOR
63 } GdkVisualType;
64 
65 /* The visual type.
66  *   "type" is the type of visual this is (PseudoColor, TrueColor, etc).
67  *   "depth" is the bit depth of this visual.
68  *   "colormap_size" is the size of a colormap for this visual.
69  *   "bits_per_rgb" is the number of significant bits per red, green and blue.
70  *  The red, green and blue masks, shifts and precisions refer
71  *   to value needed to calculate pixel values in TrueColor and DirectColor
72  *   visuals. The "mask" is the significant bits within the pixel. The
73  *   "shift" is the number of bits left we must shift a primary for it
74  *   to be in position (according to the "mask"). "prec" refers to how
75  *   much precision the pixel value contains for a particular primary.
76  */
77 struct _GdkVisual
78 {
79   GObject parent_instance;
80 
81   GdkVisualType GSEAL (type);
82   gint GSEAL (depth);
83   GdkByteOrder GSEAL (byte_order);
84   gint GSEAL (colormap_size);
85   gint GSEAL (bits_per_rgb);
86 
87   guint32 GSEAL (red_mask);
88   gint GSEAL (red_shift);
89   gint GSEAL (red_prec);
90 
91   guint32 GSEAL (green_mask);
92   gint GSEAL (green_shift);
93   gint GSEAL (green_prec);
94 
95   guint32 GSEAL (blue_mask);
96   gint GSEAL (blue_shift);
97   gint GSEAL (blue_prec);
98 };
99 
100 GType         gdk_visual_get_type            (void) G_GNUC_CONST;
101 
102 #ifndef GDK_MULTIHEAD_SAFE
103 gint	      gdk_visual_get_best_depth	     (void);
104 GdkVisualType gdk_visual_get_best_type	     (void);
105 GdkVisual*    gdk_visual_get_system	     (void);
106 GdkVisual*    gdk_visual_get_best	     (void);
107 GdkVisual*    gdk_visual_get_best_with_depth (gint	     depth);
108 GdkVisual*    gdk_visual_get_best_with_type  (GdkVisualType  visual_type);
109 GdkVisual*    gdk_visual_get_best_with_both  (gint	     depth,
110 					      GdkVisualType  visual_type);
111 
112 void gdk_query_depths	    (gint	    **depths,
113 			     gint	     *count);
114 void gdk_query_visual_types (GdkVisualType  **visual_types,
115 			     gint	     *count);
116 
117 GList* gdk_list_visuals (void);
118 #endif
119 
120 GdkScreen *gdk_visual_get_screen (GdkVisual *visual);
121 
122 GdkVisualType gdk_visual_get_visual_type         (GdkVisual *visual);
123 gint          gdk_visual_get_depth               (GdkVisual *visual);
124 GdkByteOrder  gdk_visual_get_byte_order          (GdkVisual *visual);
125 gint          gdk_visual_get_colormap_size       (GdkVisual *visual);
126 gint          gdk_visual_get_bits_per_rgb        (GdkVisual *visual);
127 void          gdk_visual_get_red_pixel_details   (GdkVisual *visual,
128                                                   guint32   *mask,
129                                                   gint      *shift,
130                                                   gint      *precision);
131 void          gdk_visual_get_green_pixel_details (GdkVisual *visual,
132                                                   guint32   *mask,
133                                                   gint      *shift,
134                                                   gint      *precision);
135 void          gdk_visual_get_blue_pixel_details  (GdkVisual *visual,
136                                                   guint32   *mask,
137                                                   gint      *shift,
138                                                   gint      *precision);
139 
140 #ifndef GDK_DISABLE_DEPRECATED
141 #define gdk_visual_ref(v) g_object_ref(v)
142 #define gdk_visual_unref(v) g_object_unref(v)
143 #endif
144 
145 G_END_DECLS
146 
147 #endif /* __GDK_VISUAL_H__ */
148