]> git.kernelconcepts.de Git - gbdfed.git/blob - gectrl.h
Fixup several compile faults due to changes in recent distributions,
[gbdfed.git] / gectrl.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_gectrl
23 #define _h_gectrl
24
25 #include <gtk/gtkdrawingarea.h>
26 #include "bdfP.h"
27 #include "gtkcompat.h"
28
29 G_BEGIN_DECLS
30
31 #define GECONTROL(obj) \
32       (G_TYPE_CHECK_INSTANCE_CAST(obj, gecontrol_get_type(), GEControl))
33 #define GECONTROL_CLASS(klass) \
34       (G_TYPE_CHECK_CLASS_CAST(klass, gecontrol_get_type(), GEControlClass))
35
36 #define IS_GECONTROL(obj) \
37       (G_TYPE_CHECK_INSTANCE_TYPE(obj, gecontrol_get_type()))
38 #define IS_GECONTROL_CLASS(klass) \
39       (G_TYPE_CHECK_CLASS_TYPE(klass, gecontrol_get_type()))
40
41 #define GECONTROL_GET_CLASS(obj) \
42       (G_TYPE_INSTANCE_GET_CLASS(obj, gecontrol_get_type(), GEControlClass))
43
44 typedef struct _GEControl      GEControl;
45 typedef struct _GEControlClass GEControlClass;
46
47 typedef enum {
48     GECONTROL_DRAW = 0,
49     GECONTROL_MOVE,
50     GECONTROL_COPY,
51     GECONTROL_FLIP_HORIZONTAL,
52     GECONTROL_FLIP_VERTICAL,
53     GECONTROL_SHEAR,
54     GECONTROL_ROTATE_LEFT_90,
55     GECONTROL_ROTATE_RIGHT_90,
56     GECONTROL_ROTATE,
57     GECONTROL_SHIFT_UP_LEFT,
58     GECONTROL_SHIFT_UP,
59     GECONTROL_SHIFT_UP_RIGHT,
60     GECONTROL_SHIFT_LEFT,
61     GECONTROL_SHIFT_RIGHT,
62     GECONTROL_SHIFT_DOWN_LEFT,
63     GECONTROL_SHIFT_DOWN,
64     GECONTROL_SHIFT_DOWN_RIGHT,
65     GECONTROL_COLOR_CHANGE
66 } GEControlOperation;
67
68 /*
69  * Structure passed to the "activate" signal handler.
70  */
71 typedef struct {
72     GEControlOperation operation;
73     gint color;
74 } GEControlActivateInfo;
75
76 typedef struct {
77     guchar *help;
78     gint x;
79     gint y;
80     GdkPixbuf *image;
81     GdkRegion *region;
82     gint other_toggles[2];
83     gboolean set;
84     gboolean toggle;
85 } GEControlButton;
86
87 typedef struct {
88     gint x;
89     gint y;
90     GdkRegion *region;
91     gboolean set;
92 } GEControlColor;
93
94 struct _GEControl {
95     GtkDrawingArea da;
96
97     /*
98      * Public fields.
99      */
100
101     /*
102      * The glyph image.
103      */
104     bdf_bitmap_t *gimage;
105
106     /*
107      * An application provided label widget where the help
108      * messages are set.
109      */
110     GtkWidget *tip_label;
111
112     /*
113      * The list of colors to use.
114      */
115     guint16 *colors;
116
117     /*
118      * Private fields.
119      */
120     gint last_button;
121
122     /*
123      * The current color index.
124      */
125     gint cidx;
126
127     /*
128      * 16 color spots. Used to track mouse position and update the tip label.
129      */
130     GdkRectangle spot;
131     GdkRegion *spot_region;
132
133     /*
134      * Timer stuff for holding down the buttons.
135      */
136     gint timer_count;
137     gint timer_button;
138     guint timer;
139
140     GdkPoint *points;
141     gint points_used;
142     gint points_size;
143
144     /*
145      * Buffer for building a grayscale glyph image.
146      */
147     guchar *rgb;
148     guint rgb_used;
149     guint rgb_size;
150
151     GEControlButton buttons[18];
152 };
153
154 struct _GEControlClass {
155     GtkDrawingAreaClass parent_class;
156
157     /*
158      * A GC for drawing the color selection rectangle.
159      */
160     GdkGC *selgc;
161
162     GdkPixbuf *draw;
163     GdkPixbuf *move;
164     GdkPixbuf *copy;
165
166     GdkPixbuf *fliph;
167     GdkPixbuf *flipv;
168     GdkPixbuf *shear;
169
170     GdkPixbuf *rleft;
171     GdkPixbuf *rright;
172     GdkPixbuf *rotate;
173
174     GdkPixbuf *uleft;
175     GdkPixbuf *up;
176     GdkPixbuf *uright;
177
178     GdkPixbuf *left;
179     GdkPixbuf *right;
180
181     GdkPixbuf *dleft;
182     GdkPixbuf *down;
183     GdkPixbuf *dright;
184
185     /*
186      * Signal handlers.
187      */
188     void (*activate)(GtkWidget *, gpointer, gpointer);
189 };
190
191 extern GType gecontrol_get_type(void);
192
193 extern GtkWidget *gecontrol_new(const gchar *prop1, ...);
194
195 extern GtkWidget *gecontrol_newv(GtkWidget *tips_label, bdf_bitmap_t *image,
196                                  guint16 *colors);
197
198 extern void gecontrol_set_glyph_image(GEControl *ge, bdf_bitmap_t *image);
199
200 extern void gecontrol_update_glyph_image(GEControl *ge, bdf_bitmap_t *image);
201
202 extern void gecontrol_set_color_list(GEControl *ge, guint16 *colors);
203
204 extern void gecontrol_change_operation(GEControl *ge, GEControlOperation op);
205
206 extern void gecontrol_change_color(GEControl *ge, gint cidx);
207
208 G_END_DECLS
209
210 #endif /* _h_gectrl */