2 * Copyright 2008 Department of Mathematical Sciences, New Mexico State University
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
29 #include "gtkcompat.h"
39 GLYPHEDIT_FLIP_HORIZONTAL,
40 GLYPHEDIT_FLIP_VERTICAL,
42 GLYPHEDIT_ROTATE_LEFT,
43 GLYPHEDIT_ROTATE_RIGHT,
45 GLYPHEDIT_SHIFT_UP_LEFT,
47 GLYPHEDIT_SHIFT_UP_RIGHT,
49 GLYPHEDIT_SHIFT_RIGHT,
50 GLYPHEDIT_SHIFT_DOWN_LEFT,
52 GLYPHEDIT_SHIFT_DOWN_RIGHT
56 * The macros for accessing various parts of the widget class.
58 #define GLYPHEDIT(o) \
59 (G_TYPE_CHECK_INSTANCE_CAST((o), glyphedit_get_type(), Glyphedit))
61 #define GLYPHEDIT_CLASS(c) \
62 (G_TYPE_CHECK_CLASS_CAST((c), glyphedit_get_type(), GlypheditClass))
64 #define IS_GLYPHEDIT(o) G_TYPE_CHECK_INSTANCE_TYPE((o), glyphedit_get_type())
66 #define IS_GLYPHEDIT_CLASS(c) \
67 (G_TYPE_CHECK_CLASS_TYPE((c), glyphedit_get_type()))
69 #define GLYPHEDIT_GET_CLASS(o) \
70 (G_TYPE_INSTANCE_GET_CLASS((o), glyphedit_get_type(), GlypheditClass))
72 typedef struct _Glyphedit Glyphedit;
73 typedef struct _GlypheditClass GlypheditClass;
78 bdf_glyph_grid_t *grid;
79 gboolean show_cap_height;
80 gboolean show_x_height;
82 GdkColor baselineColor;
83 GdkColor selectionColor;
88 * Buffer for drawing grayscale pixels and color spots.
94 gboolean owns_clipboard;
96 GlypheditOperation op;
97 GlypheditOperation pending_op;
108 guint16 default_pixel_size;
116 struct _GlypheditClass {
117 GtkWidgetClass parent_class;
125 * GC's used for drawing.
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);
142 /**************************************************************************
144 * Structures used for the API.
146 **************************************************************************/
149 * List of callback reasons.
152 GLYPHEDIT_GLYPH_MODIFIED = 0,
153 GLYPHEDIT_POINTER_MOVED,
154 GLYPHEDIT_OPERATION_CHANGE,
155 GLYPHEDIT_COLOR_CHANGE
159 * The structure passed back in the signals.
164 bdf_metrics_t *metrics;
165 GlypheditOperation operation;
169 } GlypheditSignalInfo;
171 /**************************************************************************
175 **************************************************************************/
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,
186 * Get the encoding of the current glyph.
188 extern gint32 glyphedit_get_encoding(Glyphedit *gw);
191 * Get the current glyph metrics or the current font metrics.
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);
197 * Get the PSF Unicode mappings.
199 extern bdf_psf_unimap_t *glyphedit_get_psf_mappings(Glyphedit *gw);
202 * Changes device width, width, and height values from the metrics supplied.
204 extern void glyphedit_set_metrics(Glyphedit *gw, bdf_metrics_t *metrics);
207 * Get the glyph spacing.
209 extern gint glyphedit_get_spacing(Glyphedit *gw);
212 * Changes the font spacing and the mono width if necessary.
214 extern void glyphedit_set_spacing(Glyphedit *gw, gint spacing,
218 * Get and set the operation.
220 extern void glyphedit_set_operation(Glyphedit *gw, GlypheditOperation op);
221 extern GlypheditOperation glyphedit_get_operation(Glyphedit *gw);
223 extern void glyphedit_set_pixel_size(Glyphedit *gw, guint pixel_size);
224 extern guint glyphedit_get_pixel_size(Glyphedit *gw);
227 * Sets the glyph grid.
229 extern void glyphedit_set_grid(Glyphedit *gw, bdf_glyph_grid_t *grid);
232 * Check to see if the glyph or associated info has been modified.
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);
239 * Determine if a selection is in progress.
241 extern gboolean glyphedit_get_selecting(Glyphedit *gw);
244 * Check to see if the glyph editor clipboard is empty or not.
246 extern gboolean glyphedit_clipboard_empty(Glyphedit *gw);
249 * Get the glyph image from the editor.
251 extern void glyphedit_get_image(Glyphedit *gw, bdf_bitmap_t *image);
254 * Retrieve the glyph grid.
256 extern bdf_glyph_grid_t *glyphedit_get_grid(Glyphedit *gw);
259 * Get the glyph itself.
261 extern bdf_glyph_t *glyphedit_get_glyph(Glyphedit *gw, gboolean *unencoded);
264 * Show or hide the cap height.
266 extern void glyphedit_set_show_cap_height(Glyphedit *gw, gboolean show);
269 * Show or hide the x height.
271 extern void glyphedit_set_show_x_height(Glyphedit *gw, gboolean show);
274 * Crop the glyph bitmap to get rid of empty rows and columns around the
277 extern void glyphedit_crop_glyph(Glyphedit *gw);
280 * Shift the bitmap horizontally, vertically or a combination of both.
282 extern void glyphedit_shift_glyph(Glyphedit *gw, gint16 xcount, gint16 ycount);
285 * Rotate the bitmap clockwise (positive count) or counter-clockwise
288 extern void glyphedit_rotate_glyph(Glyphedit *w, gint16 degrees);
291 * Shear the bitmap clockwise (positive count) or counter-clockwise
292 * (negative count). Limited to the range of [-20,20] degrees.
294 extern void glyphedit_shear_glyph(Glyphedit *gw, gint16 degrees);
297 * Make the glyph bold.
299 extern void glyphedit_embolden_glyph(Glyphedit *gw);
302 * Flip the bitmap horizontally or vertically.
304 extern void glyphedit_flip_glyph(Glyphedit *gw, GtkOrientation direction);
307 * Change to the draw, select, move, or copy operation.
309 extern void glyphedit_change_operation(Glyphedit *gw, GlypheditOperation op);
312 * Change the current color index.
314 extern void glyphedit_set_color(Glyphedit *gw, gint idx);
317 * Insert a bitmap from some outside source.
319 extern void glyphedit_insert_bitmap(Glyphedit *gw, bdf_bitmap_t *bitmap);
322 * Functions explicitly for importing and exporting XBM bitmaps.
324 extern int glyphedit_import_xbm(Glyphedit *gw, gchar *filename);
325 extern int glyphedit_export_xbm(Glyphedit *gw, gchar *filename);
328 * Functions dealing with the selection.
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);
337 #endif /* _h_glyphedit */