.
1 /*
2 Copyright (C) 2013 Johan Mattsson
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 3 of the
7 License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13 */
14
15 using Cairo;
16
17 namespace BirdFont {
18
19 /** Display functions for a unicode character database entry. */
20 public class CharacterInfo : GLib.Object {
21
22 Text icon;
23 double x = 0;
24 double y = 0;
25 unichar unicode;
26 bool ligature = false;
27 string name = "";
28
29 public CharacterInfo (unichar c, GlyphCollection? gc) {
30 unicode = c;
31 icon = new Text ("info_icon", 22);
32 icon.load_font ("icons.bf");
33
34 if (gc != null) {
35 ligature = ((!) gc).is_unassigned ();
36 name = ((!) gc).get_name ();
37 icon.load_font ("icons.bf");
38 icon.use_cache (true);
39 }
40 }
41
42 public string get_name () {
43 return name;
44 }
45
46 public bool is_ligature () {
47 return ligature;
48 }
49
50 public string get_entry () {
51 return CharDatabase.get_unicode_database_entry (unicode);
52 }
53
54 public void set_position (double x, double y) {
55 this.x = x;
56 this.y = y;
57 }
58
59 public bool is_over_icon (double px, double py) {
60 return (x <= px <= x + 12) && (y <= py <= y + 24);
61 }
62
63 public void draw_icon (Context cr, bool selected) {
64 if (selected) {
65 Theme.text_color (icon, "Overview Selected Foreground");
66 } else {
67 Theme.text_color (icon, "Overview Foreground");
68 }
69
70 icon.draw_at_top (cr, x, y);
71 }
72 }
73
74 }
75