1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 2 /* gtkhex.h - definition of a GtkHex widget, modified for use with GnomeMDI 3 4 Copyright (C) 1997 - 2004 Free Software Foundation 5 6 GHex is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as 8 published by the Free Software Foundation; either version 2 of the 9 License, or (at your option) any later version. 10 11 GHex is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GHex; see the file COPYING. 18 If not, write to the Free Software Foundation, Inc., 19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 21 Author: Jaka Mocnik <jaka@gnu.org> 22 */ 23 24 #ifndef __GTKHEX_H__ 25 #define __GTKHEX_H__ 26 27 #include <gtk/gtk.h> 28 #include <gdk/gdk.h> 29 30 #include <hex-document.h> 31 32 G_BEGIN_DECLS 33 34 /* how to group bytes? */ 35 #define GROUP_BYTE 1 36 #define GROUP_WORD 2 37 #define GROUP_LONG 4 38 39 #define LOWER_NIBBLE TRUE 40 #define UPPER_NIBBLE FALSE 41 42 #define GTK_TYPE_HEX (gtk_hex_get_type ()) 43 #define GTK_HEX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HEX, GtkHex)) 44 #define GTK_HEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_HEX, GtkHexClass)) 45 #define GTK_IS_HEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_HEX)) 46 #define GTK_IS_HEX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HEX)) 47 #define GTK_HEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_HEX, GtkHexClass)) 48 49 typedef struct _GtkHex GtkHex; 50 typedef struct _GtkHexClass GtkHexClass; 51 typedef struct _GtkHexChangeData GtkHexChangeData; 52 53 typedef struct _GtkHex_Highlight GtkHex_Highlight; 54 55 /* start_line and end_line only have to be set (and valid) of 56 * valid is set to TRUE. */ 57 struct _GtkHex_Highlight 58 { 59 gint start, end; 60 gint start_line, end_line; 61 GdkRGBA *bg_color; /* NULL to use the style color */ 62 gint min_select; 63 64 GtkHex_Highlight *prev, *next; 65 gboolean valid; 66 }; 67 68 /* used to automatically highlight all visible occurrences 69 * of the string. 70 */ 71 typedef struct _GtkHex_AutoHighlight GtkHex_AutoHighlight; 72 73 /* Private structure type */ 74 typedef struct _GtkHexPrivate GtkHexPrivate; 75 76 struct _GtkHex 77 { 78 GtkFixed fixed; 79 80 HexDocument *document; 81 82 GtkWidget *xdisp, *adisp, *scrollbar; 83 GtkWidget *offsets; 84 85 PangoLayout *xlayout, *alayout, *olayout; /* Changes for Gnome 2.0 */ 86 87 GtkAdjustment *adj; 88 89 PangoFontMetrics *disp_font_metrics; 90 PangoFontDescription *font_desc; 91 92 gint active_view; 93 94 guint char_width, char_height; 95 guint button; 96 97 guint cursor_pos; 98 GtkHex_Highlight selection; 99 gint lower_nibble; 100 101 guint group_type; 102 103 gint lines, vis_lines, cpl, top_line; 104 gint cursor_shown; 105 106 gint xdisp_width, adisp_width, extra_width; 107 108 /*< private > */ 109 GtkHexPrivate *priv; 110 111 GtkHex_AutoHighlight *auto_highlight; 112 113 gint scroll_dir; 114 guint scroll_timeout; 115 gboolean show_offsets; 116 gint starting_offset; 117 gboolean insert; 118 gboolean selecting; 119 }; 120 121 struct _GtkHexClass 122 { 123 GtkFixedClass parent_class; 124 125 GtkClipboard *clipboard, *primary; 126 127 void (*cursor_moved)(GtkHex *); 128 void (*data_changed)(GtkHex *, gpointer); 129 void (*cut_clipboard)(GtkHex *); 130 void (*copy_clipboard)(GtkHex *); 131 void (*paste_clipboard)(GtkHex *); 132 }; 133 134 GType gtk_hex_get_type (void) G_GNUC_CONST; 135 136 GtkWidget *gtk_hex_new(HexDocument *); 137 138 void gtk_hex_set_cursor(GtkHex *, gint); 139 void gtk_hex_set_cursor_xy(GtkHex *, gint, gint); 140 void gtk_hex_set_nibble(GtkHex *, gint); 141 142 guint gtk_hex_get_cursor(GtkHex *); 143 guchar gtk_hex_get_byte(GtkHex *, guint); 144 145 void gtk_hex_set_group_type(GtkHex *, guint); 146 147 void gtk_hex_set_starting_offset(GtkHex *, gint); 148 void gtk_hex_show_offsets(GtkHex *, gboolean); 149 void gtk_hex_set_font(GtkHex *, PangoFontMetrics *, const PangoFontDescription *); 150 151 void gtk_hex_set_insert_mode(GtkHex *, gboolean); 152 153 void gtk_hex_set_geometry(GtkHex *gh, gint cpl, gint vis_lines); 154 155 PangoFontMetrics* gtk_hex_load_font (const char *font_name); 156 157 void gtk_hex_copy_to_clipboard(GtkHex *gh); 158 void gtk_hex_cut_to_clipboard(GtkHex *gh); 159 void gtk_hex_paste_from_clipboard(GtkHex *gh); 160 161 void add_atk_namedesc(GtkWidget *widget, const gchar *name, const gchar *desc); 162 void add_atk_relation(GtkWidget *obj1, GtkWidget *obj2, AtkRelationType type); 163 164 void gtk_hex_set_selection(GtkHex *gh, gint start, gint end); 165 gboolean gtk_hex_get_selection(GtkHex *gh, gint *start, gint *end); 166 void gtk_hex_clear_selection(GtkHex *gh); 167 void gtk_hex_delete_selection(GtkHex *gh); 168 169 GtkHex_AutoHighlight *gtk_hex_insert_autohighlight(GtkHex *gh, 170 const gchar *search, 171 gint len, 172 const gchar *colour); 173 void gtk_hex_delete_autohighlight(GtkHex *gh, GtkHex_AutoHighlight *ahl); 174 175 G_END_DECLS 176 177 #endif 178