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"
34 * The macros for accessing various parts of the widget class.
37 (G_TYPE_CHECK_INSTANCE_CAST((o), fontgrid_get_type(), Fontgrid))
39 #define FONTGRID_CLASS(c) \
40 (G_TYPE_CHECK_CLASS_CAST((c), fontgrid_get_type(), FontgridClass))
42 #define IS_FONTGRID(o) G_TYPE_CHECK_INSTANCE_TYPE((o), fontgrid_get_type())
44 #define IS_FONTGRID_CLASS(c) \
45 (G_TYPE_CHECK_CLASS_TYPE((c), fontgrid_get_type()))
47 #define FONTGRID_GET_CLASS(o) \
48 (G_TYPE_INSTANCE_GET_CLASS((o), fontgrid_get_type(), FontgridClass))
50 typedef struct _Fontgrid Fontgrid;
51 typedef struct _FontgridClass FontgridClass;
65 } FontgridInternalPageInfo;
75 GtkOrientation orientation;
96 gboolean from_keyboard;
97 gboolean no_sel_callback;
116 * For creating RGB glyph images.
123 * Stuff related to the timer between clicks.
129 * The count accumulated from pressing number keys.
134 * The clipboard used to store selections among other things.
136 bdf_glyphlist_t clipboard;
139 * Page information necessary for paging an drawing.
141 FontgridInternalPageInfo npage;
142 FontgridInternalPageInfo upage;
145 struct _FontgridClass {
146 GtkWidgetClass parent_class;
148 void (*selection_start)(GtkWidget *, gpointer, gpointer);
149 void (*selection_extend)(GtkWidget *, gpointer, gpointer);
150 void (*selection_end)(GtkWidget *, gpointer, gpointer);
151 void (*page)(GtkWidget *, gpointer, gpointer);
152 void (*activate)(GtkWidget *, gpointer, gpointer);
153 void (*modified)(GtkWidget *, gpointer, gpointer);
156 /**************************************************************************
158 * Structures used for the API.
160 **************************************************************************/
163 gint32 previous_page;
166 gint32 encoded_glyphs;
167 gint32 unencoded_glyphs;
168 gboolean unencoded_page;
175 glong bits_per_pixel;
187 * Enum representing the callback reasons.
190 FONTGRID_START_SELECTION = 0,
191 FONTGRID_EXTEND_SELECTION,
192 FONTGRID_END_SELECTION,
195 } FontgridSelectionReason;
198 FontgridSelectionReason reason;
205 } FontgridSelectionInfo;
208 FONTGRID_MODIFIED = 0,
209 FONTGRID_GLYPH_NAMES_MODIFIED,
210 FONTGRID_NAME_MODIFIED,
211 FONTGRID_PROPERTIES_MODIFIED,
212 FONTGRID_COMMENTS_MODIFIED,
213 FONTGRID_DEVICE_WIDTH_MODIFIED,
214 FONTGRID_GLYPHS_MODIFIED,
215 FONTGRID_GLYPHS_DELETED,
216 FONTGRID_GLYPHS_PASTED,
217 FONTGRID_FONT_METRICS_MODIFIED,
218 FONTGRID_PSF_MAPPINGS_MODIFIED
219 } FontgridModificationReason;
222 FontgridModificationReason reason;
227 } FontgridModificationInfo;
229 /**************************************************************************
233 **************************************************************************/
235 extern GType fontgrid_get_type(void);
236 extern GtkWidget *fontgrid_new(const gchar *prop1, ...);
237 extern GtkWidget *fontgrid_newv(bdf_font_t *font, guint32 pointSize,
238 gint32 spacing, gboolean skipBlankPages,
239 gboolean overwriteMode, gboolean powersOfTwo,
241 gint32 initialGlyph, guint codeBase,
242 GtkOrientation orientation,
244 gint32 horizontalResolution,
245 gint32 verticalResolution,
246 FontgridPageInfo *initialPageInfo);
249 * A routine to force initialization before the widget is realized. This is
250 * needed to get some fields filled in for apps using the widget.
252 extern void fontgrid_force_init(Fontgrid *);
255 * Selection information.
257 extern gboolean fontgrid_clipboard_empty(Fontgrid *);
258 extern gboolean fontgrid_has_selection(Fontgrid *, FontgridSelectionInfo *);
261 * Getting and setting widget values.
263 extern bdf_font_t *fontgrid_get_font(Fontgrid *);
264 extern void fontgrid_set_font(Fontgrid *, bdf_font_t *, gint32);
266 extern gchar *fontgrid_get_font_messages(Fontgrid *);
268 extern GtkOrientation fontgrid_get_orientation(Fontgrid *);
269 extern void fontgrid_set_orientation(Fontgrid *, GtkOrientation);
271 extern gboolean fontgrid_viewing_unencoded(Fontgrid *);
272 extern void fontgrid_switch_encoding_view(Fontgrid *);
274 extern guint fontgrid_get_code_base(Fontgrid *);
275 extern void fontgrid_set_code_base(Fontgrid *, guint);
277 extern gchar *fontgrid_get_font_name(Fontgrid *);
278 extern void fontgrid_set_font_name(Fontgrid *, gchar *);
280 extern gboolean fontgrid_get_font_modified(Fontgrid *);
281 extern void fontgrid_set_font_modified(Fontgrid *, gboolean);
283 extern void fontgrid_set_unicode_glyph_names(Fontgrid *, FILE *);
284 extern void fontgrid_set_adobe_glyph_names(Fontgrid *, FILE *);
285 extern void fontgrid_set_code_glyph_names(Fontgrid *, gint);
287 extern void fontgrid_set_font_property(Fontgrid *, bdf_property_t *);
288 extern void fontgrid_delete_font_property(Fontgrid *, gchar *);
290 extern guint32 fontgrid_get_font_comments(Fontgrid *, gchar **);
291 extern void fontgrid_set_font_comments(Fontgrid *, gchar *);
293 extern gint fontgrid_get_font_spacing(Fontgrid *);
294 extern void fontgrid_set_font_spacing(Fontgrid *, gint);
296 extern guint16 fontgrid_get_font_device_width(Fontgrid *);
297 extern void fontgrid_set_font_device_width(Fontgrid *, guint16);
299 extern void fontgrid_get_font_info(Fontgrid *, FontgridFontInfo *);
300 extern void fontgrid_set_font_info(Fontgrid *, FontgridFontInfo *);
303 * Navigation and page information.
305 extern void fontgrid_goto_page(Fontgrid *fw, gint32 pageno);
306 extern void fontgrid_goto_code(Fontgrid *, gint32 pageno);
307 extern void fontgrid_goto_first_page(Fontgrid *fw);
308 extern void fontgrid_goto_last_page(Fontgrid *fw);
309 extern void fontgrid_goto_next_page(Fontgrid *fw);
310 extern void fontgrid_goto_previous_page(Fontgrid *fw);
311 extern void fontgrid_get_page_info(Fontgrid *fw, FontgridPageInfo *pageinfo);
312 extern gboolean fontgrid_select_next_glyph(Fontgrid *fw, gint32 code);
313 extern gboolean fontgrid_select_previous_glyph(Fontgrid *fw, gint32 code);
316 * Font name functions.
318 extern void fontgrid_make_xlfd_font_name(Fontgrid *);
319 extern void fontgrid_update_font_name_from_properties(Fontgrid *);
320 extern void fontgrid_update_properties_from_font_name(Fontgrid *);
323 * Graphical operations.
325 extern void fontgrid_translate_glyphs(Fontgrid *fw, gint16 dx, gint16 dy,
326 gboolean all_glyphs);
327 extern void fontgrid_rotate_glyphs(Fontgrid *fw, gint16 degrees,
328 gboolean all_glyphs);
329 extern void fontgrid_shear_glyphs(Fontgrid *fw, gint16 degrees,
330 gboolean all_glyphs);
331 extern void fontgrid_embolden_glyphs(Fontgrid *fw, gboolean all_glyphs);
334 * Clipboard operations. MERGE and OVERLAY are the same operation.
337 FONTGRID_NORMAL_PASTE = 0,
338 FONTGRID_INSERT_PASTE,
339 FONTGRID_MERGE_PASTE,
340 FONTGRID_OVERLAY_PASTE
343 extern void fontgrid_copy_selection(Fontgrid *fw);
344 extern void fontgrid_cut_selection(Fontgrid *fw);
345 extern void fontgrid_paste_selection(Fontgrid *fw,
346 FontgridPasteType paste_type);
349 * Metrics, glyph, and PSF mappings updates.
351 extern void fontgrid_update_metrics(Fontgrid *fw, bdf_metrics_t *metrics);
352 extern void fontgrid_update_glyph(Fontgrid *fw, bdf_glyph_t *glyph,
355 extern void fontgrid_update_psf_mappings(Fontgrid *fw, gint32 encoding,
356 bdf_psf_unimap_t *mappings);
359 #endif /* _h_fontgrid */