]> git.kernelconcepts.de Git - gbdfed.git/blob - grayswatch.h
Fixup several compile faults due to changes in recent distributions,
[gbdfed.git] / grayswatch.h
1 /*
2  * Copyright 2008 Department of Mathematical Sciences, New Mexico State University
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * DEPARTMENT OF MATHEMATICAL SCIENCES OR NEW MEXICO STATE UNIVERSITY BE
18  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #ifndef _h_grayswatch
23 #define _h_grayswatch
24
25 #include <gtk/gtkvbox.h>
26 #include "gtkcompat.h"
27
28 G_BEGIN_DECLS
29
30 /*
31  * The macros for accessing various parts of the widget class.
32  */
33 #define GRAYSWATCH(obj)(G_TYPE_CHECK_INSTANCE_CAST(obj, grayswatch_get_type(), Grayswatch))
34 #define GRAYSWATCH_CLASS(klass) \
35         (G_TYPE_CHECK_CLASS_CAST(klass, grayswatch_get_type(), GrayswatchClass))
36 #define IS_GRAYSWATCH(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, grayswatch_get_type())
37 #define IS_GRAYSWATCH_CLASS(klass) \
38         (G_TYPE_CHECK_CLASS_TYPE(klass, grayswatch_get_type()))
39 #define GRAYSWATCH_GET_CLASS(obj) \
40         (G_TYPE_INSTANCE_GET_CLASS(obj, grayswatch_get_type(), GrayswatchClass))
41
42 typedef struct _Grayswatch      Grayswatch;
43 typedef struct _GrayswatchClass GrayswatchClass;
44
45 struct _Grayswatch {
46     GtkVBox vbox;
47
48     /*
49      * Public members.
50      */
51     guint gray;
52
53     /*
54      * Private members.
55      */
56     GtkWidget *swatch;
57     GtkWidget *value;
58
59     /*
60      * The grayscale image used to draw the swatch color.
61      */
62     guchar *image;
63     guint image_size;
64
65     /*
66      * Flag indicating whether the signal should be blocked or not.
67      */
68     gboolean signal_blocked;
69 };
70
71 struct _GrayswatchClass {
72     GtkVBoxClass parent_class;
73
74     /*
75      * Signal handlers.
76      */
77     void (*value_changed)(GtkWidget *, gint, gpointer);
78 };
79
80 /**************************************************************************
81  *
82  * General API
83  *
84  **************************************************************************/
85
86 extern GType grayswatch_get_type(void);
87
88 extern GtkWidget *grayswatch_new(guint gray);
89
90 /*
91  * The gray value is between 0 and 255.
92  */
93 extern void grayswatch_set_gray(Grayswatch *gs, guint gray);
94
95 /*
96  * Anything over 255 returned by this routine means an error.
97  */
98 extern guint grayswatch_get_gray(Grayswatch *gs);
99
100 /*
101  * Block the signal from being emitted while setting the gray level.
102  * This is for a specific application and may not be useful anywhere else.
103  * No error checking is done to make sure blocking and unblocking are
104  * done in pairs.
105  */
106 extern void grayswatch_block_signal(Grayswatch *gs, gboolean block);
107
108 G_END_DECLS
109
110 #endif /* _h_grayswatch */