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

Revisions

View the latest version of libbirdfont/Row.vala.
Use table in recent files tab
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 21 int index = 0; 22 bool delete_button = true; 23 public Gee.ArrayList<Text> column_text = new Gee.ArrayList<Text> (); 24 GLib.Object? row_data = null; 25 26 public static const int MAX_COLUMNS = 5; 27 28 public int columns { 29 get { 30 return column_text.size; 31 } 32 } 33 34 public Row (string label, int index, bool delete_button = true) { 35 this.index = index; 36 column_text.add (new Text (label, 17 * MainWindow.units)); 37 this.delete_button = delete_button; 38 } 39 40 public Row.columns_1 (string label, int index, bool delete_button = true) { 41 this.index = index; 42 column_text.add (new Text (label, 17 * MainWindow.units)); 43 this.delete_button = delete_button; 44 } 45 46 public Row.columns_2 (string label0, string label1, int index, 47 bool delete_button = true) { 48 49 column_text.add (new Text (label0, 17 * MainWindow.units)); 50 column_text.add (new Text (label1, 17 * MainWindow.units)); 51 this.index = index; 52 this.delete_button = delete_button; 53 } 54 55 public Row.columns_3 (string label0, string label1, string label2, 56 int index, bool delete_button = true) { 57 58 column_text.add (new Text (label0, 17 * MainWindow.units)); 59 column_text.add (new Text (label1, 17 * MainWindow.units)); 60 column_text.add (new Text (label2, 17 * MainWindow.units)); 61 this.index = index; 62 this.delete_button = delete_button; 63 } 64 65 public Row.columns_4 (string label0, string label1, string label2, 66 string label3, int index, bool delete_button = true) { 67 68 column_text.add (new Text (label0, 17 * MainWindow.units)); 69 column_text.add (new Text (label1, 17 * MainWindow.units)); 70 column_text.add (new Text (label2, 17 * MainWindow.units)); 71 column_text.add (new Text (label3, 17 * MainWindow.units)); 72 this.index = index; 73 this.delete_button = delete_button; 74 } 75 76 public Row.columns_5 (string label0, string label1, string label2, 77 string label3, string label4, int index, bool delete_button = true) { 78 79 column_text.add (new Text (label0, 17 * MainWindow.units)); 80 column_text.add (new Text (label1, 17 * MainWindow.units)); 81 column_text.add (new Text (label2, 17 * MainWindow.units)); 82 column_text.add (new Text (label3, 17 * MainWindow.units)); 83 column_text.add (new Text (label4, 17 * MainWindow.units)); 84 this.index = index; 85 this.delete_button = delete_button; 86 } 87 88 public bool has_row_data () { 89 return row_data != null; 90 } 91 92 public GLib.Object? get_row_data () { 93 return row_data; 94 } 95 96 public void set_row_data (GLib.Object o) { 97 row_data = o; 98 } 99 100 public bool has_delete_button () { 101 return delete_button; 102 } 103 104 public Text get_column (int i) { 105 return_val_if_fail (0 <= i < columns, new Text ()); 106 return column_text.get (i); 107 } 108 109 public int get_index () { 110 return index; 111 } 112 113 public void set_index (int index) { 114 this.index = index; 115 } 116 } 117 118 } 119