]> git.kernelconcepts.de Git - gbdfed.git/blob - glyphedit.h
Fixup several compile faults due to changes in recent distributions,
[gbdfed.git] / glyphedit.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_glyphedit
23 #define _h_glyphedit
24
25 #include <gdk/gdk.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include "bdfP.h"
29 #include "gtkcompat.h"
30
31 G_BEGIN_DECLS
32
33 typedef enum {
34     GLYPHEDIT_NONE = 0,
35     GLYPHEDIT_SELECT,
36     GLYPHEDIT_DRAW,
37     GLYPHEDIT_MOVE,
38     GLYPHEDIT_COPY,
39     GLYPHEDIT_FLIP_HORIZONTAL,
40     GLYPHEDIT_FLIP_VERTICAL,
41     GLYPHEDIT_SHEAR,
42     GLYPHEDIT_ROTATE_LEFT,
43     GLYPHEDIT_ROTATE_RIGHT,
44     GLYPHEDIT_ROTATE,
45     GLYPHEDIT_SHIFT_UP_LEFT,
46     GLYPHEDIT_SHIFT_UP,
47     GLYPHEDIT_SHIFT_UP_RIGHT,
48     GLYPHEDIT_SHIFT_LEFT,
49     GLYPHEDIT_SHIFT_RIGHT,
50     GLYPHEDIT_SHIFT_DOWN_LEFT,
51     GLYPHEDIT_SHIFT_DOWN,
52     GLYPHEDIT_SHIFT_DOWN_RIGHT
53 } GlypheditOperation;
54
55 /*
56  * The macros for accessing various parts of the widget class.
57  */
58 #define GLYPHEDIT(o) \
59         (G_TYPE_CHECK_INSTANCE_CAST((o), glyphedit_get_type(), Glyphedit))
60
61 #define GLYPHEDIT_CLASS(c) \
62         (G_TYPE_CHECK_CLASS_CAST((c), glyphedit_get_type(), GlypheditClass))
63
64 #define IS_GLYPHEDIT(o) G_TYPE_CHECK_INSTANCE_TYPE((o), glyphedit_get_type())
65
66 #define IS_GLYPHEDIT_CLASS(c) \
67         (G_TYPE_CHECK_CLASS_TYPE((c), glyphedit_get_type()))
68
69 #define GLYPHEDIT_GET_CLASS(o) \
70         (G_TYPE_INSTANCE_GET_CLASS((o), glyphedit_get_type(), GlypheditClass))
71
72 typedef struct _Glyphedit      Glyphedit;
73 typedef struct _GlypheditClass GlypheditClass;
74
75 struct _Glyphedit {
76     GtkWidget widget;
77
78     bdf_glyph_grid_t *grid;
79     gboolean show_cap_height;
80     gboolean show_x_height;
81
82     GdkColor baselineColor;
83     GdkColor selectionColor;
84     GdkColor cursorColor;
85
86     guint16 *colors;
87     /*
88      * Buffer for drawing grayscale pixels and color spots.
89      */
90     guchar *spot;
91     guint spot_used;
92     guint spot_size;
93
94     gboolean owns_clipboard;
95
96     GlypheditOperation op;
97     GlypheditOperation pending_op;
98
99     GdkPoint sel_start;
100     GdkPoint sel_end;
101
102     gint last_x;
103     gint last_y;
104
105     gint lcolor;
106     gint cidx;
107
108     guint16 default_pixel_size;
109     guint16 pixel_size;
110
111     guint16 vmargin;
112     guint16 hmargin;
113     guint16 border;
114 };
115
116 struct _GlypheditClass {
117     GtkWidgetClass parent_class;
118
119     /*
120      * Cursor.
121      */
122     GdkCursor *cursor;
123
124     /*
125      * GC's used for drawing.
126      */
127     GdkGC *gridgc;
128     GdkGC *bbxgc;
129     GdkGC *pixgc;
130     GdkGC *cleargc;
131     GdkGC *selgc;
132
133     /*
134      * Signal handlers.
135      */
136     void (*glyph_modified)(GtkWidget *, gpointer, gpointer);
137     void (*pointer_moved)(GtkWidget *, gpointer, gpointer);
138     void (*operation_change)(GtkWidget *, gpointer, gpointer);
139     void (*color_change)(GtkWidget *, gpointer, gpointer);
140 };
141
142 /**************************************************************************
143  *
144  * Structures used for the API.
145  *
146  **************************************************************************/
147
148 /*
149  * List of callback reasons.
150  */
151 enum {
152     GLYPHEDIT_GLYPH_MODIFIED = 0,
153     GLYPHEDIT_POINTER_MOVED,
154     GLYPHEDIT_OPERATION_CHANGE,
155     GLYPHEDIT_COLOR_CHANGE
156 };
157
158 /*
159  * The structure passed back in the signals.
160  */
161 typedef struct {
162     gint reason;
163     bdf_bitmap_t *image;
164     bdf_metrics_t *metrics;
165     GlypheditOperation operation;
166     gint x;
167     gint y;
168     gint color;
169 } GlypheditSignalInfo;
170
171 /**************************************************************************
172  *
173  * General API
174  *
175  **************************************************************************/
176
177 extern GType glyphedit_get_type(void);
178 extern GtkWidget *glyphedit_new(const gchar *prop1, ...);
179 extern GtkWidget *glyphedit_newv(bdf_glyph_grid_t *grid,
180                                  guint16 default_pixel_size,
181                                  gboolean show_x_height,
182                                  gboolean show_cap_height,
183                                  guint16 *colors);
184
185 /*
186  * Get the encoding of the current glyph.
187  */
188 extern gint32 glyphedit_get_encoding(Glyphedit *gw);
189
190 /*
191  * Get the current glyph metrics or the current font metrics.
192  */
193 extern void glyphedit_get_glyph_metrics(Glyphedit *gw, bdf_metrics_t *metrics);
194 extern void glyphedit_get_font_metrics(Glyphedit *gw, bdf_metrics_t *metrics);
195
196 /*
197  * Get the PSF Unicode mappings.
198  */
199 extern bdf_psf_unimap_t *glyphedit_get_psf_mappings(Glyphedit *gw);
200
201 /*
202  * Changes device width, width, and height values from the metrics supplied.
203  */
204 extern void glyphedit_set_metrics(Glyphedit *gw, bdf_metrics_t *metrics);
205
206 /*
207  * Get the glyph spacing.
208  */
209 extern gint glyphedit_get_spacing(Glyphedit *gw);
210
211 /*
212  * Changes the font spacing and the mono width if necessary.
213  */
214 extern void glyphedit_set_spacing(Glyphedit *gw, gint spacing,
215                                   guint16 monowidth);
216
217 /*
218  * Get and set the operation.
219  */
220 extern void glyphedit_set_operation(Glyphedit *gw, GlypheditOperation op);
221 extern GlypheditOperation glyphedit_get_operation(Glyphedit *gw);
222
223 extern void glyphedit_set_pixel_size(Glyphedit *gw, guint pixel_size);
224 extern guint glyphedit_get_pixel_size(Glyphedit *gw);
225
226 /*
227  * Sets the glyph grid.
228  */
229 extern void glyphedit_set_grid(Glyphedit *gw, bdf_glyph_grid_t *grid);
230
231 /*
232  * Check to see if the glyph or associated info has been modified.
233  */
234 extern gboolean glyphedit_get_modified(Glyphedit *gw);
235 extern void glyphedit_set_modified(Glyphedit *gw, gboolean modified);
236 extern void glyphedit_signal_modified(Glyphedit *gw);
237
238 /*
239  * Determine if a selection is in progress.
240  */
241 extern gboolean glyphedit_get_selecting(Glyphedit *gw);
242
243 /*
244  * Check to see if the glyph editor clipboard is empty or not.
245  */
246 extern gboolean glyphedit_clipboard_empty(Glyphedit *gw);
247
248 /*
249  * Get the glyph image from the editor.
250  */
251 extern void glyphedit_get_image(Glyphedit *gw, bdf_bitmap_t *image);
252
253 /*
254  * Retrieve the glyph grid.
255  */
256 extern bdf_glyph_grid_t *glyphedit_get_grid(Glyphedit *gw);
257
258 /*
259  * Get the glyph itself.
260  */
261 extern bdf_glyph_t *glyphedit_get_glyph(Glyphedit *gw, gboolean *unencoded);
262
263 /*
264  * Show or hide the cap height.
265  */
266 extern void glyphedit_set_show_cap_height(Glyphedit *gw, gboolean show);
267
268 /*
269  * Show or hide the x height.
270  */
271 extern void glyphedit_set_show_x_height(Glyphedit *gw, gboolean show);
272
273 /*
274  * Crop the glyph bitmap to get rid of empty rows and columns around the
275  * glyph.
276  */
277 extern void glyphedit_crop_glyph(Glyphedit *gw);
278
279 /*
280  * Shift the bitmap horizontally, vertically or a combination of both.
281  */
282 extern void glyphedit_shift_glyph(Glyphedit *gw, gint16 xcount, gint16 ycount);
283
284 /*
285  * Rotate the bitmap clockwise (positive count) or counter-clockwise
286  * (negative count).
287  */
288 extern void glyphedit_rotate_glyph(Glyphedit *w, gint16 degrees);
289
290 /*
291  * Shear the bitmap clockwise (positive count) or counter-clockwise
292  * (negative count).  Limited to the range of [-20,20] degrees.
293  */
294 extern void glyphedit_shear_glyph(Glyphedit *gw, gint16 degrees);
295
296 /*
297  * Make the glyph bold.
298  */
299 extern void glyphedit_embolden_glyph(Glyphedit *gw);
300
301 /*
302  * Flip the bitmap horizontally or vertically.
303  */
304 extern void glyphedit_flip_glyph(Glyphedit *gw, GtkOrientation direction);
305
306 /*
307  * Change to the draw, select, move, or copy operation.
308  */
309 extern void glyphedit_change_operation(Glyphedit *gw, GlypheditOperation op);
310
311 /*
312  * Change the current color index.
313  */
314 extern void glyphedit_set_color(Glyphedit *gw, gint idx);
315
316 /*
317  * Insert a bitmap from some outside source.
318  */
319 extern void glyphedit_insert_bitmap(Glyphedit *gw, bdf_bitmap_t *bitmap);
320
321 /*
322  * Functions explicitly for importing and exporting XBM bitmaps.
323  */
324 extern int glyphedit_import_xbm(Glyphedit *gw, gchar *filename);
325 extern int glyphedit_export_xbm(Glyphedit *gw, gchar *filename);
326
327 /*
328  * Functions dealing with the selection.
329  */
330 extern void glyphedit_copy_selection(Glyphedit *gw);
331 extern void glyphedit_cut_selection(Glyphedit *gw);
332 extern void glyphedit_paste_selection(Glyphedit *gw);
333 extern void glyphedit_select_all(Glyphedit *gw);
334
335 G_END_DECLS
336
337 #endif /* _h_glyphedit */