aboutsummaryrefslogtreecommitdiffstats
path: root/char-table.h
blob: e0c828fb602bdc2cdb32453f41e368393a34e99b (plain) (blame)
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
/* See LICENSE file for copyright and license details. */
#include "common.h"


#define GCMAP_TYPE_CHAR_TABLE            (gcmap_char_table_get_type())
#define GCMAP_CHAR_TABLE(OBJ)            (G_TYPE_CHECK_INSTANCE_CAST((OBJ), GCMAP_TYPE_CHAR_TABLE, CharTable))
#define GCMAP_CHAR_TABLE_CLASS(CLASS)    (G_TYPE_CHECK_CLASS_CAST((CLASS), GCMAP_TYPE_CHAR_TABLE, CharTableClass))
#define IS_GCMAP_CHAR_TABLE(OBJ)         (G_TYPE_CHECK_INSTANCE_TYPE((OBJ), GCMAP_TYPE_CHAR_TABLE))
#define IS_GCMAP_CHAR_TABLE_CLASS(CLASS) (G_TYPE_CHECK_CLASS_TYPE((CLASS), GCMAP_TYPE_CHAR_TABLE))
#define GCMAP_CHAR_TABLE_GET_CLASS(OBJ)  (G_TYPE_INSTANCE_GET_CLASS((OBJ), GCMAP_TYPE_CHAR_TABLE, CharTableClass))


enum char_table_selection_type {
	COPY_TO_TEXTFIELD,
	COPY_TO_PRIMARY,
	COPY_TO_SECONDARY,
	DRAG_ANNOUNCEMENT
};


typedef struct _CharTable {
	GtkDrawingArea parent_instance;
	int nrows, ncols;
	int max_w, max_h;
	int cell_h;
	uint32_t nchars, selected;
	int viewport_w, viewport_h;
	PangoFontDescription *font;
	PangoLayout *layout;
	PangoLayout *magnification_layout;
	GtkWidget *magnification_window;
	GtkWidget *magnification;
	GtkAdjustment *vadjustment;
	unsigned long int vadjustment_value_changed_id;
	unsigned shift_keys;
	int right_button_down;
	uint32_t pointer_cell;
	int font_size;
	int snap_cols_to_2pow;
	int snap_rows_to_2pow;
	int drag_x, drag_y, drag_stage;
	GtkTargetList *drag_targets;
	unsigned multiclick_count;
	PangoWeight font_weight;
	PangoStyle font_style;
	const struct libcmap_range *ranges;
	size_t nranges;
	void (*selection_callback)(uint32_t index, uint32_t codepoint, enum char_table_selection_type selection_type);
} CharTable;

typedef struct _CharTableClass {
	GtkDrawingAreaClass parent_class;
} CharTableClass;


GType gcmap_char_table_get_type(void);
GtkWidget *gcmap_char_table_new(const char *font_family, int font_size, PangoWeight font_weight, PangoStyle font_style);

void gcmap_char_table_set_font_family(CharTable *this, const char *family);
void gcmap_char_table_set_font_weight(CharTable *this, PangoWeight weight);
void gcmap_char_table_set_font_style(CharTable *this, PangoStyle style);
void gcmap_char_table_set_font_size(CharTable *this, int size);
void gcmap_char_table_set_font_size_at_pointer(CharTable *this, int size, double x, double y);
void gcmap_char_table_set_snap_cols_to_2pow(CharTable *this, int active);
void gcmap_char_table_set_snap_rows_to_2pow(CharTable *this, int active);
void gcmap_char_table_set_ranges(CharTable *this, const struct libcmap_range *ranges, size_t nranges);
void gcmap_char_table_viewport_updated(CharTable *this, int viewport_w, int viewport_h);
void gcmap_char_table_select_cell(CharTable *this, int32_t selected, int clamp, int meta);
void gcmap_char_table_adjust_cell_selection(CharTable *this, int32_t adjustment, int clamp, int meta);
int gcmap_char_table_select_codepoint(CharTable *this, uint32_t codepoint);