The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

Row.vala in /libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Circle boundaries heads/master
1 /* 2 Copyright (C) 2014 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 using Cairo; 15 using Math; 16 17 namespace BirdFont { 18 19 public class Row : GLib.Object { 20 int index = 0; 21 bool delete_button = true; 22 23 public double y = 0; 24 public Gee.ArrayList<Text> column_text = new Gee.ArrayList<Text> (); 25 26 GLib.Object? row_data = null; 27 28 public static const int MAX_COLUMNS = 5; 29 30 public bool is_headline = false; 31 32 public int columns { 33 get { 34 return column_text.size; 35 } 36 } 37 38 public Row (string label, int index, bool delete_button = true) { 39 this.index = index; 40 column_text.add (new Text (label, 18 * MainWindow.units)); 41 this.delete_button = delete_button; 42 } 43 44 public Row.headline (string label) { 45 index = -1; 46 column_text.add (new Text (label, 25 * MainWindow.units)); 47 delete_button = false; 48 is_headline = true; 49 } 50 51 public Row.columns_1 (string label, int index, bool delete_button = true) { 52 this.index = index; 53 column_text.add (new Text (label, 18 * MainWindow.units)); 54 this.delete_button = delete_button; 55 } 56 57 public Row.columns_2 (string label0, string label1, int index, 58 bool delete_button = true) { 59 60 column_text.add (new Text (label0, 18 * MainWindow.units)); 61 column_text.add (new Text (label1, 18 * MainWindow.units)); 62 this.index = index; 63 this.delete_button = delete_button; 64 } 65 66 public Row.columns_3 (string label0, string label1, string label2, 67 int index, bool delete_button = true) { 68 69 column_text.add (new Text (label0, 18 * MainWindow.units)); 70 column_text.add (new Text (label1, 18 * MainWindow.units)); 71 column_text.add (new Text (label2, 18 * MainWindow.units)); 72 this.index = index; 73 this.delete_button = delete_button; 74 } 75 76 public Row.columns_4 (string label0, string label1, string label2, 77 string label3, int index, bool delete_button = true) { 78 79 column_text.add (new Text (label0, 18 * MainWindow.units)); 80 column_text.add (new Text (label1, 18 * MainWindow.units)); 81 column_text.add (new Text (label2, 18 * MainWindow.units)); 82 column_text.add (new Text (label3, 18 * MainWindow.units)); 83 this.index = index; 84 this.delete_button = delete_button; 85 } 86 87 public Row.columns_5 (string label0, string label1, string label2, 88 string label3, string label4, int index, bool delete_button = true) { 89 90 column_text.add (new Text (label0, 18 * MainWindow.units)); 91 column_text.add (new Text (label1, 18 * MainWindow.units)); 92 column_text.add (new Text (label2, 18 * MainWindow.units)); 93 column_text.add (new Text (label3, 18 * MainWindow.units)); 94 column_text.add (new Text (label4, 18 * MainWindow.units)); 95 this.index = index; 96 this.delete_button = delete_button; 97 } 98 99 public bool has_row_data () { 100 return row_data != null; 101 } 102 103 public GLib.Object? get_row_data () { 104 return row_data; 105 } 106 107 public void set_row_data (GLib.Object o) { 108 row_data = o; 109 } 110 111 public bool has_delete_button () { 112 return delete_button; 113 } 114 115 public Text get_column (int i) { 116 return_val_if_fail (0 <= i < columns, new Text ()); 117 return column_text.get (i); 118 } 119 120 public int get_index () { 121 return index; 122 } 123 124 public void set_index (int index) { 125 this.index = index; 126 } 127 128 public double get_height () { 129 return is_headline ? 75 * MainWindow.units : 25 * MainWindow.units; 130 } 131 } 132 133 } 134