-
Notifications
You must be signed in to change notification settings - Fork 3
/
gectrl.h
203 lines (163 loc) · 4.91 KB
/
gectrl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* Copyright 2008 Department of Mathematical Sciences, New Mexico State University
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* DEPARTMENT OF MATHEMATICAL SCIENCES OR NEW MEXICO STATE UNIVERSITY BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _h_gectrl
#define _h_gectrl
#include <gtk/gtk.h>
#include "bdfP.h"
G_BEGIN_DECLS
#define GECONTROL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST(obj, gecontrol_get_type(), GEControl))
#define GECONTROL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST(klass, gecontrol_get_type(), GEControlClass))
#define IS_GECONTROL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE(obj, gecontrol_get_type()))
#define IS_GECONTROL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE(klass, gecontrol_get_type()))
#define GECONTROL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS(obj, gecontrol_get_type(), GEControlClass))
typedef struct _GEControl GEControl;
typedef struct _GEControlClass GEControlClass;
typedef enum {
GECONTROL_DRAW = 0,
GECONTROL_MOVE,
GECONTROL_COPY,
GECONTROL_FLIP_HORIZONTAL,
GECONTROL_FLIP_VERTICAL,
GECONTROL_SHEAR,
GECONTROL_ROTATE_LEFT_90,
GECONTROL_ROTATE_RIGHT_90,
GECONTROL_ROTATE,
GECONTROL_SHIFT_UP_LEFT,
GECONTROL_SHIFT_UP,
GECONTROL_SHIFT_UP_RIGHT,
GECONTROL_SHIFT_LEFT,
GECONTROL_SHIFT_RIGHT,
GECONTROL_SHIFT_DOWN_LEFT,
GECONTROL_SHIFT_DOWN,
GECONTROL_SHIFT_DOWN_RIGHT,
GECONTROL_COLOR_CHANGE
} GEControlOperation;
/*
* Structure passed to the "activate" signal handler.
*/
typedef struct {
GEControlOperation operation;
gint color;
} GEControlActivateInfo;
typedef struct {
guchar *help;
gint x;
gint y;
GdkPixbuf *image;
cairo_region_t *region;
gint other_toggles[2];
gboolean set;
gboolean toggle;
} GEControlButton;
typedef struct {
gint x;
gint y;
cairo_region_t *region;
gboolean set;
} GEControlColor;
struct _GEControl {
GtkDrawingArea da;
/*
* Public fields.
*/
/*
* The glyph image.
*/
bdf_bitmap_t *gimage;
/*
* An application provided label widget where the help
* messages are set.
*/
GtkWidget *tip_label;
/*
* The list of colors to use.
*/
guint16 *colors;
/*
* Private fields.
*/
gint last_button;
/*
* The current color index.
*/
gint cidx;
/*
* 16 color spots. Used to track mouse position and update the tip label.
*/
GdkRectangle spot;
cairo_region_t *spot_region;
/*
* Timer stuff for holding down the buttons.
*/
gint timer_count;
gint timer_button;
guint timer;
GdkPoint *points;
gint points_used;
gint points_size;
/*
* Buffer for building a grayscale glyph image.
*/
cairo_surface_t *glyph_surface;
cairo_surface_t *spot_surface;
GEControlButton buttons[18];
};
struct _GEControlClass {
GtkDrawingAreaClass parent_class;
GdkPixbuf *draw;
GdkPixbuf *move;
GdkPixbuf *copy;
GdkPixbuf *fliph;
GdkPixbuf *flipv;
GdkPixbuf *shear;
GdkPixbuf *rleft;
GdkPixbuf *rright;
GdkPixbuf *rotate;
GdkPixbuf *uleft;
GdkPixbuf *up;
GdkPixbuf *uright;
GdkPixbuf *left;
GdkPixbuf *right;
GdkPixbuf *dleft;
GdkPixbuf *down;
GdkPixbuf *dright;
/*
* Signal handlers.
*/
void (*activate)(GtkWidget *, gpointer, gpointer);
};
extern GType gecontrol_get_type(void);
extern GtkWidget *gecontrol_new(const gchar *prop1, ...);
extern GtkWidget *gecontrol_newv(GtkWidget *tips_label, bdf_bitmap_t *image,
guint16 *colors);
extern void gecontrol_set_glyph_image(GEControl *ge, bdf_bitmap_t *image);
extern void gecontrol_update_glyph_image(GEControl *ge, bdf_bitmap_t *image);
extern void gecontrol_set_color_list(GEControl *ge, guint16 *colors);
extern void gecontrol_change_operation(GEControl *ge, GEControlOperation op);
extern void gecontrol_change_color(GEControl *ge, gint cidx);
G_END_DECLS
#endif /* _h_gectrl */